(grammar) allow empty cells in grammar table

This commit is contained in:
Valentyne Stigloher 2025-04-25 22:17:37 +02:00
parent acddb91946
commit f22148ceff
4 changed files with 50 additions and 54 deletions

View File

@ -16,6 +16,9 @@ const expandVariantsForSection = (sectionVariants: SectionDefinition['variants']
if (Array.isArray(sectionVariants)) {
return sectionVariants.map((sectionVariant) => {
const morphemeCells = sectionVariant.morphemeCells.map((morphemeCell) => {
if (morphemeCell === null) {
return null;
}
if (typeof morphemeCell === 'string') {
return { morpheme: morphemeCell };
}
@ -43,7 +46,8 @@ const buildVariantsForSection = (
): Variant[] => {
return expandVariantsForSection(sectionVariants).filter((variant) => {
return variant.morphemeCells.some((morphemeCell) => {
return props.exampleValues.morphemeValues.getSpelling(morphemeCell.morpheme) !== undefined;
return morphemeCell !== null &&
props.exampleValues.morphemeValues.getSpelling(morphemeCell.morpheme) !== undefined;
});
});
};
@ -125,8 +129,9 @@ const rowHeaderCount = computed(() => {
</th>
</template>
</template>
<td v-for="morphemeCell in variant.morphemeCells" :key="morphemeCell.morpheme">
<td v-for="(morphemeCell, index) in variant.morphemeCells" :key="index">
<MorphemeWithPronunciation
v-if="morphemeCell !== null"
:morpheme="morphemeCell.morpheme"
:example-values
:prefix="morphemeCell.prefix"

View File

@ -20,6 +20,47 @@ pronouns:
- 'plural_indefinite_article'
- 'inflection_c'
- 'possessive'
grammarTables:
-
columnHeader:
-
name: 'Pronombre'
-
name: 'Pr. de objeto directo'
-
name: 'Artículo determinado'
-
name: 'Artículo indeterminado'
-
name: 'Flexión'
sections:
-
header:
name: 'Singular'
variants:
-
morphemeCells:
- 'pronoun'
- 'de_pronoun'
- 'definite_article'
- 'indefinite_article'
-
morpheme: 'inflection'
prefix: '-'
-
header:
name: 'Plural'
variants:
-
morphemeCells:
- 'plural_pronoun'
- ~
- 'plural_definite_article'
- 'plural_indefinite_article'
-
morpheme: 'inflection'
prefix: '-'
suffix: 's'
route: 'pronomes'
any: 'any'
plurals: false

View File

@ -1,50 +0,0 @@
<template>
<section>
<h2 class="h4">
<Icon v="spell-check" />
<T>pronouns.grammarTable</T><T>quotation.colon</T>
</h2>
<div class="table-responsive">
<table class="table table-sm">
<thead>
<tr>
<th></th>
<th>Pronombre</th>
<th>Pr. de objeto directo</th>
<th>Artículo determinado</th>
<th>Artículo indeterminado</th>
<th>Flexión</th>
</tr>
</thead>
<tbody>
<tr>
<th>Singular</th>
<td><PronounsMorphemeWithPronunciation :pronoun="selectedPronoun" morpheme="pronoun" :counter="counter" /></td>
<td><PronounsMorphemeWithPronunciation :pronoun="selectedPronoun" morpheme="direct_object_pronoun" :counter="counter" /></td>
<td><PronounsMorphemeWithPronunciation :pronoun="selectedPronoun" morpheme="definite_article" :counter="counter" /></td>
<td><PronounsMorphemeWithPronunciation :pronoun="selectedPronoun" morpheme="indefinite_article" :counter="counter" /></td>
<td><PronounsMorphemeWithPronunciation :pronoun="selectedPronoun" morpheme="inflection" :counter="counter" prepend="-" /></td>
</tr>
<tr>
<th>Plural</th>
<td><PronounsMorphemeWithPronunciation :pronoun="selectedPronoun" morpheme="plural_pronoun" :counter="counter" /></td>
<td><PronounsMorphemeWithPronunciation :pronoun="selectedPronoun" morpheme="plural_direct_object_pronoun" :counter="counter" /></td>
<td><PronounsMorphemeWithPronunciation :pronoun="selectedPronoun" morpheme="plural_definite_article" :counter="counter" /></td>
<td><PronounsMorphemeWithPronunciation :pronoun="selectedPronoun" morpheme="plural_indefinite_article" :counter="counter" /></td>
<td><PronounsMorphemeWithPronunciation :pronoun="selectedPronoun" morpheme="inflection" :counter="counter" prepend="-" append="s" /></td>
</tr>
</tbody>
</table>
</div>
</section>
</template>
<script>
export default {
props: {
selectedPronoun: { required: true },
counter: { required: true },
},
};
</script>

View File

@ -20,7 +20,7 @@ export interface SectionDefinition {
export interface VariantDefinition {
name?: string;
morphemeCells: (string | MorphemeCellDefinition)[];
morphemeCells: (string | MorphemeCellDefinition | null)[];
}
export interface VariantsFromBaseDefinition {
@ -41,7 +41,7 @@ export interface Variant {
name?: string;
numerus?: 'singular' | 'plural';
icon?: string;
morphemeCells: MorphemeCell[];
morphemeCells: (MorphemeCell | null)[];
}
export interface MorphemeCell {