Skip to content

Commit

Permalink
chore(site): change display order of military rank and appointment
Browse files Browse the repository at this point in the history
  • Loading branch information
tooleks committed Nov 11, 2024
1 parent f00d31f commit c3ae828
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 59 deletions.
21 changes: 4 additions & 17 deletions site/components/declension-demo-section.vue
Original file line number Diff line number Diff line change
Expand Up @@ -323,23 +323,10 @@ await inflect(demoDeclensionInput);
<tr v-for="grammaticalCase in shevchenko.GrammaticalCase" :key="grammaticalCase">
<th class="text-nowrap">{{ $t(`grammaticalCase.${grammaticalCase}`) }}</th>

<td class="w-100">
<span
v-if="
declensionResults[grammaticalCase]?.militaryRank ||
declensionResults[grammaticalCase]?.militaryAppointment
"
class="text-nowrap"
>
{{ declensionResults[grammaticalCase]?.militaryRank }}
{{ declensionResults[grammaticalCase]?.militaryAppointment }}<br />
</span>

<span class="text-nowrap">
{{ declensionResults[grammaticalCase]?.familyName }}
{{ declensionResults[grammaticalCase]?.givenName }}
{{ declensionResults[grammaticalCase]?.patronymicName }}
</span>
<td class="w-100 text-nowrap">
{{ declensionResults[grammaticalCase]?.familyName }}
{{ declensionResults[grammaticalCase]?.givenName }}
{{ declensionResults[grammaticalCase]?.patronymicName }}
</td>

