From 78ebeda2c671dbfced0755a87a2eeeaccd693bfa Mon Sep 17 00:00:00 2001 From: Lyubov Voloshko Date: Tue, 5 May 2026 11:53:29 +0000 Subject: [PATCH] add/edit row: fix fields order taking into account columns_view --- .../db-table-view/db-table-view.component.ts | 8 ++++++++ .../db-table-row-edit/db-table-row-edit.component.ts | 11 +++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/frontend/src/app/components/dashboard/db-table-view/db-table-view.component.ts b/frontend/src/app/components/dashboard/db-table-view/db-table-view.component.ts index 96ef14d4b..9212f7d09 100644 --- a/frontend/src/app/components/dashboard/db-table-view/db-table-view.component.ts +++ b/frontend/src/app/components/dashboard/db-table-view/db-table-view.component.ts @@ -728,9 +728,17 @@ export class DbTableViewComponent implements OnInit, OnChanges { onColumnVisibilityChange() { this.tableData.changleColumnList(this.connectionID, this.name); this.cdr.detectChanges(); + + // Send selected columns first, then non-selected at the end + const orderedColumns = [ + ...this.tableData.columns.filter((col) => col.selected), + ...this.tableData.columns.filter((col) => !col.selected), + ]; + this._tables .updatePersonalTableViewSettings(this.connectionID, this.name, { columns_view: this.tableData.displayedDataColumns, + list_fields: orderedColumns.map((col) => col.title), }) .subscribe({ next: () => { diff --git a/frontend/src/app/components/db-table-row-edit/db-table-row-edit.component.ts b/frontend/src/app/components/db-table-row-edit/db-table-row-edit.component.ts index c56b2c956..d6c743a47 100644 --- a/frontend/src/app/components/db-table-row-edit/db-table-row-edit.component.ts +++ b/frontend/src/app/components/db-table-row-edit/db-table-row-edit.component.ts @@ -198,8 +198,10 @@ export class DbTableRowEditComponent implements OnInit { return { [field.column_name]: '' }; }), ); - if (res.list_fields.length) { - const shownFieldsList = this.shownRows.map((field: TableField) => field.column_name); + const shownFieldsList = this.shownRows.map((field: TableField) => field.column_name); + if (res.columns_view && res.columns_view.length) { + this.fieldsOrdered = [...res.columns_view].filter((field) => shownFieldsList.includes(field)); + } else if (res.list_fields.length) { this.fieldsOrdered = [...res.list_fields].filter((field) => shownFieldsList.includes(field)); } else { this.fieldsOrdered = Object.keys(this.tableRowValues).map((key) => key); @@ -244,8 +246,9 @@ export class DbTableRowEditComponent implements OnInit { this.tableForeignKeys = res.foreignKeys; // this.shownRows = res.structure.filter((field: TableField) => !field.column_default?.startsWith('nextval')); this.tableRowValues = { ...res.row }; - if (res.list_fields.length) { - // const shownFieldsList = this.shownRows.map((field: TableField) => field.column_name); + if (res.columns_view && res.columns_view.length) { + this.fieldsOrdered = [...res.columns_view]; + } else if (res.list_fields.length) { this.fieldsOrdered = [...res.list_fields]; } else { this.fieldsOrdered = Object.keys(this.tableRowValues).map((key) => key);