From 1c5f550cda066d02a1319156817bdcb1a68181ec Mon Sep 17 00:00:00 2001 From: Volha Mardvilka Date: Mon, 3 Feb 2025 10:59:06 +0000 Subject: [PATCH] 391367086: (feat) [GM3] add new risk profile form --- .../dynamic-form/dynamic-form.component.scss | 2 +- .../list-layout/list-layout.component.html | 6 +- .../pages/devices/devices.component.spec.ts | 34 +++++++++-- .../profile-form/profile-form.component.html | 1 - .../profile-form/profile-form.component.scss | 3 +- .../risk-assessment.component.html | 41 ------------- .../risk-assessment.component.scss | 59 ++----------------- .../risk-assessment.component.spec.ts | 4 +- modules/ui/src/styles.scss | 21 ------- 9 files changed, 43 insertions(+), 128 deletions(-) diff --git a/modules/ui/src/app/components/dynamic-form/dynamic-form.component.scss b/modules/ui/src/app/components/dynamic-form/dynamic-form.component.scss index 3ef463e0d..b28de1d15 100644 --- a/modules/ui/src/app/components/dynamic-form/dynamic-form.component.scss +++ b/modules/ui/src/app/components/dynamic-form/dynamic-form.component.scss @@ -26,7 +26,7 @@ line-height: 24px; letter-spacing: 0.1px; color: colors.$on-surface-variant; - padding: 20px 20px 8px 16px; + padding: 8px 16px; display: inline-block; &:has(+ .field-select-multiple.ng-invalid.ng-dirty) { color: mat.get-theme-color($light-theme, error, 40); diff --git a/modules/ui/src/app/components/list-layout/list-layout.component.html b/modules/ui/src/app/components/list-layout/list-layout.component.html index 1377b2944..6dfe504d6 100644 --- a/modules/ui/src/app/components/list-layout/list-layout.component.html +++ b/modules/ui/src/app/components/list-layout/list-layout.component.html @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - + @@ -44,7 +44,9 @@ *ngIf="isOpenEntityForm() && !initialEntity()" class="fake-list-item"> - New device + {{ + title() === LayoutType.Device ? 'New device' : 'New risk profile' + }} { let component: DevicesComponent; @@ -68,12 +69,22 @@ describe('DevicesComponent', () => { MatIconTestingModule, DevicesComponent, FakeProgressComponent, + FakeDeviceQualificationComponent, ], providers: [ { provide: DevicesStore, useValue: mockDevicesStore }, { provide: FocusManagerService, useValue: stateServiceMock }, ], - }).compileComponents(); + }) + .overrideComponent(DevicesComponent, { + remove: { + imports: [DeviceQualificationFromComponent], + }, + add: { + imports: [FakeDeviceQualificationComponent], + }, + }) + .compileComponents(); TestBed.overrideProvider(DevicesStore, { useValue: mockDevicesStore }); @@ -104,7 +115,6 @@ describe('DevicesComponent', () => { }); mockDevicesStore.devices$ = of([]); mockDevicesStore.testModules$ = of([]); - mockDevicesStore.isOpenAddDevice$ = of(true); fixture.detectChanges(); }); @@ -115,6 +125,7 @@ describe('DevicesComponent', () => { }); it('should open form if isOpenAddDevice$ as true', () => { + mockDevicesStore.isOpenAddDevice$ = of(true); component.ngOnInit(); expect(component.isOpenDeviceForm).toBeTrue(); @@ -263,3 +274,18 @@ describe('DevicesComponent', () => { template: '', }) class FakeProgressComponent {} + +@Component({ + selector: 'app-device-qualification-from', + template: '
', +}) +class FakeDeviceQualificationComponent { + initialDevice = input(null); + devices = input([]); + testModules = input([]); + isCreate = input(true); + + save = output(); + delete = output(); + cancel = output(); +} diff --git a/modules/ui/src/app/pages/risk-assessment/profile-form/profile-form.component.html b/modules/ui/src/app/pages/risk-assessment/profile-form/profile-form.component.html index 8bde474ba..7e0bf87db 100644 --- a/modules/ui/src/app/pages/risk-assessment/profile-form/profile-form.component.html +++ b/modules/ui/src/app/pages/risk-assessment/profile-form/profile-form.component.html @@ -20,7 +20,6 @@ appearance="outline" floatLabel="always" class="profile-form-field"> - Specify risk assessment profile name Required for saving a profile - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - { const title = compiled.querySelector('h2.title'); const titleContent = title?.innerHTML.trim(); - // const profileForm = compiled.querySelectorAll('app-profile-form'); + const profileForm = compiled.querySelectorAll('app-profile-form'); expect(title).toBeTruthy(); expect(titleContent).toContain('Risk Assessment'); - // expect(profileForm).toBeTruthy(); + expect(profileForm).toBeTruthy(); }); }); diff --git a/modules/ui/src/styles.scss b/modules/ui/src/styles.scss index cac27fb17..a6c6b2ae7 100644 --- a/modules/ui/src/styles.scss +++ b/modules/ui/src/styles.scss @@ -364,12 +364,6 @@ body #main { } } - &:has(app-risk-assessment .profiles-drawer) { - .app-callout-container { - width: calc(100% - #{variables.$profiles-drawer-width}); - } - } - &:has(app-settings) { .app-callout-container app-callout:last-of-type .callout-container { margin-bottom: 0; @@ -429,21 +423,6 @@ body #main { overflow: hidden; } - app-risk-assessment:has(.profiles-drawer) { - .risk-assessment-content-empty { - width: calc(100% - $profiles-drawer-width-xs) !important; - } - } - - app-risk-assessment .main-content { - width: auto !important; - padding: 16px 4px !important; - } - - .risk-assessment-content { - padding-right: $profiles-drawer-width-xs !important; - } - app-dynamic-form { width: 100%; }