From 249277ec3d1b2fbed7bb4644021298d94565fa3c Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Thu, 26 Sep 2019 12:09:01 -0400 Subject: [PATCH] (js) Restore cards selection after refresh Fixes #4809 --- NEWS | 1 + .../js/Contacts/AddressBook.service.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 2e7a813be..ba6f47a61 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,7 @@ Bug fixes - [web] fixed saving value of receipt action for main IMAP account - [web] fixed search results in Calendar module when targeting all events - [web] properly encode URL of cards from exteral sources + - [web] restore cards selection after automatic refresh (#4809) - [core] honor IMAPLoginFieldName also when setting IMAP ACLs - [core] honor groups when setting IMAP ACLs - [core] honor "any authenticated user" when setting IMAP ACLs diff --git a/UI/WebServerResources/js/Contacts/AddressBook.service.js b/UI/WebServerResources/js/Contacts/AddressBook.service.js index 329393071..32221ac91 100644 --- a/UI/WebServerResources/js/Contacts/AddressBook.service.js +++ b/UI/WebServerResources/js/Contacts/AddressBook.service.js @@ -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);