Skip to content

Commit

Permalink
Merge pull request #39 from owncloud/groups-for-exit
Browse files Browse the repository at this point in the history
Groups from categories in vcards
  • Loading branch information
jancborchardt committed Feb 19, 2016
2 parents c4dbf40 + 437ce3c commit 216ab7a
Show file tree
Hide file tree
Showing 21 changed files with 302 additions and 27 deletions.
Expand Up @@ -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() {
Expand Down
8 changes: 7 additions & 1 deletion js/components/contact/contact_controller.js
@@ -1,6 +1,12 @@
app.controller('contactCtrl', [function() {
app.controller('contactCtrl', ['$route', '$routeParams', function($route, $routeParams) {
var ctrl = this;

ctrl.openContact = function() {
$route.updateParams({
gid: $routeParams.gid,
uid: ctrl.contact.uid()});
};

console.log("Contact: ",ctrl.contact);

}]);
3 changes: 3 additions & 0 deletions js/components/contactDetails/contactDetails_controller.js
Expand Up @@ -8,6 +8,9 @@ app.controller('contactdetailsCtrl', ['ContactService', '$routeParams', '$scope'
});

ctrl.changeContact = function(uid) {
if (typeof uid === "undefined") {
return;
}
ContactService.getById(uid).then(function(contact) {
ctrl.contact = contact;
});
Expand Down
17 changes: 16 additions & 1 deletion js/components/contactList/contactList_controller.js
@@ -1,6 +1,8 @@
app.controller('contactlistCtrl', ['$scope', 'ContactService', function($scope, ContactService) {
app.controller('contactlistCtrl', ['$scope', 'ContactService', '$routeParams', function($scope, ContactService, $routeParams) {
var ctrl = this;

ctrl.routeParams = $routeParams;

ContactService.registerObserverCallback(function(contacts) {
$scope.$apply(function() {
ctrl.contacts = contacts;
Expand All @@ -16,4 +18,17 @@ app.controller('contactlistCtrl', ['$scope', 'ContactService', function($scope,
ctrl.createContact = function() {
ContactService.create();
};

ctrl.hasContacts = function () {
if (!ctrl.contacts) {
return false;
}
return ctrl.contacts.length > 0;
};

$scope.selectedContactId = $routeParams.uid;
$scope.setSelected = function (selectedContactId) {
$scope.selectedContactId = selectedContactId;
};

}]);
4 changes: 4 additions & 0 deletions js/components/group/group_controller.js
@@ -0,0 +1,4 @@
app.controller('groupCtrl', function() {
var ctrl = this;
console.log(this);
});
12 changes: 12 additions & 0 deletions js/components/group/group_directive.js
@@ -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: {
group: "=data"
},
templateUrl: OC.linkTo('contactsrework', 'templates/group.html')
};
});
13 changes: 13 additions & 0 deletions js/components/groupList/groupList_controller.js
@@ -0,0 +1,13 @@
app.controller('grouplistCtrl', ['$scope', 'ContactService', '$routeParams', function($scope, ContactService, $routeParams) {

$scope.groups = ['All'];

ContactService.getGroups().then(function(groups) {
$scope.groups = groups;
});

$scope.selectedGroup = $routeParams.gid;
$scope.setSelected = function (selectedGroup) {
$scope.selectedGroup = selectedGroup;
};
}]);
10 changes: 10 additions & 0 deletions js/components/groupList/groupList_directive.js
@@ -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')
};
});
22 changes: 22 additions & 0 deletions js/filters/contactGroup_filter.js
@@ -0,0 +1,22 @@
app.filter('contactGroupFilter', [
function() {
'use strict';
return function (contacts, group) {
if (typeof contacts === "undefined") {
return contacts;
}
if (typeof group === "undefined" || group.toLowerCase() === 'all') {
return contacts;
}
var filter = [];
if (contacts.length > 0) {
for (var i = 0; i < contacts.length; i++) {
if (contacts[i].categories().indexOf(group) >= 0) {
filter.push(contacts[i]);
}
}
}
return filter;
};
}
]);
8 changes: 7 additions & 1 deletion js/main.js
Expand Up @@ -12,8 +12,14 @@ var app = angular.module('contactsApp', ['uuid4', 'angular-cache', 'ngRoute']);

app.config(['$routeProvider', function($routeProvider){

$routeProvider.when("/:uid", {
$routeProvider.when("/:gid", {
template: '<contactdetails></contactdetails>'
});

$routeProvider.when("/:gid/:uid", {
template: '<contactdetails></contactdetails>'
});

$routeProvider.otherwise("/All");

}]);
1 change: 1 addition & 0 deletions js/models/addressBook_model.js
Expand Up @@ -5,6 +5,7 @@ app.factory('AddressBook', function()

displayName: "",
contacts: [],
groups: data.data.props.groups,

getContact: function(uid) {
for(var i in this.contacts) {
Expand Down
15 changes: 15 additions & 0 deletions js/models/contact_model.js
Expand Up @@ -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];
Expand Down

0 comments on commit 216ab7a

Please sign in to comment.