(js) Restore cards selection after refresh

Fixes #4809
This commit is contained in:
Francis Lachapelle
2019-09-26 12:09:01 -04:00
parent ac9fa92d4f
commit 249277ec3d
2 changed files with 9 additions and 2 deletions
@@ -757,6 +757,7 @@
// Expose and resolve the promise
this.$futureAddressBookData = futureAddressBookData.then(function(response) {
var selectedCards = _.map(_this.$selectedCards(), 'id');
return AddressBook.$timeout(function() {
var headers;
@@ -779,12 +780,17 @@
// Instanciate Card objects
_.reduce(_this.ids, function(cards, card, i) {
var data = { pid: _this.id, id: card };
var data = { pid: _this.id, id: card }, cardObject;
// Build map of ID <=> index
_this.idsMap[data.id] = i;
cards.push(new AddressBook.$Card(data));
cardObject = new AddressBook.$Card(data);
// Restore selection
cardObject.selected = selectedCards.indexOf(cardObject.id) > -1;
cards.push(cardObject);
return cards;
}, _this.$cards);