|
|
|
@ -7,6 +7,7 @@ import {
|
|
|
|
|
computed, |
|
|
|
|
inject, |
|
|
|
|
ref, |
|
|
|
|
useExpandedFormDetached, |
|
|
|
|
useLTARStoreOrThrow, |
|
|
|
|
useSmartsheetRowStoreOrThrow, |
|
|
|
|
useVModel, |
|
|
|
@ -22,6 +23,8 @@ const vModel = useVModel(props, 'modelValue', emit)
|
|
|
|
|
|
|
|
|
|
const column = inject(ColumnInj) |
|
|
|
|
|
|
|
|
|
const { open, close } = useExpandedFormDetached() |
|
|
|
|
|
|
|
|
|
const { |
|
|
|
|
childrenExcludedList, |
|
|
|
|
loadChildrenExcludedList, |
|
|
|
@ -57,8 +60,6 @@ watch(vModel, (nextVal, prevVal) => {
|
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const expandedFormDlg = ref(false) |
|
|
|
|
|
|
|
|
|
/** populate initial state for a new row which is parent/child of current record */ |
|
|
|
|
const newRowState = computed(() => { |
|
|
|
|
if (isNew.value) return {} |
|
|
|
@ -93,11 +94,23 @@ const newRowState = computed(() => {
|
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
// if it's an existing record close the list |
|
|
|
|
// after new record creation since it's already linking while creating |
|
|
|
|
watch(expandedFormDlg, (nexVal) => { |
|
|
|
|
if (!nexVal && !isNew.value) vModel.value = false |
|
|
|
|
}) |
|
|
|
|
function openExpandedForm() { |
|
|
|
|
// if it's an existing record close the list |
|
|
|
|
// after new record creation since it's already linking while creating |
|
|
|
|
if (!isNew.value) { |
|
|
|
|
vModel.value = false |
|
|
|
|
return close() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
open({ |
|
|
|
|
isOpen: true, |
|
|
|
|
row: { row: {}, oldRow: {}, rowMeta: { new: true } }, |
|
|
|
|
meta: relatedTableMeta.value, |
|
|
|
|
loadRow: false, |
|
|
|
|
useMetaFields: true, |
|
|
|
|
state: newRowState.value, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
@ -122,7 +135,7 @@ watch(expandedFormDlg, (nexVal) => {
|
|
|
|
|
<MdiReload class="cursor-pointer text-gray-500 nc-reload" @click="loadChildrenExcludedList" /> |
|
|
|
|
|
|
|
|
|
<!-- Add new record --> |
|
|
|
|
<a-button v-if="!isPublic" type="primary" size="small" @click="expandedFormDlg = true"> |
|
|
|
|
<a-button v-if="!isPublic" type="primary" size="small" @click="openExpandedForm"> |
|
|
|
|
{{ $t('activity.addNewRecord') }} |
|
|
|
|
</a-button> |
|
|
|
|
</div> |
|
|
|
@ -156,17 +169,6 @@ watch(expandedFormDlg, (nexVal) => {
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<a-empty v-else class="my-10" :image="Empty.PRESENTED_IMAGE_SIMPLE" /> |
|
|
|
|
|
|
|
|
|
<Suspense> |
|
|
|
|
<LazySmartsheetExpandedForm |
|
|
|
|
v-if="expandedFormDlg" |
|
|
|
|
v-model="expandedFormDlg" |
|
|
|
|
:meta="relatedTableMeta" |
|
|
|
|
:row="{ row: {}, oldRow: {}, rowMeta: { new: true } }" |
|
|
|
|
:state="newRowState" |
|
|
|
|
use-meta-fields |
|
|
|
|
/> |
|
|
|
|
</Suspense> |
|
|
|
|
</div> |
|
|
|
|
</a-modal> |
|
|
|
|
</template> |
|
|
|
|