From c95092903a37159aa73073e31519ed363ed404b7 Mon Sep 17 00:00:00 2001
From: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com>
Date: Sun, 31 Aug 2025 19:53:38 +0900
Subject: refactor(frontend): フロントエンドの型エラー解消(途中まで) (#16477)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* refactor(frontend): フロントエンドの型エラー解消
* fix
---------
Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
---
packages/frontend/src/components/MkFormDialog.vue | 28 +++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
(limited to 'packages/frontend/src/components/MkFormDialog.vue')
diff --git a/packages/frontend/src/components/MkFormDialog.vue b/packages/frontend/src/components/MkFormDialog.vue
index 6ac4441cac..8d697499a5 100644
--- a/packages/frontend/src/components/MkFormDialog.vue
+++ b/packages/frontend/src/components/MkFormDialog.vue
@@ -41,11 +41,11 @@ SPDX-License-Identifier: AGPL-3.0-only
({{ i18n.ts.optional }})
-
+
({{ i18n.ts.optional }})
-
+
({{ i18n.ts.optional }})
@@ -77,7 +77,7 @@ import MkRange from './MkRange.vue';
import MkButton from './MkButton.vue';
import MkRadios from './MkRadios.vue';
import XFile from './MkFormDialog.file.vue';
-import type { Form } from '@/utility/form.js';
+import type { EnumItem, Form, RadioFormItem } from '@/utility/form.js';
import MkModalWindow from '@/components/MkModalWindow.vue';
import { i18n } from '@/i18n.js';
@@ -99,7 +99,11 @@ const dialog = useTemplateRef('dialog');
const values = reactive({});
for (const item in props.form) {
- values[item] = props.form[item].default ?? null;
+ if ('default' in props.form[item]) {
+ values[item] = props.form[item].default ?? null;
+ } else {
+ values[item] = null;
+ }
}
function ok() {
@@ -115,4 +119,20 @@ function cancel() {
});
dialog.value?.close();
}
+
+function getEnumLabel(e: EnumItem) {
+ return typeof e === 'string' ? e : e.label;
+}
+
+function getEnumValue(e: EnumItem) {
+ return typeof e === 'string' ? e : e.value;
+}
+
+function getEnumKey(e: EnumItem) {
+ return typeof e === 'string' ? e : typeof e.value === 'string' ? e.value : JSON.stringify(e.value);
+}
+
+function getRadioKey(e: RadioFormItem['options'][number]) {
+ return typeof e.value === 'string' ? e.value : JSON.stringify(e.value);
+}
--
cgit v1.2.3-freya