mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-26 06:23:35 -04:00
(nouns) add optional filter for templates in subpage and nouns submit and enable it for (pl) and (ru)
This commit is contained in:
parent
4fad0e0fd7
commit
7123b88229
@ -91,9 +91,36 @@
|
|||||||
<T>nouns.template.header</T>
|
<T>nouns.template.header</T>
|
||||||
</a>
|
</a>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<T>nouns.template.root</T><T>quotation.colon</T>
|
<div class="input-group mb-3 bg-white">
|
||||||
<input v-model="templateBase" class="form-control form-control-sm d-inline-block w-auto" autofocus>
|
<span class="input-group-text">
|
||||||
<NounTemplatesTable :template-base="templateBase">
|
<Icon v="scroll-old" />
|
||||||
|
</span>
|
||||||
|
<input
|
||||||
|
v-model="templateBase"
|
||||||
|
class="form-control form-control-sm border-primary"
|
||||||
|
autofocus
|
||||||
|
:placeholder="$t('nouns.template.root')"
|
||||||
|
>
|
||||||
|
<template v-if="$config.nouns.templates.filter">
|
||||||
|
<span class="input-group-text">
|
||||||
|
<Icon v="filter" />
|
||||||
|
</span>
|
||||||
|
<input
|
||||||
|
ref="templateFilter"
|
||||||
|
v-model="templateFilter"
|
||||||
|
class="form-control form-control-sm border-primary"
|
||||||
|
:placeholder="$t('crud.filterLong')"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
v-if="templateFilter"
|
||||||
|
class="btn btn-sm btn-outline-danger"
|
||||||
|
@click="templateFilter = ''; $tRefs.templateFilter?.focus()"
|
||||||
|
>
|
||||||
|
<Icon v="times" />
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<NounTemplatesTable :template-base="templateBase" :filter="templateFilter">
|
||||||
<template #buttons="{ template }">
|
<template #buttons="{ template }">
|
||||||
<li>
|
<li>
|
||||||
<button
|
<button
|
||||||
@ -144,6 +171,10 @@ import { abbreviations } from '../src/data.ts';
|
|||||||
import type { Noun, MinimalNoun } from '../src/classes.ts';
|
import type { Noun, MinimalNoun } from '../src/classes.ts';
|
||||||
import type { Config } from '../locale/config.ts';
|
import type { Config } from '../locale/config.ts';
|
||||||
|
|
||||||
|
interface Refs {
|
||||||
|
templateFilter: HTMLInputElement | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
const emptyForm = (config: Config): MinimalNoun => {
|
const emptyForm = (config: Config): MinimalNoun => {
|
||||||
return {
|
return {
|
||||||
masc: [''],
|
masc: [''],
|
||||||
@ -164,10 +195,16 @@ export default Vue.extend({
|
|||||||
submitting: false,
|
submitting: false,
|
||||||
afterSubmit: false,
|
afterSubmit: false,
|
||||||
templateBase: '',
|
templateBase: '',
|
||||||
|
templateFilter: '',
|
||||||
templateVisible: false,
|
templateVisible: false,
|
||||||
abbreviations,
|
abbreviations,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
$tRefs(): Refs {
|
||||||
|
return this.$refs as unknown as Refs;
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async applyTemplate(template: MinimalNoun): Promise<void> {
|
async applyTemplate(template: MinimalNoun): Promise<void> {
|
||||||
if (JSON.stringify(this.form) !== JSON.stringify(emptyForm(this.$config))) {
|
if (JSON.stringify(this.form) !== JSON.stringify(emptyForm(this.$config))) {
|
||||||
|
@ -1,58 +1,66 @@
|
|||||||
<template>
|
<template>
|
||||||
<table class="table table-striped table-hover table-fixed-3 mt-2">
|
<Table :data="templates" :columns="3" fixed>
|
||||||
<thead>
|
<template #header>
|
||||||
<tr>
|
<th class="text-nowrap">
|
||||||
<th class="text-nowrap">
|
<Icon v="mars" />
|
||||||
<Icon v="mars" />
|
<T>nouns.masculine</T>
|
||||||
<span class="d-none d-md-inline"><T>nouns.masculine</T></span>
|
</th>
|
||||||
<span class="d-md-none"><T>nouns.masculineShort</T></span>
|
<th class="text-nowrap">
|
||||||
</th>
|
<Icon v="venus" />
|
||||||
<th class="text-nowrap">
|
<T>nouns.feminine</T>
|
||||||
<Icon v="venus" />
|
</th>
|
||||||
<span class="d-none d-md-inline"><T>nouns.feminine</T></span>
|
<th class="text-nowrap">
|
||||||
<span class="d-md-none"><T>nouns.feminineShort</T></span>
|
<Icon v="neuter" />
|
||||||
</th>
|
<T>nouns.neuter</T>
|
||||||
<th class="text-nowrap">
|
</th>
|
||||||
<Icon v="neuter" />
|
<th></th>
|
||||||
<span class="d-none d-md-inline"><T>nouns.neuter</T></span>
|
</template>
|
||||||
<span class="d-md-none"><T>nouns.neuterShort</T></span>
|
<template #row="{ el: template }">
|
||||||
</th>
|
<td>
|
||||||
<th></th>
|
<Noun :noun="template" gender="masc" />
|
||||||
</tr>
|
</td>
|
||||||
</thead>
|
<td>
|
||||||
<tbody>
|
<Noun :noun="template" gender="fem" />
|
||||||
<tr v-for="(template, i) in templates" :key="i">
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<Noun :noun="template" gender="masc" />
|
<Noun :noun="template" gender="neutr" />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<th>
|
||||||
<Noun :noun="template" gender="fem" />
|
<ul class="list-unstyled list-btn-concise">
|
||||||
</td>
|
<slot name="buttons" :template="template"></slot>
|
||||||
<td>
|
</ul>
|
||||||
<Noun :noun="template" gender="neutr" />
|
</th>
|
||||||
</td>
|
</template>
|
||||||
<th>
|
|
||||||
<ul class="list-unstyled list-btn-concise">
|
<template #empty>
|
||||||
<slot name="buttons" :template="template"></slot>
|
<Icon v="search" />
|
||||||
</ul>
|
<T>nouns.empty</T>
|
||||||
</th>
|
</template>
|
||||||
</tr>
|
</Table>
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import type { MinimalNoun } from '../src/classes.ts';
|
import type { MinimalNoun } from '../src/classes.ts';
|
||||||
|
import { gendersWithNumerus } from '../src/classes.ts';
|
||||||
import { nounTemplates } from '../src/data.ts';
|
import { nounTemplates } from '../src/data.ts';
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
props: {
|
props: {
|
||||||
templateBase: { default: '', type: String },
|
templateBase: { default: '', type: String },
|
||||||
|
filter: { default: '', type: String },
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
templates(): MinimalNoun[] {
|
templates(): MinimalNoun[] {
|
||||||
return nounTemplates.map((template) => {
|
return nounTemplates.filter((template) => {
|
||||||
|
for (const field of gendersWithNumerus) {
|
||||||
|
for (const value of template[field]) {
|
||||||
|
if (value.toLowerCase().includes(this.filter)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).map((template) => {
|
||||||
return template.fill(this.templateBase || '-');
|
return template.fill(this.templateBase || '-');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -389,6 +389,11 @@ interface NounTemplatesConfig {
|
|||||||
* route path for noun templates (translated)
|
* route path for noun templates (translated)
|
||||||
*/
|
*/
|
||||||
route?: string;
|
route?: string;
|
||||||
|
/**
|
||||||
|
* whether a filter is shown for templates, useful when the language has several templates
|
||||||
|
* @default false
|
||||||
|
*/
|
||||||
|
filter?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CommunityConfig {
|
interface CommunityConfig {
|
||||||
|
@ -226,6 +226,7 @@ nouns:
|
|||||||
submit: true
|
submit: true
|
||||||
templates:
|
templates:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
filter: true
|
||||||
subroutes:
|
subroutes:
|
||||||
- 'neutratywy'
|
- 'neutratywy'
|
||||||
- 'dukatywy'
|
- 'dukatywy'
|
||||||
|
@ -105,6 +105,7 @@ nouns:
|
|||||||
templates:
|
templates:
|
||||||
enabled: true
|
enabled: true
|
||||||
route: 'endings'
|
route: 'endings'
|
||||||
|
filter: true
|
||||||
|
|
||||||
community:
|
community:
|
||||||
route: 'terminology'
|
route: 'terminology'
|
||||||
|
@ -15,7 +15,19 @@
|
|||||||
|
|
||||||
<AdPlaceholder :phkey="['content-0', 'content-mobile-0']" />
|
<AdPlaceholder :phkey="['content-0', 'content-mobile-0']" />
|
||||||
|
|
||||||
<NounTemplatesTable />
|
<section v-if="$config.nouns.templates?.filter" class="sticky-top">
|
||||||
|
<div class="input-group mb-3 bg-white">
|
||||||
|
<span class="input-group-text">
|
||||||
|
<Icon v="filter" />
|
||||||
|
</span>
|
||||||
|
<input ref="filter" v-model="filter" class="form-control border-primary" :placeholder="$t('crud.filterLong')">
|
||||||
|
<button v-if="filter" class="btn btn-outline-danger" @click="filter = ''; $tRefs.filter?.focus()">
|
||||||
|
<Icon v="times" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<NounTemplatesTable :filter="filter" />
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -23,12 +35,26 @@
|
|||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import { head } from '../src/helpers.ts';
|
import { head } from '../src/helpers.ts';
|
||||||
|
|
||||||
|
interface Refs {
|
||||||
|
filter: HTMLInputElement | undefined;
|
||||||
|
}
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
filter: '',
|
||||||
|
};
|
||||||
|
},
|
||||||
head() {
|
head() {
|
||||||
return head({
|
return head({
|
||||||
title: this.$t('nouns.headerLonger'),
|
title: this.$t('nouns.headerLonger'),
|
||||||
description: this.$t('nouns.description'),
|
description: this.$t('nouns.description'),
|
||||||
}, this.$translator);
|
}, this.$translator);
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
$tRefs(): Refs {
|
||||||
|
return this.$refs as unknown as Refs;
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user