Browse Source

fix(gui-v2): show comments only for saved records

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/3271/head
Pranav C 2 years ago
parent
commit
4a6883094e
  1. 2
      packages/nc-gui-v2/components/smartsheet/expanded-form/Header.vue
  2. 5
      packages/nc-gui-v2/components/smartsheet/expanded-form/index.vue
  3. 2
      packages/nc-gui-v2/components/virtual-cell/components/ItemChip.vue
  4. 7
      packages/nc-gui-v2/composables/useExpandedFormStore.ts

2
packages/nc-gui-v2/components/smartsheet/expanded-form/Header.vue

@ -57,7 +57,7 @@ const iconColor = '#1890ff'
<component <component
:is="drawerToggleIcon" :is="drawerToggleIcon"
v-if="isUIAllowed('rowComments')" v-if="isUIAllowed('rowComments') && !isNew"
class="cursor-pointer select-none nc-toggle-comments" class="cursor-pointer select-none nc-toggle-comments"
@click="commentsDrawer = !commentsDrawer" @click="commentsDrawer = !commentsDrawer"
/> />

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

@ -53,7 +53,7 @@ const fields = computedInject(FieldsInj, (_fields) => {
provide(MetaInj, meta) provide(MetaInj, meta)
const { commentsDrawer, changedColumns, state: rowState } = useProvideExpandedFormStore(meta, row) const { commentsDrawer, changedColumns, state: rowState, isNew } = useProvideExpandedFormStore(meta, row)
const { $api } = useNuxtApp() const { $api } = useNuxtApp()
@ -113,6 +113,7 @@ export default {
<div class="w-[500px] mx-auto"> <div class="w-[500px] mx-auto">
<div v-for="col of fields" :key="col.title" class="mt-2 py-2" :class="`nc-expand-col-${col.title}`"> <div v-for="col of fields" :key="col.title" class="mt-2 py-2" :class="`nc-expand-col-${col.title}`">
<SmartsheetHeaderVirtualCell v-if="isVirtualCol(col)" :column="col" /> <SmartsheetHeaderVirtualCell v-if="isVirtualCol(col)" :column="col" />
<SmartsheetHeaderCell v-else :column="col" /> <SmartsheetHeaderCell v-else :column="col" />
<div class="!bg-white rounded px-1 min-h-[35px] flex items-center mt-2"> <div class="!bg-white rounded px-1 min-h-[35px] flex items-center mt-2">
@ -130,7 +131,7 @@ export default {
</div> </div>
</div> </div>
<div class="nc-comments-drawer min-w-0 min-h-full max-h-full" :class="{ active: commentsDrawer }"> <div v-if="!isNew" class="nc-comments-drawer min-w-0 min-h-full max-h-full" :class="{ active: commentsDrawer }">
<div class="h-full"> <div class="h-full">
<Comments v-if="commentsDrawer" /> <Comments v-if="commentsDrawer" />
</div> </div>

2
packages/nc-gui-v2/components/virtual-cell/components/ItemChip.vue

@ -58,7 +58,7 @@ export default {
<ExpandedForm <ExpandedForm
v-if="!readOnly && !isLocked && expandedFormDlg" v-if="!readOnly && !isLocked && expandedFormDlg"
v-model="expandedFormDlg" v-model="expandedFormDlg"
:row="{ row: item }" :row="{ row: item, rowMeta: {}, oldRow: { ...item } }"
:meta="relatedTableMeta" :meta="relatedTableMeta"
load-row load-row
use-meta-fields use-meta-fields

7
packages/nc-gui-v2/composables/useExpandedFormStore.ts

@ -121,7 +121,7 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m
return obj return obj
}, {} as Record<string, any>) }, {} as Record<string, any>)
if (row.value.rowMeta.new) { if (row.value.rowMeta?.new) {
data = await $api.dbTableRow.create('noco', project.value.title as string, meta.value.title, updateOrInsertObj) data = await $api.dbTableRow.create('noco', project.value.title as string, meta.value.title, updateOrInsertObj)
/* todo: /* todo:
@ -133,11 +133,12 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m
} }
} }
} */ } */
row.value = {
Object.assign(row.value, {
row: data, row: data,
rowMeta: {}, rowMeta: {},
oldRow: { ...data }, oldRow: { ...data },
} })
/// todo: /// todo:
// await this.reload(); // await this.reload();

Loading…
Cancel
Save