Fix work package save spec

pull/4238/head
Alex Dik 9 years ago
parent d94ceb82dc
commit 30e0dc7ecc
  1. 14
      frontend/app/components/api/api-v3/hal-resources/hal-resource.service.ts
  2. 10
      frontend/app/components/api/api-v3/hal-resources/work-package-resource.service.ts

@ -93,19 +93,7 @@ function halResource($q, _, lazy, halTransform, HalLink) {
}
public $plain() {
let element:any = angular.copy(this);
let linked:string[] = Object.keys(this.$links);
element._links = {};
linked.forEach(linkName => {
if (this[linkName] && element[linkName].$links && !angular.isFunction(this[linkName])) {
element._links[linkName] = element[linkName].$links.self.$link;
}
delete element[linkName];
});
return element;
return angular.copy(this.$source);
}
private proxyProperties() {

@ -66,23 +66,23 @@ function wpResource(HalResource:typeof op.HalResource, NotificationsService:any,
this.getForm()
.catch(deferred.reject)
.then(form => {
var plain_payload = form.payload.$source;
var plainPayload = form.payload.$plain();
var schema = form.$embedded.schema;
angular.forEach(plain, (value, key) => {
if (typeof(schema[key]) === 'object' && schema[key]['writable'] === true) {
plain_payload[key] = value;
plainPayload[key] = value;
}
});
angular.forEach(plain_payload._links, (_value, key) => {
angular.forEach(plainPayload._links, (_value, key) => {
if (this[key] && typeof(schema[key]) === 'object' && schema[key]['writable'] === true) {
var value = this[key].href === 'null' ? null : this[key].href;
plain_payload._links[key] = {href: value};
plainPayload._links[key] = {href: value};
}
});
return this.$links.updateImmediately(plain_payload)
return this.$links.updateImmediately(plainPayload)
.then(workPackage => {
angular.extend(this, workPackage);

Loading…
Cancel
Save