Initial work for muliple selections + new toolbar with ops

This commit is contained in:
Ludovic Marcotte
2015-06-12 12:02:16 -04:00
committed by Francis Lachapelle
parent 499e66ffe9
commit 7d54bd5e86
9 changed files with 95 additions and 19 deletions
@@ -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
@@ -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')
@@ -26,6 +26,8 @@
// The promise will be unwrapped first
this.$unwrap(futureCardData);
}
this.selected = false;
}
Card.$TEL_TYPES = ['work', 'home', 'cell', 'fax', 'pager'];