diff --git a/app/javascript/vue/shared/datatable/table.vue b/app/javascript/vue/shared/datatable/table.vue
index 45a98ddf0..3107d7352 100644
--- a/app/javascript/vue/shared/datatable/table.vue
+++ b/app/javascript/vue/shared/datatable/table.vue
@@ -14,9 +14,11 @@
:filters="filters"
:columnDefs="columnDefs"
:tableState="tableState"
+ :order="order"
@applyFilters="applyFilters"
@setTableView="switchViewRender('table')"
@setCardsView="switchViewRender('cards')"
+ @sort="applyOrder"
@hideColumn="hideColumn"
@showColumn="showColumn"
/>
@@ -248,6 +250,8 @@ export default {
}
},
currentViewRender() {
+ this.columnApi = null;
+ this.gridApi = null;
this.saveTableState();
},
perPage() {
@@ -258,7 +262,7 @@ export default {
if (this.tableState) {
this.currentViewRender = this.tableState.currentViewRender || 'table';
this.perPage = this.tableState.perPage || 20;
- [this.order] = this.getOrder(this.tableState.columnsState);
+ this.order = this.tableState.order;
}
},
mounted() {
@@ -328,6 +332,13 @@ export default {
this.columnApi = params.columnApi;
if (this.tableState) {
+ 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
@@ -363,6 +374,7 @@ export default {
}
const tableState = {
columnsState: columnsState || [],
+ order: this.order,
currentViewRender: this.currentViewRender,
perPage: this.perPage
};
@@ -410,6 +422,14 @@ export default {
column: column.colId,
dir: column.sort
}));
+ },
+ applyOrder(column, dir) {
+ this.order = {
+ column,
+ dir
+ };
+ this.saveTableState();
+ this.reloadTable();
}
}
};
diff --git a/app/javascript/vue/shared/datatable/toolbar.vue b/app/javascript/vue/shared/datatable/toolbar.vue
index 43b64ed6c..f37aa7e4c 100644
--- a/app/javascript/vue/shared/datatable/toolbar.vue
+++ b/app/javascript/vue/shared/datatable/toolbar.vue
@@ -76,6 +76,28 @@
@click="$emit('search:change', '')">
+
+
+
+
+
+
+
+
{{ col.headerName }}
+
+
+
+
+
+
+
+
import MenuDropdown from '../menu_dropdown.vue';
+import GeneralDropdown from '../general_dropdown.vue';
import FilterDropdown from '../filters/filter_dropdown.vue';
import ColumnsModal from './modals/columns.vue';
@@ -131,12 +154,16 @@ export default {
},
tableState: {
type: Object
+ },
+ order: {
+ type: Object
}
},
components: {
MenuDropdown,
FilterDropdown,
- ColumnsModal
+ ColumnsModal,
+ GeneralDropdown
},
computed: {
viewModesMenu() {
@@ -159,6 +186,9 @@ export default {
return view;
}
});
+ },
+ sortableColumns() {
+ return this.columnDefs.filter((column) => column.sortable);
}
},
data() {
diff --git a/app/javascript/vue/shared/general_dropdown.vue b/app/javascript/vue/shared/general_dropdown.vue
index 6ab944b1f..b0adf3682 100644
--- a/app/javascript/vue/shared/general_dropdown.vue
+++ b/app/javascript/vue/shared/general_dropdown.vue
@@ -58,9 +58,7 @@ export default {
},
methods: {
closeMenu(e) {
-
if (e && e.target.closest('.sn-dropdown, .sn-select-dropdown, .dp__instance_calendar')) return;
-
this.isOpen = false;
}
}
diff --git a/app/javascript/vue/shared/menu_dropdown.vue b/app/javascript/vue/shared/menu_dropdown.vue
index 46450ca23..09ec75ba3 100644
--- a/app/javascript/vue/shared/menu_dropdown.vue
+++ b/app/javascript/vue/shared/menu_dropdown.vue
@@ -8,12 +8,12 @@
diff --git a/app/javascript/vue/shared/mixins/fixed_flyout.js b/app/javascript/vue/shared/mixins/fixed_flyout.js
index 55ac00c0e..94196e1cc 100644
--- a/app/javascript/vue/shared/mixins/fixed_flyout.js
+++ b/app/javascript/vue/shared/mixins/fixed_flyout.js
@@ -9,14 +9,16 @@ export default {
isOpen() {
if (this.isOpen) {
this.$nextTick(() => {
+ this.setPosition();
this.overflowContainerListener();
});
}
- },
+ }
},
methods: {
overflowContainerListener() {
const { field, flyout } = this.$refs;
+
if (!field || !flyout) return;
const fieldRect = field.getBoundingClientRect();