Initial work for muliple selections + new toolbar with ops
parent
499e66ffe9
commit
7d54bd5e86
|
@ -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];
|
||||
|
|
|
@ -254,7 +254,9 @@
|
|||
<div class="md-toolbar-tools md-toolbar-tools-top sg-padded" layout="row" layout-align="space-between start">
|
||||
<var:component className="UIxTopnavToolbarTemplate" />
|
||||
</div>
|
||||
<div class="md-toolbar-tools md-toolbar-tools-bottom" layout="row" layout-align="space-between center">
|
||||
<div class="md-toolbar-tools md-toolbar-tools-bottom"
|
||||
layout="row" layout-align="space-between center"
|
||||
ng-show="currentFolder.$selectedCount() == 0">
|
||||
<div class="view-list sg-padded" layout="row" layout-align="space-between center"
|
||||
sg-search="currentFolder.$filter(searchText, { search: searchField })">
|
||||
<md-input-container class="sg-search-field-container">
|
||||
|
@ -271,6 +273,15 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div layout="row" layout-align="space-between center" ng-show="currentFolder.$selectedCount() > 0">
|
||||
<md-button ng-click="unselectCards()">
|
||||
<i class="md-icon-arrow-back"><!-- unselect all --></i>
|
||||
</md-button>
|
||||
<label>{{currentFolder.$selectedCount()}} selected</label>
|
||||
<md-button ng-click="confirmDeleteSelectedCards()">
|
||||
<i class="md-icon-delete"><!-- delete --></i>
|
||||
</md-button>
|
||||
</div>
|
||||
</md-toolbar>
|
||||
<div layout="row" class="md-flex" layout-align="space-between">
|
||||
<div class="view-list" layout="column" flex="true" style="position: relative;">
|
||||
|
@ -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})">
|
||||
<sg-gravatar-image class="md-tile-left"
|
||||
ng-show="currentCard.tag == 'vcard'"
|
||||
email="{{currentCard.$preferredEmail(currentFolder.$query)}}"
|
||||
size="48"><!-- gravatar -->
|
||||
</sg-gravatar-image>
|
||||
<div class="sg-list-avatar" ng-show="currentCard.tag == 'vlist'">
|
||||
<!--list avatar-->
|
||||
<div class="sg-selected-avatar" ng-show="currentCard.selected"
|
||||
ng-click="currentCard.selected = !currentCard.selected">
|
||||
<!-- selected avatar -->
|
||||
</div>
|
||||
<div class="sg-tile-content">
|
||||
<div class="sg-md-subhead-multi" ng-bind-html="currentCard.$fullname()"><!-- cn --></div>
|
||||
<div class="sg-md-body-multi">{{currentCard.$preferredEmail(currentFolder.$query)}}</div>
|
||||
<sg-gravatar-image class="md-tile-left"
|
||||
ng-show="notSelectedComponent(currentCard,'vcard')"
|
||||
ng-click="currentCard.selected = !currentCard.selected"
|
||||
email="{{currentCard.$preferredEmail(currentFolder.$query)}}"
|
||||
size="48">
|
||||
<!-- gravatar -->
|
||||
</sg-gravatar-image>
|
||||
<div class="sg-list-avatar"
|
||||
ng-show="notSelectedComponent(currentCard, 'vlist')"
|
||||
ng-click="currentCard.selected = !currentCard.selected">
|
||||
<!--list avatar-->
|
||||
</div>
|
||||
<div class="sg-tile-content">
|
||||
<div class="sg-md-subhead-multi" ng-bind-html="currentCard.$fullname()"><!-- cn --></div>
|
||||
<div class="sg-md-body-multi">{{currentCard.$preferredEmail(currentFolder.$query)}}</div>
|
||||
</div>
|
||||
</md-list-item>
|
||||
</md-list>
|
||||
|
|
|
@ -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'];
|
||||
|
|
|
@ -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) });
|
||||
});
|
||||
|
|
|
@ -80,3 +80,8 @@
|
|||
margin-right: 0;
|
||||
margin-left: 0;
|
||||
}
|
||||
.sg-selected-avatar {
|
||||
@extend .md-tile-left-selected;
|
||||
margin-right: 0;
|
||||
margin-left: 0;
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
}
|
||||
|
|
|
@ -12,5 +12,4 @@
|
|||
|
||||
label.login-lang {
|
||||
margin: 0 $bl $bl 0;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue