mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 05:07:52 +00:00
[CLA Approved] Add rows refractor (#5284)
* addRows Refractor Co-authored-by: Jesse Mazzella <ozyx@users.noreply.github.com> Co-authored-by: Andrew Henry <akhenry@gmail.com> Co-authored-by: John Hill <john.c.hill@nasa.gov>
This commit is contained in:
parent
57e02db6b5
commit
7f2ed27106
@ -178,7 +178,7 @@ define([
|
||||
if (this.paused) {
|
||||
this.delayedActions.push(this.tableRows.addRows.bind(this, telemetryRows, 'add'));
|
||||
} else {
|
||||
this.tableRows.addRows(telemetryRows, 'add');
|
||||
this.tableRows.addRows(telemetryRows);
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -229,7 +229,7 @@ define([
|
||||
});
|
||||
});
|
||||
|
||||
this.tableRows.addRows(allRows, 'filter');
|
||||
this.tableRows.clearRowsFromTableAndFilter(allRows);
|
||||
}
|
||||
|
||||
updateFilters(updatedFilters) {
|
||||
|
@ -61,30 +61,39 @@ define(
|
||||
this.emit('remove', removed);
|
||||
}
|
||||
|
||||
addRows(rows, type = 'add') {
|
||||
if (this.sortOptions === undefined) {
|
||||
throw 'Please specify sort options';
|
||||
}
|
||||
|
||||
let isFilterTriggeredReset = type === 'filter';
|
||||
let anyActiveFilters = Object.keys(this.columnFilters).length > 0;
|
||||
let rowsToAdd = !anyActiveFilters ? rows : rows.filter(this.matchesFilters, this);
|
||||
|
||||
// if type is filter, then it's a reset of all rows,
|
||||
// need to wipe current rows
|
||||
if (isFilterTriggeredReset) {
|
||||
this.rows = [];
|
||||
}
|
||||
addRows(rows) {
|
||||
let rowsToAdd = this.filterRows(rows);
|
||||
|
||||
this.sortAndMergeRows(rowsToAdd);
|
||||
|
||||
// we emit filter no matter what to trigger
|
||||
// an update of visible rows
|
||||
if (rowsToAdd.length > 0 || isFilterTriggeredReset) {
|
||||
this.emit(type, rowsToAdd);
|
||||
if (rowsToAdd.length > 0) {
|
||||
this.emit('add', rowsToAdd);
|
||||
}
|
||||
}
|
||||
|
||||
clearRowsFromTableAndFilter(rows) {
|
||||
|
||||
let rowsToAdd = this.filterRows(rows);
|
||||
// Reset of all rows, need to wipe current rows
|
||||
this.rows = [];
|
||||
|
||||
this.sortAndMergeRows(rowsToAdd);
|
||||
|
||||
// We emit filter and update of visible rows
|
||||
this.emit('filter', rowsToAdd);
|
||||
}
|
||||
|
||||
filterRows(rows) {
|
||||
|
||||
if (Object.keys(this.columnFilters).length > 0) {
|
||||
return rows.filter(this.matchesFilters, this);
|
||||
}
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
sortAndMergeRows(rows) {
|
||||
const sortedRowsToAdd = this.sortCollection(rows);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user