Skip to content

Commit 11ec327

Browse files
committed
refactor: improve naming
1 parent 7544f40 commit 11ec327

File tree

16 files changed

+106
-108
lines changed

16 files changed

+106
-108
lines changed

.husky/install.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ if (process.env.NODE_ENV === "production" || process.env.CI === "true") {
33
process.exit(0);
44
}
55
const husky = (await import("husky")).default;
6-
// eslint-disable-next-line no-console
76
console.log(husky());

app/app.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ const items: NavigationMenuItem[] = [
103103
];
104104
105105
const uiStore = useUIStore();
106-
const translationStore = useTranslationStore();
106+
const jsonStore = useJsonStore();
107107
108108
onMounted(() => {
109109
if (
@@ -120,9 +120,9 @@ onMounted(() => {
120120
uiStore.nwpTranslations = parseTranslationFile(uiStore.nwpString);
121121
}
122122
123-
typedKeys(translationStore.input).forEach((key) => {
124-
if (translationStore.input[key] && !translationStore.translations[key]) {
125-
translationStore.setTranslations(translationStore.input, key);
123+
typedKeys(jsonStore.input).forEach((key) => {
124+
if (jsonStore.input[key] && !jsonStore.translations[key]) {
125+
jsonStore.setTranslations(jsonStore.input, key);
126126
}
127127
});
128128
});

app/components/ImportForm.vue

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,46 @@
66
@error="onError"
77
@submit="onSubmit"
88
>
9-
<UFormField
10-
required
11-
name="ui"
12-
label="NWS UI"
13-
description="Plak tekst uit het Google Docs bestand."
14-
>
15-
<UTextarea
16-
v-model="state.ui"
17-
class="w-full"
18-
placeholder="about: About&#10;about1: New World Scheduler..."
19-
/>
20-
</UFormField>
21-
<UFormField
22-
v-if="!noNwp"
23-
name="nwp"
24-
label="NWP UI"
25-
description="Plak tekst uit het Google Docs bestand."
26-
>
27-
<UTextarea
28-
v-model="state.nwp"
29-
class="w-full"
30-
placeholder='"____v360____": "",&#10;"____GENERAL____": "",&#10;"help": "Help",&#10;...'
31-
/>
32-
</UFormField>
33-
<UFormField
34-
v-for="file in jsonFiles"
35-
:key="file.key"
36-
:name="file.key"
37-
:label="file.label"
38-
:error="errors[file.key]"
39-
description="Plak tekst uit het lokale .json-bestand (Literature, Outlines, Songs, Tips)."
40-
>
41-
<UTextarea v-model="state[file.key]" class="w-full" />
42-
</UFormField>
9+
<fieldset>
10+
<legend>UI</legend>
11+
<UFormField
12+
required
13+
name="ui"
14+
label="NWS UI"
15+
description="Plak tekst uit het Google Docs bestand."
16+
>
17+
<UTextarea
18+
v-model="state.ui"
19+
class="w-full"
20+
placeholder="about: About&#10;about1: New World Scheduler..."
21+
/>
22+
</UFormField>
23+
<UFormField
24+
v-if="!noNwp"
25+
name="nwp"
26+
label="NWP UI"
27+
description="Plak tekst uit het Google Docs bestand."
28+
>
29+
<UTextarea
30+
v-model="state.nwp"
31+
class="w-full"
32+
placeholder='"____v360____": "",&#10;"____GENERAL____": "",&#10;"help": "Help",&#10;...'
33+
/>
34+
</UFormField>
35+
</fieldset>
36+
<fieldset>
37+
<legend>JSON-bestanden</legend>
38+
<UFormField
39+
v-for="file in jsonFiles"
40+
:key="file.key"
41+
:name="file.key"
42+
:label="file.label"
43+
:error="errors[file.key]"
44+
description="Plak tekst uit het lokale .json-bestand (Literature, Outlines, Songs, Tips)."
45+
>
46+
<UTextarea v-model="state[file.key]" class="w-full" />
47+
</UFormField>
48+
</fieldset>
4349
<UButton class="w-fit" type="submit" label="Opslaan" />
4450
</UForm>
4551
</template>

app/components/JsonChanges.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const props = defineProps<{
1818
type: "literature" | "outlines" | "songs" | "tips";
1919
}>();
2020
21-
const translationStore = useTranslationStore();
21+
const jsonStore = useJsonStore();
2222
2323
const label = computed(() => {
2424
switch (props.type) {
@@ -36,18 +36,18 @@ const label = computed(() => {
3636
});
3737
3838
const inputTranslations = computed(() => {
39-
return JSON.stringify(translationStore.input[props.type], null, 2);
39+
return JSON.stringify(jsonStore.input[props.type], null, 2);
4040
});
4141
4242
const translations = computed(() => {
43-
return JSON.stringify(translationStore.translations[props.type], null, 2);
43+
return JSON.stringify(jsonStore.translations[props.type], null, 2);
4444
});
4545
4646
const isDifferent = computed(() => {
4747
return inputTranslations.value !== translations.value;
4848
});
4949
5050
const resetUI = () => {
51-
translationStore.setTranslations({ ...translationStore.input });
51+
jsonStore.setTranslations({ ...jsonStore.input });
5252
};
5353
</script>

app/components/LiteratureForm.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ const props = defineProps<{
2525
item: LiteratureItem;
2626
}>();
2727
28-
const translationStore = useTranslationStore();
28+
const jsonStore = useJsonStore();
2929
3030
const translation = computed(() =>
31-
translationStore.translations.literature?.find((s) => s.id === props.item.id),
31+
jsonStore.translations.literature?.find((s) => s.id === props.item.id),
3232
);
3333
3434
const schema = z.object({
@@ -44,11 +44,11 @@ const state = reactive<Partial<Schema>>({
4444
const { showSuccess } = useFlash();
4545
4646
function onSubmit(event: FormSubmitEvent<Schema>) {
47-
const literature = translationStore.translations.literature?.map((item) =>
47+
const literature = jsonStore.translations.literature?.map((item) =>
4848
item.id === props.item.id ? { ...item, ...event.data } : item,
4949
);
5050
51-
translationStore.setTranslations({ literature }, "literature");
51+
jsonStore.setTranslations({ literature }, "literature");
5252
showSuccess({ description: "Lectuurartikel opgeslagen.", id: "item-saved" });
5353
}
5454
</script>

app/components/OutlineForm.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ const props = defineProps<{
4242
outline: Outline;
4343
}>();
4444
45-
const translationStore = useTranslationStore();
45+
const jsonStore = useJsonStore();
4646
4747
const translation = computed(() =>
48-
translationStore.translations.outlines?.find(
48+
jsonStore.translations.outlines?.find(
4949
(s) => s.number === props.outline.number,
5050
),
5151
);
@@ -67,13 +67,13 @@ const state = reactive<Partial<Schema>>({
6767
const { showSuccess } = useFlash();
6868
6969
function onSubmit(event: FormSubmitEvent<Schema>) {
70-
const outlines = translationStore.translations.outlines?.map((outline) =>
70+
const outlines = jsonStore.translations.outlines?.map((outline) =>
7171
outline.number === props.outline.number
7272
? { ...outline, ...event.data }
7373
: outline,
7474
);
7575
76-
translationStore.setTranslations({ outlines }, "outlines");
76+
jsonStore.setTranslations({ outlines }, "outlines");
7777
showSuccess({ description: "Schema opgeslagen.", id: "outline-saved" });
7878
}
7979
</script>

app/components/SongForm.vue

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ const props = defineProps<{
2424
song: Song;
2525
}>();
2626
27-
const translationStore = useTranslationStore();
27+
const jsonStore = useJsonStore();
2828
2929
const translation = computed(() =>
30-
translationStore.translations.songs?.find(
31-
(s) => s.number === props.song.number,
32-
),
30+
jsonStore.translations.songs?.find((s) => s.number === props.song.number),
3331
);
3432
3533
const schema = z.object({
@@ -45,11 +43,11 @@ const state = reactive<Partial<Schema>>({
4543
const { showSuccess } = useFlash();
4644
4745
function onSubmit(event: FormSubmitEvent<Schema>) {
48-
const songs = translationStore.translations.songs?.map((song) =>
46+
const songs = jsonStore.translations.songs?.map((song) =>
4947
song.number === props.song.number ? { ...song, ...event.data } : song,
5048
);
5149
52-
translationStore.setTranslations({ songs }, "songs");
50+
jsonStore.setTranslations({ songs }, "songs");
5351
showSuccess({ description: "Lied opgeslagen.", id: "song-saved" });
5452
}
5553
</script>

app/components/TipForm.vue

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ const props = defineProps<{
3636
tip: Tip;
3737
}>();
3838
39-
const translationStore = useTranslationStore();
39+
const jsonStore = useJsonStore();
4040
41-
const translation = computed(
42-
() => translationStore.translations.tips?.[props.index],
43-
);
41+
const translation = computed(() => jsonStore.translations.tips?.[props.index]);
4442
4543
const schema = z.object({
4644
heading: z.string().nonempty(),
@@ -57,11 +55,11 @@ const state = reactive<Partial<Schema>>({
5755
const { showSuccess } = useFlash();
5856
5957
function onSubmit(event: FormSubmitEvent<Schema>) {
60-
const tips = translationStore.translations.tips?.map((tip, i) =>
58+
const tips = jsonStore.translations.tips?.map((tip, i) =>
6159
i === props.index ? { ...tip, ...event.data } : tip,
6260
);
6361
64-
translationStore.setTranslations({ tips }, "tips");
62+
jsonStore.setTranslations({ tips }, "tips");
6563
showSuccess({ description: "Tip opgeslagen.", id: "tip-saved" });
6664
}
6765
</script>

app/pages/export.vue

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</template>
3131
<script setup lang="ts">
3232
const uiStore = useUIStore();
33-
const translationStore = useTranslationStore();
33+
const jsonStore = useJsonStore();
3434
3535
const { showError } = useFlash();
3636
@@ -55,30 +55,28 @@ const { showError } = useFlash();
5555
const jsonFiles = computed(() => {
5656
return [
5757
{
58-
changed: translationStore.changedGroups.includes("literature"),
59-
data: translationStore.translations.literature,
58+
changed: jsonStore.changedGroups.includes("literature"),
59+
data: jsonStore.translations.literature,
6060
name: "Literature",
6161
},
6262
{
63-
changed: translationStore.changedGroups.includes("outlines"),
64-
data: translationStore.translations.outlines,
63+
changed: jsonStore.changedGroups.includes("outlines"),
64+
data: jsonStore.translations.outlines,
6565
name: "Outlines",
6666
},
6767
{
68-
changed:
69-
JSON.stringify(uiStore.translations) !==
70-
JSON.stringify(uiStore.remoteTranslations),
68+
changed: false, // Don't include in zip file
7169
data: uiStore.translations,
7270
name: "ProgramUI",
7371
},
7472
{
75-
changed: translationStore.changedGroups.includes("songs"),
76-
data: translationStore.translations.songs,
73+
changed: jsonStore.changedGroups.includes("songs"),
74+
data: jsonStore.translations.songs,
7775
name: "Songs",
7876
},
7977
{
80-
changed: translationStore.changedGroups.includes("tips"),
81-
data: translationStore.translations.tips,
78+
changed: jsonStore.changedGroups.includes("tips"),
79+
data: jsonStore.translations.tips,
8280
name: "Tips",
8381
},
8482
];

app/pages/import.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ import type { Output } from "~/components/ImportForm.vue";
4646
const uiStore = useUIStore();
4747
const { nwpString, originalsString, translationsString } = storeToRefs(uiStore);
4848
49-
const translationStore = useTranslationStore();
49+
const jsonStore = useJsonStore();
5050
5151
const originals = ref<Output>({
5252
nwp: nwpString.value,
5353
ui: originalsString.value,
54-
...translationStore.originals,
54+
...jsonStore.originals,
5555
});
5656
const translations = ref<Output>({
5757
nwp: nwpString.value,
5858
ui: translationsString.value,
59-
...translationStore.input,
59+
...jsonStore.input,
6060
});
6161
6262
const { showSuccess } = useFlash();
@@ -75,7 +75,7 @@ watch(nwpString, (nwp) => {
7575
7676
watch(originals, (val) => {
7777
originalsString.value = val.ui;
78-
translationStore.setOriginals(val);
78+
jsonStore.setOriginals(val);
7979
showSuccess({
8080
description: "Originele teksten zijn opgeslagen.",
8181
id: "originals-import",
@@ -92,8 +92,8 @@ watch(translations, (val) => {
9292
uiStore.nwpTranslations = val.nwp ? parseTranslationFile(val.nwp) : undefined;
9393
9494
// JSON
95-
translationStore.setInput(val);
96-
translationStore.setTranslations(val);
95+
jsonStore.setInput(val);
96+
jsonStore.setTranslations(val);
9797
9898
showSuccess({
9999
description: "Vertalingen zijn opgeslagen.",

0 commit comments

Comments
 (0)