(js) Fix handling of contact categories
parent
3787296fd6
commit
5c4da276bf
|
@ -108,7 +108,7 @@
|
|||
|
||||
<!-- categories -->
|
||||
<md-chips ng-model="editor.card.categories"
|
||||
md-transform-chip="{ value: $chip }">
|
||||
md-transform-chip="editor.transformCategory($chip)">
|
||||
<md-chip-template>{{$chip.value}}</md-chip-template>
|
||||
<md-autocomplete
|
||||
md-selected-item="editor.categories.selected"
|
||||
|
|
|
@ -129,6 +129,7 @@
|
|||
*/
|
||||
Card.prototype.init = function(data, partial) {
|
||||
this.refs = [];
|
||||
this.categories = [];
|
||||
angular.extend(this, data);
|
||||
if (!this.$$fullname)
|
||||
this.$$fullname = this.$fullname();
|
||||
|
@ -316,22 +317,22 @@
|
|||
return this.orgUnits.length - 1;
|
||||
};
|
||||
|
||||
Card.prototype.$addCategory = function(category) {
|
||||
if (category) {
|
||||
if (angular.isUndefined(this.categories)) {
|
||||
this.categories = [{value: category}];
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < this.categories.length; i++) {
|
||||
if (this.categories[i].value == category) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == this.categories.length)
|
||||
this.categories.push({value: category});
|
||||
}
|
||||
}
|
||||
};
|
||||
// Card.prototype.$addCategory = function(category) {
|
||||
// if (category) {
|
||||
// if (angular.isUndefined(this.categories)) {
|
||||
// this.categories = [{value: category}];
|
||||
// }
|
||||
// else {
|
||||
// for (var i = 0; i < this.categories.length; i++) {
|
||||
// if (this.categories[i].value == category) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (i == this.categories.length)
|
||||
// this.categories.push({value: category});
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
|
||||
Card.prototype.$addEmail = function(type) {
|
||||
if (angular.isUndefined(this.emails)) {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
vm.allAddressTypes = Card.$ADDRESS_TYPES;
|
||||
vm.categories = {};
|
||||
vm.userFilterResults = [];
|
||||
vm.transformCategory = transformCategory;
|
||||
vm.addOrgUnit = addOrgUnit;
|
||||
vm.addBirthday = addBirthday;
|
||||
vm.addScreenName = addScreenName;
|
||||
|
@ -38,6 +39,12 @@
|
|||
vm.toggleRawSource = toggleRawSource;
|
||||
vm.showRawSource = false;
|
||||
|
||||
function transformCategory(input) {
|
||||
if (angular.isString(input))
|
||||
return { value: input };
|
||||
else
|
||||
return input;
|
||||
}
|
||||
function addOrgUnit() {
|
||||
var i = vm.card.$addOrgUnit('');
|
||||
focus('orgUnit_' + i);
|
||||
|
|
Loading…
Reference in New Issue