(js) New progress indicator in AddressBook module

pull/105/head
Francis Lachapelle 2015-08-27 14:09:43 -04:00
parent 3611c4021d
commit 1667f8879d
2 changed files with 15 additions and 29 deletions

View File

@ -366,6 +366,12 @@
</div>
</md-list>
</md-virtual-repeat-container>
<div class="sg-progress-circular-floating"
ng-show="addressbook.selectedFolder.$isLoading">
<md-progress-circular class="md-accent"
md-mode="indeterminate"
md-diameter="32"><!-- progress --></md-progress-circular>
</div>
<md-button class="md-fab md-fab-bottom-right md-accent"
label:aria-label="New Contact"
ng-show="addressbook.selectedFolder.acls.objectCreator"

View File

@ -215,6 +215,7 @@
* @param {object} data - attributes of addressbook
*/
AddressBook.prototype.init = function(data) {
this.$isLoading = true;
this.$cards = [];
this.cards = [];
angular.extend(this, data);
@ -289,34 +290,7 @@
var _this = this;
this.$startRefreshTimeout();
return AddressBook.$$resource.fetch(this.id, 'view')
.then(function(response) {
var index, card,
results = response.cards,
cards = _this.cards,
compareIds = function(data) {
return this.id == data.id;
};
// Remove cards that no longer exist
for (index = cards.length - 1; index >= 0; index--) {
card = cards[index];
if (_.isUndefined(_.find(results, compareIds, card))) {
cards.splice(index, 1);
}
}
// Add new cards
_.each(results, function(data, index) {
if (_.isUndefined(_.find(cards, compareIds, data))) {
var card = new AddressBook.$Card(data);
cards.splice(index, 0, card);
}
});
return cards;
});
return this.$filter();
};
/**
@ -330,6 +304,8 @@
AddressBook.prototype.$filter = function(search, options, excludedCards) {
var _this = this;
this.$isLoading = true;
return AddressBook.$Preferences.ready().then(function() {
if (options) {
angular.extend(AddressBook.$query, options);
@ -347,7 +323,8 @@
}
}
AddressBook.$query.value = search;
if (angular.isDefined(search))
AddressBook.$query.value = search;
return _this.$id().then(function(addressbookId) {
return AddressBook.$$resource.fetch(addressbookId, 'view', AddressBook.$query);
@ -396,6 +373,7 @@
cards.splice(index, 0, removedCards[0]);
}
});
_this.$isLoading = false;
return cards;
});
});
@ -528,6 +506,8 @@
_this.$startRefreshTimeout();
_this.$isLoading = false;
return _this;
});
}, function(data) {