Fix overridden setter/getter in multivalue select field

pull/5799/head
Oliver Günther 7 years ago
parent a0ff005444
commit 6b537b8132
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 1
      frontend/app/components/wp-edit-form/work-package-changeset.ts
  2. 5
      frontend/app/components/wp-edit-form/work-package-edit-form.ts
  3. 27
      frontend/app/components/wp-edit/field-types/wp-edit-multi-select-field.module.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;

@ -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(() => {

@ -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 = <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() {

Loading…
Cancel
Save