mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[AAE-2984] fix save not modified Form with dropdown (#5976)
* fix save not modified Form with dropdown * Update form-field.model.ts * Update form-field.model.ts * fix empty value scenario * fix unit
This commit is contained in:
@@ -274,14 +274,19 @@ export class FormFieldModel extends FormWidgetModel {
|
||||
but saving back as object: { id: <id>, name: <name> }
|
||||
*/
|
||||
if (json.type === FormFieldTypes.DROPDOWN) {
|
||||
if (json.hasEmptyValue && json.options) {
|
||||
|
||||
if (json.options) {
|
||||
const options = <FormFieldOption[]> json.options || [];
|
||||
if (options.length > 0) {
|
||||
const emptyOption = json.options[0];
|
||||
if (value === '' || value === emptyOption.id || value === emptyOption.name) {
|
||||
value = emptyOption.id;
|
||||
} else if (value.id && value.name) {
|
||||
value = value.id;
|
||||
if (json.hasEmptyValue) {
|
||||
const emptyOption = json.options[0];
|
||||
if (value === '' || value === emptyOption.id || value === emptyOption.name) {
|
||||
value = emptyOption.id;
|
||||
}
|
||||
} else {
|
||||
if (value?.id && value?.name) {
|
||||
value = value.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -62,7 +62,7 @@ export const fakeForm: any = {
|
||||
1: [
|
||||
{
|
||||
fieldType: 'RestFieldRepresentation',
|
||||
id: 'label',
|
||||
id: 'dropdownId',
|
||||
name: 'Label',
|
||||
type: 'dropdown',
|
||||
value: 'Choose one...',
|
||||
|
@@ -250,9 +250,6 @@ describe('PaginationComponent', () => {
|
||||
expect(component.isFirstPage).toBe(true, 'isFirstPage');
|
||||
expect(component.isLastPage).toBe(true, 'isLastPage');
|
||||
|
||||
// tslint:disable-next-line: no-console
|
||||
console.log(JSON.stringify(component.pagination));
|
||||
|
||||
expect(component.range).toEqual([ 0, 0 ], 'range');
|
||||
expect(component.pages).toEqual([ 1 ], 'pages');
|
||||
});
|
||||
|
Reference in New Issue
Block a user