From 78dccf1e0ad4b8bcfe4ca40d235d29066df582d5 Mon Sep 17 00:00:00 2001 From: Andrew Henry Date: Mon, 25 Mar 2019 11:35:47 -0700 Subject: [PATCH] Persist table sort options (#2329) --- src/plugins/telemetryTable/TelemetryTable.js | 23 +++++++++++++++---- .../telemetryTable/components/table.vue | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/plugins/telemetryTable/TelemetryTable.js b/src/plugins/telemetryTable/TelemetryTable.js index 358e0354e0..0efbb959b2 100644 --- a/src/plugins/telemetryTable/TelemetryTable.js +++ b/src/plugins/telemetryTable/TelemetryTable.js @@ -59,6 +59,7 @@ define([ this.filterObserver = undefined; this.createTableRowCollections(); + openmct.time.on('bounds', this.refreshData); openmct.time.on('timeSystem', this.refreshData); } @@ -74,13 +75,17 @@ define([ createTableRowCollections() { this.boundedRows = new BoundedTableRowCollection(this.openmct); - - //By default, sort by current time system, ascending. this.filteredRows = new FilteredTableRowCollection(this.boundedRows); - this.filteredRows.sortBy({ + + //Fetch any persisted default sort + let sortOptions = this.configuration.getConfiguration().sortOptions; + + //If no persisted sort order, default to sorting by time system, ascending. + sortOptions = sortOptions || { key: this.openmct.time.timeSystem().key, direction: 'asc' - }); + }; + this.filteredRows.sortBy(sortOptions); } loadComposition() { @@ -210,6 +215,16 @@ define([ delete this.subscriptions[keyString]; } + sortBy(sortOptions) { + this.filteredRows.sortBy(sortOptions); + + if (this.openmct.editor.isEditing()) { + let configuration = this.configuration.getConfiguration(); + configuration.sortOptions = sortOptions; + this.configuration.updateConfiguration(configuration); + } + } + destroy() { this.boundedRows.destroy(); this.filteredRows.destroy(); diff --git a/src/plugins/telemetryTable/components/table.vue b/src/plugins/telemetryTable/components/table.vue index 13c40f66a9..574d4f10c4 100644 --- a/src/plugins/telemetryTable/components/table.vue +++ b/src/plugins/telemetryTable/components/table.vue @@ -409,7 +409,7 @@ export default { direction: 'asc' } } - this.table.filteredRows.sortBy(this.sortOptions); + this.table.sortBy(this.sortOptions); }, scroll() { if (!this.processingScroll) {