Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: search config slot in search header and column group slot in interactive-data-view #369

Merged
merged 61 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
334e13e
feat: slot passes down inputs and outputs
markuczy Jul 31, 2024
a725b2b
feat: update remote components inputs and outputs
markuczy Aug 1, 2024
fb97c3f
feat: change type of emitters
markuczy Aug 1, 2024
3ba9a16
feat: slot used in search header
markuczy Aug 5, 2024
22e7760
feat: correct prop passing not optimised
markuczy Aug 5, 2024
61f1a67
Merge branch 'main' into feat/search-config-remote-component
markuczy Aug 14, 2024
82e9f28
feat: emitter column type change
markuczy Aug 16, 2024
63fc40c
Merge branch 'main' into feat/search-config-remote-component
markuczy Aug 20, 2024
c5852a5
feat: column group slot + search-config slot adjustment
markuczy Aug 28, 2024
38c0e8d
fix: removed redundant sub
markuczy Aug 28, 2024
d5ebf3a
feat: viewMode passing added
markuczy Aug 30, 2024
255e467
feat: added search config topic
markuczy Sep 4, 2024
d831797
feat: formgroup viewchild prep
markuczy Sep 4, 2024
ff606ae
Merge branch 'main' into feat/search-config-remote-component
markuczy Sep 4, 2024
fa273cd
feat: prop passing adjustments
markuczy Sep 4, 2024
627bf13
feat: default column group and bug fixes
markuczy Sep 4, 2024
930cbc5
refactor: comment out unused code
markuczy Sep 4, 2024
ddc8322
feat: removed pageName and search header comment
markuczy Sep 5, 2024
d535591
feat: disable search button when form is invalid
markuczy Sep 5, 2024
d89509e
refactor: removed not needed log
markuczy Sep 5, 2024
2a3890a
feat: removed topic
markuczy Sep 5, 2024
9bd5b1c
feat: lowered debounce time
markuczy Sep 10, 2024
d866fd3
feat: allow undefined in config selection changed
markuczy Sep 11, 2024
b603fb1
feat: search header passes visible values only
markuczy Sep 11, 2024
783ff6b
feat: added skeletons for slots
markuczy Sep 12, 2024
90939b6
feat: display search config slot only if client observes config changes
markuczy Sep 13, 2024
b06e4a3
feat: tests for search header and interactive data view
markuczy Sep 16, 2024
edd0b29
feat: search header state changed on selected search config
markuczy Sep 16, 2024
0f99fba
fix: fix interactive data view tests
markuczy Sep 16, 2024
7fafc82
Merge branch 'main' into feat/search-config-remote-component
markuczy Sep 16, 2024
b0e9609
refactor: lint
markuczy Sep 16, 2024
883034f
fix: fix data table reload
markuczy Sep 17, 2024
8894131
feat: interactive data view adjustments to correctly choose columns
markuczy Sep 17, 2024
36cb153
feat: add layout as input for search config slot
markuczy Sep 17, 2024
f755c89
feat: correct reinit of column group selection remtoe component
markuczy Sep 18, 2024
bf2cb7a
refactor: lint
markuczy Sep 18, 2024
665f485
Merge branch 'main' into feat/search-config-remote-component
markuczy Sep 18, 2024
3e56ad8
feat: permission directive adjusted and permissions for slot displayi…
markuczy Sep 19, 2024
8b1dbe3
Merge branch 'main' into feat/search-config-remote-component
markuczy Sep 19, 2024
fb210e8
feat: search header and interactive data view params change, guard fo…
markuczy Sep 19, 2024
65e19b4
fix: tests fixed
markuczy Sep 19, 2024
def86c3
feat: saving only search config name in search header state
markuczy Sep 24, 2024
b9bda6a
feat: provide slot service token in module instead of component
markuczy Sep 24, 2024
0d52509
feat: slot error on slot service
markuczy Sep 24, 2024
50470b8
fix: lint
markuczy Sep 24, 2024
8eb6a35
Merge branch 'main' into feat/search-config-remote-component
markuczy Sep 24, 2024
6d314af
fix: lint
markuczy Sep 24, 2024
c587642
Merge branch 'main' into feat/search-config-remote-component
markuczy Sep 30, 2024
b983583
feat: remote translate loader with mfe translations
markuczy Oct 1, 2024
6a8178b
feat: SLOT_SERVICE provided in remote components module
markuczy Oct 1, 2024
674a88b
fix: group selection change async
markuczy Oct 1, 2024
9e49eaf
feat: pageName default and search config selection change emitters split
markuczy Oct 1, 2024
6f514ea
fix: async behavior in layout change sub
markuczy Oct 1, 2024
dea8ad0
refactor: changed name of translate loader
markuczy Oct 1, 2024
139cca8
feat: dropdown harness update
markuczy Oct 1, 2024
e4169a0
feat: slot-service mock in angular remote components
markuczy Oct 1, 2024
3c4af41
feat: emitter now use types
markuczy Oct 1, 2024
f4a61f7
fix: fixed slot hiding mechanism
markuczy Oct 1, 2024
fa4f502
feat: search-config cleanup
markuczy Oct 2, 2024
3d1b741
fix: lint fixes
markuczy Oct 2, 2024
df79cb1
Merge branch 'main' into feat/search-config-remote-component
markuczy Oct 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/angular-accelerator/assets/i18n/de.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"OCX_CUSTOM_GROUP_COLUMN_SELECTOR": {
"DROPDOWN_LABEL": "Spalten",
"DROPDOWN_LABEL": "Spaltengruppe",
"OPEN_BUTTON_DETAIL": "Dialog zur Auswahl einer benutzerdefinierten Gruppe öffnen",
"ACTIVE_COLUMNS_LABEL": "Aktive Spalten",
"INACTIVE_COLUMNS_LABEL": "Inaktive Spalten",
Expand Down
2 changes: 1 addition & 1 deletion libs/angular-accelerator/assets/i18n/en.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"OCX_CUSTOM_GROUP_COLUMN_SELECTOR": {
"DROPDOWN_LABEL": "Columns",
"DROPDOWN_LABEL": "Column group",
"OPEN_BUTTON_DETAIL": "Open custom group selection dialog",
"ACTIVE_COLUMNS_LABEL": "Active columns",
"INACTIVE_COLUMNS_LABEL": "Inactive columns",
Expand Down
1 change: 0 additions & 1 deletion libs/angular-accelerator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export * from './lib/components/search-header/search-header.component'
// services
export * from './lib/services/breadcrumb.service'
export * from './lib/services/translation-cache.service'
export * from './lib/services/app-config-service'

// pipes
export * from './lib/pipes/dynamic.pipe'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { RouterModule } from '@angular/router'
import { MissingTranslationHandler, MissingTranslationHandlerParams, TranslateModule } from '@ngx-translate/core'

import { UserService } from '@onecx/angular-integration-interface'
import { AppConfigService, UserService } from '@onecx/angular-integration-interface'
import { AngularRemoteComponentsModule } from '@onecx/angular-remote-components'

import { AngularAcceleratorPrimeNgModule } from './angular-accelerator-primeng.module'
import { ColumnGroupSelectionComponent } from './components/column-group-selection/column-group-selection.component'
Expand All @@ -26,7 +27,6 @@ import { HAS_PERMISSION_CHECKER, IfPermissionDirective } from './directives/if-p
import { SrcDirective } from './directives/src.directive'
import { DynamicPipe } from './pipes/dynamic.pipe'
import { OcxTimeAgoPipe } from './pipes/ocxtimeago.pipe'
import { AppConfigService } from './services/app-config-service'
import { DynamicLocaleId } from './utils/dynamic-locale-id'
import { firstValueFrom, skip } from 'rxjs'
import { TooltipOnOverflowDirective } from './directives/tooltipOnOverflow.directive'
Expand All @@ -48,6 +48,7 @@ function appInitializer(userService: UserService) {
imports: [
CommonModule,
AngularAcceleratorPrimeNgModule,
AngularRemoteComponentsModule,
TranslateModule,
FormsModule,
RouterModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@
</div>

<div *ngIf="layout === 'table'" class="flex flex-wrap justify-content-between align-items-center gap-2">
<ocx-slot
*ngIf="isColumnGroupSelectionComponentDefined$ | async"
name="{{columnGroupSlotName}}"
[inputs]="{ placeholderKey: groupSelectionNoGroupSelectedKey, defaultGroupKey: defaultGroupKey, customGroupKey: customGroupKey, columns: columns, selectedGroupKey: selectedGroupKey }"
[outputs]="{ groupSelectionChanged: groupSelectionChanged }"
></ocx-slot>
<ocx-column-group-selection
*ngIf="!(isColumnGroupSelectionComponentDefined$ | async)"
[selectedGroupKey]="selectedGroupKey"
[columns]="columns"
[defaultGroupKey]="defaultGroupKey"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
TemplateRef,
ViewChild,
} from '@angular/core'
import { BehaviorSubject, Observable, ReplaySubject, combineLatest, map, startWith, timestamp } from 'rxjs'
import { BehaviorSubject, Observable, ReplaySubject, combineLatest, map, startWith, tap, timestamp } from 'rxjs'
import { DataAction } from '../../model/data-action'
import { DataSortDirection } from '../../model/data-sort-direction'
import { DataTableColumn } from '../../model/data-table-column.model'
Expand All @@ -26,6 +26,7 @@ import {
ColumnSelectionChangedEvent,
CustomGroupColumnSelectorComponentState,
} from '../custom-group-column-selector/custom-group-column-selector.component'
import { SLOT_SERVICE, SlotService } from '@onecx/angular-remote-components'
import { DataLayoutSelectionComponentState } from '../data-layout-selection/data-layout-selection.component'
import { DataListGridSortingComponentState } from '../data-list-grid-sorting/data-list-grid-sorting.component'
import { Filter, Row, Sort } from '../data-table/data-table.component'
Expand All @@ -40,7 +41,10 @@ export type InteractiveDataViewComponentState = ColumnGroupSelectionComponentSta
selector: 'ocx-interactive-data-view',
templateUrl: './interactive-data-view.component.html',
styleUrls: ['./interactive-data-view.component.css'],
providers: [{ provide: 'InteractiveDataViewComponent', useExisting: InteractiveDataViewComponent }],
providers: [
{ provide: 'InteractiveDataViewComponent', useExisting: InteractiveDataViewComponent },
{ provide: SLOT_SERVICE, useExisting: SlotService },
markuczy marked this conversation as resolved.
Show resolved Hide resolved
],
})
export class InteractiveDataViewComponent implements OnInit, AfterContentInit {
_dataViewComponent: DataViewComponent | undefined
Expand Down Expand Up @@ -100,7 +104,7 @@ export class InteractiveDataViewComponent implements OnInit, AfterContentInit {
@Input() selectedRows: Row[] = []
displayedColumnKeys$ = new BehaviorSubject<string[]>([])
displayedColumns$: Observable<DataTableColumn[]> | undefined
@Input()
@Input()
get displayedColumnKeys(): string[] {
return this.displayedColumnKeys$.getValue()
}
Expand All @@ -112,11 +116,11 @@ export class InteractiveDataViewComponent implements OnInit, AfterContentInit {
*/
@Input()
get displayedColumns(): DataTableColumn[] {
return (
(this.displayedColumnKeys
.map((d) => this.columns.find((c) => c.id === d))
.filter((d) => d) as DataTableColumn[]) ?? []
);
return (
(this.displayedColumnKeys
.map((d) => this.columns.find((c) => c.id === d))
.filter((d) => d) as DataTableColumn[]) ?? []
)
}
set displayedColumns(value: DataTableColumn[]) {
this.displayedColumnKeys$.next(value.map((d) => d.id))
Expand Down Expand Up @@ -198,6 +202,7 @@ export class InteractiveDataViewComponent implements OnInit, AfterContentInit {
@Output() displayedColumnsChange = new EventEmitter<DataTableColumn[]>()
@Output() displayedColumnKeysChange = new EventEmitter<string[]>()
@Output() selectionChanged: EventEmitter<Row[]> = new EventEmitter()
groupSelectionChanged = new EventEmitter<{ activeColumns: DataTableColumn[]; groupKey: string }>()

@Output() pageChanged: EventEmitter<number> = new EventEmitter()
@Output() pageSizeChanged = new EventEmitter<number>()
Expand Down Expand Up @@ -313,21 +318,40 @@ export class InteractiveDataViewComponent implements OnInit, AfterContentInit {
this._data = value
}

columnGroupSlotName = 'onecx-shell-column-group-selection'
isColumnGroupSelectionComponentDefined$: Observable<boolean>

constructor(private slotService: SlotService) {
this.isColumnGroupSelectionComponentDefined$ = this.slotService.isSomeComponentDefinedForSlot(
this.columnGroupSlotName
)

this.groupSelectionChanged.subscribe((event: { activeColumns: DataTableColumn[]; groupKey: string }) => {
this.displayedColumnKeys = event.activeColumns.map((col) => col.id)
this.selectedGroupKey = event.groupKey
// TODO: Remove following line once displayedColumns (deprecated) has been removed
markuczy marked this conversation as resolved.
Show resolved Hide resolved
this.displayedColumnsChange.emit(this.displayedColumns)
this.displayedColumnKeysChange.emit(this.displayedColumnKeys)
})
}

ngOnInit(): void {
this.selectedGroupKey = this.defaultGroupKey
if(!this.displayedColumns || this.displayedColumns.length === 0) {
if (!this.displayedColumns || this.displayedColumns.length === 0) {
this.displayedColumnKeys = this.columns.map((column) => column.id)
}
if (this.defaultGroupKey) {
this.displayedColumnKeys = this.columns.filter((column) =>
column.predefinedGroupKeys?.includes(this.defaultGroupKey)
).map((column) => column.id)
this.displayedColumnKeys = this.columns
.filter((column) => column.predefinedGroupKeys?.includes(this.defaultGroupKey))
.map((column) => column.id)
}
this.displayedColumns$ = this.displayedColumnKeys$.pipe(map((columnKeys) => (
(columnKeys
.map((key) => this.columns.find((col) => col.id === key))
.filter((d) => d) as DataTableColumn[]) ?? []
)))
this.displayedColumns$ = this.displayedColumnKeys$.pipe(
map(
(columnKeys) =>
(columnKeys.map((key) => this.columns.find((col) => col.id === key)).filter((d) => d) as DataTableColumn[]) ??
[]
)
)
// TODO: Remove following line once displayedColumns (deprecated) has been removed
markuczy marked this conversation as resolved.
Show resolved Hide resolved
this.displayedColumnsChange.emit(this.displayedColumns)
this.displayedColumnKeysChange.emit(this.displayedColumnKeys)
Expand Down Expand Up @@ -566,5 +590,4 @@ export class InteractiveDataViewComponent implements OnInit, AfterContentInit {
this.pageSize = event
this.pageSizeChanged.emit(event)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
[actions]="headerActions"
>
<ng-template #additionalToolbarContentLeft>
<ocx-search-config [searchConfigs]="searchConfigs" (selectedSearchConfigChanged)="confirmSearchConfig($event)">
</ocx-search-config>
<ocx-slot
name="onecx-shell-search-config"
[inputs]="{ pageName: pageName, currentFieldValues: fieldValues$ | async, displayedColumnsIds: displayedColumnsIds, viewMode: viewMode}"
[outputs]="{ searchConfigSelected: selectedSearchConfigChanged }"
></ocx-slot>
<ng-container
*ngIf="_additionalToolbarContentLeft"
[ngTemplateOutlet]="_additionalToolbarContentLeft"
Expand Down Expand Up @@ -41,7 +44,7 @@
icon="pi pi-search"
[attr.aria-label]="'OCX_SEARCH_HEADER.SEARCH_BUTTON.DETAIL' | translate"
title="{{ 'OCX_SEARCH_HEADER.SEARCH_BUTTON.DETAIL' | translate }}"
[disabled]="searchButtonDisabled"
[disabled]="searchButtonDisabled || formGroup?.invalid"
>
</p-button>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
AfterContentInit,
AfterViewInit,
Component,
ContentChild,
Expand All @@ -10,11 +11,15 @@ import {
ViewChild,
} from '@angular/core'
import { Action } from '../page-header/page-header.component'
import { SearchConfigInfo } from '../../model/search-config-info'
markuczy marked this conversation as resolved.
Show resolved Hide resolved
import { SLOT_SERVICE, SlotService } from '@onecx/angular-remote-components'
// import { SearchConfigInfo } from '../../model/search-config-info'
import { DataTableColumn } from '../../model/data-table-column.model'
import { FormGroup, FormGroupDirective } from '@angular/forms'
import { Observable, debounceTime, map, mergeMap, of } from 'rxjs'

export interface SearchHeaderComponentState {
activeViewMode?: 'basic' | 'advanced'
selectedSearchConfig?: SearchConfigInfo
// selectedSearchConfig?: SearchConfigInfo
markuczy marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand All @@ -26,9 +31,9 @@ export interface SearchHeaderComponentState {
@Component({
selector: 'ocx-search-header',
templateUrl: './search-header.component.html',
providers: [{ provide: SLOT_SERVICE, useExisting: SlotService }],
markuczy marked this conversation as resolved.
Show resolved Hide resolved
})
export class SearchHeaderComponent implements AfterViewInit {
@Input() searchConfigs: SearchConfigInfo[] | undefined
export class SearchHeaderComponent implements AfterContentInit, AfterViewInit {
@Input() header = ''

/**
Expand All @@ -42,7 +47,22 @@ export class SearchHeaderComponent implements AfterViewInit {
this.header = value
}
@Input() subheader: string | undefined
@Input() viewMode: 'basic' | 'advanced' = 'basic'
_viewMode: 'basic' | 'advanced' = 'basic'
@Input()
get viewMode(): 'basic' | 'advanced' {
return this._viewMode
}
set viewMode(viewMode: 'basic' | 'advanced') {
if (this.viewMode !== viewMode) {
this._viewMode = viewMode
this.viewModeChanged?.emit(this.viewMode)
this.componentStateChanged.emit({
activeViewMode: this.viewMode,
})
this.updateHeaderActions()
setTimeout(() => this.addKeyUpEventListener())
}
}
@Input() manualBreadcrumbs = false
_actions: Action[] = []
@Input()
Expand All @@ -55,10 +75,29 @@ export class SearchHeaderComponent implements AfterViewInit {
}
@Input() searchButtonDisabled = false
@Input() resetButtonDisabled = false
@Input() pageName: string = ''

_displayedColumnsIds: string[] = []
get displayedColumnsIds(): string[] {
return this._displayedColumnsIds
}

_displayedColumns: DataTableColumn[] = []
@Input() get displayedColumns(): DataTableColumn[] {
return this._displayedColumns
}
set displayedColumns(value: DataTableColumn[]) {
this._displayedColumns = [...value]
this._displayedColumnsIds = this._displayedColumns.map((column) => column.id)
}

@Output() searched: EventEmitter<any> = new EventEmitter()
@Output() resetted: EventEmitter<any> = new EventEmitter()
@Output() selectedSearchConfigChanged: EventEmitter<SearchConfigInfo> = new EventEmitter()
@Output() selectedSearchConfigChanged: EventEmitter<{
fieldValues: { [key: string]: string }
displayedColumnsIds: string[]
viewMode: 'basic' | 'advanced'
}> = new EventEmitter()
@Output() viewModeChanged: EventEmitter<'basic' | 'advanced'> = new EventEmitter()
@Output() componentStateChanged: EventEmitter<SearchHeaderComponentState> = new EventEmitter()
@ContentChild('additionalToolbarContent')
Expand All @@ -74,23 +113,35 @@ export class SearchHeaderComponent implements AfterViewInit {
return this.additionalToolbarContentLeft
}

@ContentChild(FormGroupDirective) formGroup: FormGroup | undefined
@ViewChild('searchParameterFields') searchParameterFields: ElementRef | undefined

hasAdvanced = false
headerActions: Action[] = []

fieldValues$: Observable<{ [key: string]: unknown }> | undefined = of({})

ngAfterContentInit(): void {
this.fieldValues$ = this.formGroup?.valueChanges.pipe(
debounceTime(500),
map((values) =>
Object.entries(values).reduce(
(acc, [key, value]) => ({
...acc,
[key]: value || undefined,
}),
{}
)
)
)
}

ngAfterViewInit(): void {
this.addKeyUpEventListener()
}

toggleViewMode() {
this.viewMode = this.viewMode === 'basic' ? 'advanced' : 'basic'
this.viewModeChanged?.emit(this.viewMode)
this.componentStateChanged.emit({
activeViewMode: this.viewMode
})
this.updateHeaderActions()
setTimeout(() => this.addKeyUpEventListener())
}

onResetClicked() {
Expand Down Expand Up @@ -136,11 +187,4 @@ export class SearchHeaderComponent implements AfterViewInit {
this.onSearchClicked()
}
}

confirmSearchConfig(searchConfig: SearchConfigInfo) {
this.selectedSearchConfigChanged?.emit(searchConfig)
this.componentStateChanged.emit({
selectedSearchConfig: searchConfig
})
}
}
1 change: 1 addition & 0 deletions libs/angular-integration-interface/mocks/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './mock-user-service'
export * from './app-state-service-mock'
export * from './fake-topic'
1 change: 1 addition & 0 deletions libs/angular-integration-interface/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// services
export * from './lib/services/app-config-service'
export * from './lib/services/app-state.service'
export * from './lib/services/configuration.service'
export * from './lib/services/user.service'
Expand Down
2 changes: 1 addition & 1 deletion libs/angular-remote-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"peerDependencies": {
"@angular/common": "^18.0.5",
"@angular/core": "^18.0.5",
"@onecx/angular-accelerator": "^5",
"@onecx/angular-integration-interface": "^5",
"@onecx/integration-interface": "^5",
"@ngx-translate/core": "^15.0.0",
"@angular-architects/module-federation": "18.0.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NgModule } from '@angular/core'
import { CommonModule } from '@angular/common'
import { SlotComponent } from './components/slot/slot.component'
import { AppConfigService } from '@onecx/angular-accelerator'
import { AppConfigService } from '@onecx/angular-integration-interface'

@NgModule({
imports: [CommonModule],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ export class SlotComponent implements OnInit, OnDestroy {
})
}

updateDataSub: Subscription | undefined

_viewContainers$ = new BehaviorSubject<QueryList<ViewContainerRef> | undefined>(undefined)
@ViewChildren('slot', { read: ViewContainerRef })
set viewContainers(value: QueryList<ViewContainerRef>) {
Expand Down
Loading
Loading