Date: Mon, 8 Jan 2024 08:42:20 +0000
Subject: [PATCH 09/15] fix: comment info
---
packages/nc-gui/components/smartsheet/details/Fields.vue | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/packages/nc-gui/components/smartsheet/details/Fields.vue b/packages/nc-gui/components/smartsheet/details/Fields.vue
index 1681b60168..9416c5f6c5 100644
--- a/packages/nc-gui/components/smartsheet/details/Fields.vue
+++ b/packages/nc-gui/components/smartsheet/details/Fields.vue
@@ -275,7 +275,7 @@ const onFieldUpdate = (state: TableExplorerColumn) => {
const diffs = diff(col, state)
- // hack to prevent update status `Updated Field` when clicking on field
+ // hack to prevent update status `Updated Field` when clicking on field first time
let isUpdated = true
switch (col?.uidt) {
@@ -308,7 +308,6 @@ const onFieldUpdate = (state: TableExplorerColumn) => {
) {
isUpdated = false
}
-
break
}
From 6d3bc801ce84e133c15be35b97e879c8fe4c8dd0 Mon Sep 17 00:00:00 2001
From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com>
Date: Mon, 8 Jan 2024 08:42:20 +0000
Subject: [PATCH 10/15] fix: multifield editor on click field status update
issues
---
.../components/smartsheet/details/Fields.vue | 23 +++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/packages/nc-gui/components/smartsheet/details/Fields.vue b/packages/nc-gui/components/smartsheet/details/Fields.vue
index 9416c5f6c5..85ea412fdb 100644
--- a/packages/nc-gui/components/smartsheet/details/Fields.vue
+++ b/packages/nc-gui/components/smartsheet/details/Fields.vue
@@ -280,20 +280,20 @@ const onFieldUpdate = (state: TableExplorerColumn) => {
switch (col?.uidt) {
case UITypes.QrCode:
- if (Object.keys(diffs).length === 1 && col?.colOptions?.fk_qr_value_column_id === state?.fk_qr_value_column_id) {
+ if (Object.keys(diffs).length === 1 && col?.colOptions?.fk_qr_value_column_id === diffs?.fk_qr_value_column_id) {
isUpdated = false
}
break
case UITypes.Barcode:
- if (Object.keys(diffs).length === 1 && col?.colOptions?.fk_barcode_value_column_id === state?.fk_barcode_value_column_id) {
+ if (Object.keys(diffs).length === 1 && col?.colOptions?.fk_barcode_value_column_id === diffs?.fk_barcode_value_column_id) {
isUpdated = false
}
break
case UITypes.Lookup:
if (
Object.keys(diffs).length === 2 &&
- col?.colOptions?.fk_lookup_column_id === state?.fk_lookup_column_id &&
- col?.colOptions?.fk_relation_column_id === state?.fk_relation_column_id
+ col?.colOptions?.fk_lookup_column_id === diffs?.fk_lookup_column_id &&
+ col?.colOptions?.fk_relation_column_id === diffs?.fk_relation_column_id
) {
isUpdated = false
}
@@ -309,6 +309,21 @@ const onFieldUpdate = (state: TableExplorerColumn) => {
isUpdated = false
}
break
+ case UITypes.Formula:
+ if (Object.keys(diffs).length === 1 && col?.colOptions?.formula_raw === diffs?.formula_raw) {
+ isUpdated = false
+ }
+ break
+ case UITypes.Rollup:
+ if (
+ Object.keys(diffs).length === 3 &&
+ col?.colOptions?.fk_relation_column_id === diffs?.fk_relation_column_id &&
+ col?.colOptions?.fk_rollup_column_id === diffs?.fk_rollup_column_id &&
+ col?.colOptions?.rollup_function === diffs?.rollup_function
+ ) {
+ isUpdated = false
+ }
+ break
}
if (Object.keys(diffs).length === 0 || (Object.keys(diffs).length === 1 && 'altered' in diffs) || !isUpdated) {
From 7b1cb7cb751900f5b28b631f736e257d341376de Mon Sep 17 00:00:00 2001
From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com>
Date: Mon, 8 Jan 2024 08:42:20 +0000
Subject: [PATCH 11/15] fix: reorder and status update issue for some fields
---
.../components/smartsheet/details/Fields.vue | 113 ++++++++++--------
1 file changed, 66 insertions(+), 47 deletions(-)
diff --git a/packages/nc-gui/components/smartsheet/details/Fields.vue b/packages/nc-gui/components/smartsheet/details/Fields.vue
index 85ea412fdb..44623b3b5b 100644
--- a/packages/nc-gui/components/smartsheet/details/Fields.vue
+++ b/packages/nc-gui/components/smartsheet/details/Fields.vue
@@ -100,6 +100,7 @@ const fields = computed
({
const x = ((meta.value?.columns as ColumnType[]) ?? [])
.filter((field) => !field.fk_column_id && !isSystemColumn(field))
.concat(newFields.value)
+ .map((field) => updateDefaultColumnValues(field))
.sort((a, b) => {
return getFieldOrder(a) - getFieldOrder(b)
})
@@ -278,52 +279,21 @@ const onFieldUpdate = (state: TableExplorerColumn) => {
// hack to prevent update status `Updated Field` when clicking on field first time
let isUpdated = true
- switch (col?.uidt) {
- case UITypes.QrCode:
- if (Object.keys(diffs).length === 1 && col?.colOptions?.fk_qr_value_column_id === diffs?.fk_qr_value_column_id) {
- isUpdated = false
- }
- break
- case UITypes.Barcode:
- if (Object.keys(diffs).length === 1 && col?.colOptions?.fk_barcode_value_column_id === diffs?.fk_barcode_value_column_id) {
- isUpdated = false
- }
- break
- case UITypes.Lookup:
- if (
- Object.keys(diffs).length === 2 &&
- col?.colOptions?.fk_lookup_column_id === diffs?.fk_lookup_column_id &&
- col?.colOptions?.fk_relation_column_id === diffs?.fk_relation_column_id
- ) {
- isUpdated = false
- }
- break
- case UITypes.SingleSelect:
- case UITypes.MultiSelect:
- if (
- Object.keys(diffs).length === 1 &&
- diffs?.colOptions?.options &&
- (diffs?.colOptions?.options?.length === 0 ||
- (diffs?.colOptions?.options[0]?.index !== undefined && Object.keys(diffs?.colOptions?.options[0] || {}).length === 1))
- ) {
- isUpdated = false
- }
- break
- case UITypes.Formula:
- if (Object.keys(diffs).length === 1 && col?.colOptions?.formula_raw === diffs?.formula_raw) {
- isUpdated = false
- }
- break
- case UITypes.Rollup:
- if (
- Object.keys(diffs).length === 3 &&
- col?.colOptions?.fk_relation_column_id === diffs?.fk_relation_column_id &&
- col?.colOptions?.fk_rollup_column_id === diffs?.fk_rollup_column_id &&
- col?.colOptions?.rollup_function === diffs?.rollup_function
- ) {
- isUpdated = false
- }
- break
+ if (
+ [UITypes.SingleSelect, UITypes.MultiSelect].includes(col.uidt) &&
+ Object.keys(diffs).length === 1 &&
+ diffs?.colOptions?.options &&
+ (diffs?.colOptions?.options?.length === 0 ||
+ (diffs?.colOptions?.options[0]?.index !== undefined && Object.keys(diffs?.colOptions?.options[0] || {}).length === 1))
+ ) {
+ isUpdated = false
+ }
+
+ if (!isUpdated) {
+ let field = fields.value.find((field) => compareCols(field, state))
+ if (field) {
+ field = state
+ }
}
if (Object.keys(diffs).length === 0 || (Object.keys(diffs).length === 1 && 'altered' in diffs) || !isUpdated) {
@@ -495,6 +465,52 @@ const isColumnValid = (column: TableExplorerColumn) => {
return true
}
+const updateDefaultColumnValues = (column: TableExplorerColumn) => {
+ if (column.uidt === UITypes.QrCode && column.colOptions?.fk_qr_value_column_id) {
+ if (!column?.fk_qr_value_column_id) {
+ column.fk_qr_value_column_id = column.colOptions.fk_qr_value_column_id
+ }
+ }
+
+ if (column.uidt === UITypes.Barcode && column.colOptions?.fk_barcode_value_column_id) {
+ if (!column?.fk_barcode_value_column_id) {
+ column.fk_barcode_value_column_id = column.colOptions.fk_barcode_value_column_id
+ }
+ }
+
+ if (column.uidt === UITypes.Lookup && column?.colOptions?.fk_lookup_column_id && column?.colOptions?.fk_relation_column_id) {
+ if (!column?.fk_lookup_column_id) {
+ column.fk_lookup_column_id = column.colOptions.fk_lookup_column_id
+ }
+ if (!column?.fk_relation_column_id) {
+ column.fk_relation_column_id = column.colOptions.fk_relation_column_id
+ }
+ }
+
+ if (
+ column.uidt === UITypes.Rollup &&
+ column?.colOptions?.fk_relation_column_id &&
+ column?.colOptions?.fk_rollup_column_id &&
+ column?.colOptions?.rollup_function
+ ) {
+ if (!column?.fk_relation_column_id) {
+ column.fk_relation_column_id = column.colOptions.fk_relation_column_id
+ }
+ if (!column?.fk_rollup_column_id) {
+ column.fk_rollup_column_id = column.colOptions.fk_rollup_column_id
+ }
+ if (!column?.rollup_function) {
+ column.rollup_function = column.colOptions.rollup_function
+ }
+ }
+
+ if (column.uidt === UITypes.Formula && column.colOptions?.formula_raw && !column?.formula_raw) {
+ column.formula_raw = column.colOptions?.formula_raw
+ }
+
+ return column
+}
+
const recoverField = (state: TableExplorerColumn) => {
const field = ops.value.find((op) => compareCols(op.column, state))
if (field) {
@@ -598,7 +614,10 @@ const saveChanges = async () => {
await loadViewColumns()
if (res) {
- ops.value = (res.failedOps as op[]) || []
+ ops.value =
+ res.failedOps && res.failedOps?.length
+ ? (res.failedOps as (op & { error: unknown })[]).map(({ error, ...rest }) => rest)
+ : []
newFields.value = newFields.value.filter((col) => {
if (res.failedOps) {
const op = res.failedOps.find((fop) => {
From e20f0be5cf75942e7140958d1559ce4cc80cc8e5 Mon Sep 17 00:00:00 2001
From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com>
Date: Mon, 8 Jan 2024 08:42:21 +0000
Subject: [PATCH 12/15] fix: duplicate fields in payload issue
---
.../components/smartsheet/details/Fields.vue | 35 +++++++++++--------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/packages/nc-gui/components/smartsheet/details/Fields.vue b/packages/nc-gui/components/smartsheet/details/Fields.vue
index 44623b3b5b..03bd63e746 100644
--- a/packages/nc-gui/components/smartsheet/details/Fields.vue
+++ b/packages/nc-gui/components/smartsheet/details/Fields.vue
@@ -318,7 +318,7 @@ const onFieldUpdate = (state: TableExplorerColumn) => {
return
}
- if (field && !moveField) {
+ if (field || (field && moveField)) {
field.column = state
} else {
ops.value.push({
@@ -403,6 +403,19 @@ const onMove = (_event: { moved: { newIndex: number; oldIndex: number } }) => {
return
}
+ const mop = moveOps.value.find((op) => compareCols(op.column, fields.value[_event.moved.oldIndex]))
+ if (mop) {
+ mop.index = _event.moved.newIndex
+ mop.order = order
+ } else {
+ moveOps.value.push({
+ op: 'move',
+ column: fields.value[_event.moved.oldIndex],
+ index: _event.moved.newIndex,
+ order,
+ })
+ }
+
if (op) {
onFieldUpdate({
...op.column,
@@ -420,19 +433,6 @@ const onMove = (_event: { moved: { newIndex: number; oldIndex: number } }) => {
},
})
}
-
- const mop = moveOps.value.find((op) => compareCols(op.column, fields.value[_event.moved.oldIndex]))
- if (mop) {
- mop.index = _event.moved.newIndex
- mop.order = order
- } else {
- moveOps.value.push({
- op: 'move',
- column: fields.value[_event.moved.oldIndex],
- index: _event.moved.newIndex,
- order,
- })
- }
}
const isColumnValid = (column: TableExplorerColumn) => {
@@ -585,6 +585,13 @@ const saveChanges = async () => {
view_id: view.value?.id as string,
}
}
+
+ if (op && op.op === 'update') {
+ op.column.column_order = {
+ order: mop.order,
+ view_id: view.value?.id as string,
+ }
+ }
}
for (const op of ops.value) {
From de58fc34869c2a60fd10cdd7df625c5e7b60ce11 Mon Sep 17 00:00:00 2001
From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com>
Date: Mon, 8 Jan 2024 08:42:21 +0000
Subject: [PATCH 13/15] feat: bulk update reorder view support for Links &
LinkToAnotherRecord
---
.../nocodb/src/services/columns.service.ts | 25 ++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/packages/nocodb/src/services/columns.service.ts b/packages/nocodb/src/services/columns.service.ts
index b07d36a485..40830ca928 100644
--- a/packages/nocodb/src/services/columns.service.ts
+++ b/packages/nocodb/src/services/columns.service.ts
@@ -52,6 +52,7 @@ import {
KanbanView,
Model,
Source,
+ View,
} from '~/models';
import Noco from '~/Noco';
import NcConnectionMgrv2 from '~/utils/common/NcConnectionMgrv2';
@@ -195,7 +196,8 @@ export class ColumnsService {
formula?: string;
formula_raw?: string;
parsed_tree?: any;
- };
+ } & Partial>;
+
if (
isCreatedOrLastModifiedTimeCol(column) ||
[
@@ -274,7 +276,28 @@ export class ColumnsService {
meta: colBody.meta,
});
}
+
+ if (
+ [UITypes.Links, UITypes.LinkToAnotherRecord].includes(
+ column.uidt,
+ ) &&
+ colBody?.column_order &&
+ colBody.column_order?.order &&
+ colBody.column_order?.view_id
+ ) {
+ const viewColumn = (
+ await View.getColumns(colBody.column_order.view_id)
+ ).find((col) => col.fk_column_id === column.id);
+ await View.updateColumn(
+ colBody.column_order.view_id,
+ viewColumn.id,
+ {
+ order: colBody.column_order.order,
+ },
+ );
+ }
}
+
await this.updateRollupOrLookup(colBody, column);
} else {
NcError.notImplemented(
From 88e28da71f03bb7c99b784e310b7e7b89196bde4 Mon Sep 17 00:00:00 2001
From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com>
Date: Mon, 8 Jan 2024 08:42:21 +0000
Subject: [PATCH 14/15] fix: lint error
---
packages/nocodb/src/services/columns.service.ts | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/packages/nocodb/src/services/columns.service.ts b/packages/nocodb/src/services/columns.service.ts
index 40830ca928..94edb59fad 100644
--- a/packages/nocodb/src/services/columns.service.ts
+++ b/packages/nocodb/src/services/columns.service.ts
@@ -197,7 +197,7 @@ export class ColumnsService {
formula_raw?: string;
parsed_tree?: any;
} & Partial>;
-
+
if (
isCreatedOrLastModifiedTimeCol(column) ||
[
@@ -277,6 +277,7 @@ export class ColumnsService {
});
}
+ // handle reorder column for Links and LinkToAnotherRecord
if (
[UITypes.Links, UITypes.LinkToAnotherRecord].includes(
column.uidt,
From c1b0991521a57a745928bfb1f22f4a301d90f3df Mon Sep 17 00:00:00 2001
From: Ramesh Mane <101566080+rameshmane7218@users.noreply.github.com>
Date: Mon, 8 Jan 2024 08:42:21 +0000
Subject: [PATCH 15/15] fix: review changes
---
.../nc-gui/components/smartsheet/details/Fields.vue | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/packages/nc-gui/components/smartsheet/details/Fields.vue b/packages/nc-gui/components/smartsheet/details/Fields.vue
index 03bd63e746..7f32a19197 100644
--- a/packages/nc-gui/components/smartsheet/details/Fields.vue
+++ b/packages/nc-gui/components/smartsheet/details/Fields.vue
@@ -117,10 +117,6 @@ const fields = computed({
},
})
-const _fields = computed(() => {
- return fields.value
-})
-
// Current Selected Field
const activeField = ref()
@@ -465,7 +461,7 @@ const isColumnValid = (column: TableExplorerColumn) => {
return true
}
-const updateDefaultColumnValues = (column: TableExplorerColumn) => {
+function updateDefaultColumnValues(column: TableExplorerColumn) {
if (column.uidt === UITypes.QrCode && column.colOptions?.fk_qr_value_column_id) {
if (!column?.fk_qr_value_column_id) {
column.fk_qr_value_column_id = column.colOptions.fk_qr_value_column_id
@@ -585,7 +581,7 @@ const saveChanges = async () => {
view_id: view.value?.id as string,
}
}
-
+
if (op && op.op === 'update') {
op.column.column_order = {
order: mop.order,
@@ -623,7 +619,7 @@ const saveChanges = async () => {
if (res) {
ops.value =
res.failedOps && res.failedOps?.length
- ? (res.failedOps as (op & { error: unknown })[]).map(({ error, ...rest }) => rest)
+ ? (res.failedOps as (op & { error: unknown })[]).map(({ error: _, ...rest }) => rest)
: []
newFields.value = newFields.value.filter((col) => {
if (res.failedOps) {
@@ -872,7 +868,7 @@ watch(