Skip to content

Commit

Permalink
mgr/dashboard: Update selected items on table refresh
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo Marques <rimarques@suse.com>
  • Loading branch information
ricardoasmarques committed Mar 28, 2018
1 parent 2739b6f commit e3bca67
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,25 @@ export class TableComponent implements AfterContentChecked, OnInit, OnChanges, O
}
this.loadingIndicator = false;
this.updating = false;
this.updateSelected();
}

/**
* After updating the data, we have to update the selected items
* because details may have changed,
* or some selected items may have been removed.
*/
updateSelected() {
const newSelected = [];
this.selection.selected.forEach((selectedItem) => {
for (const row of this.data) {
if (selectedItem[this.identifier] === row[this.identifier]) {
newSelected.push(row);
}
}
});
this.selection.selected = newSelected;
this.onSelect();
}

onSelect() {
Expand Down

0 comments on commit e3bca67

Please sign in to comment.