diff options
-rw-r--r-- | css/public/style.css | 1 | ||||
-rw-r--r-- | js/components/contactList/contactList_controller.js | 17 | ||||
-rw-r--r-- | js/components/newContactButton/newContactButton_controller.js | 23 | ||||
-rw-r--r-- | js/components/newContactButton/newContactButton_directive.js | 11 | ||||
-rw-r--r-- | templates/contactList.html | 2 | ||||
-rw-r--r-- | templates/main.php | 2 | ||||
-rw-r--r-- | templates/newContactButton.html | 2 |
7 files changed, 38 insertions, 20 deletions
diff --git a/css/public/style.css b/css/public/style.css index cc62ab1c..43ab6bd0 100644 --- a/css/public/style.css +++ b/css/public/style.css @@ -363,7 +363,6 @@ li.addressBook-share-item span.shareeIdentifier { /* Contacts List */ #new-contact-button { - margin: 14px auto; /* to have the same height than a contact*/ } diff --git a/js/components/contactList/contactList_controller.js b/js/components/contactList/contactList_controller.js index 4688895e..72c5d2de 100644 --- a/js/components/contactList/contactList_controller.js +++ b/js/components/contactList/contactList_controller.js @@ -10,7 +10,7 @@ angular.module('contactsApp') ctrl.invalid = false; ctrl.t = { - addContact : t('contacts', 'Add contact'), + addContact : t('contacts', '+ New contact'), emptySearch : t('contacts', 'No search result for {query}', {query: ctrl.searchTerm}) }; @@ -157,21 +157,6 @@ angular.module('contactsApp') ctrl.invalid = (displayName === ''); }); - ctrl.createContact = function() { - ContactService.create().then(function(contact) { - ['tel', 'adr', 'email'].forEach(function(field) { - var defaultValue = vCardPropertiesService.getMeta(field).defaultValue || {value: ''}; - contact.addProperty(field, defaultValue); - } ); - if ([t('contacts', 'All contacts'), t('contacts', 'Not grouped')].indexOf($routeParams.gid) === -1) { - contact.categories($routeParams.gid); - } else { - contact.categories(''); - } - $('#details-fullName').focus(); - }); - }; - ctrl.hasContacts = function () { if (!ctrl.contacts) { return false; diff --git a/js/components/newContactButton/newContactButton_controller.js b/js/components/newContactButton/newContactButton_controller.js new file mode 100644 index 00000000..263059c0 --- /dev/null +++ b/js/components/newContactButton/newContactButton_controller.js @@ -0,0 +1,23 @@ +angular.module('contactsApp') +.controller('newContactButtonCtrl', function($scope, ContactService, $routeParams, vCardPropertiesService) { + var ctrl = this; + + ctrl.t = { + addContact : t('contacts', '+ New contact') + }; + + ctrl.createContact = function() { + ContactService.create().then(function(contact) { + ['tel', 'adr', 'email'].forEach(function(field) { + var defaultValue = vCardPropertiesService.getMeta(field).defaultValue || {value: ''}; + contact.addProperty(field, defaultValue); + } ); + if ([t('contacts', 'All contacts'), t('contacts', 'Not grouped')].indexOf($routeParams.gid) === -1) { + contact.categories($routeParams.gid); + } else { + contact.categories(''); + } + $('#details-fullName').focus(); + }); + }; +}); diff --git a/js/components/newContactButton/newContactButton_directive.js b/js/components/newContactButton/newContactButton_directive.js new file mode 100644 index 00000000..65c2ee8a --- /dev/null +++ b/js/components/newContactButton/newContactButton_directive.js @@ -0,0 +1,11 @@ +angular.module('contactsApp') +.directive('newcontactbutton', function() { + return { + restrict: 'EA', // has to be an attribute to work with core css + scope: {}, + controller: 'newContactButtonCtrl', + controllerAs: 'ctrl', + bindToController: {}, + templateUrl: OC.linkTo('contacts', 'templates/newContactButton.html') + }; +}); diff --git a/templates/contactList.html b/templates/contactList.html index fc91f156..a1a99ae3 100644 --- a/templates/contactList.html +++ b/templates/contactList.html @@ -1,6 +1,4 @@ <div style="height: 90%" class="contacts-list" ng-class="{loading: ctrl.loading, 'mobile-show': ctrl.show}"> - <button ng-show="!ctrl.loading && !ctrl.invalid" class="app-content-list-button" id="new-contact-button" - type="button" name="button" ng-click="ctrl.createContact()">{{ctrl.t.addContact}}</button> <div class="app-content-list-item" ng-repeat="contact in ctrl.contactList = (ctrl.contacts | contactGroupFilter:ctrl.routeParams.gid | localeOrderBy:'displayName' | filter:query) as filtered track by contact.uid()" contact data="contact" diff --git a/templates/main.php b/templates/main.php index fe4e9299..a1454dfa 100644 --- a/templates/main.php +++ b/templates/main.php @@ -25,7 +25,7 @@ vendor_style('select2/select2'); <div id="app" ng-app="contactsApp"> <div id="app-navigation"> - + <newContactButton></newContactButton> <ul groupList></ul> <div id="app-settings"> diff --git a/templates/newContactButton.html b/templates/newContactButton.html new file mode 100644 index 00000000..3db7e527 --- /dev/null +++ b/templates/newContactButton.html @@ -0,0 +1,2 @@ +<button ng-show="!ctrl.loading && !ctrl.invalid" class="app-content-list-button" id="new-contact-button" + type="button" name="button" ng-click="ctrl.createContact()">{{ctrl.t.addContact}}</button> |