From 0b805f3e9b0357840ad2e4d0deb14f555ee51c68 Mon Sep 17 00:00:00 2001 From: Darren Thornton <6361057+dthornton-hyl@users.noreply.github.com> Date: Tue, 10 Feb 2026 07:02:35 -0600 Subject: [PATCH] =?UTF-8?q?Revert=20"AAE-40604=20Fix=20case=20when=20rest/?= =?UTF-8?q?variable=20are=20okay=20and=20dropdown=20is=20requir=E2=80=A6"?= =?UTF-8?q?=20(#11634)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 31bafd718e3e2e853bb7c8410d82242fa874721b. --- .../dropdown/dropdown-cloud.widget.spec.ts | 135 ------------------ .../widgets/dropdown/dropdown-cloud.widget.ts | 17 +-- 2 files changed, 4 insertions(+), 148 deletions(-) diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.spec.ts b/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.spec.ts index 5c16022547..bfc3d492d9 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.spec.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.spec.ts @@ -303,34 +303,6 @@ describe('DropdownCloudWidgetComponent', () => { }); }); - describe('when options load successfully from restUrl', () => { - beforeEach(() => { - spyOn(formCloudService, 'getRestWidgetData').and.returnValue(of(fakeOptionList)); - widget.field.restUrl = 'https://fake-rest-url'; - widget.field.optionType = 'rest'; - widget.field.required = true; - widget.field.value = ''; - widget.field.isVisible = true; - }); - - it('should show required message for rest type when required and value is empty after touch', fakeAsync(() => { - widget.ngOnInit(); - fixture.detectChanges(); - tick(DROPDOWN_CLOUD_WIDGET_SET_VALUE_DEBOUNCE); - fixture.detectChanges(); - - expect(widget.isRestApiFailed).toBe(false); - expect(widget.dropdownControl.errors?.required).toBeTruthy(); - - widget.dropdownControl.markAsTouched(); - fixture.detectChanges(); - - const requiredErrorElement = fixture.debugElement.query(By.css('.adf-dropdown-required-message .adf-error-text')); - expect(requiredErrorElement).toBeTruthy(); - expect(requiredErrorElement.nativeElement.innerText).toEqual('FORM.FIELD.REQUIRED'); - })); - }); - it('should preselect dropdown widget value when Json (rest call) passed', async () => { widget.field.restUrl = 'https://fake-rest-url'; widget.field.optionType = 'rest'; @@ -1155,86 +1127,6 @@ describe('DropdownCloudWidgetComponent', () => { expect(widget.dropdownControl.value).toEqual({ id: 'testValueObj', name: 'testValueObjName' }); })); - it('should set dropdownControl value to null when field value is undefined', fakeAsync(() => { - widget.field = { - value: undefined, - options: [], - isVisible: true, - markAsValid: () => {} - } as FormFieldModel; - - fixture.detectChanges(); - widget['setFormControlValue'](); - - tick(DROPDOWN_CLOUD_WIDGET_SET_VALUE_DEBOUNCE); - - expect(widget.dropdownControl.value).toBeNull(); - })); - - it('should set dropdownControl value to null when field value is empty string', fakeAsync(() => { - widget.field = { - value: '', - options: [], - isVisible: true, - markAsValid: () => {} - } as FormFieldModel; - - fixture.detectChanges(); - widget['setFormControlValue'](); - - tick(DROPDOWN_CLOUD_WIDGET_SET_VALUE_DEBOUNCE); - - expect(widget.dropdownControl.value).toBeNull(); - })); - - it('should set dropdownControl value to null when field value is null', fakeAsync(() => { - widget.field = { - value: null, - options: [], - isVisible: true, - markAsValid: () => {} - } as FormFieldModel; - - fixture.detectChanges(); - widget['setFormControlValue'](); - - tick(DROPDOWN_CLOUD_WIDGET_SET_VALUE_DEBOUNCE); - - expect(widget.dropdownControl.value).toBeNull(); - })); - - it('should set dropdownControl value to null when field value is default/empty option object', fakeAsync(() => { - widget.field = { - value: { id: 'empty', name: 'Choose one...' }, - options: [], - isVisible: true, - markAsValid: () => {} - } as FormFieldModel; - - fixture.detectChanges(); - widget['setFormControlValue'](); - - tick(DROPDOWN_CLOUD_WIDGET_SET_VALUE_DEBOUNCE); - - expect(widget.dropdownControl.value).toBeNull(); - })); - - it('should set dropdownControl value to null when field value object has empty id', fakeAsync(() => { - widget.field = { - value: { id: '', name: 'label' }, - options: [], - isVisible: true, - markAsValid: () => {} - } as FormFieldModel; - - fixture.detectChanges(); - widget['setFormControlValue'](); - - tick(DROPDOWN_CLOUD_WIDGET_SET_VALUE_DEBOUNCE); - - expect(widget.dropdownControl.value).toBeNull(); - })); - it('should display options persisted from process variable', async () => { widget.field = getVariableDropdownWidget( 'variables.json-variable', @@ -1320,33 +1212,6 @@ describe('DropdownCloudWidgetComponent', () => { expect(variableFailedElement).toBeTruthy(); }); - it('should show required message for variable type when options load successfully and required and value is empty after touch', fakeAsync(() => { - widget.field = getVariableDropdownWidget( - 'variables.json-variable', - 'response.people.players', - 'playerId', - 'playerFullName', - mockProcessVariablesWithJson - ); - widget.field.required = true; - widget.field.value = ''; - widget.field.isVisible = true; - widget.ngOnInit(); - fixture.detectChanges(); - tick(DROPDOWN_CLOUD_WIDGET_SET_VALUE_DEBOUNCE); - fixture.detectChanges(); - - expect(widget.variableOptionsFailed).toBe(false); - expect(widget.dropdownControl.errors?.required).toBeTruthy(); - - widget.dropdownControl.markAsTouched(); - fixture.detectChanges(); - - const requiredErrorElement = fixture.debugElement.query(By.css('.adf-dropdown-required-message .adf-error-text')); - expect(requiredErrorElement).toBeTruthy(); - expect(requiredErrorElement.nativeElement.innerText).toEqual('FORM.FIELD.REQUIRED'); - })); - it('should return empty array and display error when id is incorrect', () => { widget.field = getVariableDropdownWidget( 'variables.json-variable', diff --git a/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.ts b/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.ts index 79a4282184..e1d22ce633 100644 --- a/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.ts +++ b/lib/process-services-cloud/src/lib/form/components/widgets/dropdown/dropdown-cloud.widget.ts @@ -142,14 +142,9 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI if (Array.isArray(this.field.value)) { value = this.field?.value; } else if (this.field?.value && typeof this.field?.value === 'object') { - const obj = this.field.value; - if (obj.id === DEFAULT_OPTION.id || obj.id === '' || obj.id === undefined) { - value = null; - } else { - value = { id: obj.id, name: obj.name }; - } - } else if (this.field.value === null || this.field.value === undefined || this.field.value === '') { - value = null; + value = { id: this.field?.value.id, name: this.field?.value.name }; + } else if (this.field.value === null) { + value = this.field.value; } else { value = { id: this.field?.value, name: '' }; } @@ -524,11 +519,7 @@ export class DropdownCloudWidgetComponent extends WidgetComponent implements OnI return event.field.type === FormFieldTypes.DROPDOWN; } - private setOptionValue(option: FormFieldOption | FormFieldOption[] | null, field: FormFieldModel) { - if (option == null) { - field.value = undefined; - return; - } + private setOptionValue(option: FormFieldOption | FormFieldOption[], field: FormFieldModel) { if (Array.isArray(option) || field.hasMultipleValues) { field.value = option; return;