diff --git a/packages/nc-gui/components/smartsheet/Gallery.vue b/packages/nc-gui/components/smartsheet/Gallery.vue index 686da30886..b66b9cc6d0 100644 --- a/packages/nc-gui/components/smartsheet/Gallery.vue +++ b/packages/nc-gui/components/smartsheet/Gallery.vue @@ -100,6 +100,8 @@ const attachments = (record: any): Attachment[] => { const expandForm = (row: RowType, state?: Record) => { const rowId = extractPkFromRow(row.row, meta.value!.columns!) + expandedFormRow.value = row + expandedFormRowState.value = state if (rowId && !isPublic.value) { router.push({ @@ -109,8 +111,6 @@ const expandForm = (row: RowType, state?: Record) => { }, }) } else { - expandedFormRow.value = row - expandedFormRowState.value = state expandedFormDlg.value = true } } @@ -340,6 +340,7 @@ watch( v-if="expandedFormRow && expandedFormDlg" v-model="expandedFormDlg" :row="expandedFormRow" + :load-row="!isPublic" :state="expandedFormRowState" :meta="meta" :view="view" @@ -350,8 +351,9 @@ watch( { const expandForm = (row: RowType, state?: Record) => { const rowId = extractPkFromRow(row.row, meta.value!.columns!) - + expandedFormRow.value = row + expandedFormRowState.value = state if (rowId && !isPublic.value) { router.push({ query: { @@ -148,8 +149,6 @@ const expandForm = (row: RowType, state?: Record) => { }, }) } else { - expandedFormRow.value = row - expandedFormRowState.value = state expandedFormDlg.value = true } } @@ -729,6 +728,7 @@ const getRowId = (row: RowType) => { :row="expandedFormRow" :state="expandedFormRowState" :meta="meta" + :load-row="!isPublic" :view="view" /> @@ -736,9 +736,9 @@ const getRowId = (row: RowType) => { `mapView.${viewId}.cente const expandForm = (row: Row, state?: Record) => { const rowId = extractPkFromRow(row.row, meta.value!.columns!) + expandedFormRow.value = row + if (rowId) { router.push({ query: { @@ -59,7 +61,6 @@ const expandForm = (row: Row, state?: Record) => { }, }) } else { - expandedFormRow.value = row expandedFormRowState.value = state expandedFormDlg.value = true } @@ -236,6 +237,7 @@ const count = computed(() => paginationData.value.totalRows) v-if="expandedFormRow && expandedFormDlg" v-model="expandedFormDlg" :row="expandedFormRow" + :load-row="!isPublic" :state="expandedFormRowState" :meta="meta" :view="view" @@ -245,8 +247,9 @@ const count = computed(() => paginationData.value.totalRows) diff --git a/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue b/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue index 463ea3dc11..169996d599 100644 --- a/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue +++ b/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue @@ -681,13 +681,13 @@ const stopDrag = (event: MouseEvent) => { } const dragStart = (event: MouseEvent, record: Row) => { - if (!isUIAllowed('dataEdit')) return let target = event.target as HTMLElement isDragging.value = false // We use a timeout to determine if the user is dragging or clicking on the record dragTimeout.value = setTimeout(() => { + if (!isUIAllowed('dataEdit')) return isDragging.value = true while (!target.classList.contains('draggable-record')) { target = target.parentElement as HTMLElement diff --git a/packages/nc-gui/components/smartsheet/calendar/MonthView.vue b/packages/nc-gui/components/smartsheet/calendar/MonthView.vue index 78af507744..e9375044c1 100644 --- a/packages/nc-gui/components/smartsheet/calendar/MonthView.vue +++ b/packages/nc-gui/components/smartsheet/calendar/MonthView.vue @@ -567,11 +567,12 @@ const stopDrag = (event: MouseEvent) => { } const dragStart = (event: MouseEvent, record: Row) => { - if (!isUIAllowed('dataEdit') || resizeInProgress.value || !record.rowMeta.id) return + if (resizeInProgress.value || !record.rowMeta.id) return let target = event.target as HTMLElement isDragging.value = false dragTimeout.value = setTimeout(() => { + if (!isUIAllowed('dataEdit')) return isDragging.value = true while (!target.classList.contains('draggable-record')) { @@ -825,7 +826,6 @@ const addRecord = (date: dayjs.Dayjs) => { :resize="!!record.rowMeta.range?.fk_to_col && isUIAllowed('dataEdit')" :selected="dragRecord?.rowMeta?.id === record.rowMeta.id || resizeRecord?.rowMeta?.id === record.rowMeta.id" @resize-start="onResizeStart" - @dblclick.stop="emit('expandRecord', record)" > diff --git a/packages/nc-gui/components/smartsheet/expanded-form/index.vue b/packages/nc-gui/components/smartsheet/expanded-form/index.vue index 6c0dac31e7..af5eda0ed9 100644 --- a/packages/nc-gui/components/smartsheet/expanded-form/index.vue +++ b/packages/nc-gui/components/smartsheet/expanded-form/index.vue @@ -63,8 +63,6 @@ const isFirstRow = toRef(props, 'firstRow') const route = useRoute() -const router = useRouter() - const isPublic = inject(IsPublicInj, ref(false)) // to check if a expanded form which is not yet saved exist or not @@ -303,14 +301,20 @@ provide(ReloadRowDataHookInj, reloadHook) if (isKanban.value) { // adding column titles to changedColumns if they are preset - for (const [k, v] of Object.entries(_row.value.row)) { - if (v) { - changedColumns.value.add(k) + if (_row.value.rowMeta.new) { + for (const [k, v] of Object.entries(_row.value.row)) { + if (v) { + changedColumns.value.add(k) + } } } } provide(IsExpandedFormOpenInj, isExpanded) +const triggerRowLoad = async (rowId?: string) => { + await Promise.allSettled([loadComments(), loadAudits(), _loadRow(rowId)]) +} + const cellWrapperEl = ref() onMounted(async () => { @@ -318,22 +322,15 @@ onMounted(async () => { isLoading.value = true const focusFirstCell = !isExpandedFormCommentMode.value + let isTriggered = false - if (props.loadRow) { - await _loadRow() - await Promise.all([loadComments(), loadAudits()]) - } - - if (props.rowId) { - try { - await _loadRow(props.rowId) - await Promise.all([loadComments(), loadAudits()]) - } catch (e: any) { - if (e.response?.status === 404) { - message.error(t('msg.noRecordFound')) - router.replace({ query: {} }) - } else throw e - } + if (props.loadRow && !props.rowId) { + await triggerRowLoad() + isTriggered = true + } else if (props.rowId && props.loadRow && !isTriggered) { + await triggerRowLoad(props.rowId) + } else { + _row.value = props.row } isLoading.value = false @@ -401,7 +398,7 @@ useActiveKeyupListener( ;(document.activeElement as HTMLInputElement)?.blur?.() if (changedColumns.value.size > 0) { - await Modal.confirm({ + Modal.confirm({ title: t('msg.saveChanges'), okText: t('general.save'), cancelText: t('labels.discard'), @@ -415,7 +412,7 @@ useActiveKeyupListener( }, }) } else if (isNew.value) { - await Modal.confirm({ + Modal.confirm({ title: 'Do you want to save the record?', okText: t('general.save'), cancelText: t('labels.discard'), @@ -458,8 +455,7 @@ const onConfirmDeleteRowClick = async () => { } watch(rowId, async (nRow) => { - await _loadRow(nRow) - await Promise.all([loadComments(), loadAudits()]) + await triggerRowLoad(nRow) }) const showRightSections = computed(() => { diff --git a/packages/nc-gui/components/smartsheet/grid/Table.vue b/packages/nc-gui/components/smartsheet/grid/Table.vue index 00bdb44efe..23264e6e42 100644 --- a/packages/nc-gui/components/smartsheet/grid/Table.vue +++ b/packages/nc-gui/components/smartsheet/grid/Table.vue @@ -1930,7 +1930,6 @@ onKeyStroke('ArrowDown', onDown)
, fromToolbar = false) { const rowId = extractPkFromRow(row.row, meta.value?.columns as ColumnType[]) - - if (rowId) { - expandedFormRowState.value = state - + expandedFormRow.value = row + expandedFormRowState.value = state + if (rowId && !isPublic.value) { router.push({ query: { ...routeQuery.value, @@ -97,8 +98,6 @@ function expandForm(row: Row, state?: Record, fromToolbar = false) }, }) } else { - expandedFormRow.value = row - expandedFormRowState.value = state expandedFormDlg.value = true skipRowRemovalOnCancel.value = !fromToolbar } @@ -238,6 +237,7 @@ const goToPreviousRow = () => { { {