コードのコメントとその他のコンテンツの追加

This commit is contained in:
Mouriya
2024-07-11 21:17:26 +09:00
parent 18b97c249a
commit 0443257f86

View File

@@ -26,13 +26,13 @@
<!-- <div class="col-1"> <!-- <div class="col-1">
</div> --> </div> -->
<div class="col-5"> <div class="col-5">
<div class="row justify-between q-mx-sm"> <div class="row justify-between q-mr-md">
<div class="">目標</div> <div class="">目標</div>
<q-btn outline color="primary" size="xs" label="最新のフィールドを取得する" <q-btn outline color="primary" size="xs" label="最新のフィールドを取得する"
@click="() => updateFields(sourceAppId!)" /> @click="() => updateFields(sourceAppId!)" />
</div> </div>
</div> </div>
<div class="col-1 q-pl-md"> <div class="col-1 q-pl-sm">
キー キー
</div> </div>
</div> </div>
@@ -98,7 +98,7 @@ import ConditionObject from '../ConditionEditor/ConditionObject.vue';
import ShowDialog from '../ShowDialog.vue'; import ShowDialog from '../ShowDialog.vue';
import AppFieldSelectBox from '../AppFieldSelectBox.vue'; import AppFieldSelectBox from '../AppFieldSelectBox.vue';
import FieldSelect from '../FieldSelect.vue'; import FieldSelect from '../FieldSelect.vue';
import IAppFields from './AppFieldSelect.vue'; import { IApp, IField } from './AppFieldSelect.vue';
import { api } from 'boot/axios'; import { api } from 'boot/axios';
type ContextProps = { type ContextProps = {
@@ -120,8 +120,10 @@ type CurrentModelValueType = {
type MappingValueType = { type MappingValueType = {
id: string; id: string;
from: object; from: { sharedText?: string };
to: typeof IAppFields & { to: {
app?: IApp,
fields: (IField & { label?: string })[]
isDialogVisible: boolean; isDialogVisible: boolean;
}; };
isKey: boolean; isKey: boolean;
@@ -180,55 +182,56 @@ export default defineComponent({
emit('update:modelValue', { data: mappingProps.value, createWithNull: createWithNull.value }); 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) const createWithNull = ref(props.modelValue?.createWithNull ?? false)
watch(() => sourceAppId.value, async (newId, ) => { // 外部ソースコンポーネントの appid をリッスンし、変更されたときに現在のコンポーネントを更新します
watch(() => sourceAppId.value, async (newId,) => {
if (!newId) return; if (!newId) return;
updateFields(newId) updateFields(newId)
}) })
const updateFields = async (sourceAppId: string) => { const updateFields = async (sourceAppId: string) => {
const modelValueData = props.modelValue?.data ?? [];
const ktAppFields = await api.get('api/v1/appfields', { const ktAppFields = await api.get('api/v1/appfields', {
params: { params: {
app: sourceAppId app: sourceAppId
} }
}).then(res => { }).then(res => {
return Object.values(res.data.properties) return Object.values(res.data.properties)
// kintoneのデフォルトの非表示フィールドフィルタリング
.filter(f => !blackListLabelName.find(label => f.label === label)) .filter(f => !blackListLabelName.find(label => f.label === label))
.map(f => ({ name: f.label, objectType: 'field', ...f })) .map(f => ({ name: f.label, objectType: 'field', ...f }))
.map(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 { return {
id: uuidv4(), id: uuidv4(),
from: beforeData?.from ?? {}, from: beforeData?.from ?? {}, // 以前のデータを入力します
to: { to: {
app: sourceApp.value, app: sourceApp.value,
fields: [f], fields: [f],
isDialogVisible: false isDialogVisible: false
}, },
isKey: beforeData?.isKey ?? false, isKey: beforeData?.isKey ?? false, // 以前のデータを入力します
disabled: false disabled: false
} }
}) })
}) })
// 「ルックアップ」によってロックされているフィールドを検索する
const lookupFixedField = ktAppFields const lookupFixedField = ktAppFields
.filter(field => field.to.fields[0].lookup !== undefined) .filter(field => field.to.fields[0].lookup !== undefined)
.flatMap(field => field.to.fields[0].lookup.fieldMappings.map((m) => m.field)) .flatMap(field => field.to.fields[0].lookup.fieldMappings.map((m) => m.field))
// 「ルックアップ」でロックされたビューコンポーネントを非対話型に設定します
if (lookupFixedField.length > 0) { if (lookupFixedField.length > 0) {
ktAppFields.filter(f => lookupFixedField.includes(f.to.fields[0].code)).forEach(f => f.disabled = true) 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(() => const mappingObjectsInputDisplay = computed(() =>
(mappingProps.value && Array.isArray(mappingProps.value)) ? (mappingProps.value && Array.isArray(mappingProps.value)) ?
mappingProps.value mappingProps.value
@@ -270,6 +273,5 @@ export default defineComponent({
}, },
}); });
</script> </script>
<style lang="scss"></style> <style lang="scss"></style>