summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHendrik Leppelsack <hendrik@leppelsack.de>2017-10-31 20:16:59 +0100
committerHendrik Leppelsack <hendrik@leppelsack.de>2017-10-31 20:16:59 +0100
commit379be9395adbb0870f594675824e0dcaeefcf216 (patch)
tree5180de9749d061c2bb9fa86f948dc4bf87f336b7
parent179e97ebdeca7482537666dd795439c4c0c2bcec (diff)
fix references
-rw-r--r--js/components/detailsItem/detailsItem_controller.js16
-rw-r--r--js/components/detailsItem/detailsItem_directive.js2
-rw-r--r--js/components/propertyGroup/propertyGroup_directive.js2
-rw-r--r--js/models/contact_model.js3
-rw-r--r--templates/contactDetails.html2
-rw-r--r--templates/propertyGroup.html2
6 files changed, 15 insertions, 12 deletions
diff --git a/js/components/detailsItem/detailsItem_controller.js b/js/components/detailsItem/detailsItem_controller.js
index 9d952885..af62cae1 100644
--- a/js/components/detailsItem/detailsItem_controller.js
+++ b/js/components/detailsItem/detailsItem_controller.js
@@ -55,8 +55,8 @@ angular.module('contactsApp')
}
}
if (!_.isUndefined(ctrl.data) && !_.isUndefined(ctrl.data.namespace)) {
- if (!_.isUndefined(ctrl.model.contact.props['X-ABLABEL'])) {
- var val = _.find(this.model.contact.props['X-ABLABEL'], function(x) { return x.namespace === ctrl.data.namespace; });
+ if (!_.isUndefined(ctrl.contact.props['X-ABLABEL'])) {
+ var val = _.find(this.contact.props['X-ABLABEL'], function(x) { return x.namespace === ctrl.data.namespace; });
ctrl.type = val.value.toUpperCase();
if (!_.isUndefined(val)) {
// in case the type is not yet in the default list of available options we add it
@@ -80,7 +80,7 @@ angular.module('contactsApp')
ctrl.data.meta = ctrl.data.meta || {};
ctrl.data.meta.type = ctrl.data.meta.type || [];
ctrl.data.meta.type[0] = val;
- ctrl.model.updateContact();
+ ContactService.queueUpdate(ctrl.contact);
};
ctrl.dateInputChanged = function () {
@@ -93,7 +93,7 @@ angular.module('contactsApp')
ctrl.data.meta.value = ctrl.data.meta.value || [];
ctrl.data.meta.value[0] = 'text';
}
- ctrl.model.updateContact();
+ ContactService.queueUpdate(ctrl.contact);
};
ctrl.updateDetailedName = function () {
@@ -114,8 +114,8 @@ angular.module('contactsApp')
fn += ctrl.data.value[4];
}
- ctrl.model.contact.fullName(fn);
- ctrl.model.updateContact();
+ ctrl.contact.fullName(fn);
+ ContactService.queueUpdate(ctrl.contact);
};
ctrl.getTemplate = function() {
@@ -124,7 +124,7 @@ angular.module('contactsApp')
};
ctrl.deleteField = function () {
- ctrl.model.deleteField(ctrl.name, ctrl.data);
- ctrl.model.updateContact();
+ ctrl.contact.removeProperty(ctrl.name, ctrl.data);
+ ContactService.queueUpdate(ctrl.contact);
};
});
diff --git a/js/components/detailsItem/detailsItem_directive.js b/js/components/detailsItem/detailsItem_directive.js
index 37099ddc..b7a2521a 100644
--- a/js/components/detailsItem/detailsItem_directive.js
+++ b/js/components/detailsItem/detailsItem_directive.js
@@ -7,7 +7,7 @@ angular.module('contactsApp')
bindToController: {
name: '=',
data: '=',
- model: '=',
+ contact: '=model',
index: '='
},
link: function(scope, element, attrs, ctrl) {
diff --git a/js/components/propertyGroup/propertyGroup_directive.js b/js/components/propertyGroup/propertyGroup_directive.js
index fc86dbd9..d16a5d20 100644
--- a/js/components/propertyGroup/propertyGroup_directive.js
+++ b/js/components/propertyGroup/propertyGroup_directive.js
@@ -7,7 +7,7 @@ angular.module('contactsApp')
bindToController: {
properties: '=data',
name: '=',
- model: '='
+ contact: '=model'
},
templateUrl: OC.linkTo('contacts', 'templates/propertyGroup.html'),
link: function(scope, element, attrs, ctrl) {
diff --git a/js/models/contact_model.js b/js/models/contact_model.js
index 7cca631f..83562d22 100644
--- a/js/models/contact_model.js
+++ b/js/models/contact_model.js
@@ -256,6 +256,9 @@ angular.module('contactsApp')
},
removeProperty: function (name, prop) {
angular.copy(_.without(this.props[name], prop), this.props[name]);
+ if(this.props[name].length === 0) {
+ delete this.props[name];
+ }
this.data.addressData = $filter('JSON2vCard')(this.props);
},
setETag: function(etag) {
diff --git a/templates/contactDetails.html b/templates/contactDetails.html
index d3fb8bc1..58a2f2d2 100644
--- a/templates/contactDetails.html
+++ b/templates/contactDetails.html
@@ -42,7 +42,7 @@
</div>
</header>
<section>
- <propertyGroup ng-repeat="prop in ctrl.contact.props | toArray | orderDetailItems:'$key'" contact="ctrl" prop="prop" name="prop.$key"></propertyGroup>
+ <propertyGroup ng-repeat="prop in ctrl.contact.props | toArray | orderDetailItems:'$key'" model="ctrl.contact" data="prop" name="prop.$key"></propertyGroup>
<div class="select-addressbook" ng-if="ctrl.addressBooks.length > 1 && !ctrl.addressBook.readOnly">
<label for="details-addressbook">{{ctrl.t.addressBook}}</label>
diff --git a/templates/propertyGroup.html b/templates/propertyGroup.html
index 1d7ad3ef..99b4a818 100644
--- a/templates/propertyGroup.html
+++ b/templates/propertyGroup.html
@@ -1,3 +1,3 @@
<h3 class="propertyGroup__title" ng-class="ctrl.getIconClass()" style="display: inline-block; background-size: 16px 16px; background-position-x: 0; padding-left: 20px;">{{ctrl.getReadableName()}}</h3>
-<detailsItem ng-repeat="property in ctrl.properties" name="ctrl.name" data="property" model="ctrl" index="$index"
+<detailsItem ng-repeat="property in ctrl.properties" name="ctrl.name" data="property" model="ctrl.contact" index="$index"
class="details-item-{{ctrl.name}}" ng-class="{ 'failed': ctrl.contact.failedProps.indexOf(ctrl.name) !== -1 }"></detailsItem>