#65 info about the group on pronoun page

This commit is contained in:
Andrea Vos 2020-10-05 18:35:17 +02:00
parent c8f3668967
commit deb8099de1
3 changed files with 53 additions and 5 deletions

View File

@ -266,7 +266,7 @@
}, },
addSlash(link) { addSlash(link) {
return link + (link.substr(link.length - 1) === '*' ? '/' : ''); return link + (link.substr(link.length - 1) === '*' ? '/' : '');
} },
}, },
} }
</script> </script>

View File

@ -44,6 +44,36 @@
</div> </div>
</section> </section>
<section v-if="templateGroup && templateGroup.group.description">
<ul class="list-group mt-4">
<li class="list-group-item">
<p class="h5">
{{ templateGroup.group.name }}
</p>
<div class="small my-1">
<Icon v="info-circle"/>
<em v-html="templateGroup.group.description"></em>
</div>
<ul class="list-unstyled">
<li v-for="template in templateGroup.groupTemplates" :key="template.canonicalName">
<nuxt-link v-if="typeof template === 'string'" :to="'/' + template">
<strong>{{template.replace(/&/g, ' ' + $t('template.or') + ' ')}}</strong>
</nuxt-link>
<nuxt-link v-else :to="addSlash('/' + template.canonicalName)">
<strong>{{template.name(glue)}}</strong>
<small>{{template.description}}</small>
</nuxt-link>
<NormativeBadge v-if="template.normative"/>
</li>
</ul>
</li>
<nuxt-link to="/" class="list-group-item list-group-item-action text-center">
<Icon v="ellipsis-h-alt"/>
</nuxt-link>
</ul>
</section>
<section> <section>
<Share :title="`${$t('template.intro')}: ${selectedTemplate.name(glue)}`"/> <Share :title="`${$t('template.intro')}: ${selectedTemplate.name(glue)}`"/>
</section> </section>
@ -65,7 +95,7 @@
</template> </template>
<script> <script>
import { examples, templates, getSources } from "~/src/data"; import { examples, templates, getSources, templateLibrary } from "~/src/data";
import { buildTemplate } from "../src/buildTemplate"; import { buildTemplate } from "../src/buildTemplate";
import { head } from "../src/helpers"; import { head } from "../src/helpers";
import GrammarTables from "../data/GrammarTables"; import GrammarTables from "../data/GrammarTables";
@ -73,12 +103,14 @@
export default { export default {
components: { GrammarTables }, components: { GrammarTables },
data() { data() {
const selectedTemplate = buildTemplate(templates, this.$route.path.substr(1).replace(/\/$/, ''));
return { return {
examples: examples, examples,
templates: templates, templates,
glue: ' ' + this.$t('template.or') + ' ', glue: ' ' + this.$t('template.or') + ' ',
selectedTemplate: buildTemplate(templates, this.$route.path.substr(1).replace(/\/$/, '')), selectedTemplate,
templateGroup: templateLibrary.find(selectedTemplate),
counter: 0, counter: 0,
} }
@ -94,6 +126,11 @@
banner: `banner${this.$route.path.replace(/\/$/, '')}.png`, banner: `banner${this.$route.path.replace(/\/$/, '')}.png`,
}) : {}; }) : {};
}, },
methods: {
addSlash(link) {
return link + (link.substr(link.length - 1) === '*' ? '/' : '');
},
},
computed: { computed: {
sources() { sources() {
return getSources(this.selectedTemplate); return getSources(this.selectedTemplate);

View File

@ -258,6 +258,17 @@ export class TemplateLibrary {
}), }),
]; ];
} }
find(template) {
for (let [group, groupTemplates] of this.split()) {
for (let t of groupTemplates) {
if (t.canonicalName === template.canonicalName) {
return {group, groupTemplates};
}
}
}
return null;
}
} }
export class Noun { export class Noun {