Fixed issue when adding repeatable onebox field with vocabulary

This commit is contained in:
Giuseppe Digilio
2020-07-31 15:17:51 +02:00
parent 79db49043f
commit 0582bc5622
2 changed files with 5 additions and 2 deletions

View File

@@ -46,7 +46,7 @@ export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent imple
@ViewChild('instance', { static: false }) instance: NgbTypeahead; @ViewChild('instance', { static: false }) instance: NgbTypeahead;
pageInfo: PageInfo; pageInfo: PageInfo = new PageInfo();
searching = false; searching = false;
searchFailed = false; searchFailed = false;
hideSearchingWhenUnsubscribed$ = new Observable(() => () => this.changeSearchingStatus(false)); hideSearchingWhenUnsubscribed$ = new Observable(() => () => this.changeSearchingStatus(false));
@@ -247,6 +247,7 @@ export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent imple
this.getInitValueFromModel() this.getInitValueFromModel()
.subscribe((formValue: FormFieldMetadataValueObject) => { .subscribe((formValue: FormFieldMetadataValueObject) => {
this.currentValue = formValue; this.currentValue = formValue;
this.cdr.detectChanges();
}); });
} else { } else {
if (isEmpty(value)) { if (isEmpty(value)) {
@@ -258,6 +259,7 @@ export class DsDynamicOneboxComponent extends DsDynamicVocabularyComponent imple
} }
this.currentValue = result; this.currentValue = result;
this.cdr.detectChanges();
} }
} }

View File

@@ -11,6 +11,7 @@ import { FormService } from './form.service';
import { FormEntry, FormError } from './form.reducer'; import { FormEntry, FormError } from './form.reducer';
import { DYNAMIC_FORM_CONTROL_TYPE_SCROLLABLE_DROPDOWN } from './builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.model'; import { DYNAMIC_FORM_CONTROL_TYPE_SCROLLABLE_DROPDOWN } from './builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.model';
import { QUALDROP_GROUP_SUFFIX } from './builder/ds-dynamic-form-ui/models/ds-dynamic-qualdrop.model'; import { QUALDROP_GROUP_SUFFIX } from './builder/ds-dynamic-form-ui/models/ds-dynamic-qualdrop.model';
import { DYNAMIC_FORM_CONTROL_TYPE_ONEBOX } from './builder/ds-dynamic-form-ui/models/onebox/dynamic-onebox.model';
const QUALDROP_GROUP_REGEX = new RegExp(`${QUALDROP_GROUP_SUFFIX}_\\d+$`); const QUALDROP_GROUP_REGEX = new RegExp(`${QUALDROP_GROUP_SUFFIX}_\\d+$`);
@@ -316,7 +317,7 @@ export class FormComponent implements OnDestroy, OnInit {
// set that field to the new value // set that field to the new value
const model = arrayContext.groups[arrayContext.groups.length - 1].group[0] as any; const model = arrayContext.groups[arrayContext.groups.length - 1].group[0] as any;
if (model.type === DYNAMIC_FORM_CONTROL_TYPE_SCROLLABLE_DROPDOWN) { if (model.type === DYNAMIC_FORM_CONTROL_TYPE_SCROLLABLE_DROPDOWN || model.type === DYNAMIC_FORM_CONTROL_TYPE_ONEBOX) {
model.value = Object.values(value)[0]; model.value = Object.values(value)[0];
} else if (this.formBuilderService.isQualdropGroup(model)) { } else if (this.formBuilderService.isQualdropGroup(model)) {
const ctrl = formArrayControl.controls[formArrayControl.length - 1]; const ctrl = formArrayControl.controls[formArrayControl.length - 1];