mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +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:
parent
3d19b79699
commit
6fcac9f5f9
.eslintrc.json
lib/process-services-cloud/src/lib/form/components/widgets/dropdown
@ -89,7 +89,14 @@
|
||||
"rxjs/no-subject-unsubscribe": "error",
|
||||
"rxjs/no-subject-value": "error",
|
||||
"rxjs/no-unsafe-takeuntil": "error",
|
||||
"unicorn/filename-case": "error"
|
||||
"unicorn/filename-case": "error",
|
||||
"@typescript-eslint/no-unused-expressions": [
|
||||
"error",
|
||||
{
|
||||
"allowShortCircuit": true,
|
||||
"allowTernary": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -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();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user