diff options
-rw-r--r-- | js/components/contactDetails/contactDetails_controller.js | 19 | ||||
-rw-r--r-- | templates/contactDetails.html | 4 |
2 files changed, 7 insertions, 16 deletions
diff --git a/js/components/contactDetails/contactDetails_controller.js b/js/components/contactDetails/contactDetails_controller.js index af9c2e1c..91e35404 100644 --- a/js/components/contactDetails/contactDetails_controller.js +++ b/js/components/contactDetails/contactDetails_controller.js @@ -15,20 +15,14 @@ app.controller('contactdetailsCtrl', function(ContactService, AddressBookService ctrl.fieldDefinitions = vCardPropertiesService.fieldDefinitions; ctrl.focus = undefined; ctrl.field = undefined; - $scope.addressBooks = []; ctrl.addressBooks = []; AddressBookService.getAll().then(function(addressBooks) { ctrl.addressBooks = addressBooks; - $scope.addressBooks = addressBooks.map(function (element) { - return { - id: element.displayName, - name: element.displayName - }; - }); + if (!_.isUndefined(ctrl.contact)) { - $scope.addressBook = _.find($scope.addressBooks, function(book) { - return book.id === ctrl.contact.addressBookId; + ctrl.addressBook = _.find(ctrl.addressBooks, function(book) { + return book.displayName === ctrl.contact.addressBookId; }); } ctrl.loading = false; @@ -45,8 +39,8 @@ app.controller('contactdetailsCtrl', function(ContactService, AddressBookService ContactService.getById(uid).then(function(contact) { ctrl.contact = contact; ctrl.photo = ctrl.contact.photo(); - $scope.addressBook = _.find($scope.addressBooks, function(book) { - return book.id === ctrl.contact.addressBookId; + ctrl.addressBook = _.find(ctrl.addressBooks, function(book) { + return book.displayName === ctrl.contact.addressBookId; }); }); }; @@ -72,9 +66,6 @@ app.controller('contactdetailsCtrl', function(ContactService, AddressBookService }; ctrl.changeAddressBook = function (addressBook) { - addressBook = _.find(ctrl.addressBooks, function(book) { - return book.displayName === addressBook.id; - }); ContactService.moveContact(ctrl.contact, addressBook); }; }); diff --git a/templates/contactDetails.html b/templates/contactDetails.html index acd5b518..0445ff79 100644 --- a/templates/contactDetails.html +++ b/templates/contactDetails.html @@ -23,8 +23,8 @@ <div ng-repeat="prop in ctrl.contact.props | toArray | orderDetailItems:'$key'"> <detailsItem ng-repeat="propData in prop" name="prop.$key" data="propData" model="ctrl" index="$index" ng-class="[ 'details-item-' + prop.$key ]"></detailsItem> </div> - <div class="select-addressbook" ng-if="addressBooks.length > 1"> - <select ng-model="addressBook" ng-change="ctrl.changeAddressBook(addressBook)" ng-options="book.id for book in addressBooks track by book.id"> + <div class="select-addressbook" ng-if="ctrl.addressBooks.length > 1"> + <select ng-model="ctrl.addressBook" ng-change="ctrl.changeAddressBook(ctrl.addressBook)" ng-options="book.displayName for book in ctrl.addressBooks"> </select> </div> <select class="add-field" ng-model="ctrl.field" ng-change="ctrl.addField(ctrl.field)"> |