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 fd14688f7..b36b5c2b0 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 @@ -165,12 +165,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 @@ -265,7 +259,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.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 ); 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 ) {