diff --git a/app/javascript/vue/shared/datatable/table.vue b/app/javascript/vue/shared/datatable/table.vue index 16a155b50..7bbb6a2c2 100644 --- a/app/javascript/vue/shared/datatable/table.vue +++ b/app/javascript/vue/shared/datatable/table.vue @@ -48,7 +48,7 @@ @first-data-rendered="onFirstDataRendered" @sortChanged="setOrder" @columnResized="saveTableState" - @columnMoved="saveTableState" + @columnMoved="onColumnMoved" @bodyScroll="handleScroll" @columnPinned="handlePin" @columnVisible="handleVisibility" @@ -66,7 +66,7 @@ :params="actionsParams" @toolbar:action="emitAction" /> -
+
{ if (response.data.data) { - const { currentViewRender, columnsState, perPage, order } = response.data.data; - this.tableState = response.data.data; - this.currentViewRender = currentViewRender; - this.columnsState = columnsState; - this.perPage = perPage; - this.order = order; - - if (this.order) { - this.tableState.columnsState.forEach((column) => { - const updatedColumn = column; - updatedColumn.sort = this.order.column === column.colId ? this.order.dir : null; - return updatedColumn; - }); + this.fetchedTableState = response.data.data; + if (this.gridReady && this.fetchedTableState) { + this.applyTableState(this.fetchedTableState); } - this.columnApi.applyColumnState({ - state: this.tableState.columnsState, - applyOrder: true - }); } else { + this.initializing = false; this.saveTableState(); } - setTimeout(() => { - this.initializing = false; - }, 200); }); }, + applyTableState(state) { + const { currentViewRender, columnsState, perPage, order } = state; + this.tableState = state; + this.currentViewRender = currentViewRender; + this.columnsState = columnsState; + this.perPage = perPage; + this.order = order; + + if (this.order) { + this.tableState.columnsState.forEach((column) => { + const updatedColumn = column; + updatedColumn.sort = this.order.column === column.colId ? this.order.dir : null; + return updatedColumn; + }); + } + this.columnApi.applyColumnState({ + state: this.tableState.columnsState, + applyOrder: true + }); + setTimeout(() => { + this.initializing = false; + }, 200); + }, getRowClass() { if (this.currentViewMode === 'archived') { return '!bg-sn-super-light-grey'; @@ -435,8 +447,10 @@ export default { onGridReady(params) { this.gridApi = params.api; this.columnApi = params.columnApi; - - this.fetchAndApplyTableState(); + this.gridReady = true; + if (this.fetchedTableState) { + this.applyTableState(this.fetchedTableState); + } }, onFirstDataRendered() { this.resize(); @@ -459,6 +473,9 @@ export default { this.reloadTable(false); }, saveTableState() { + if (this.initializing) { + return; + } const columnsState = this.columnApi ? this.columnApi.getColumnState() : this.tableState?.columnsState || []; const tableState = { columnsState, @@ -551,6 +568,11 @@ export default { }; this.saveTableState(); this.reloadTable(false); + }, + onColumnMoved(event) { + if (event.finished) { + this.saveTableState(); + } } } }; diff --git a/app/javascript/vue/shared/select_dropdown.vue b/app/javascript/vue/shared/select_dropdown.vue index 6fe3bebf6..b056e1c97 100644 --- a/app/javascript/vue/shared/select_dropdown.vue +++ b/app/javascript/vue/shared/select_dropdown.vue @@ -228,6 +228,9 @@ export default { this.fetchOptions(); }, watch: { + value(newValue) { + this.newValue = newValue; + }, isOpen() { if (this.isOpen) { this.$nextTick(() => { diff --git a/app/services/lists/repositories_service.rb b/app/services/lists/repositories_service.rb index 6c08d256b..69eecf495 100644 --- a/app/services/lists/repositories_service.rb +++ b/app/services/lists/repositories_service.rb @@ -45,11 +45,11 @@ module Lists def sortable_columns @sortable_columns ||= { name: 'repositories.name', - team: 'teams.name', - created_by: 'creators.full_name', + team: 'team_name', + created_by: 'created_by_user', created_at: 'repositories.created_at', archived_on: 'repositories.archived_on', - archived_by: 'archivers.full_name', + archived_by: 'archived_by_user', nr_of_rows: 'row_count' } end