diff --git a/frontend/app/components/wp-edit-form/work-package-changeset.ts b/frontend/app/components/wp-edit-form/work-package-changeset.ts index efadd759b5..f798df5352 100644 --- a/frontend/app/components/wp-edit-form/work-package-changeset.ts +++ b/frontend/app/components/wp-edit-form/work-package-changeset.ts @@ -138,6 +138,7 @@ export class WorkPackageChangeset { var deferred = this.$q.defer(); + console.trace("UPDATING FORM"); this.workPackage.$links.update(payload) .then((form) => { this.wpForm = form; diff --git a/frontend/app/components/wp-edit-form/work-package-edit-form.ts b/frontend/app/components/wp-edit-form/work-package-edit-form.ts index ea6c2c6800..658ae7ad19 100644 --- a/frontend/app/components/wp-edit-form/work-package-edit-form.ts +++ b/frontend/app/components/wp-edit-form/work-package-edit-form.ts @@ -80,10 +80,11 @@ export class WorkPackageEditForm { this.wpSubscription = this.states.workPackages.get(workPackage.id) .values$() .subscribe((wp:WorkPackageResourceInterface) => { - debugLog("Refreshing work package and form"); this.workPackage = wp; this.changeset.workPackage = wp; - this.changeset.updateForm(); + + // Reset the current form + this.changeset.wpForm = null; }); this.formSubscription = this.editResource.subscribe(() => { diff --git a/frontend/app/components/wp-edit/field-types/wp-edit-multi-select-field.module.ts b/frontend/app/components/wp-edit/field-types/wp-edit-multi-select-field.module.ts index 87ab12ab96..9142945100 100644 --- a/frontend/app/components/wp-edit/field-types/wp-edit-multi-select-field.module.ts +++ b/frontend/app/components/wp-edit/field-types/wp-edit-multi-select-field.module.ts @@ -27,9 +27,9 @@ // ++ import {EditField} from '../wp-edit-field/wp-edit-field.module'; -import {WorkPackageResourceInterface} from '../../api/api-v3/hal-resources/work-package-resource.service'; import {CollectionResource} from '../../api/api-v3/hal-resources/collection-resource.service'; import {HalResource} from '../../api/api-v3/hal-resources/hal-resource.service'; +import {$injectFields} from '../../angular/angular-injector-bridge.functions'; export class MultiSelectEditField extends EditField { public options:any[]; @@ -38,17 +38,17 @@ export class MultiSelectEditField extends EditField { public isMultiselect: boolean; // Dependencies - protected I18n:op.I18n = MultiSelectEditField.$injector.get('I18n'); + public I18n:op.I18n; public currentValueInvalid:boolean = false; protected initialize() { + $injectFields(this, 'I18n'); this.isMultiselect = this.isValueMulti(); - const I18n:any = this.$injector.get('I18n'); this.text = { - requiredPlaceholder: I18n.t('js.placeholders.selection'), - placeholder: I18n.t('js.placeholders.default'), + requiredPlaceholder: this.I18n.t('js.placeholders.selection'), + placeholder: this.I18n.t('js.placeholders.default'), save: this.I18n.t('js.inplace.button_save', { attribute: this.schema.name }), cancel: this.I18n.t('js.inplace.button_cancel', { attribute: this.schema.name }) }; @@ -70,23 +70,30 @@ export class MultiSelectEditField extends EditField { } public get value() { + const val = this.changeset.value(this.name); + if (this.isMultiselect) { - return this.resource[this.name]; + return val; } else { - return this.resource[this.name][0]; + return val[0]; } } public set value(val) { + this.changeset.setValue(this.name, this.parseValue(val)); + } + + protected parseValue(val:any) { if (Array.isArray(val)) { - this.resource[this.name] = val; + return val; } else { - this.resource[this.name] = [val]; + return [val]; } } public isValueMulti() { - return this.resource[this.name].length > 1; + const val = this.changeset.value(this.name); + return val.length > 1; } public toggleMultiselect() {