Respect org being an array - fixes #177

This commit is contained in:
Thomas Müller 2016-03-10 12:20:44 +01:00
parent 0420a8f26a
commit 8e4d25291f
3 changed files with 42 additions and 32 deletions

View File

@ -6,7 +6,4 @@ app.controller('contactCtrl', ['$route', '$routeParams', function($route, $route
gid: $routeParams.gid,
uid: ctrl.contact.uid()});
};
console.log('Contact: ', ctrl.contact);
}]);

View File

@ -48,13 +48,21 @@ app.factory('Contact', [ '$filter', function($filter) {
},
org: function(value) {
var property = this.getProperty('org');
if (angular.isDefined(value)) {
var val = value;
// setter
return this.setProperty('org', { value: value });
if(property && Array.isArray(property.value)) {
val = property.value;
val[0] = value;
}
return this.setProperty('org', { value: val });
} else {
// getter
var property = this.getProperty('org');
if(property) {
if (Array.isArray(property.value)) {
return property.value[0];
}
return property.value;
} else {
return undefined;

View File

@ -199,6 +199,28 @@ app.directive('addressbook', function() {
};
});
app.controller('contactCtrl', ['$route', '$routeParams', function($route, $routeParams) {
var ctrl = this;
ctrl.openContact = function() {
$route.updateParams({
gid: $routeParams.gid,
uid: ctrl.contact.uid()});
};
}]);
app.directive('contact', function() {
return {
scope: {},
controller: 'contactCtrl',
controllerAs: 'ctrl',
bindToController: {
contact: '=data'
},
templateUrl: OC.linkTo('contacts', 'templates/contact.html')
};
});
app.controller('addressbooklistCtrl', ['$scope', 'AddressBookService', 'SettingsService', function(scope, AddressBookService, SettingsService) {
var ctrl = this;
@ -229,31 +251,6 @@ app.directive('addressbooklist', 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);
}]);
app.directive('contact', function() {
return {
scope: {},
controller: 'contactCtrl',
controllerAs: 'ctrl',
bindToController: {
contact: '=data'
},
templateUrl: OC.linkTo('contacts', 'templates/contact.html')
};
});
app.controller('contactdetailsCtrl', ['ContactService', 'AddressBookService', 'vCardPropertiesService', '$routeParams', '$scope', function(ContactService, AddressBookService, vCardPropertiesService, $routeParams, $scope) {
var ctrl = this;
@ -730,13 +727,21 @@ app.factory('Contact', [ '$filter', function($filter) {
},
org: function(value) {
var property = this.getProperty('org');
if (angular.isDefined(value)) {
var val = value;
// setter
return this.setProperty('org', { value: value });
if(property && Array.isArray(property.value)) {
val = property.value;
val[0] = value;
}
return this.setProperty('org', { value: val });
} else {
// getter
var property = this.getProperty('org');
if(property) {
if (Array.isArray(property.value)) {
return property.value[0];
}
return property.value;
} else {
return undefined;