From 3baacc436e4150a7eab7c40430c21ad02e022d2a Mon Sep 17 00:00:00 2001 From: kurilova Date: Thu, 5 Sep 2024 11:10:01 +0000 Subject: [PATCH 1/2] Open Edit device window when delete device is cancelled --- .../device-qualification-from.component.ts | 12 +++++------- .../ui/src/app/pages/devices/devices.component.ts | 13 +++++++++++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/modules/ui/src/app/pages/devices/components/device-qualification-from/device-qualification-from.component.ts b/modules/ui/src/app/pages/devices/components/device-qualification-from/device-qualification-from.component.ts index 00bddbf4f..0b561fffc 100644 --- a/modules/ui/src/app/pages/devices/components/device-qualification-from/device-qualification-from.component.ts +++ b/modules/ui/src/app/pages/devices/components/device-qualification-from/device-qualification-from.component.ts @@ -163,12 +163,6 @@ export class DeviceQualificationFromComponent return this.getStep(0).controls['test_modules'] as FormArray; } - get formPristine() { - return ( - this.deviceQualificationForm.get('steps') as FormArray - ).controls.every(control => (control as FormGroup).pristine); - } - get formValid() { return ( this.deviceQualificationForm.get('steps') as FormArray @@ -258,7 +252,11 @@ export class DeviceQualificationFromComponent } delete(): void { - this.dialogRef.close({ action: FormAction.Delete } as FormResponse); + this.dialogRef.close({ + action: FormAction.Delete, + device: this.createDeviceFromForm(), + index: this.stepper.selectedIndex, + } as FormResponse); } closeForm(): void { diff --git a/modules/ui/src/app/pages/devices/devices.component.ts b/modules/ui/src/app/pages/devices/devices.component.ts index b62468593..1411ced7a 100644 --- a/modules/ui/src/app/pages/devices/devices.component.ts +++ b/modules/ui/src/app/pages/devices/devices.component.ts @@ -172,7 +172,16 @@ export class DevicesComponent implements OnInit, OnDestroy { } if (response.action === FormAction.Delete && initialDevice) { this.devicesStore.selectDevice(initialDevice); - this.openDeleteDialog(devices, testModules, initialDevice); + if (response.device) { + this.openDeleteDialog( + devices, + testModules, + initialDevice, + response.device, + isEditDevice, + response.index + ); + } } }); } @@ -219,7 +228,7 @@ export class DevicesComponent implements OnInit, OnDestroy { devices: Device[], testModules: TestModule[], initialDevice: Device, - device?: Device, + device: Device, isEditDevice = false, index = 0 ) { From 707875f7eed6030b33c70e83d0c0bc8d2ea1a8d5 Mon Sep 17 00:00:00 2001 From: kurilova Date: Thu, 5 Sep 2024 11:18:18 +0000 Subject: [PATCH 2/2] Fix test --- modules/ui/src/app/pages/devices/devices.component.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/ui/src/app/pages/devices/devices.component.spec.ts b/modules/ui/src/app/pages/devices/devices.component.spec.ts index 4df5fed2b..c7bc533b7 100644 --- a/modules/ui/src/app/pages/devices/devices.component.spec.ts +++ b/modules/ui/src/app/pages/devices/devices.component.spec.ts @@ -289,7 +289,7 @@ describe('DevicesComponent', () => { afterClosed: () => of(true), } as MatDialogRef); - component.openDeleteDialog([device], MOCK_TEST_MODULES, device); + component.openDeleteDialog([device], MOCK_TEST_MODULES, device, device); const args = mockDevicesStore.deleteDevice.calls.argsFor(0); // @ts-expect-error config is in object @@ -303,13 +303,13 @@ describe('DevicesComponent', () => { afterClosed: () => of(null), } as MatDialogRef); - component.openDeleteDialog([device], MOCK_TEST_MODULES, device); + component.openDeleteDialog([device], MOCK_TEST_MODULES, device, device); expect(openDeviceDialogSpy).toHaveBeenCalledWith( [device], MOCK_TEST_MODULES, device, - undefined, + device, false, 0 );