Browse Source

fix: expanded record

pull/6554/head
DarkPhoenix2704 1 year ago
parent
commit
72a3c42fb8
  1. 24
      packages/nc-gui/components/smartsheet/expanded-form/index.vue
  2. 3
      packages/nc-gui/composables/useExpandedFormStore.ts

24
packages/nc-gui/components/smartsheet/expanded-form/index.vue

@ -29,15 +29,14 @@ import {
useVModel, useVModel,
watch, watch,
} from '#imports' } from '#imports'
import type { Row } from '#imports'
interface Props { interface Props {
modelValue?: boolean modelValue?: boolean
row: Row
state?: Record<string, any> | null state?: Record<string, any> | null
meta: TableType meta: TableType
loadRow?: boolean loadRow?: boolean
useMetaFields?: boolean useMetaFields?: boolean
row?: Row
rowId?: string rowId?: string
view?: ViewType view?: ViewType
showNextPrevIcons?: boolean showNextPrevIcons?: boolean
@ -153,14 +152,14 @@ const isExpanded = useVModel(props, 'modelValue', emits, {
}) })
const onClose = () => { const onClose = () => {
if (row.value?.rowMeta?.new) emits('cancel') if (_row.value?.rowMeta?.new) emits('cancel')
isExpanded.value = false isExpanded.value = false
} }
const onDuplicateRow = () => { const onDuplicateRow = () => {
duplicatingRowInProgress.value = true duplicatingRowInProgress.value = true
isUnsavedFormExist.value = true isUnsavedFormExist.value = true
const oldRow = { ...row.value.row } const oldRow = { ..._row.value.row }
delete oldRow.ncRecordId delete oldRow.ncRecordId
const newRow = Object.assign( const newRow = Object.assign(
{}, {},
@ -171,7 +170,7 @@ const onDuplicateRow = () => {
}, },
) )
setTimeout(async () => { setTimeout(async () => {
row.value = newRow _row.value = newRow
duplicatingRowInProgress.value = false duplicatingRowInProgress.value = false
message.success(t('msg.success.rowDuplicatedWithoutSavedYet')) message.success(t('msg.success.rowDuplicatedWithoutSavedYet'))
}, 500) }, 500)
@ -223,7 +222,7 @@ provide(ReloadRowDataHookInj, reloadHook)
if (isKanban.value) { if (isKanban.value) {
// adding column titles to changedColumns if they are preset // adding column titles to changedColumns if they are preset
for (const [k, v] of Object.entries(row.value.row)) { for (const [k, v] of Object.entries(_row.value.row)) {
if (v) { if (v) {
changedColumns.value.add(k) changedColumns.value.add(k)
} }
@ -241,7 +240,7 @@ onMounted(() => {
const addNewRow = () => { const addNewRow = () => {
setTimeout(async () => { setTimeout(async () => {
row.value = { _row.value = {
row: {}, row: {},
oldRow: {}, oldRow: {},
rowMeta: { new: true }, rowMeta: { new: true },
@ -363,11 +362,10 @@ export default {
:body-style="{ padding: 0 }" :body-style="{ padding: 0 }"
:closable="false" :closable="false"
size="small" size="small"
transition=""
class="nc-drawer-expanded-form" class="nc-drawer-expanded-form"
:class="{ active: isExpanded }" :class="{ active: isExpanded }"
> >
<div :key="rowId" class="h-[85vh] xs:(max-h-full) max-h-215 flex flex-col p-6"> <div class="h-[85vh] xs:(max-h-full) max-h-215 flex flex-col p-6">
<div class="flex h-8 flex-shrink-0 w-full items-center nc-expanded-form-header relative mb-4 justify-between"> <div class="flex h-8 flex-shrink-0 w-full items-center nc-expanded-form-header relative mb-4 justify-between">
<template v-if="!isMobileMode"> <template v-if="!isMobileMode">
<div class="flex gap-3 w-100"> <div class="flex gap-3 w-100">
@ -507,11 +505,11 @@ export default {
:ref="i ? null : (el: any) => (cellWrapperEl = el)" :ref="i ? null : (el: any) => (cellWrapperEl = el)"
class="!bg-white rounded-lg !w-[20rem] !xs:w-full border-1 border-gray-200 px-1 min-h-[35px] flex items-center relative" class="!bg-white rounded-lg !w-[20rem] !xs:w-full border-1 border-gray-200 px-1 min-h-[35px] flex items-center relative"
> >
<LazySmartsheetVirtualCell v-if="isVirtualCol(col)" v-model="row.row[col.title]" :row="row" :column="col" /> <LazySmartsheetVirtualCell v-if="isVirtualCol(col)" v-model="_row.row[col.title]" :row="_row" :column="col" />
<LazySmartsheetCell <LazySmartsheetCell
v-else v-else
v-model="row.row[col.title]" v-model="_row.row[col.title]"
:column="col" :column="col"
:edit-enabled="true" :edit-enabled="true"
:active="true" :active="true"
@ -551,11 +549,11 @@ export default {
:ref="i ? null : (el: any) => (cellWrapperEl = el)" :ref="i ? null : (el: any) => (cellWrapperEl = el)"
class="!bg-white rounded-lg !w-[20rem] border-1 border-gray-200 px-1 min-h-[35px] flex items-center relative" class="!bg-white rounded-lg !w-[20rem] border-1 border-gray-200 px-1 min-h-[35px] flex items-center relative"
> >
<LazySmartsheetVirtualCell v-if="isVirtualCol(col)" v-model="row.row[col.title]" :row="row" :column="col" /> <LazySmartsheetVirtualCell v-if="isVirtualCol(col)" v-model="_row.row[col.title]" :row="_row" :column="col" />
<LazySmartsheetCell <LazySmartsheetCell
v-else v-else
v-model="row.row[col.title]" v-model="_row.row[col.title]"
:column="col" :column="col"
:edit-enabled="true" :edit-enabled="true"
:active="true" :active="true"

3
packages/nc-gui/composables/useExpandedFormStore.ts

@ -24,7 +24,7 @@ import {
} from '#imports' } from '#imports'
import type { Row } from '#imports' import type { Row } from '#imports'
const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((meta: Ref<TableType>, row: Ref<Row>) => { const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((meta: Ref<TableType>, _row: Ref<Row>) => {
const { $e, $state, $api } = useNuxtApp() const { $e, $state, $api } = useNuxtApp()
const { api, isLoading: isCommentsLoading, error: commentsError } = useApi() const { api, isLoading: isCommentsLoading, error: commentsError } = useApi()
@ -44,6 +44,7 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m
const changedColumns = ref(new Set<string>()) const changedColumns = ref(new Set<string>())
const { base } = storeToRefs(useBase()) const { base } = storeToRefs(useBase())
const row = ref<Row>(_row.value.rowMeta.new ? _row.value : ({ row: {}, oldRow: {}, rowMeta: {} } as Row))
const rowStore = useProvideSmartsheetRowStore(meta, row) const rowStore = useProvideSmartsheetRowStore(meta, row)

Loading…
Cancel
Save