mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-8554] - Fix linked dropdown values are displayed but not submitted (#7590)
* [AAE-8554] - Fix dropdown values are displayed but not submitted * Make eslint allow ternary
This commit is contained in:
@@ -592,13 +592,15 @@ describe('DropdownCloudWidgetComponent', () => {
|
||||
entries: mockConditionalEntries
|
||||
}
|
||||
});
|
||||
const updateFormSpy = spyOn(widget.field, 'updateForm');
|
||||
const mockParentDropdown = { id: 'parentDropdown', value: 'IT' };
|
||||
const updateFormSpy = spyOn(widget.field, 'updateForm').and.callThrough();
|
||||
const mockParentDropdown = { id: 'parentDropdown', value: 'IT', validate: (): boolean => true };
|
||||
spyOn(widget.field.form, 'getFormFields').and.returnValue([mockParentDropdown]);
|
||||
widget.field.value = 'MI';
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(updateFormSpy).toHaveBeenCalled();
|
||||
expect(widget.field.options).toEqual(mockConditionalEntries[1].options);
|
||||
expect(widget.field.form.values).toEqual({ 'child-dropdown-id': { id: 'MI', name: 'MILAN' }});
|
||||
});
|
||||
|
||||
it('should load the selection of a rest type linked dropdown', () => {
|
||||
|
@@ -135,11 +135,7 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI
|
||||
|
||||
private parentValueChanged(value: string) {
|
||||
if (value && !this.isDefaultValue(value)) {
|
||||
if (this.isValidRestType()) {
|
||||
this.persistFieldOptionsFromRestApi();
|
||||
} else {
|
||||
this.persistFieldOptionsFromManualList(value);
|
||||
}
|
||||
this.isValidRestType() ? this.persistFieldOptionsFromRestApi() : this.persistFieldOptionsFromManualList(value);
|
||||
} else if (this.isDefaultValue(value)) {
|
||||
this.resetRestApiErrorMessage();
|
||||
this.addDefaultOption();
|
||||
@@ -165,6 +161,7 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI
|
||||
if (ruleEntry.key === value) {
|
||||
this.field.options = ruleEntry.options;
|
||||
this.resetInvalidValue();
|
||||
this.field.updateForm();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user