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
@ -89,7 +89,14 @@
|
|||||||
"rxjs/no-subject-unsubscribe": "error",
|
"rxjs/no-subject-unsubscribe": "error",
|
||||||
"rxjs/no-subject-value": "error",
|
"rxjs/no-subject-value": "error",
|
||||||
"rxjs/no-unsafe-takeuntil": "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
|
entries: mockConditionalEntries
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const updateFormSpy = spyOn(widget.field, 'updateForm');
|
const updateFormSpy = spyOn(widget.field, 'updateForm').and.callThrough();
|
||||||
const mockParentDropdown = { id: 'parentDropdown', value: 'IT' };
|
const mockParentDropdown = { id: 'parentDropdown', value: 'IT', validate: (): boolean => true };
|
||||||
spyOn(widget.field.form, 'getFormFields').and.returnValue([mockParentDropdown]);
|
spyOn(widget.field.form, 'getFormFields').and.returnValue([mockParentDropdown]);
|
||||||
|
widget.field.value = 'MI';
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(updateFormSpy).toHaveBeenCalled();
|
expect(updateFormSpy).toHaveBeenCalled();
|
||||||
expect(widget.field.options).toEqual(mockConditionalEntries[1].options);
|
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', () => {
|
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) {
|
private parentValueChanged(value: string) {
|
||||||
if (value && !this.isDefaultValue(value)) {
|
if (value && !this.isDefaultValue(value)) {
|
||||||
if (this.isValidRestType()) {
|
this.isValidRestType() ? this.persistFieldOptionsFromRestApi() : this.persistFieldOptionsFromManualList(value);
|
||||||
this.persistFieldOptionsFromRestApi();
|
|
||||||
} else {
|
|
||||||
this.persistFieldOptionsFromManualList(value);
|
|
||||||
}
|
|
||||||
} else if (this.isDefaultValue(value)) {
|
} else if (this.isDefaultValue(value)) {
|
||||||
this.resetRestApiErrorMessage();
|
this.resetRestApiErrorMessage();
|
||||||
this.addDefaultOption();
|
this.addDefaultOption();
|
||||||
@ -165,6 +161,7 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI
|
|||||||
if (ruleEntry.key === value) {
|
if (ruleEntry.key === value) {
|
||||||
this.field.options = ruleEntry.options;
|
this.field.options = ruleEntry.options;
|
||||||
this.resetInvalidValue();
|
this.resetInvalidValue();
|
||||||
|
this.field.updateForm();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user