From 0443257f86105dd02d7c720c761acd9579e66244 Mon Sep 17 00:00:00 2001 From: Mouriya Date: Thu, 11 Jul 2024 21:17:26 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=B3=E3=83=BC=E3=83=89=E3=81=AE=E3=82=B3?= =?UTF-8?q?=E3=83=A1=E3=83=B3=E3=83=88=E3=81=A8=E3=81=9D=E3=81=AE=E4=BB=96?= =?UTF-8?q?=E3=81=AE=E3=82=B3=E3=83=B3=E3=83=86=E3=83=B3=E3=83=84=E3=81=AE?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/right/DataMapping.vue | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/right/DataMapping.vue b/frontend/src/components/right/DataMapping.vue index 2629b78..21b9e09 100644 --- a/frontend/src/components/right/DataMapping.vue +++ b/frontend/src/components/right/DataMapping.vue @@ -26,13 +26,13 @@
-
+
目標
-
+
キー
@@ -98,7 +98,7 @@ import ConditionObject from '../ConditionEditor/ConditionObject.vue'; import ShowDialog from '../ShowDialog.vue'; import AppFieldSelectBox from '../AppFieldSelectBox.vue'; import FieldSelect from '../FieldSelect.vue'; -import IAppFields from './AppFieldSelect.vue'; +import { IApp, IField } from './AppFieldSelect.vue'; import { api } from 'boot/axios'; type ContextProps = { @@ -120,8 +120,10 @@ type CurrentModelValueType = { type MappingValueType = { id: string; - from: object; - to: typeof IAppFields & { + from: { sharedText?: string }; + to: { + app?: IApp, + fields: (IField & { label?: string })[] isDialogVisible: boolean; }; isKey: boolean; @@ -180,55 +182,56 @@ export default defineComponent({ emit('update:modelValue', { data: mappingProps.value, createWithNull: createWithNull.value }); } - const mappingProps = computed(() => props.modelValue?.data ?? []); + const mappingProps = ref(props.modelValue?.data ?? []); const createWithNull = ref(props.modelValue?.createWithNull ?? false) - watch(() => sourceAppId.value, async (newId, ) => { + // 外部ソースコンポーネントの appid をリッスンし、変更されたときに現在のコンポーネントを更新します + watch(() => sourceAppId.value, async (newId,) => { if (!newId) return; updateFields(newId) }) const updateFields = async (sourceAppId: string) => { - const modelValueData = props.modelValue?.data ?? []; - const ktAppFields = await api.get('api/v1/appfields', { params: { app: sourceAppId } }).then(res => { return Object.values(res.data.properties) + // kintoneのデフォルトの非表示フィールドフィルタリング .filter(f => !blackListLabelName.find(label => f.label === label)) .map(f => ({ name: f.label, objectType: 'field', ...f })) .map(f => { - const beforeData = modelValueData.find(m => m.to.fields[0].code === f.code) + // 更新前の値を求める + const beforeData = mappingProps.value.find(m => m.to.fields[0].code === f.code) return { id: uuidv4(), - from: beforeData?.from ?? {}, + from: beforeData?.from ?? {}, // 以前のデータを入力します to: { app: sourceApp.value, fields: [f], isDialogVisible: false }, - isKey: beforeData?.isKey ?? false, + isKey: beforeData?.isKey ?? false, // 以前のデータを入力します disabled: false } }) }) + // 「ルックアップ」によってロックされているフィールドを検索する const lookupFixedField = ktAppFields .filter(field => field.to.fields[0].lookup !== undefined) .flatMap(field => field.to.fields[0].lookup.fieldMappings.map((m) => m.field)) + // 「ルックアップ」でロックされたビューコンポーネントを非対話型に設定します if (lookupFixedField.length > 0) { ktAppFields.filter(f => lookupFixedField.includes(f.to.fields[0].code)).forEach(f => f.disabled = true) } - emit('update:modelValue', { data: ktAppFields, createWithNull: createWithNull }); + mappingProps.value = ktAppFields } - console.log(createWithNull.value); - const mappingObjectsInputDisplay = computed(() => (mappingProps.value && Array.isArray(mappingProps.value)) ? mappingProps.value @@ -270,6 +273,5 @@ export default defineComponent({ }, }); -