mirror of https://github.com/nextcloud/contacts
Respect org being an array - fixes #177
This commit is contained in:
parent
0420a8f26a
commit
8e4d25291f
|
@ -6,7 +6,4 @@ app.controller('contactCtrl', ['$route', '$routeParams', function($route, $route
|
|||
gid: $routeParams.gid,
|
||||
uid: ctrl.contact.uid()});
|
||||
};
|
||||
|
||||
console.log('Contact: ', ctrl.contact);
|
||||
|
||||
}]);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue