Persist table sort options (#2329)

This commit is contained in:
Andrew Henry 2019-03-25 11:35:47 -07:00 committed by Deep Tailor
parent 9cb7e09aef
commit 78dccf1e0a
2 changed files with 20 additions and 5 deletions

View File

@ -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();

View File

@ -409,7 +409,7 @@ export default {
direction: 'asc'
}
}
this.table.filteredRows.sortBy(this.sortOptions);
this.table.sortBy(this.sortOptions);
},
scroll() {
if (!this.processingScroll) {