<td class="text-end">
Expand Down
60 changes: 30 additions & 30 deletions site/components/military/declension-demo-section.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { isEqual } from 'lodash-es';
const demoDeclensionInput: shevchenko.DeclensionInput = {
gender: shevchenko.GrammaticalGender.MASCULINE,
militaryRank: 'солдат',
militaryAppointment: 'помічник гранатометника',
militaryRank: 'солдат',
familyName: 'Шевченко',
givenName: 'Тарас',
patronymicName: 'Григорович',
Expand All @@ -28,8 +28,8 @@ const [hasGenderDetectionError, showGenderDetectionError] = useToggle(false);
type FormData = {
gender: shevchenko.GrammaticalGender | typeof GENDER_AUTO_DETECT;
autoDetectedGender: shevchenko.GrammaticalGender;
militaryRank?: string;
militaryAppointment?: string;
militaryRank?: string;
familyName?: string;
givenName?: string;
patronymicName?: string;
Expand All @@ -38,8 +38,8 @@ type FormData = {
const formData = reactive<FormData>({
gender: GENDER_AUTO_DETECT,
autoDetectedGender: demoDeclensionInput.gender,
militaryRank: '',
militaryAppointment: '',
militaryRank: '',
familyName: '',
givenName: '',
patronymicName: '',
Expand All @@ -48,8 +48,8 @@ const formData = reactive<FormData>({
function fillFormData(formDataChange: FormData): void {
formData.gender = formDataChange.gender;
formData.autoDetectedGender = formDataChange.autoDetectedGender;
formData.militaryRank = formDataChange.militaryRank;
formData.militaryAppointment = formDataChange.militaryAppointment;
formData.militaryRank = formDataChange.militaryRank;
formData.familyName = formDataChange.familyName;
formData.givenName = formDataChange.givenName;
formData.patronymicName = formDataChange.patronymicName;
Expand All @@ -59,8 +59,8 @@ function isValidFormData(formData: Partial<FormData>): formData is FormData {
return Boolean(
(formData.gender === GENDER_AUTO_DETECT ||
Object.values(shevchenko.GrammaticalGender).includes(formData.gender)) &&
(formData?.militaryRank ||
formData?.militaryAppointment ||
(formData?.militaryAppointment ||
formData?.militaryRank ||
formData.familyName ||
formData.givenName ||
formData.patronymicName),
Expand All @@ -71,23 +71,23 @@ async function handleFormSubmit(): Promise<void> {
showGenderDetectionError(false);
let gender: FormData['gender'] | null;
let militaryRank: FormData['militaryRank'];
let militaryAppointment: FormData['militaryAppointment'];
let militaryRank: FormData['militaryRank'];
let familyName: FormData['familyName'];
let givenName: FormData['givenName'];
let patronymicName: FormData['patronymicName'];
if (isValidFormData(formData)) {
gender = formData.gender;
militaryRank = formData.militaryRank;
militaryAppointment = formData.militaryAppointment;
militaryRank = formData.militaryRank;
familyName = formData.familyName;
givenName = formData.givenName;
patronymicName = formData.patronymicName;
} else {
gender = demoDeclensionInput.gender;
militaryRank = demoDeclensionInput.militaryRank;
militaryAppointment = demoDeclensionInput.militaryAppointment;
militaryRank = demoDeclensionInput.militaryRank;
familyName = demoDeclensionInput.familyName;
givenName = demoDeclensionInput.givenName;
patronymicName = demoDeclensionInput.patronymicName;
Expand All @@ -103,8 +103,8 @@ async function handleFormSubmit(): Promise<void> {
const declensionInput: shevchenko.DeclensionInput = {
gender,
militaryRank,
militaryAppointment,
militaryRank,
familyName,
givenName,
patronymicName,
Expand Down Expand Up @@ -172,14 +172,14 @@ async function inflect(declensionInput: shevchenko.DeclensionInput): Promise<voi
function getDeclensionResultString(declensionResult: shevchenko.DeclensionOutput): string {
const resultParts: string[] = [];
if (declensionResult.militaryRank) {
resultParts.push(declensionResult.militaryRank);
}
if (declensionResult.militaryAppointment) {
resultParts.push(declensionResult.militaryAppointment);
}
if (declensionResult.militaryRank) {
resultParts.push(declensionResult.militaryRank);
}
if (declensionResult.familyName) {
resultParts.push(declensionResult.familyName);
}
Expand Down Expand Up @@ -265,32 +265,32 @@ await inflect(demoDeclensionInput);
</div>

<div class="mb-3">
<label class="form-label" for="military-rank">
{{ $t('anthroponym.militaryRank') }}
<label class="form-label" for="military-appointment">
{{ $t('anthroponym.militaryAppointment') }}
</label>

<input
id="military-rank"
v-model.trim="formData.militaryRank"
id="military-appointment"
v-model.trim="formData.militaryAppointment"
type="text"
class="form-control"
name="military-rank"
:placeholder="demoDeclensionInput.militaryRank"
name="military-appointment"
:placeholder="demoDeclensionInput.militaryAppointment"
/>
</div>

<div class="mb-3">
<label class="form-label" for="military-appointment">
{{ $t('anthroponym.militaryAppointment') }}
<label class="form-label" for="military-rank">
{{ $t('anthroponym.militaryRank') }}
</label>

<input
id="military-appointment"
v-model.trim="formData.militaryAppointment"
id="military-rank"
v-model.trim="formData.militaryRank"
type="text"
class="form-control"
name="military-appointment"
:placeholder="demoDeclensionInput.militaryAppointment"
name="military-rank"
:placeholder="demoDeclensionInput.militaryRank"
/>
</div>

Expand Down Expand Up @@ -384,13 +384,13 @@ await inflect(demoDeclensionInput);
<td class="w-100">
<span
v-if="
declensionResults[grammaticalCase]?.militaryRank ||
declensionResults[grammaticalCase]?.militaryAppointment
declensionResults[grammaticalCase]?.militaryAppointment ||
declensionResults[grammaticalCase]?.militaryRank
"
class="text-nowrap"
>
{{ declensionResults[grammaticalCase]?.militaryRank }}
{{ declensionResults[grammaticalCase]?.militaryAppointment }}<br />
{{ declensionResults[grammaticalCase]?.militaryAppointment }}
{{ declensionResults[grammaticalCase]?.militaryRank }}<br />
</span>

<span class="text-nowrap">
Expand Down
20 changes: 10 additions & 10 deletions site/components/military/declension-slideshow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,43 @@ import { useDeclensionSlideshow } from '~/composables/declension-slideshow';
const anthroponyms: shevchenko.DeclensionInput[] = [
{
gender: shevchenko.GrammaticalGender.MASCULINE,
militaryRank: 'солдат',
militaryAppointment: 'помічник гранатометника',
militaryRank: 'солдат',
},
{
gender: shevchenko.GrammaticalGender.MASCULINE,
militaryRank: 'старший солдат',
militaryAppointment: 'старший вогнеметник',
militaryRank: 'старший солдат',
},
{
gender: shevchenko.GrammaticalGender.MASCULINE,
militaryRank: 'старший солдат',
militaryAppointment: 'механік-водій',
militaryRank: 'старший солдат',
},
{
gender: shevchenko.GrammaticalGender.MASCULINE,
militaryRank: 'молодший сержант',
militaryAppointment: 'бойовий медик взводу',
militaryRank: 'молодший сержант',
},
{
gender: shevchenko.GrammaticalGender.MASCULINE,
militaryRank: 'сержант',
militaryAppointment: 'командир відділення',
militaryRank: 'сержант',
},
{
gender: shevchenko.GrammaticalGender.MASCULINE,
militaryRank: 'штаб-сержант',
militaryAppointment: 'льотчик',
militaryRank: 'штаб-сержант',
},
{
gender: shevchenko.GrammaticalGender.MASCULINE,
militaryRank: 'штаб-старшина',
militaryAppointment: 'командир десантного катера',
militaryRank: 'штаб-старшина',
},
{
gender: shevchenko.GrammaticalGender.MASCULINE,
militaryRank: 'головний старшина',
militaryAppointment: 'командир морського катера',
militaryRank: 'головний старшина',
},
];
Expand All @@ -50,8 +50,8 @@ const anthroponym = useDeclensionSlideshow(anthroponyms, shevchenko.inAccusative

<template>
<transition name="preview" mode="out-in">
<span v-if="anthroponym" :key="`${anthroponym.militaryRank}${anthroponym.militaryAppointment}`">
{{ anthroponym.militaryRank }} - {{ anthroponym.militaryAppointment }}
<span v-if="anthroponym" :key="`${anthroponym.militaryAppointment}${anthroponym.militaryRank}`">
{{ anthroponym.militaryAppointment }} - {{ anthroponym.militaryRank }}
</span>
</transition>
</template>
Expand Down
4 changes: 2 additions & 2 deletions site/components/military/docs-section.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ shevchenko.registerExtension(militaryExtension);
async function main() {
const input = {
gender: 'masculine',
militaryRank: 'солдат',
militaryAppointment: 'помічник гранатометника',
militaryRank: 'солдат',
familyName: 'Шевченко',
givenName: 'Тарас',
patronymicName: 'Григорович',
};
const output = await shevchenko.inGenitive(input);
console.log(output); // { militaryRank: "солдата", militaryAppointment: "помічника гранатометника", familyName: "Шевченка", givenName: "Тараса", patronymicName: "Григоровича" }
console.log(output); // { militaryAppointment: "помічника гранатометника", militaryRank: "солдата", familyName: "Шевченка", givenName: "Тараса", patronymicName: "Григоровича" }
}
main().catch((error) => console.error(error));
Expand Down

0 comments on commit c3ae828

Please sign in to comment.