Move button to the side bar - fixes #483 (#493)

This commit is contained in:
Thomas Müller 2016-08-22 22:09:24 +02:00 committed by GitHub
parent 7d43efebfb
commit 4bd9608d8e
7 changed files with 38 additions and 20 deletions

View File

@ -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*/
}

View File

@ -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;

View File

@ -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();
});
};
});

View File

@ -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')
};
});

View File

@ -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"

View File

@ -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">

View File

@ -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>