mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-09-29 17:10:31 +00:00
Initial work for muliple selections + new toolbar with ops
This commit is contained in:
committed by
Francis Lachapelle
parent
499e66ffe9
commit
7d54bd5e86
@@ -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'];
|
||||
|
||||
Reference in New Issue
Block a user