diff --git a/UI/Common/UIxFolderActions.m b/UI/Common/UIxFolderActions.m index a71c4e5b1..2b36d7173 100644 --- a/UI/Common/UIxFolderActions.m +++ b/UI/Common/UIxFolderActions.m @@ -301,12 +301,13 @@ - (id) batchDeleteAction { WOResponse *response; - NSString *idsParam; + NSDictionary *data; NSArray *ids; - idsParam = [[context request] formValueForKey: @"ids"]; - ids = [idsParam componentsSeparatedByString: @","]; - if ([ids count]) + data = [[[context request] contentAsString] objectFromJSONString]; + ids = [data objectForKey: @"uids"]; + + if ([ids isKindOfClass: [NSArray class]] && [ids count]) { clientObject = [self clientObject]; [clientObject deleteEntriesWithIds: ids]; diff --git a/UI/Templates/ContactsUI/UIxContactFoldersView.wox b/UI/Templates/ContactsUI/UIxContactFoldersView.wox index 448c1dc83..cd89db8b0 100644 --- a/UI/Templates/ContactsUI/UIxContactFoldersView.wox +++ b/UI/Templates/ContactsUI/UIxContactFoldersView.wox @@ -254,7 +254,9 @@
-
+
@@ -271,6 +273,15 @@
+
+ + + + + + + +
@@ -299,17 +310,25 @@ ng-click="selectCard(currentCard)" ui-sref-active="sg-active" ui-sref="app.addressbook.card.view({addressbookId: currentFolder.id, cardId: currentCard.id})"> - - -
- +
+
-
-
-
{{currentCard.$preferredEmail(currentFolder.$query)}}
+ + + +
+ +
+
+
+
{{currentCard.$preferredEmail(currentFolder.$query)}}
diff --git a/UI/WebServerResources/js/Contacts/AddressBook.service.js b/UI/WebServerResources/js/Contacts/AddressBook.service.js index 47c6baaa2..05ccc27e0 100644 --- a/UI/WebServerResources/js/Contacts/AddressBook.service.js +++ b/UI/WebServerResources/js/Contacts/AddressBook.service.js @@ -71,6 +71,16 @@ }); }; + AddressBook.prototype.$selectedCount = function() { + var count; + + count = 0; + if (this.cards) { + count = (_.filter(this.cards, function(card) { return card.selected })).length; + } + return count; + }; + /** * @memberof AddressBook * @desc Add a new addressbook to the static list of addressbooks @@ -264,6 +274,22 @@ return d.promise; }; + /** + * @function $deleteCards + * @memberof AddressBook.prototype + * @desc Delete multiple cards from addressbook. + * @return a promise of the HTTP operation + */ + AddressBook.prototype.$deleteCards = function(cards) { + + var uids = _.map(cards, function(card) { return card.id }); + var _this = this; + + return AddressBook.$$resource.post(this.id, 'batchDelete', {uids: uids}).then(function() { + _this.cards = _.difference(_this.cards, cards); + }); + }; + /** * @function $save * @memberof AddressBook.prototype diff --git a/UI/WebServerResources/js/Contacts/AddressBookController.js b/UI/WebServerResources/js/Contacts/AddressBookController.js index b5a538305..62f1ecc24 100644 --- a/UI/WebServerResources/js/Contacts/AddressBookController.js +++ b/UI/WebServerResources/js/Contacts/AddressBookController.js @@ -55,7 +55,27 @@ } } }; - } + + $scope.notSelectedComponent = function(currentCard, type) { + return (currentCard.tag == type && !currentCard.selected); + }; + + $scope.unselectCards = function() { + _.each($rootScope.currentFolder.cards, function(card) { card.selected = false; }); + }; + + $scope.confirmDeleteSelectedCards = function() { + Dialog.confirm(l('Warning'), + l('Are you sure you want to delete the selected contacts?')) + .then(function() { + // User confirmed the deletion + var selectedCards = _.filter($rootScope.currentFolder.cards, function(card) { return card.selected }); + $rootScope.currentFolder.$deleteCards(selectedCards); + }, function(data, status) { + // Delete failed + }); + }; + } angular .module('SOGo.ContactsUI') diff --git a/UI/WebServerResources/js/Contacts/Card.service.js b/UI/WebServerResources/js/Contacts/Card.service.js index 7c99a2c75..395994db4 100644 --- a/UI/WebServerResources/js/Contacts/Card.service.js +++ b/UI/WebServerResources/js/Contacts/Card.service.js @@ -26,6 +26,8 @@ // The promise will be unwrapped first this.$unwrap(futureCardData); } + + this.selected = false; } Card.$TEL_TYPES = ['work', 'home', 'cell', 'fax', 'pager']; diff --git a/UI/WebServerResources/js/Mailer/MessageController.js b/UI/WebServerResources/js/Mailer/MessageController.js index 7bd5eb45c..c3a474717 100644 --- a/UI/WebServerResources/js/Mailer/MessageController.js +++ b/UI/WebServerResources/js/Mailer/MessageController.js @@ -23,11 +23,11 @@ }; $scope.doDelete = function() { stateMailbox.$deleteMessages([stateMessage.uid]).then(function() { - // Remove card from list of addressbook + // Remove message from list of messages stateMailbox.$messages = _.reject(stateMailbox.$messages, function(o) { return o.uid == stateMessage.uid; }); - // Remove card object from scope + // Remove message object from scope $rootScope.message = null; $state.go('mail.account.mailbox', { accountId: stateAccount.id, mailboxId: encodeUriFilter(stateMailbox.path) }); }); diff --git a/UI/WebServerResources/scss/components/autoScrollList/autoScrollList.scss b/UI/WebServerResources/scss/components/autoScrollList/autoScrollList.scss index 95770fe7d..febf62ddf 100644 --- a/UI/WebServerResources/scss/components/autoScrollList/autoScrollList.scss +++ b/UI/WebServerResources/scss/components/autoScrollList/autoScrollList.scss @@ -80,3 +80,8 @@ margin-right: 0; margin-left: 0; } +.sg-selected-avatar { + @extend .md-tile-left-selected; + margin-right: 0; + margin-left: 0; +} diff --git a/UI/WebServerResources/scss/components/list/list.scss b/UI/WebServerResources/scss/components/list/list.scss index 3c7117e1a..0dace3597 100644 --- a/UI/WebServerResources/scss/components/list/list.scss +++ b/UI/WebServerResources/scss/components/list/list.scss @@ -95,3 +95,7 @@ div.md-tile-left { @extend .md-tile-left; content: "\f2d4"; } +.md-tile-left-selected:before { + @extend .md-tile-left; + content: "\f299"; +} diff --git a/UI/WebServerResources/scss/views/LoginUI.scss b/UI/WebServerResources/scss/views/LoginUI.scss index 5713ef2f9..e1f0dce5d 100644 --- a/UI/WebServerResources/scss/views/LoginUI.scss +++ b/UI/WebServerResources/scss/views/LoginUI.scss @@ -12,5 +12,4 @@ label.login-lang { margin: 0 $bl $bl 0; - }