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 @@
- @@ -26,7 +26,7 @@ - +
@@ -73,42 +71,40 @@ - + - + - +
diff --git a/src/app/help/help-form/help-form.component.spec.ts b/src/app/help/help-form/help-form.component.spec.ts index 9ee7e24..deae266 100644 --- a/src/app/help/help-form/help-form.component.spec.ts +++ b/src/app/help/help-form/help-form.component.spec.ts @@ -106,4 +106,21 @@ describe('HelpFormComponent', () => { expect(component.productsFiltered[0].displayName).toEqual('OneCx Tenant UI') }) + + describe('sortProductsByName', () => { + const p1: Product = { name: 'p1', displayName: 'P1' } + const p2: Product = { name: 'p2', displayName: 'P2' } + + it('should return 0 when both strings are identical', () => { + expect(component.sortProductsByName(p1, p1)).toBe(0) + }) + + it('should return -1', () => { + expect(component.sortProductsByName(p1, p2)).toBe(-1) + }) + + it('should return 1', () => { + expect(component.sortProductsByName(p2, p1)).toBe(1) + }) + }) }) diff --git a/src/app/help/help-form/help-form.component.ts b/src/app/help/help-form/help-form.component.ts index 0803996..1b81169 100644 --- a/src/app/help/help-form/help-form.component.ts +++ b/src/app/help/help-form/help-form.component.ts @@ -29,8 +29,8 @@ export class HelpFormComponent implements OnChanges { { field: 'context', header: 'CONTEXT' }, { field: 'resourceUrl', header: 'RESOURCE_URL' } ] - public productsFiltered: Product[] = [] + constructor() { this.formGroup = new FormGroup({ product: new FormControl(null, [Validators.required]), @@ -55,5 +55,10 @@ export class HelpFormComponent implements OnChanges { public filterProducts(event: { query: string }) { const query = event.query.toLowerCase() this.productsFiltered = this.products?.filter((product) => product.displayName.toLowerCase().includes(query)) + this.productsFiltered.sort(this.sortProductsByName) + } + + public sortProductsByName(a: Product, b: Product): number { + return a.displayName.toUpperCase().localeCompare(b.displayName.toUpperCase()) } } diff --git a/src/app/help/help-search/help-criteria/help-criteria.component.scss b/src/app/help/help-search/help-criteria/help-criteria.component.scss index 80a0054..f07d3bf 100644 --- a/src/app/help/help-search/help-criteria/help-criteria.component.scss +++ b/src/app/help/help-search/help-criteria/help-criteria.component.scss @@ -3,3 +3,4 @@ @include correct-search-criteria; @include correct-autocomplete; @include displaying-text-responsive; +@include dropdown-zebra-rows; diff --git a/src/app/help/help-search/help-search.component.html b/src/app/help/help-search/help-search.component.html index a44c93c..f685684 100644 --- a/src/app/help/help-search/help-search.component.html +++ b/src/app/help/help-search/help-search.component.html @@ -79,7 +79,7 @@ - +