Skip to content

Commit

Permalink
Merge branch 'main' into fix/data-table-header-layout
Browse files Browse the repository at this point in the history
  • Loading branch information
markuczy authored Nov 13, 2024
2 parents 1ac1d87 + 07a9f63 commit 38adc00
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,7 @@
<div class="data-list-items p-3">
<div class="item-name-row flex flex-row justify-content-between">
<div class="item-name mr-3 text-2xl font-medium align-content-center">
<a *ngIf="titleLineId" [routerLink]="" (click)="onViewRow(item)"
>{{ resolveFieldData(item, titleLineId) || '' }}</a
>
<span *ngIf="titleLineId">{{ resolveFieldData(item, titleLineId) || '' }}</span>
</div>
<div class="flex flex-row">
<ng-container
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ export class DataListGridComponent extends DataSortBase implements OnInit, DoChe
@Input() emptyResultsMessage: string | undefined
@Input() fallbackImage = 'placeholder.png'
@Input() layout: 'grid' | 'list' = 'grid'
@Input() viewPermission: string | undefined
@Input() editPermission: string | undefined
@Input() deletePermission: string | undefined
@Input() viewPermission: string | string[] | undefined
@Input() editPermission: string | string[] | undefined
@Input() deletePermission: string | string[] | undefined
@Input() deleteActionVisibleField: string | undefined
@Input() deleteActionEnabledField: string | undefined
@Input() viewActionVisibleField: string | undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ export class DataTableComponent extends DataSortBase implements OnInit, AfterCon

