diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2017-11-20 19:10:23 +0100 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2017-11-21 16:00:05 +0100 |
commit | ba494835767bd2db0265c8b1a472432ce1ee696d (patch) | |
tree | 1deee4a0347f96e40040dd1d420691dac2fa0f47 /js/services/addressBook_service.js | |
parent | 2bc57687a399cf143b8be56edd485c579d09e273 (diff) |
Prevent import if no addressbook is available
Add notify on contact import from addressbook
Fix Groups update on enabling/disabling
Changed default ab to first that is writtable instead of first of the list
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'js/services/addressBook_service.js')
-rw-r--r-- | js/services/addressBook_service.js | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/js/services/addressBook_service.js b/js/services/addressBook_service.js index 23419e3e..f456866c 100644 --- a/js/services/addressBook_service.js +++ b/js/services/addressBook_service.js @@ -43,7 +43,7 @@ angular.module('contactsApp') }); }, - getGroups: function () { + getGroups: function() { return this.getAll().then(function(addressBooks) { return addressBooks.map(function (element) { return element.groups; @@ -53,8 +53,16 @@ angular.module('contactsApp') }); }, - getDefaultAddressBook: function() { - return addressBooks[0]; + getDefaultAddressBook: function(throwOC) { + var i = addressBooks.findIndex(function(addressBook) { + return addressBook.enabled && !addressBook.readOnly; + }); + if (i !== -1) { + return addressBooks[i]; + } else if(throwOC) { + OC.Notification.showTemporary(t('contacts', 'There is no address book available to create a contact.')); + } + return false; }, getAddressBook: function(displayName) { @@ -69,6 +77,7 @@ angular.module('contactsApp') resourcetype: res[0].props.resourcetype, syncToken: res[0].props.syncToken }); + notifyObservers('create', addressBook); return addressBook; }); }); |