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: filter view component with chips and overlay #579

Merged
merged 13 commits into from
Nov 6, 2024
22 changes: 22 additions & 0 deletions libs/angular-accelerator/assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,28 @@
"CUSTOM_GROUP": "Benutzerdefinierte Gruppe",
"NO_GROUP_SELECTED": "Keine Gruppe ausgewählt"
},
"OCX_FILTER_VIEW": {
"NO_FILTERS": "Keine Filter ausgewählt",
"RESET_FILTERS_BUTTON": {
"ARIA_LABEL": "Angewandte Filter zurücksetzen",
"DETAIL": "Angewandte Filter zurücksetzen"
},
"FILTER_YES": "Ja",
"FILTER_NO": "Nein",
"MANAGE_FILTERS_BUTTON": {
"LABEL": "Filter",
"ARIA_LABEL": "Aktive Filter verwalten",
"DETAIL": "Aktive Filter verwalten"
},
"TABLE": {
"COLUMN_NAME": "Spaltenname",
"VALUE": "Filterwert",
"ACTIONS": "Aktionen",
"REMOVE_FILTER_TITLE": "Filter löschen",
"REMOVE_FILTER_ARIA_LABEL": "Filter löschen"
},
"PANEL_TITLE": "Filter"
},
"OCX_SEARCH_HEADER": {
"TOGGLE_BUTTON": {
"SIMPLE": {
Expand Down
22 changes: 22 additions & 0 deletions libs/angular-accelerator/assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,28 @@
"CUSTOM_GROUP": "Custom group",
"NO_GROUP_SELECTED": "No group selected"
},
"OCX_FILTER_VIEW": {
"NO_FILTERS": "No filters selected",
"RESET_FILTERS_BUTTON": {
"ARIA_LABEL": "Reset applied filters",
"DETAIL": "Reset applied filters"
},
"FILTER_YES": "Yes",
"FILTER_NO": "No",
"MANAGE_FILTERS_BUTTON": {
"LABEL": "Filters",
"ARIA_LABEL": "Manage active filters",
"DETAIL": "Manage active filters"
},
"TABLE": {
"COLUMN_NAME": "Column name",
"VALUE": "Filter value",
"ACTIONS": "Actions",
"REMOVE_FILTER_TITLE": "Remove filter",
"REMOVE_FILTER_ARIA_LABEL": "Remove filter"
},
"PANEL_TITLE": "Filters"
},
"OCX_SEARCH_HEADER": {
"TOGGLE_BUTTON": {
"SIMPLE": {
Expand Down
2 changes: 2 additions & 0 deletions libs/angular-accelerator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ export * from './lib/utils/create-remote-component-translate-loader.utils'
export * from './lib/utils/enum-to-dropdown-options.utils'
export * from './lib/utils/criteria.utils'
export * from './lib/utils/string-and-array-helper-functions.utils'
export * from './lib/utils/template.utils'
export * from './lib/utils/filter.utils'
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ import { MessageModule } from 'primeng/message'
import { SharedModule } from 'primeng/api'
import { CheckboxModule } from 'primeng/checkbox'
import { FloatLabelModule } from 'primeng/floatlabel'
import { ChipModule } from 'primeng/chip'
import { OverlayPanelModule } from 'primeng/overlaypanel'
import { FocusTrapModule } from 'primeng/focustrap'

@NgModule({
imports: [
BreadcrumbModule,
ChipModule,
CheckboxModule,
DropdownModule,
ButtonModule,
Expand All @@ -33,10 +37,13 @@ import { FloatLabelModule } from 'primeng/floatlabel'
SkeletonModule,
MessageModule,
FloatLabelModule,
OverlayPanelModule,
FocusTrapModule,
SharedModule,
],
exports: [
BreadcrumbModule,
ChipModule,
CheckboxModule,
DropdownModule,
ButtonModule,
Expand All @@ -51,6 +58,8 @@ import { FloatLabelModule } from 'primeng/floatlabel'
SkeletonModule,
MessageModule,
FloatLabelModule,
OverlayPanelModule,
FocusTrapModule,
SharedModule,
],
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { TooltipOnOverflowDirective } from './directives/tooltipOnOverflow.direc
import { DynamicPipe } from './pipes/dynamic.pipe'
import { OcxTimeAgoPipe } from './pipes/ocxtimeago.pipe'
import { DynamicLocaleId } from './utils/dynamic-locale-id'
import { FilterViewComponent } from './components/filter-view/filter-view.component'

export class AngularAcceleratorMissingTranslationHandler implements MissingTranslationHandler {
handle(params: MissingTranslationHandlerParams) {
Expand Down Expand Up @@ -75,6 +76,7 @@ function appInitializer(userService: UserService) {
OcxTimeAgoPipe,
AdvancedDirective,
TooltipOnOverflowDirective,
FilterViewComponent,
],
providers: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@
(selectionChange)="onSelectionChange($event)"
[selection]="(selectedRows$ | async) ?? []"
[scrollable]="true"
scrollHeight="flex"
[style]="tableStyle"
paginatorDropdownAppendTo="body"
>
<ng-template pTemplate="header">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { ObjectUtils } from '../../utils/objectutils'
import { DataSortBase } from '../data-sort-base/data-sort-base'
import { MultiSelectItem } from 'primeng/multiselect'
import { Filter, FilterType } from '../../model/filter.model'
import { findTemplate } from '../../utils/template.utils'

export type Primitive = number | string | boolean | bigint | Date
export type Row = {
Expand Down Expand Up @@ -175,6 +176,7 @@ export class DataTableComponent extends DataSortBase implements OnInit, AfterCon
@Input() allowSelectAll = true
@Input() paginator = true
@Input() page = 0
@Input() tableStyle: { [klass: string]: any } | undefined
@Input()
get totalRecordsOnServer(): number | undefined {
return this.params['totalRecordsOnServer'] ? Number(this.params['totalRecordsOnServer']) : undefined
Expand Down Expand Up @@ -786,17 +788,6 @@ export class DataTableComponent extends DataSortBase implements OnInit, AfterCon
[TemplateType.FILTERCELL]: this.filterTemplatesData,
}

findTemplate(templates: PrimeTemplate[], names: string[]): PrimeTemplate | undefined {
for (let index = 0; index < names.length; index++) {
const name = names[index]
const template = templates.find((template) => template.name === name)
if (template) {
return template
}
}
return undefined
}

getColumnTypeTemplate(templates: PrimeTemplate[], columnType: ColumnType, templateType: TemplateType) {
let template: TemplateRef<any> | undefined

Expand Down Expand Up @@ -847,7 +838,7 @@ export class DataTableComponent extends DataSortBase implements OnInit, AfterCon

return (
template ??
this.findTemplate(templates, this.templatesDataMap[templateType].templateNames[columnType])?.template ??
findTemplate(templates, this.templatesDataMap[templateType].templateNames[columnType])?.template ??
null
)
}
Expand All @@ -863,7 +854,7 @@ export class DataTableComponent extends DataSortBase implements OnInit, AfterCon
]).pipe(
map(([t, vt, pt]) => {
const templates = [...(t ?? []), ...(vt ?? []), ...(pt ?? [])]
const columnTemplate = this.findTemplate(
const columnTemplate = findTemplate(
templates,
templatesData.idSuffix.map((suffix) => column.id + suffix)
)?.template
Expand Down
Loading
Loading