This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Zaimki/routes/sources.vue

181 lines
7.0 KiB
Vue
Raw Normal View History

2020-07-22 13:19:23 -07:00
<template>
2020-11-29 02:03:01 -08:00
<div>
2020-09-11 03:17:29 -07:00
<h2>
2020-07-22 13:19:23 -07:00
<Icon v="books"/>
<T>sources.headerLonger</T>
2020-09-11 03:17:29 -07:00
</h2>
2020-07-22 13:19:23 -07:00
2020-10-10 02:33:01 -07:00
<p v-if="$t('sources.subheader')">
<em><T>sources.subheader</T></em>
</p>
2020-07-24 07:15:28 -07:00
<section>
<Share :title="$t('sources.headerLonger')"/>
2020-07-24 07:15:28 -07:00
</section>
2020-10-31 06:54:56 -07:00
<section v-if="config.sources.submit">
<button v-if="!submitShown" class="btn btn-outline-success btn-block" @click="submitShown = true">
<Icon v="plus-circle"/>
<T>sources.submit.header</T>
</button>
<SourceSubmitForm v-else/>
</section>
2020-07-24 05:14:37 -07:00
<section>
2020-09-08 09:10:04 -07:00
<button v-if="!tocShown" class="btn btn-outline-primary btn-block" @click="tocShown = true">
<Icon v="list"/>
<T>sources.toc</T>
2020-09-08 09:10:04 -07:00
</button>
<ul v-if="tocShown" class="list-group">
<li v-for="[group, groupPronouns] in pronounLibrary.split(filterPronoun, false)" v-if="groupPronouns.length" class="list-group-item">
2020-09-08 09:10:04 -07:00
<p class="h5">
{{ group.name }}
</p>
<div class="small my-1" v-if="group.description">
<Icon v="info-circle"/>
2020-09-16 13:23:28 -07:00
<em v-html="group.description"></em>
2020-09-08 09:10:04 -07:00
</div>
<ul class="list-unstyled">
<li v-for="pronoun in groupPronouns" :key="pronoun.canonicalName">
<a v-if="typeof pronoun === 'string'" :href="'#' + toId(pronoun)">
<strong>{{ pronoun.replace(/&/g, glue) }}</strong>
2020-09-08 09:10:04 -07:00
</a>
<a v-else :href="'#' + toId(pronoun.name(glue))">
<strong>{{ pronoun.name(glue) }}</strong>
2020-09-08 09:10:04 -07:00
<small>{{ pronoun.description }}</small>
2020-09-08 09:10:04 -07:00
</a>
<NormativeBadge v-if="pronoun.normative"/>
2020-09-08 09:10:04 -07:00
</li>
</ul>
</li>
2020-12-04 13:09:57 -08:00
<li class="list-group-item" v-if="sourceLibrary.multiple.length">
<p class="h5 mb-0">
<a :href="'#' + $t('pronouns.alt.raw')">
<strong><T>pronouns.alt.header</T></strong>
</a>
</p>
</li>
<li class="list-group-item" v-if="sourceLibrary.getForPronoun('')">
2020-09-08 09:10:04 -07:00
<p class="h5 mb-0">
<a :href="'#' + $t('pronouns.othersRaw')">
<strong><T>pronouns.others</T></strong>
2020-09-08 09:10:04 -07:00
</a>
</p>
</li>
</ul>
2020-07-24 05:14:37 -07:00
</section>
2020-11-09 12:41:52 -08:00
<section class="sticky-top bg-white">
<div class="input-group mb-1 bg-white">
<div class="input-group-prepend">
<span class="input-group-text">
<Icon v="filter"/>
</span>
</div>
<input class="form-control border-primary" v-model="filter" :placeholder="$t('crud.filterLong')" ref="filter"/>
<div class="input-group-append" v-if="filter">
<button class="btn btn-outline-danger" @click="filter = ''; $refs.filter.focus()">
<Icon v="times"/>
2020-08-25 01:41:38 -07:00
</button>
</div>
</div>
2020-11-09 12:41:52 -08:00
<div class="btn-group btn-block">
<button v-for="(icon, type) in sourceTypes"
:class="['btn btn-sm', type === filterType ? 'btn-primary' : 'btn-outline-primary']"
@click="filterType = type"
>
<Icon :v="icon"/>
<span class="d-none d-md-inline">
<T>sources.type.{{type || 'All'}}</T>
2020-11-09 12:41:52 -08:00
</span>
</button>
2020-07-27 10:06:41 -07:00
</div>
</section>
2020-12-04 13:09:57 -08:00
<section v-for="pronoun in pronouns" v-if="sourceLibrary.getForPronoun(pronoun.canonicalName).length">
<SourceList :sources="sourceLibrary.getForPronoun(pronoun.canonicalName)" :filter="filter" :filterType="filterType">
<h2 class="h4" :id="toId(pronoun.name(glue))">
2020-12-03 10:42:55 -08:00
<nuxt-link :to="'/' + pronoun.canonicalName">
{{ pronoun.description }}
<small>({{ pronoun.name(glue) }})</small>
2020-11-09 12:41:52 -08:00
</nuxt-link>
</h2>
</SourceList>
</section>
2020-12-04 13:09:57 -08:00
<a :id="$t('pronouns.alt.raw')"/>
<section v-for="multiple in sourceLibrary.multiple" v-if="sourceLibrary.getForPronoun(multiple).length">
<SourceList :sources="sourceLibrary.getForPronoun(multiple)" :filter="filter" :filterType="filterType">
2020-11-09 12:41:52 -08:00
<h2 class="h4" :id="toId(multiple)">
<nuxt-link :to="'/' + multiple">
<T>pronouns.alt.header</T>
2020-12-04 03:24:12 -08:00
<small>({{ multiple.replace(/&/g, glue) }})</small>
2020-11-09 12:41:52 -08:00
</nuxt-link>
</h2>
</SourceList>
</section>
2020-12-04 13:09:57 -08:00
<section v-if="sourceLibrary.getForPronoun('')">
<SourceList :sources="sourceLibrary.getForPronoun('')" :filter="filter" :filterType="filterType">
<h2 class="h4" :id="$t('pronouns.othersRaw')">
<T>pronouns.others</T>
2020-11-09 12:41:52 -08:00
</h2>
</SourceList>
</section>
2020-07-22 13:19:23 -07:00
</div>
</template>
<script>
2020-12-04 13:09:57 -08:00
import { pronouns, pronounLibrary } from '../src/data'
import { Source, SourceLibrary } from "../src/classes";
2020-09-23 12:29:55 -07:00
import { head } from "../src/helpers";
2020-07-22 13:19:23 -07:00
export default {
data() {
return {
pronouns,
pronounLibrary,
2020-09-08 09:10:04 -07:00
tocShown: false,
2020-07-27 10:06:41 -07:00
sourceTypes: Source.TYPES,
filter: '',
2020-11-09 12:41:52 -08:00
filterType: '',
glue: ' ' + this.$t('pronouns.or') + ' ',
2020-10-31 06:54:56 -07:00
submitShown: false,
2020-07-22 13:19:23 -07:00
};
},
2020-12-04 13:09:57 -08:00
async asyncData({app}) {
return {
sources: await app.$axios.$get(`/sources`),
}
},
mounted() {
if (process.client && window.location.hash) {
const $hashEl = this.$el.querySelector(window.location.hash);
if ($hashEl) {
$hashEl.scrollIntoView();
}
}
},
2020-07-22 13:19:23 -07:00
head() {
2020-09-23 12:29:55 -07:00
return head({
title: this.$t('sources.headerLonger'),
2020-09-23 12:29:55 -07:00
});
2020-07-22 13:19:23 -07:00
},
computed: {
2020-12-04 13:09:57 -08:00
sourceLibrary() {
return new SourceLibrary(this.sources);
},
},
methods: {
toId(str) {
return str.replace(/\//g, '-').replace(/&/g, '_');
2020-09-08 09:10:04 -07:00
},
2020-12-04 13:09:57 -08:00
filterPronoun(pronoun) {
return this.sourceLibrary.getForPronoun(pronoun.canonicalName).length > 0;
},
},
2020-07-22 13:19:23 -07:00
}
</script>