mirror of https://github.com/nextcloud/contacts
Display groups on the left side bar
This commit is contained in:
parent
f55d2b5f7b
commit
9a8fcbc7ec
|
@ -3,7 +3,7 @@ app.controller('addressbooklistCtrl', ['$scope', 'AddressBookService', 'Settings
|
|||
|
||||
console.log(AddressBookService);
|
||||
AddressBookService.getAll().then(function(addressBooks) {
|
||||
ctrl.addressBooks = addressBooks;
|
||||
ctrl.addressBooks = addressBooks;
|
||||
});
|
||||
|
||||
ctrl.createAddressBook = function() {
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
app.controller('groupCtrl', function() {
|
||||
var ctrl = this;
|
||||
console.log(this);
|
||||
});
|
|
@ -0,0 +1,12 @@
|
|||
app.directive('group', function() {
|
||||
return {
|
||||
restrict: 'A', // has to be an attribute to work with core css
|
||||
scope: {},
|
||||
controller: 'groupCtrl',
|
||||
controllerAs: 'ctrl',
|
||||
bindToController: {
|
||||
addressBook: "=data"
|
||||
},
|
||||
templateUrl: OC.linkTo('contactsrework', 'templates/group.html')
|
||||
};
|
||||
});
|
|
@ -0,0 +1,9 @@
|
|||
app.controller('grouplistCtrl', ['$scope', 'ContactService', function($scope, ContactService) {
|
||||
|
||||
$scope.groups = [];
|
||||
|
||||
ContactService.getGroups().then(function(groups) {
|
||||
$scope.groups = groups;
|
||||
});
|
||||
|
||||
}]);
|
|
@ -0,0 +1,10 @@
|
|||
app.directive('grouplist', function() {
|
||||
return {
|
||||
restrict: 'EA', // has to be an attribute to work with core css
|
||||
scope: {},
|
||||
controller: 'grouplistCtrl',
|
||||
controllerAs: 'ctrl',
|
||||
bindToController: {},
|
||||
templateUrl: OC.linkTo('contactsrework', 'templates/groupList.html')
|
||||
};
|
||||
});
|
|
@ -5,6 +5,7 @@ app.factory('AddressBook', function()
|
|||
|
||||
displayName: "",
|
||||
contacts: [],
|
||||
groups: data.data.props.groups,
|
||||
|
||||
getContact: function(uid) {
|
||||
for(var i in this.contacts) {
|
||||
|
|
|
@ -45,6 +45,21 @@ app.factory('Contact', [ '$filter', function($filter) {
|
|||
}
|
||||
},
|
||||
|
||||
categories: function(value) {
|
||||
if (angular.isDefined(value)) {
|
||||
// setter
|
||||
return this.setProperty('categories', { value: value });
|
||||
} else {
|
||||
// getter
|
||||
var property = this.getProperty('categories');
|
||||
if(property) {
|
||||
return property.value.split(',');
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getProperty: function(name) {
|
||||
if (this.props[name]) {
|
||||
return this.props[name][0];
|
||||
|
|
|
@ -23,7 +23,7 @@ app.controller('addressbooklistCtrl', ['$scope', 'AddressBookService', 'Settings
|
|||
|
||||
console.log(AddressBookService);
|
||||
AddressBookService.getAll().then(function(addressBooks) {
|
||||
ctrl.addressBooks = addressBooks;
|
||||
ctrl.addressBooks = addressBooks;
|
||||
});
|
||||
|
||||
ctrl.createAddressBook = function() {
|
||||
|
@ -148,6 +148,45 @@ app.directive('contactlist', function() {
|
|||
templateUrl: OC.linkTo('contactsrework', 'templates/contactList.html')
|
||||
};
|
||||
});
|
||||
app.controller('groupCtrl', function() {
|
||||
var ctrl = this;
|
||||
console.log(this);
|
||||
});
|
||||
|
||||
app.directive('group', function() {
|
||||
return {
|
||||
restrict: 'A', // has to be an attribute to work with core css
|
||||
scope: {},
|
||||
controller: 'groupCtrl',
|
||||
controllerAs: 'ctrl',
|
||||
bindToController: {
|
||||
addressBook: "=data"
|
||||
},
|
||||
templateUrl: OC.linkTo('contactsrework', 'templates/group.html')
|
||||
};
|
||||
});
|
||||
|
||||
app.controller('grouplistCtrl', ['$scope', 'ContactService', function($scope, ContactService) {
|
||||
|
||||
$scope.groups = [];
|
||||
|
||||
ContactService.getGroups().then(function(groups) {
|
||||
$scope.groups = groups;
|
||||
});
|
||||
|
||||
}]);
|
||||
|
||||
app.directive('grouplist', function() {
|
||||
return {
|
||||
restrict: 'EA', // has to be an attribute to work with core css
|
||||
scope: {},
|
||||
controller: 'grouplistCtrl',
|
||||
controllerAs: 'ctrl',
|
||||
bindToController: {},
|
||||
templateUrl: OC.linkTo('contactsrework', 'templates/groupList.html')
|
||||
};
|
||||
});
|
||||
|
||||
app.factory('AddressBook', function()
|
||||
{
|
||||
return function AddressBook(data) {
|
||||
|
@ -155,6 +194,7 @@ app.factory('AddressBook', function()
|
|||
|
||||
displayName: "",
|
||||
contacts: [],
|
||||
groups: data.data.props.groups,
|
||||
|
||||
getContact: function(uid) {
|
||||
for(var i in this.contacts) {
|
||||
|
@ -216,6 +256,21 @@ app.factory('Contact', [ '$filter', function($filter) {
|
|||
}
|
||||
},
|
||||
|
||||
categories: function(value) {
|
||||
if (angular.isDefined(value)) {
|
||||
// setter
|
||||
return this.setProperty('categories', { value: value });
|
||||
} else {
|
||||
// getter
|
||||
var property = this.getProperty('categories');
|
||||
if(property) {
|
||||
return property.value.split(',');
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getProperty: function(name) {
|
||||
if (this.props[name]) {
|
||||
return this.props[name][0];
|
||||
|
@ -301,6 +356,17 @@ app.factory('AddressBookService', ['DavClient', 'DavService', 'SettingsService',
|
|||
});
|
||||
},
|
||||
|
||||
getGroups: function () {
|
||||
return this.getAll().then(function(addressBooks){
|
||||
return ['All'].concat(
|
||||
addressBooks.map(function (element) {
|
||||
return element.groups;
|
||||
}).reduce(function(a, b){
|
||||
return a.concat(b);
|
||||
}));
|
||||
});
|
||||
},
|
||||
|
||||
getEnabled: function() {
|
||||
return DavService.then(function(account) {
|
||||
return account.addressBooks.filter(function(addressBook) {
|
||||
|
@ -409,6 +475,17 @@ app.service('ContactService', [ 'DavClient', 'AddressBookService', 'Contact', '$
|
|||
|
||||
};
|
||||
|
||||
this.getGroups = function () {
|
||||
return this.getAll().then(function(contacts){
|
||||
return ['All'].concat(
|
||||
contacts.map(function (element) {
|
||||
return element.categories();
|
||||
}).reduce(function(a, b){
|
||||
return a.concat(b);
|
||||
}));
|
||||
});
|
||||
};
|
||||
|
||||
this.getById = function(uid) {
|
||||
if(cacheFilled === false) {
|
||||
return this.fillCache().then(function() {
|
||||
|
|
|
@ -18,6 +18,17 @@ app.factory('AddressBookService', ['DavClient', 'DavService', 'SettingsService',
|
|||
});
|
||||
},
|
||||
|
||||
getGroups: function () {
|
||||
return this.getAll().then(function(addressBooks){
|
||||
return ['All'].concat(
|
||||
addressBooks.map(function (element) {
|
||||
return element.groups;
|
||||
}).reduce(function(a, b){
|
||||
return a.concat(b);
|
||||
}));
|
||||
});
|
||||
},
|
||||
|
||||
getEnabled: function() {
|
||||
return DavService.then(function(account) {
|
||||
return account.addressBooks.filter(function(addressBook) {
|
||||
|
|
|
@ -47,6 +47,17 @@ app.service('ContactService', [ 'DavClient', 'AddressBookService', 'Contact', '$
|
|||
|
||||
};
|
||||
|
||||
this.getGroups = function () {
|
||||
return this.getAll().then(function(contacts){
|
||||
return ['All'].concat(
|
||||
contacts.map(function (element) {
|
||||
return element.categories();
|
||||
}).reduce(function(a, b){
|
||||
return a.concat(b);
|
||||
}));
|
||||
});
|
||||
};
|
||||
|
||||
this.getById = function(uid) {
|
||||
if(cacheFilled === false) {
|
||||
return this.fillCache().then(function() {
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<a>{{ctrl.addressBook}}</a>
|
|
@ -0,0 +1 @@
|
|||
<li ng-repeat="group in groups" group data="group"></li>
|
|
@ -19,7 +19,7 @@ style('contactsrework', 'public/style');
|
|||
<div id="app" ng-app="contactsApp">
|
||||
<div id="app-navigation">
|
||||
|
||||
<ul addressBookList></ul>
|
||||
<ul groupList></ul>
|
||||
|
||||
<div id="app-settings">
|
||||
<div id="app-settings-header">
|
||||
|
|
Loading…
Reference in New Issue