Fix WP save method for linked resources

pull/4159/head
Alex Dik 9 years ago
parent 08efd59277
commit 673b3fb3ba
  1. 4
      frontend/app/components/api/api-v3/hal/hal-resource.service.ts
  2. 11
      frontend/app/components/api/api-v3/hal/work-package-resource.service.ts

@ -96,7 +96,9 @@ function halResource(halTransform, HalLink, $q) {
element._links = {};
linked.forEach(linkName => {
element._links[linkName] = this[linkName];
if (this[linkName] && !angular.isFunction(this[linkName])) {
element._links[linkName] = element[linkName].$links.self.$link;
}
delete element[linkName];
});

@ -49,13 +49,16 @@ function wpResource(HalResource: typeof op.HalResource) {
}
save() {
var data = this.$plain();
const plain = this.$plain();
//TODO: Remove non-writable properties automatically
delete data.createdAt;
delete data.updatedAt;
delete plain.createdAt;
delete plain.updatedAt;
return this.$source.patch(data);
return this.$links.updateImmediately(plain).then(workPackage => {
angular.extend(this, workPackage);
return this;
});
}
}

Loading…
Cancel
Save