|
|
@ -5,6 +5,7 @@ import { message } from 'ant-design-vue' |
|
|
|
import type { Permission } from '~/composables/useUIPermission/rolePermissions' |
|
|
|
import type { Permission } from '~/composables/useUIPermission/rolePermissions' |
|
|
|
import { |
|
|
|
import { |
|
|
|
ActiveViewInj, |
|
|
|
ActiveViewInj, |
|
|
|
|
|
|
|
EditModeInj, |
|
|
|
IsFormInj, |
|
|
|
IsFormInj, |
|
|
|
MetaInj, |
|
|
|
MetaInj, |
|
|
|
computed, |
|
|
|
computed, |
|
|
@ -22,7 +23,6 @@ import { |
|
|
|
useViewData, |
|
|
|
useViewData, |
|
|
|
watch, |
|
|
|
watch, |
|
|
|
} from '#imports' |
|
|
|
} from '#imports' |
|
|
|
import { EditModeInj } from '~/context' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
provide(IsFormInj, ref(true)) |
|
|
|
provide(IsFormInj, ref(true)) |
|
|
|
|
|
|
|
|
|
|
@ -45,7 +45,7 @@ const secondsRemain = ref(0) |
|
|
|
|
|
|
|
|
|
|
|
const isEditable = isUIAllowed('editFormView' as Permission) |
|
|
|
const isEditable = isUIAllowed('editFormView' as Permission) |
|
|
|
|
|
|
|
|
|
|
|
const meta = inject(MetaInj) |
|
|
|
const meta = inject(MetaInj)! |
|
|
|
|
|
|
|
|
|
|
|
const view = inject(ActiveViewInj) |
|
|
|
const view = inject(ActiveViewInj) |
|
|
|
|
|
|
|
|
|
|
@ -56,12 +56,14 @@ const { showAll, hideAll, saveOrUpdate } = useViewColumns(view, meta as any, fal |
|
|
|
setFormData() |
|
|
|
setFormData() |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { syncLTARRefs } = useProvideSmartsheetRowStore( |
|
|
|
const { syncLTARRefs } = useProvideSmartsheetRowStore(meta!, ref({ |
|
|
|
meta, |
|
|
|
|
|
|
|
ref({ |
|
|
|
row: formState, |
|
|
|
row: formState, |
|
|
|
oldRow: {}, |
|
|
|
oldRow: {}, |
|
|
|
rowMeta: { new: true }, |
|
|
|
rowMeta: { new: true }, |
|
|
|
})) |
|
|
|
}), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
const columns = computed(() => meta?.value?.columns || []) |
|
|
|
const columns = computed(() => meta?.value?.columns || []) |
|
|
|
|
|
|
|
|
|
|
@ -133,7 +135,10 @@ 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<string, any> |
|
|
|
const col = columns.value.find((c: Record<string, any>) => c.id === column.colOptions.fk_child_column_id) as Record< |
|
|
|
|
|
|
|
string, |
|
|
|
|
|
|
|
any |
|
|
|
|
|
|
|
> |
|
|
|
if (col.rqd && !col.default) { |
|
|
|
if (col.rqd && !col.default) { |
|
|
|
isRequired = true |
|
|
|
isRequired = true |
|
|
|
} |
|
|
|
} |
|
|
@ -170,7 +175,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 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -268,8 +273,10 @@ 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<string, |
|
|
|
columnObj = columns.value.find((c: Record<string, any>) => c.id === columnObj.colOptions.fk_child_column_id) as Record< |
|
|
|
any> |
|
|
|
string, |
|
|
|
|
|
|
|
any |
|
|
|
|
|
|
|
> |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return required || (columnObj && columnObj.rqd && !columnObj.cdf) |
|
|
|
return required || (columnObj && columnObj.rqd && !columnObj.cdf) |
|
|
@ -413,8 +420,7 @@ onMounted(async () => { |
|
|
|
</a-card> |
|
|
|
</a-card> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
<template #footer> |
|
|
|
<template #footer> |
|
|
|
<div |
|
|
|
<div class="mt-4 border-dashed border-2 border-gray-400 py-3 text-gray-400 text-center nc-drag-n-drop-to-hide"> |
|
|
|
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> |
|
|
@ -578,11 +584,9 @@ 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 class="text-sm text-gray-500 mr-2 nc-form-input-required">{{ $t('general.required') }}</span> |
|
|
|
}}</span> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<a-switch v-model:checked="element.required" size="small" class="my-2" |
|
|
|
<a-switch v-model:checked="element.required" size="small" class="my-2" @change="updateColMeta(element)" /> |
|
|
|
@change="updateColMeta(element)" /> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
@ -625,8 +629,8 @@ onMounted(async () => { |
|
|
|
v-model:value="formViewData.success_msg" |
|
|
|
v-model:value="formViewData.success_msg" |
|
|
|
:rows="3" |
|
|
|
:rows="3" |
|
|
|
hide-details |
|
|
|
hide-details |
|
|
|
@change="updateView" |
|
|
|
|
|
|
|
class="nc-form-after-submit-msg" |
|
|
|
class="nc-form-after-submit-msg" |
|
|
|
|
|
|
|
@change="updateView" |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
|
|
|
|
<!-- Other options --> |
|
|
|
<!-- Other options --> |
|
|
@ -637,8 +641,8 @@ onMounted(async () => { |
|
|
|
v-model:checked="formViewData.submit_another_form" |
|
|
|
v-model:checked="formViewData.submit_another_form" |
|
|
|
v-t="[`a:form-view:submit-another-form`]" |
|
|
|
v-t="[`a:form-view:submit-another-form`]" |
|
|
|
size="small" |
|
|
|
size="small" |
|
|
|
@change="updateView" |
|
|
|
|
|
|
|
class="nc-form-checkbox-submit-another-form" |
|
|
|
class="nc-form-checkbox-submit-another-form" |
|
|
|
|
|
|
|
@change="updateView" |
|
|
|
/> |
|
|
|
/> |
|
|
|
<span class="ml-4">{{ $t('msg.info.submitAnotherForm') }}</span> |
|
|
|
<span class="ml-4">{{ $t('msg.info.submitAnotherForm') }}</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -649,8 +653,8 @@ onMounted(async () => { |
|
|
|
v-model:checked="formViewData.show_blank_form" |
|
|
|
v-model:checked="formViewData.show_blank_form" |
|
|
|
v-t="[`a:form-view:show-blank-form`]" |
|
|
|
v-t="[`a:form-view:show-blank-form`]" |
|
|
|
size="small" |
|
|
|
size="small" |
|
|
|
@change="updateView" |
|
|
|
|
|
|
|
class="nc-form-checkbox-show-blank-form" |
|
|
|
class="nc-form-checkbox-show-blank-form" |
|
|
|
|
|
|
|
@change="updateView" |
|
|
|
/> |
|
|
|
/> |
|
|
|
<span class="ml-4">{{ $t('msg.info.showBlankForm') }}</span> |
|
|
|
<span class="ml-4">{{ $t('msg.info.showBlankForm') }}</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -660,13 +664,12 @@ onMounted(async () => { |
|
|
|
v-model:checked="emailMe" |
|
|
|
v-model:checked="emailMe" |
|
|
|
v-t="[`a:form-view:email-me`]" |
|
|
|
v-t="[`a:form-view:email-me`]" |
|
|
|
size="small" |
|
|
|
size="small" |
|
|
|
@change="onEmailChange" |
|
|
|
|
|
|
|
class="nc-form-checkbox-send-email" |
|
|
|
class="nc-form-checkbox-send-email" |
|
|
|
|
|
|
|
@change="onEmailChange" |
|
|
|
/> |
|
|
|
/> |
|
|
|
<!-- 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 |
|
|
|
{{ $t('msg.info.emailForm') }} <span class="text-bold text-gray-600">{{ state.user.value?.email }}</span> |
|
|
|
}}</span> |
|
|
|
|
|
|
|
</span> |
|
|
|
</span> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|