From 63ccb069790d784f971de2e9ad1bc6a38528f1f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henry=20T=C3=A4schner?= <129834483+HenryT-CG@users.noreply.github.com> Date: Tue, 29 Oct 2024 11:48:28 +0100 Subject: [PATCH] Harmonize app setup files and align help-item-edit form (#241) * fix: harmonize app setup files and align help-item-edit form * fix: tests * fix: increase test coverage * fix: increase test coverage --- src/app/_hm-mixins.scss | 8 + src/app/app.component.spec.ts | 11 +- src/app/app.module.ts | 30 ++-- .../help-detail/help-detail.component.html | 6 +- .../help-detail/help-detail.component.spec.ts | 3 + .../help/help-form/help-form.component.html | 28 ++-- .../help-form/help-form.component.spec.ts | 17 ++ src/app/help/help-form/help-form.component.ts | 7 +- .../help-criteria.component.scss | 1 + .../help-search/help-search.component.html | 2 +- .../help/help-search/help-search.component.ts | 4 +- src/app/onecx-help-remote.module.ts | 33 ++-- .../help-item-editor-form.component.html | 152 ++++++++++-------- .../help-item-editor-form.component.scss | 14 ++ .../help-item-editor-form.component.spec.ts | 24 +-- .../help-item-editor-form.component.ts | 17 +- .../help-item-editor-form.harness.ts | 29 +--- .../help-item-editor.component.ts | 22 +-- src/styles.scss | 18 +-- webpack.config.js | 9 +- 20 files changed, 221 insertions(+), 214 deletions(-) diff --git a/src/app/_hm-mixins.scss b/src/app/_hm-mixins.scss index 182744f..d9fbc67 100644 --- a/src/app/_hm-mixins.scss +++ b/src/app/_hm-mixins.scss @@ -371,6 +371,14 @@ } } } +// This does not work if located inside the app, should be placed into src/styles.scss +@mixin autocomplete-zebra-rows { + .p-autocomplete-panel .p-autocomplete-items { + .p-autocomplete-item:nth-child(even) { + background-color: var(--table-body-row-even-bg); + } + } +} @mixin listbox-zebra-rows { :host ::ng-deep { .p-listbox:not(.p-disabled) .p-listbox-item:not(.p-highlight):not(.p-disabled) { diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index c03db24..8ae8ed4 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -1,6 +1,6 @@ +import { NO_ERRORS_SCHEMA } from '@angular/core' import { TestBed } from '@angular/core/testing' import { AppComponent } from './app.component' -import { NO_ERRORS_SCHEMA } from '@angular/core' describe('AppComponent', () => { beforeEach(async () => { @@ -21,13 +21,4 @@ describe('AppComponent', () => { const app = fixture.componentInstance expect(app.title).toEqual('onecx-help-ui') }) - - /* - it('should render title', () => { - const fixture = TestBed.createComponent(AppComponent) - fixture.detectChanges() - const compiled = fixture.nativeElement as HTMLElement - expect(compiled.querySelector('h1')?.textContent).toContain('Welcome Help Mgmt') - }) - */ }) diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 5ce3a90..0e83575 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,23 +1,18 @@ -import { APP_INITIALIZER, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, NgModule } from '@angular/core' +import { APP_INITIALIZER, NgModule } from '@angular/core' import { CommonModule } from '@angular/common' -import { HttpClient, HttpClientModule } from '@angular/common/http' +import { HttpClient, provideHttpClient, withInterceptorsFromDi } from '@angular/common/http' import { RouterModule, Routes } from '@angular/router' import { BrowserModule } from '@angular/platform-browser' import { BrowserAnimationsModule } from '@angular/platform-browser/animations' import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core' -import { - APP_CONFIG, - AppStateService, - createTranslateLoader, - translateServiceInitializer, - PortalCoreModule, - UserService -} from '@onecx/portal-integration-angular' import { KeycloakAuthModule } from '@onecx/keycloak-auth' +import { createTranslateLoader } from '@onecx/angular-accelerator' +import { APP_CONFIG, AppStateService, UserService } from '@onecx/angular-integration-interface' +import { translateServiceInitializer, PortalCoreModule } from '@onecx/portal-integration-angular' -import { AppComponent } from './app.component' import { environment } from 'src/environments/environment' +import { AppComponent } from './app.component' const routes: Routes = [{ path: '', pathMatch: 'full' }] @NgModule({ @@ -26,14 +21,13 @@ const routes: Routes = [{ path: '', pathMatch: 'full' }] imports: [ CommonModule, BrowserModule, - HttpClientModule, - KeycloakAuthModule, BrowserAnimationsModule, + KeycloakAuthModule, + PortalCoreModule.forRoot('onecx-help-ui'), RouterModule.forRoot(routes, { initialNavigation: 'enabledBlocking', enableTracing: true }), - PortalCoreModule.forRoot('onecx-help-ui'), TranslateModule.forRoot({ isolate: true, loader: { @@ -50,12 +44,12 @@ const routes: Routes = [{ path: '', pathMatch: 'full' }] useFactory: translateServiceInitializer, multi: true, deps: [UserService, TranslateService] - } - ], - schemas: [NO_ERRORS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA] + }, + provideHttpClient(withInterceptorsFromDi()) + ] }) export class AppModule { constructor() { - console.info('App Module constructor') + console.info('OneCX Help Module constructor') } } diff --git a/src/app/help/help-detail/help-detail.component.html b/src/app/help/help-detail/help-detail.component.html index cf51326..9f0fcbd 100644 --- a/src/app/help/help-detail/help-detail.component.html +++ b/src/app/help/help-detail/help-detail.component.html @@ -26,7 +26,7 @@ icon="pi pi-times" (onClick)="onDialogHide()" [label]="'ACTIONS.NAVIGATION.CLOSE' | translate" - [aria-label]="'ACTIONS.NAVIGATION.CLOSE' | translate" + [ariaLabel]="'ACTIONS.NAVIGATION.CLOSE' | translate" [pTooltip]="'ACTIONS.NAVIGATION.CLOSE.TOOLTIP' | translate" tooltipPosition="top" tooltipEvent="hover" @@ -37,7 +37,7 @@ icon="pi pi-times" (onClick)="onDialogHide()" [label]="'ACTIONS.CANCEL' | translate" - [aria-label]="'ACTIONS.CANCEL' | translate" + [ariaLabel]="'ACTIONS.CANCEL' | translate" [pTooltip]="'ACTIONS.TOOLTIPS.CANCEL' | translate" tooltipPosition="top" tooltipEvent="hover" @@ -49,7 +49,7 @@ (onClick)="onSave()" [disabled]="!helpFormComponent.formGroup.valid" [label]="'ACTIONS.SAVE' | translate" - [aria-label]="'ACTIONS.SAVE' | translate" + [ariaLabel]="'ACTIONS.SAVE' | translate" [pTooltip]="'ACTIONS.TOOLTIPS.SAVE' | translate" tooltipPosition="top" tooltipEvent="hover" diff --git a/src/app/help/help-detail/help-detail.component.spec.ts b/src/app/help/help-detail/help-detail.component.spec.ts index aa9a15a..8b18352 100644 --- a/src/app/help/help-detail/help-detail.component.spec.ts +++ b/src/app/help/help-detail/help-detail.component.spec.ts @@ -51,6 +51,9 @@ describe('HelpDetailComponent', () => { filterProducts(event: { query: string }): void { console.log('Filtering products with query:', event.query) } + sortProductsByName(a: Product, b: Product): number { + return a.displayName.toUpperCase().localeCompare(b.displayName.toUpperCase()) + } // eslint-disable-next-line @angular-eslint/use-lifecycle-interface ngOnChanges(): void { console.log('On changes') diff --git a/src/app/help/help-form/help-form.component.html b/src/app/help/help-form/help-form.component.html index 879e5e5..35752d6 100644 --- a/src/app/help/help-form/help-form.component.html +++ b/src/app/help/help-form/help-form.component.html @@ -2,7 +2,7 @@