@Input() emptyResultsMessage: string | undefined
@Input() name = ''
@Input() deletePermission: string | undefined
@Input() viewPermission: string | undefined
@Input() editPermission: string | undefined
@Input() deletePermission: string | string[] | undefined
@Input() viewPermission: string | string[] | undefined
@Input() editPermission: string | string[] | undefined
@Input() deleteActionVisibleField: string | undefined
@Input() deleteActionEnabledField: string | undefined
@Input() viewActionVisibleField: string | undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ export class DataViewComponent implements DoCheck, OnInit, AfterContentInit {
dataTableComponentState$ = new ReplaySubject<DataTableComponentState>(1)
dataListGridComponentState$ = new ReplaySubject<DataListGridComponentState>(1)

@Input() deletePermission: string | undefined
@Input() editPermission: string | undefined
@Input() viewPermission: string | undefined
@Input() deletePermission: string | string[] | undefined
@Input() editPermission: string | string[] | undefined
@Input() viewPermission: string | string[] | undefined
@Input() deleteActionVisibleField: string | undefined
@Input() deleteActionEnabledField: string | undefined
@Input() viewActionVisibleField: string | undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ export class InteractiveDataViewComponent implements OnInit, AfterContentInit {
dataViewComponentState$ = new ReplaySubject<DataViewComponentState>(1)
filterViewComponentState$ = new ReplaySubject<FilterViewComponentState>(1)

@Input() searchConfigPermission: string | undefined
@Input() deletePermission: string | undefined
@Input() editPermission: string | undefined
@Input() viewPermission: string | undefined
@Input() searchConfigPermission: string | string[] | undefined
@Input() deletePermission: string | string[] | string[] | undefined
@Input() editPermission: string | string[] | undefined
@Input() viewPermission: string | string[] | undefined
@Input() deleteActionVisibleField: string | undefined
@Input() deleteActionEnabledField: string | undefined
@Input() viewActionVisibleField: string | undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('PageHeaderComponent', () => {
let component: PageHeaderComponent
let fixture: ComponentFixture<PageHeaderComponent>
let pageHeaderHarness: PageHeaderHarness
let userServiceSpy: jest.SpyInstance<boolean, [permissionKey: string], any>
let userServiceSpy: jest.SpyInstance<boolean, [permissionKey: string | string[]], any>

beforeEach(async () => {
await TestBed.configureTestingModule({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<ng-content></ng-content>
</div>
</div>
<div class="flex flex-wrap gap-2">
<div class="flex flex-wrap gap-2" [ngClass]="searchButtonsReversed ? 'flex-row-reverse' : 'flex-row'">
<p-button
id="resetButton"
*ngIf="resetted.observed"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Action } from '../page-header/page-header.component'
import { FormControlName, FormGroup, FormGroupDirective } from '@angular/forms'
import { Observable, combineLatest, debounceTime, map, of, startWith } from 'rxjs'
import { getLocation } from '@onecx/accelerator'
import { CONFIG_KEY, ConfigurationService } from '@onecx/angular-integration-interface'

export interface SearchHeaderComponentState {
activeViewMode?: 'basic' | 'advanced'
Expand Down Expand Up @@ -80,7 +81,7 @@ export class SearchHeaderComponent implements AfterContentInit, AfterViewInit {
this._actions = value
this.updateHeaderActions()
}
@Input() searchConfigPermission: string | undefined
@Input() searchConfigPermission: string | string[] | undefined
@Input() searchButtonDisabled = false
@Input() resetButtonDisabled = false
@Input() pageName: string | undefined = getLocation().applicationPath
Expand Down Expand Up @@ -120,17 +121,19 @@ export class SearchHeaderComponent implements AfterContentInit, AfterViewInit {
show: 'always',
}
headerActions: Action[] = []

searchButtonsReversed = false
fieldValues$: Observable<{ [key: string]: unknown }> | undefined = of({})
searchConfigChangedSlotEmitter: EventEmitter<SearchConfigData | undefined> = new EventEmitter()

constructor() {
constructor(configurationService: ConfigurationService) {
this.searchConfigChangedSlotEmitter.subscribe((config) => {
this.componentStateChanged.emit({
selectedSearchConfig: config?.name ?? null,
})
this.selectedSearchConfigChanged.emit(config)
})
this.searchButtonsReversed =
configurationService.getProperty(CONFIG_KEY.ONECX_PORTAL_SEARCH_BUTTONS_REVERSED) === 'true'
}

ngAfterContentInit(): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { StorybookTranslateModule } from '../../storybook-translate.module'
import { PageHeaderComponent } from '../page-header/page-header.component'
import { StorybookBreadcrumbModule } from './../../storybook-breadcrumb.module'
import { SearchHeaderComponent } from './search-header.component'
import { ConfigurationService } from '@onecx/angular-integration-interface'
import { provideHttpClient } from '@angular/common/http'

export default {
title: 'SearchHeaderComponent',
Expand All @@ -25,6 +27,8 @@ export default {
importProvidersFrom(BrowserModule),
importProvidersFrom(BrowserAnimationsModule),
importProvidersFrom(RouterModule.forRoot([], { useHash: true })),
importProvidersFrom(ConfigurationService),
provideHttpClient(),
],
}),
moduleMetadata({
Expand Down
2 changes: 1 addition & 1 deletion libs/angular-accelerator/src/lib/model/data-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ export interface DataAction {
id?: string
labelKey?: string
icon?: string
permission: string
permission: string | string[]
classes?: string[]
disabled?: boolean
actionVisibleField?: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BehaviorSubject } from 'rxjs'
export class MockUserService {
lang$ = new BehaviorSubject<string>('en')
/* eslint-disable @typescript-eslint/no-unused-vars */
hasPermission(permissionKey: string): boolean {
hasPermission(permissionKey: string | string[]): boolean {
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export enum CONFIG_KEY {
ONECX_PORTAL_SETTINGS_DISABLED = 'ONECX_PORTAL_SETTINGS_DISABLED',
ONECX_PORTAL_MY_ROLES_PERMISSIONS_DISABLED = 'ONECX_PORTAL_MY_ROLES_PERMISSIONS_DISABLED',
ONECX_PORTAL_HELP_DISABLED = 'ONECX_PORTAL_HELP_DISABLED',
ONECX_PORTAL_SEARCH_BUTTONS_REVERSED = 'ONECX_PORTAL_SEARCH_BUTTONS_REVERSED',
APP_VERSION = 'APP_VERSION',
IS_SHELL = 'IS_SHELL',
AUTH_SERVICE = 'AUTH_SERVICE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ export class UserService implements OnDestroy {
this.profile$.destroy()
}

hasPermission(permissionKey: string): boolean {
hasPermission(permissionKey: string | string[]): boolean {
if (Array.isArray(permissionKey)) {
return permissionKey.every((key) => this.hasPermission(key))
}
const oldConceptResult = this.permissions$.getValue()
? this.permissions$.getValue()?.includes(permissionKey)
: false
Expand Down

0 comments on commit 38adc00

Please sign in to comment.