Browse Source

fix: insert before cause primary value to move

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/5060/head
mertmit 2 years ago
parent
commit
242f568c7d
  1. 2
      packages/nocodb/src/lib/models/GridViewColumn.ts
  2. 5
      packages/nocodb/src/lib/models/View.ts

2
packages/nocodb/src/lib/models/GridViewColumn.ts

@ -108,6 +108,8 @@ export default class GridViewColumn implements GridColumnType {
[column.fk_view_id], [column.fk_view_id],
`${CacheScope.GRID_VIEW_COLUMN}:${id}` `${CacheScope.GRID_VIEW_COLUMN}:${id}`
); );
await View.fixPVColumnForView(column.fk_view_id, ncMeta);
return this.get(id, ncMeta); return this.get(id, ncMeta);
} }

5
packages/nocodb/src/lib/models/View.ts

@ -1184,6 +1184,9 @@ export default class View implements ViewType {
if (primary_value_column_meta) { if (primary_value_column_meta) {
const primary_value_column = view_columns.find((col) => col.fk_column_id === primary_value_column_meta.id); const primary_value_column = view_columns.find((col) => col.fk_column_id === primary_value_column_meta.id);
const primary_value_column_index = view_columns.findIndex((col) => col.fk_column_id === primary_value_column_meta.id); const primary_value_column_index = view_columns.findIndex((col) => col.fk_column_id === primary_value_column_meta.id);
const view_orders = view_columns.map((col) => col.order);
const view_min_order = Math.min(...view_orders);
// if primary_value_column is not visible, make it visible // if primary_value_column is not visible, make it visible
if (!primary_value_column.show) { if (!primary_value_column.show) {
await ncMeta.metaUpdate( await ncMeta.metaUpdate(
@ -1199,7 +1202,7 @@ export default class View implements ViewType {
); );
} }
if (primary_value_column.order < 2) { if (primary_value_column.order === view_min_order && view_orders.filter((o) => o === view_min_order).length === 1) {
// if primary_value_column is in first order do nothing // if primary_value_column is in first order do nothing
return; return;
} else { } else {

Loading…
Cancel
Save