Skip to content

Commit 6871c49

Browse files
committed
fix: auto fix ltierature mistakes
1 parent 3496ac4 commit 6871c49

File tree

6 files changed

+64
-5
lines changed

6 files changed

+64
-5
lines changed

app/components/JsonChanges.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ const isDifferent = computed(() => {
5252
});
5353
5454
const resetUI = () => {
55-
jsonStore.setTranslations({ ...jsonStore.input });
55+
jsonStore.setTranslations({ ...jsonStore.input }, props.type);
5656
};
5757
</script>

app/components/LiteratureForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
name="title"
1010
:hint="item.symbol"
1111
:description="item.title"
12-
:label="`Lectuurartikel ${item.id}`"
12+
:label="`Lectuurartikel #${item.id}${item.itemNumber ? ` (${item.itemNumber})` : ''}`"
1313
>
1414
<UInput v-model="state.title" class="w-full" />
1515
</UFormField>

app/pages/translate/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ const cards = computed(
8787
{
8888
count: jsonStore.originals.literature?.length ?? 0,
8989
icon: "i-lucide:book-open",
90-
inconsistent: 0,
90+
inconsistent: jsonStore.wrongLiterature.length,
9191
missing: jsonStore.missingLiterature.length,
9292
title: "Lectuur",
9393
to: "/translate/literature",

app/pages/translate/literature/index.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,21 @@
1717
</UPageGrid>
1818
</template>
1919
<template v-else>
20+
<UPageCard
21+
v-if="jsonStore.wrongLiterature.length > 0"
22+
highlight
23+
highlight-color="error"
24+
:title="`${jsonStore.wrongLiterature.length} verkeerde vertaling(en) gevonden:`"
25+
description="De JSON-bestanden zijn niet consistent. Categorie, artikelnummer en symbool moeten gelijk zijn."
26+
>
27+
<UPageGrid>
28+
<LiteratureForm
29+
v-for="item in jsonStore.wrongLiterature"
30+
:key="item.id"
31+
:item="item"
32+
/>
33+
</UPageGrid>
34+
</UPageCard>
2035
<UPageGrid>
2136
<LiteratureForm
2237
v-for="item in jsonStore.originals.literature"

app/pages/translate/outlines/index.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@
2828
</UPageGrid>
2929
</template>
3030
<template v-else>
31+
<UPageCard
32+
v-if="jsonStore.missingOutlines.length > 0"
33+
highlight
34+
highlight-color="error"
35+
:title="`${jsonStore.missingOutlines.length} ontbrekende vertaling(en) gevonden:`"
36+
>
37+
<UPageGrid>
38+
<OutlineForm
39+
v-for="outline in jsonStore.missingOutlines"
40+
:key="outline.number"
41+
:outline="outline"
42+
/>
43+
</UPageGrid>
44+
</UPageCard>
3145
<UPageGrid>
3246
<OutlineForm
3347
v-for="outline in jsonStore.originals.outlines"

app/stores/json.ts

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,20 @@ export const useJsonStore = defineStore("json", {
6767
group?: JsonKey,
6868
) {
6969
if (!group || group === "literature") {
70-
this.literature = { ...this.literature, translations: literature };
70+
this.literature = {
71+
...this.literature,
72+
translations: literature?.map((l) => {
73+
const original = this.literature.originals?.find(
74+
(o) => o.id === l.id,
75+
);
76+
if (!original) return l;
77+
78+
return {
79+
...original,
80+
title: l.title,
81+
};
82+
}),
83+
};
7184
}
7285
if (!group || group === "outlines") {
7386
this.outlines = { ...this.outlines, translations: outlines };
@@ -151,7 +164,11 @@ export const useJsonStore = defineStore("json", {
151164
(o) =>
152165
!!o.title &&
153166
!state.outlines.translations?.some(
154-
(t) => t.number === o.number && !!t.title && !!t.updated,
167+
(t) =>
168+
t.number === o.number &&
169+
!!t.title &&
170+
!!t.updated &&
171+
(!o.notes || !!t.notes),
155172
),
156173
) ?? []
157174
);
@@ -186,6 +203,19 @@ export const useJsonStore = defineStore("json", {
186203
tips: state.tips.translations,
187204
};
188205
},
206+
wrongLiterature(state) {
207+
return (
208+
state.literature.originals?.filter((item) => {
209+
const translation = state.literature.translations?.find(
210+
(t) => t.id === item.id,
211+
);
212+
if (!translation) return false;
213+
if (item.categoryName !== translation.categoryName) return true;
214+
if (item.itemNumber !== translation.itemNumber) return true;
215+
if (item.symbol !== translation.symbol) return true;
216+
}) ?? []
217+
);
218+
},
189219
},
190220
persist: true,
191221
state: (): JsonState => ({

0 commit comments

Comments
 (0)