Browse Source

revert(nc-gui): list items to use regular expanded form

pull/4141/head
braks 2 years ago
parent
commit
030bab3c9b
  1. 1
      packages/nc-gui/components/smartsheet/Grid.vue
  2. 39
      packages/nc-gui/components/virtual-cell/components/ListChildItems.vue
  3. 40
      packages/nc-gui/components/virtual-cell/components/ListItems.vue

1
packages/nc-gui/components/smartsheet/Grid.vue

@ -18,6 +18,7 @@ import {
ReloadViewDataHookInj, ReloadViewDataHookInj,
computed, computed,
createEventHook, createEventHook,
enumColor,
extractPkFromRow, extractPkFromRow,
inject, inject,
isColumnRequiredAndNull, isColumnRequiredAndNull,

39
packages/nc-gui/components/virtual-cell/components/ListChildItems.vue

@ -11,13 +11,11 @@ import {
h, h,
inject, inject,
ref, ref,
useExpandedFormDetached,
useLTARStoreOrThrow, useLTARStoreOrThrow,
useSmartsheetRowStoreOrThrow, useSmartsheetRowStoreOrThrow,
useVModel, useVModel,
watch, watch,
} from '#imports' } from '#imports'
import type { Row } from '~/lib'
const props = defineProps<{ modelValue?: boolean; cellValue: any }>() const props = defineProps<{ modelValue?: boolean; cellValue: any }>()
@ -33,8 +31,6 @@ const column = inject(ColumnInj)
const readonly = inject(ReadonlyInj, false) const readonly = inject(ReadonlyInj, false)
const { open } = useExpandedFormDetached()
const { const {
childrenList, childrenList,
deleteRelatedRow, deleteRelatedRow,
@ -81,6 +77,10 @@ const container = computed(() =>
: Modal, : Modal,
) )
const expandedFormDlg = ref(false)
const expandedFormRow = ref()
/** reload children list whenever cell value changes and list is visible */ /** reload children list whenever cell value changes and list is visible */
watch( watch(
() => props.cellValue, () => props.cellValue,
@ -88,18 +88,6 @@ watch(
if (!isNew.value && vModel.value) loadChildrenList() if (!isNew.value && vModel.value) loadChildrenList()
}, },
) )
function openExpandedForm(row: Row) {
if (readonly) return
open({
isOpen: true,
row: { row, oldRow: row, rowMeta: {} },
meta: relatedTableMeta.value,
loadRow: true,
useMetaFields: true,
})
}
</script> </script>
<template> <template>
@ -138,7 +126,13 @@ function openExpandedForm(row: Row) {
v-for="(row, i) of childrenList?.list ?? state?.[column?.title] ?? []" v-for="(row, i) of childrenList?.list ?? state?.[column?.title] ?? []"
:key="i" :key="i"
class="!my-4 hover:(!bg-gray-200/50 shadow-md)" class="!my-4 hover:(!bg-gray-200/50 shadow-md)"
@click="openExpandedForm(row)" @click="
() => {
if (readonly) return
expandedFormRow = row
expandedFormDlg = true
}
"
> >
<div class="flex items-center"> <div class="flex items-center">
<div class="flex-1 overflow-hidden min-w-0"> <div class="flex-1 overflow-hidden min-w-0">
@ -182,6 +176,17 @@ function openExpandedForm(row: Row) {
:image-style="isForm ? { height: '20px' } : {}" :image-style="isForm ? { height: '20px' } : {}"
/> />
</div> </div>
<Suspense>
<LazySmartsheetExpandedForm
v-if="expandedFormRow && expandedFormDlg"
v-model="expandedFormDlg"
:row="{ row: expandedFormRow, oldRow: expandedFormRow, rowMeta: {} }"
:meta="relatedTableMeta"
load-row
use-meta-fields
/>
</Suspense>
</component> </component>
</template> </template>

40
packages/nc-gui/components/virtual-cell/components/ListItems.vue

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

Loading…
Cancel
Save