|
|
@ -22,9 +22,12 @@ import { |
|
|
|
useViewData, |
|
|
|
useViewData, |
|
|
|
watch, |
|
|
|
watch, |
|
|
|
} from '#imports' |
|
|
|
} from '#imports' |
|
|
|
|
|
|
|
import { EditModeInj } from '~/context' |
|
|
|
|
|
|
|
|
|
|
|
provide(IsFormInj, ref(true)) |
|
|
|
provide(IsFormInj, ref(true)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
provide(EditModeInj, ref(true)) |
|
|
|
|
|
|
|
|
|
|
|
// todo: generate hideCols based on default values |
|
|
|
// todo: generate hideCols based on default values |
|
|
|
const hiddenCols = ['created_at', 'updated_at'] |
|
|
|
const hiddenCols = ['created_at', 'updated_at'] |
|
|
|
|
|
|
|
|
|
|
@ -53,6 +56,13 @@ const { showAll, hideAll, saveOrUpdate } = useViewColumns(view, meta as any, fal |
|
|
|
setFormData() |
|
|
|
setFormData() |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { syncLTARRefs } = useProvideSmartsheetRowStore(meta!, ref({ |
|
|
|
|
|
|
|
row: formState, |
|
|
|
|
|
|
|
oldRow: {}, |
|
|
|
|
|
|
|
rowMeta: { new: true }, |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
|
|
|
|
const columns = computed(() => meta?.value?.columns || []) |
|
|
|
const columns = computed(() => meta?.value?.columns || []) |
|
|
|
|
|
|
|
|
|
|
|
const localColumns = ref<Record<string, any>[]>([]) |
|
|
|
const localColumns = ref<Record<string, any>[]>([]) |
|
|
@ -92,7 +102,11 @@ async function submitForm() { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await insertRow(formState) |
|
|
|
const insertedRowData = await insertRow(formState) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (insertedRowData) { |
|
|
|
|
|
|
|
await syncLTARRefs(insertedRowData) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
submitted.value = true |
|
|
|
submitted.value = true |
|
|
|
} |
|
|
|
} |
|
|
@ -119,10 +133,7 @@ function isDbRequired(column: Record<string, any>) { |
|
|
|
// primary column |
|
|
|
// primary column |
|
|
|
(column.pk && !column.ai && !column.cdf) |
|
|
|
(column.pk && !column.ai && !column.cdf) |
|
|
|
if (column.uidt === UITypes.LinkToAnotherRecord && column.colOptions.type === RelationTypes.BELONGS_TO) { |
|
|
|
if (column.uidt === UITypes.LinkToAnotherRecord && column.colOptions.type === RelationTypes.BELONGS_TO) { |
|
|
|
const col = columns.value.find((c: Record<string, any>) => c.id === column.colOptions.fk_child_column_id) as Record< |
|
|
|
const col = columns.value.find((c: Record<string, any>) => c.id === column.colOptions.fk_child_column_id) as Record<string, any> |
|
|
|
string, |
|
|
|
|
|
|
|
any |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
if (col.rqd && !col.default) { |
|
|
|
if (col.rqd && !col.default) { |
|
|
|
isRequired = true |
|
|
|
isRequired = true |
|
|
|
} |
|
|
|
} |
|
|
@ -159,7 +170,7 @@ function onMove(event: any) { |
|
|
|
|
|
|
|
|
|
|
|
function hideColumn(idx: number) { |
|
|
|
function hideColumn(idx: number) { |
|
|
|
if (isDbRequired(localColumns.value[idx]) || localColumns.value[idx].required) { |
|
|
|
if (isDbRequired(localColumns.value[idx]) || localColumns.value[idx].required) { |
|
|
|
message.info("Required field can't be moved") |
|
|
|
message.info('Required field can\'t be moved') |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -257,10 +268,8 @@ function isRequired(_columnObj: Record<string, any>, required = false) { |
|
|
|
columnObj.colOptions && |
|
|
|
columnObj.colOptions && |
|
|
|
columnObj.colOptions.type === RelationTypes.BELONGS_TO |
|
|
|
columnObj.colOptions.type === RelationTypes.BELONGS_TO |
|
|
|
) { |
|
|
|
) { |
|
|
|
columnObj = columns.value.find((c: Record<string, any>) => c.id === columnObj.colOptions.fk_child_column_id) as Record< |
|
|
|
columnObj = columns.value.find((c: Record<string, any>) => c.id === columnObj.colOptions.fk_child_column_id) as Record<string, |
|
|
|
string, |
|
|
|
any> |
|
|
|
any |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return required || (columnObj && columnObj.rqd && !columnObj.cdf) |
|
|
|
return required || (columnObj && columnObj.rqd && !columnObj.cdf) |
|
|
@ -404,7 +413,8 @@ onMounted(async () => { |
|
|
|
</a-card> |
|
|
|
</a-card> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
<template #footer> |
|
|
|
<template #footer> |
|
|
|
<div class="mt-4 border-dashed border-2 border-gray-400 py-3 text-gray-400 text-center nc-drag-n-drop-to-hide"> |
|
|
|
<div |
|
|
|
|
|
|
|
class="mt-4 border-dashed border-2 border-gray-400 py-3 text-gray-400 text-center nc-drag-n-drop-to-hide"> |
|
|
|
<!-- Drag and drop fields here to hide --> |
|
|
|
<!-- Drag and drop fields here to hide --> |
|
|
|
{{ $t('msg.info.dragDropHide') }} |
|
|
|
{{ $t('msg.info.dragDropHide') }} |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -568,9 +578,11 @@ onMounted(async () => { |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
|
|
|
|
|
|
|
|
|
<div class="items-center flex"> |
|
|
|
<div class="items-center flex"> |
|
|
|
<span class="text-sm text-gray-500 mr-2 nc-form-input-required">{{ $t('general.required') }}</span> |
|
|
|
<span class="text-sm text-gray-500 mr-2 nc-form-input-required">{{ $t('general.required') |
|
|
|
|
|
|
|
}}</span> |
|
|
|
|
|
|
|
|
|
|
|
<a-switch v-model:checked="element.required" size="small" class="my-2" @change="updateColMeta(element)" /> |
|
|
|
<a-switch v-model:checked="element.required" size="small" class="my-2" |
|
|
|
|
|
|
|
@change="updateColMeta(element)" /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
@ -653,7 +665,8 @@ onMounted(async () => { |
|
|
|
/> |
|
|
|
/> |
|
|
|
<!-- Email me at <email> --> |
|
|
|
<!-- Email me at <email> --> |
|
|
|
<span class="ml-4"> |
|
|
|
<span class="ml-4"> |
|
|
|
{{ $t('msg.info.emailForm') }} <span class="text-bold text-gray-600">{{ state.user.value?.email }}</span> |
|
|
|
{{ $t('msg.info.emailForm') }} <span class="text-bold text-gray-600">{{ state.user.value?.email |
|
|
|
|
|
|
|
}}</span> |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|