@one-paragon/angular-utilities 2.1.4 → 2.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/karma.conf.js +44 -0
- package/ng-package.json +7 -0
- package/package.json +15 -27
- package/src/action-state/action-state-spinner/action-state-spinner.component.css +16 -0
- package/src/action-state/action-state-spinner/action-state-spinner.component.html +6 -0
- package/src/action-state/action-state-spinner/action-state-spinner.component.spec.ts +25 -0
- package/src/action-state/action-state-spinner/action-state-spinner.component.ts +25 -0
- package/src/action-state/action-state-ui/action-state-ui.module.ts +13 -0
- package/{action-state/index.d.ts → src/action-state/index.ts} +8 -4
- package/src/action-state/ngrx-ext/ngrx-ext.module.ts +15 -0
- package/src/action-state/ngrx.ts +69 -0
- package/src/http-request-state/RequestStateFactory.ts +56 -0
- package/src/http-request-state/RequestStateStore.ts +284 -0
- package/{http-request-state/deprecated.d.ts → src/http-request-state/deprecated.ts} +20 -20
- package/src/http-request-state/directives/HttpStateDirectiveBase.ts +29 -0
- package/src/http-request-state/directives/http-error-state-directive.ts +21 -0
- package/src/http-request-state/directives/http-inProgress-state-directive.ts +19 -0
- package/src/http-request-state/directives/http-notStarted-state-directive.ts +19 -0
- package/src/http-request-state/directives/http-success-state-directive.ts +29 -0
- package/{http-request-state/directives/index.d.ts → src/http-request-state/directives/index.ts} +5 -5
- package/src/http-request-state/directives/request-state-directive.spec.ts +73 -0
- package/src/http-request-state/directives/request-state-directive.ts +78 -0
- package/src/http-request-state/helpers.ts +30 -0
- package/src/http-request-state/http-state-module.ts +23 -0
- package/{http-request-state/index.d.ts → src/http-request-state/index.ts} +7 -7
- package/src/http-request-state/models/view-context.ts +18 -0
- package/src/http-request-state/observable.spec.ts +43 -0
- package/src/http-request-state/request-state.ts +69 -0
- package/src/http-request-state/rxjs/getRequestorBody.ts +10 -0
- package/src/http-request-state/rxjs/getRequestorState.ts +8 -0
- package/{http-request-state/rxjs/index.d.ts → src/http-request-state/rxjs/index.ts} +4 -4
- package/src/http-request-state/rxjs/tapError.ts +16 -0
- package/src/http-request-state/rxjs/tapSuccess.ts +16 -0
- package/src/http-request-state/strategies.spec.ts +42 -0
- package/src/http-request-state/types.ts +54 -0
- package/src/ngrx/actionable-selector.ts +160 -0
- package/src/ngrx/index.ts +1 -0
- package/{public-api.d.ts → src/public-api.ts} +35 -16
- package/src/rxjs/defaultShareReplay.ts +8 -0
- package/{rxjs/index.d.ts → src/rxjs/index.ts} +5 -5
- package/src/rxjs/mapError.ts +8 -0
- package/src/rxjs/rxjs-operators.ts +130 -0
- package/src/rxjs/subjectifier.ts +17 -0
- package/src/rxjs/subscriber.directive.ts +57 -0
- package/src/specs/clickSubject.spec.ts +95 -0
- package/src/specs/dialog.spec.ts +101 -0
- package/src/specs/toggleGroupDirective.spec.ts +229 -0
- package/src/table-builder/classes/DefaultSettings.ts +11 -0
- package/src/table-builder/classes/MatTableObservableDataSource.ts +23 -0
- package/src/table-builder/classes/TableBuilderConfig.ts +42 -0
- package/src/table-builder/classes/TableBuilderDataSource.ts +65 -0
- package/src/table-builder/classes/TableState.ts +125 -0
- package/src/table-builder/classes/data-store.ts +10 -0
- package/{table-builder/classes/display-col.d.ts → src/table-builder/classes/display-col.ts} +5 -5
- package/src/table-builder/classes/filter-info.ts +126 -0
- package/src/table-builder/classes/table-builder-general-settings.ts +198 -0
- package/src/table-builder/classes/table-builder.ts +105 -0
- package/src/table-builder/classes/table-store.helpers.ts +104 -0
- package/src/table-builder/classes/table-store.ts +440 -0
- package/src/table-builder/components/array-column.component.ts +34 -0
- package/src/table-builder/components/column-builder/column-builder.component.html +73 -0
- package/src/table-builder/components/column-builder/column-builder.component.scss +43 -0
- package/src/table-builder/components/column-builder/column-builder.component.spec.ts +49 -0
- package/src/table-builder/components/column-builder/column-builder.component.ts +129 -0
- package/src/table-builder/components/column-builder/column-helpers.ts +54 -0
- package/src/table-builder/components/column-header-menu/column-header-menu.component.html +109 -0
- package/src/table-builder/components/column-header-menu/column-header-menu.component.scss +97 -0
- package/src/table-builder/components/column-header-menu/column-header-menu.component.ts +94 -0
- package/src/table-builder/components/date-filter/date-filter.component.html +23 -0
- package/src/table-builder/components/date-filter/date-filter.component.ts +22 -0
- package/src/table-builder/components/date-time-filter/date-time-filter.component.html +9 -0
- package/src/table-builder/components/date-time-filter/date-time-filter.component.ts +20 -0
- package/src/table-builder/components/filter/filter.component.html +103 -0
- package/src/table-builder/components/filter/filter.component.scss +60 -0
- package/src/table-builder/components/filter/filter.component.spec.ts +87 -0
- package/src/table-builder/components/filter/filter.component.ts +64 -0
- package/src/table-builder/components/filter/in-list/in-list-filter.component.ts +85 -0
- package/src/table-builder/components/gen-col-displayer/gen-col-displayer.component.html +60 -0
- package/src/table-builder/components/gen-col-displayer/gen-col-displayer.component.scss +57 -0
- package/src/table-builder/components/gen-col-displayer/gen-col-displayer.component.ts +44 -0
- package/src/table-builder/components/generic-table/generic-table.component.html +96 -0
- package/src/table-builder/components/generic-table/generic-table.component.scss +38 -0
- package/src/table-builder/components/generic-table/generic-table.component.ts +399 -0
- package/src/table-builder/components/generic-table/paginator.component.ts +106 -0
- package/src/table-builder/components/group-by-list/group-by-list.component.css +17 -0
- package/src/table-builder/components/group-by-list/group-by-list.component.html +14 -0
- package/src/table-builder/components/group-by-list/group-by-list.component.spec.ts +23 -0
- package/src/table-builder/components/group-by-list/group-by-list.component.ts +18 -0
- package/src/table-builder/components/in-filter/in-filter.component.css +3 -0
- package/src/table-builder/components/in-filter/in-filter.component.html +19 -0
- package/src/table-builder/components/in-filter/in-filter.component.ts +65 -0
- package/{table-builder/components/index.d.ts → src/table-builder/components/index.ts} +9 -9
- package/src/table-builder/components/initialization-component/initialization-component.html +78 -0
- package/src/table-builder/components/initialization-component/initialization-component.ts +27 -0
- package/src/table-builder/components/link-column.component.ts +42 -0
- package/src/table-builder/components/number-filter/number-filter.component.css +10 -0
- package/src/table-builder/components/number-filter/number-filter.component.html +22 -0
- package/src/table-builder/components/number-filter/number-filter.component.spec.ts +30 -0
- package/src/table-builder/components/number-filter/number-filter.component.ts +25 -0
- package/src/table-builder/components/profiles-menu/profiles-menu.component.html +76 -0
- package/src/table-builder/components/profiles-menu/profiles-menu.component.scss +126 -0
- package/src/table-builder/components/profiles-menu/profiles-menu.component.spec.ts +23 -0
- package/src/table-builder/components/profiles-menu/profiles-menu.component.ts +63 -0
- package/src/table-builder/components/reset-menu/reset-menu.component.css +3 -0
- package/src/table-builder/components/reset-menu/reset-menu.component.html +10 -0
- package/src/table-builder/components/reset-menu/reset-menu.component.ts +87 -0
- package/src/table-builder/components/scroll-strategy.ts +139 -0
- package/src/table-builder/components/sort-menu/sort-menu.component-store.ts +57 -0
- package/src/table-builder/components/sort-menu/sort-menu.component.html +109 -0
- package/src/table-builder/components/sort-menu/sort-menu.component.scss +119 -0
- package/src/table-builder/components/sort-menu/sort-menu.component.ts +88 -0
- package/src/table-builder/components/table-container/table-container.helpers/data-state.helpers.ts +112 -0
- package/src/table-builder/components/table-container/table-container.helpers/filter-state.helpers.ts +125 -0
- package/src/table-builder/components/table-container/table-container.helpers/groupBy.helpers.ts +120 -0
- package/src/table-builder/components/table-container/table-container.helpers/meta-data.helpers.ts +16 -0
- package/src/table-builder/components/table-container/table-container.helpers/sort-state.helpers.ts +47 -0
- package/src/table-builder/components/table-container/table-container.html +79 -0
- package/src/table-builder/components/table-container/table-container.scss +47 -0
- package/src/table-builder/components/table-container/table-container.ts +403 -0
- package/src/table-builder/components/table-container/tableProps.ts +18 -0
- package/src/table-builder/components/table-container/virtual-scroll-container.ts +216 -0
- package/src/table-builder/components/table-container-filter/filter-list/filter-list.component.html +34 -0
- package/src/table-builder/components/table-container-filter/filter-list/filter-list.component.ts +44 -0
- package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.css +42 -0
- package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.html +11 -0
- package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.spec.ts +85 -0
- package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.ts +36 -0
- package/src/table-builder/components/table-container-filter/table-wrapper-filter-store.ts +23 -0
- package/src/table-builder/components/table-header-menu/table-header-menu.component.css +21 -0
- package/src/table-builder/components/table-header-menu/table-header-menu.component.html +48 -0
- package/src/table-builder/components/table-header-menu/table-header-menu.component.ts +35 -0
- package/src/table-builder/directives/custom-cell-directive.ts +59 -0
- package/{table-builder/directives/index.d.ts → src/table-builder/directives/index.ts} +6 -5
- package/src/table-builder/directives/multi-sort.directive.spec.ts +124 -0
- package/src/table-builder/directives/multi-sort.directive.ts +50 -0
- package/src/table-builder/directives/resize-column.directive.ts +107 -0
- package/src/table-builder/directives/table-wrapper.directive.ts +13 -0
- package/src/table-builder/directives/tb-filter.directive.ts +376 -0
- package/src/table-builder/enums/filterTypes.ts +40 -0
- package/src/table-builder/functions/boolean-filter-function.ts +12 -0
- package/src/table-builder/functions/date-filter-function.ts +68 -0
- package/src/table-builder/functions/download-data.ts +11 -0
- package/src/table-builder/functions/null-filter-function.ts +9 -0
- package/src/table-builder/functions/number-filter-function.ts +41 -0
- package/src/table-builder/functions/sort-data-function.ts +80 -0
- package/src/table-builder/functions/string-filter-function.ts +51 -0
- package/{table-builder/interfaces/ColumnInfo.d.ts → src/table-builder/interfaces/ColumnInfo.ts} +7 -6
- package/src/table-builder/interfaces/column-template.ts +9 -0
- package/{table-builder/interfaces/dictionary.d.ts → src/table-builder/interfaces/dictionary.ts} +3 -3
- package/src/table-builder/interfaces/report-def.ts +186 -0
- package/src/table-builder/ngrx/tableBuilderStateStore.ts +197 -0
- package/src/table-builder/pipes/column-total.pipe.ts +16 -0
- package/src/table-builder/pipes/format-filter-type.pipe.ts +12 -0
- package/src/table-builder/pipes/format-filter-value.pipe.ts +40 -0
- package/src/table-builder/pipes/key-display.ts +13 -0
- package/src/table-builder/services/export-to-csv.service.ts +75 -0
- package/src/table-builder/services/link-creator.service.ts +98 -0
- package/src/table-builder/services/table-template-service.ts +47 -0
- package/src/table-builder/services/transform-creator.ts +96 -0
- package/src/table-builder/specs/table-custom-filters.spec.ts +262 -0
- package/src/table-builder/styles/collapser.styles.scss +16 -0
- package/src/table-builder/table-builder.module.ts +38 -0
- package/src/test.ts +17 -0
- package/src/utilities/array-helpers.ts +13 -0
- package/src/utilities/directives/auto-focus.directive.ts +20 -0
- package/src/utilities/directives/clickEmitterDirective.ts +15 -0
- package/src/utilities/directives/clickSubject.ts +19 -0
- package/src/utilities/directives/conditional-classes.directive.ts +36 -0
- package/src/utilities/directives/dialog-service.ts +19 -0
- package/src/utilities/directives/dialog.ts +144 -0
- package/src/utilities/directives/mat-toggle-group-directive.ts +60 -0
- package/src/utilities/directives/prevent-enter.directive.ts +12 -0
- package/src/utilities/directives/stop-propagation.directive.ts +19 -0
- package/src/utilities/directives/styler.ts +44 -0
- package/src/utilities/directives/trim-whitespace.directive.ts +20 -0
- package/{utilities/index.d.ts → src/utilities/index.ts} +22 -15
- package/src/utilities/module.ts +55 -0
- package/src/utilities/pipes/function.pipe.ts +21 -0
- package/src/utilities/pipes/phone.pipe.ts +20 -0
- package/src/utilities/pipes/space-case.pipes.spec.ts +47 -0
- package/src/utilities/pipes/space-case.pipes.ts +26 -0
- package/tsconfig.lib.json +20 -0
- package/tsconfig.lib.prod.json +10 -0
- package/tsconfig.spec.json +17 -0
- package/action-state/action-state-spinner/action-state-spinner.component.d.ts +0 -12
- package/action-state/action-state-ui/action-state-ui.module.d.ts +0 -7
- package/action-state/ngrx-ext/ngrx-ext.module.d.ts +0 -8
- package/action-state/ngrx.d.ts +0 -31
- package/fesm2022/one-paragon-angular-utilities.mjs +0 -6336
- package/fesm2022/one-paragon-angular-utilities.mjs.map +0 -1
- package/http-request-state/RequestStateFactory.d.ts +0 -17
- package/http-request-state/RequestStateStore.d.ts +0 -101
- package/http-request-state/directives/HttpStateDirectiveBase.d.ts +0 -14
- package/http-request-state/directives/http-error-state-directive.d.ts +0 -9
- package/http-request-state/directives/http-inProgress-state-directive.d.ts +0 -9
- package/http-request-state/directives/http-notStarted-state-directive.d.ts +0 -9
- package/http-request-state/directives/http-success-state-directive.d.ts +0 -16
- package/http-request-state/directives/request-state-directive.d.ts +0 -34
- package/http-request-state/helpers.d.ts +0 -9
- package/http-request-state/http-state-module.d.ts +0 -11
- package/http-request-state/request-state.d.ts +0 -12
- package/http-request-state/rxjs/getRequestorBody.d.ts +0 -3
- package/http-request-state/rxjs/getRequestorState.d.ts +0 -3
- package/http-request-state/rxjs/tapError.d.ts +0 -3
- package/http-request-state/rxjs/tapSuccess.d.ts +0 -3
- package/http-request-state/types.d.ts +0 -41
- package/index.d.ts +0 -5
- package/ngrx/actionable-selector.d.ts +0 -32
- package/ngrx/index.d.ts +0 -1
- package/rxjs/defaultShareReplay.d.ts +0 -2
- package/rxjs/mapError.d.ts +0 -2
- package/rxjs/rxjs-operators.d.ts +0 -13
- package/rxjs/subjectifier.d.ts +0 -10
- package/rxjs/subscriber.directive.d.ts +0 -14
- package/table-builder/classes/DefaultSettings.d.ts +0 -9
- package/table-builder/classes/MatTableObservableDataSource.d.ts +0 -9
- package/table-builder/classes/TableBuilderConfig.d.ts +0 -23
- package/table-builder/classes/TableBuilderDataSource.d.ts +0 -18
- package/table-builder/classes/TableState.d.ts +0 -81
- package/table-builder/classes/data-store.d.ts +0 -8
- package/table-builder/classes/filter-info.d.ts +0 -39
- package/table-builder/classes/table-builder-general-settings.d.ts +0 -117
- package/table-builder/classes/table-builder.d.ts +0 -22
- package/table-builder/classes/table-store.d.ts +0 -146
- package/table-builder/classes/table-store.helpers.d.ts +0 -31
- package/table-builder/components/array-column.component.d.ts +0 -15
- package/table-builder/components/column-builder/column-builder.component.d.ts +0 -41
- package/table-builder/components/column-builder/column-helpers.d.ts +0 -38
- package/table-builder/components/column-header-menu/column-header-menu.component.d.ts +0 -50
- package/table-builder/components/date-filter/date-filter.component.d.ts +0 -37
- package/table-builder/components/date-time-filter/date-time-filter.component.d.ts +0 -37
- package/table-builder/components/filter/filter.component.d.ts +0 -48
- package/table-builder/components/filter/in-list/in-list-filter.component.d.ts +0 -23
- package/table-builder/components/gen-col-displayer/gen-col-displayer.component.d.ts +0 -17
- package/table-builder/components/generic-table/generic-table.component.d.ts +0 -84
- package/table-builder/components/generic-table/paginator.component.d.ts +0 -26
- package/table-builder/components/group-by-list/group-by-list.component.d.ts +0 -7
- package/table-builder/components/in-filter/in-filter.component.d.ts +0 -20
- package/table-builder/components/initialization-component/initialization-component.d.ts +0 -15
- package/table-builder/components/link-column.component.d.ts +0 -23
- package/table-builder/components/number-filter/number-filter.component.d.ts +0 -39
- package/table-builder/components/profiles-menu/profiles-menu.component.d.ts +0 -33
- package/table-builder/components/reset-menu/reset-menu.component.d.ts +0 -25
- package/table-builder/components/scroll-strategy.d.ts +0 -45
- package/table-builder/components/sort-menu/sort-menu.component-store.d.ts +0 -24
- package/table-builder/components/sort-menu/sort-menu.component.d.ts +0 -19
- package/table-builder/components/table-container/table-container.d.ts +0 -104
- package/table-builder/components/table-container/table-container.helpers/data-state.helpers.d.ts +0 -7
- package/table-builder/components/table-container/table-container.helpers/filter-state.helpers.d.ts +0 -19
- package/table-builder/components/table-container/table-container.helpers/groupBy.helpers.d.ts +0 -19
- package/table-builder/components/table-container/table-container.helpers/meta-data.helpers.d.ts +0 -2
- package/table-builder/components/table-container/table-container.helpers/sort-state.helpers.d.ts +0 -12
- package/table-builder/components/table-container/tableProps.d.ts +0 -10
- package/table-builder/components/table-container/virtual-scroll-container.d.ts +0 -40
- package/table-builder/components/table-container-filter/filter-list/filter-list.component.d.ts +0 -15
- package/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.d.ts +0 -12
- package/table-builder/components/table-container-filter/table-wrapper-filter-store.d.ts +0 -14
- package/table-builder/components/table-header-menu/table-header-menu.component.d.ts +0 -15
- package/table-builder/directives/custom-cell-directive.d.ts +0 -34
- package/table-builder/directives/multi-sort.directive.d.ts +0 -10
- package/table-builder/directives/resize-column.directive.d.ts +0 -43
- package/table-builder/directives/table-wrapper.directive.d.ts +0 -8
- package/table-builder/directives/tb-filter.directive.d.ts +0 -116
- package/table-builder/enums/filterTypes.d.ts +0 -36
- package/table-builder/functions/boolean-filter-function.d.ts +0 -3
- package/table-builder/functions/date-filter-function.d.ts +0 -4
- package/table-builder/functions/download-data.d.ts +0 -1
- package/table-builder/functions/null-filter-function.d.ts +0 -2
- package/table-builder/functions/number-filter-function.d.ts +0 -4
- package/table-builder/functions/sort-data-function.d.ts +0 -6
- package/table-builder/functions/string-filter-function.d.ts +0 -5
- package/table-builder/interfaces/report-def.d.ts +0 -171
- package/table-builder/ngrx/tableBuilderStateStore.d.ts +0 -69
- package/table-builder/pipes/column-total.pipe.d.ts +0 -8
- package/table-builder/pipes/format-filter-type.pipe.d.ts +0 -8
- package/table-builder/pipes/format-filter-value.pipe.d.ts +0 -11
- package/table-builder/pipes/key-display.d.ts +0 -9
- package/table-builder/services/export-to-csv.service.d.ts +0 -14
- package/table-builder/services/link-creator.service.d.ts +0 -16
- package/table-builder/services/table-template-service.d.ts +0 -14
- package/table-builder/services/transform-creator.d.ts +0 -7
- package/table-builder/table-builder.module.d.ts +0 -14
- package/utilities/array-helpers.d.ts +0 -1
- package/utilities/directives/auto-focus.directive.d.ts +0 -9
- package/utilities/directives/clickEmitterDirective.d.ts +0 -7
- package/utilities/directives/clickSubject.d.ts +0 -9
- package/utilities/directives/conditional-classes.directive.d.ts +0 -12
- package/utilities/directives/dialog-service.d.ts +0 -10
- package/utilities/directives/dialog.d.ts +0 -45
- package/utilities/directives/mat-toggle-group-directive.d.ts +0 -21
- package/utilities/directives/prevent-enter.directive.d.ts +0 -6
- package/utilities/directives/stop-propagation.directive.d.ts +0 -7
- package/utilities/directives/styler.d.ts +0 -16
- package/utilities/directives/trim-whitespace.directive.d.ts +0 -7
- package/utilities/module.d.ts +0 -19
- package/utilities/pipes/function.pipe.d.ts +0 -11
- package/utilities/pipes/phone.pipe.d.ts +0 -8
- package/utilities/pipes/space-case.pipes.d.ts +0 -17
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Predicate } from "@angular/core";
|
|
2
|
+
import { TableBuilderSort } from "../components/table-container/table-container.helpers/sort-state.helpers";
|
|
3
|
+
|
|
4
|
+
export function sortData<T>(data: T[], sorted: TableBuilderSort[]): T[] {
|
|
5
|
+
return data.sort(compareT(sorted));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function filterData<T>(data: T[], filters: Predicate<T>[], resetAll = false){
|
|
9
|
+
if(filters.length === 0){
|
|
10
|
+
if(resetAll){
|
|
11
|
+
for (let index = 0; index < data.length; index++) {
|
|
12
|
+
const element = data[index];
|
|
13
|
+
element[tbNoShowSymbol] = false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
for (let index = 0; index < data.length; index++) {
|
|
19
|
+
const element = data[index];
|
|
20
|
+
const hide = !filters.every(filter => filter(element));
|
|
21
|
+
if(hide || resetAll){
|
|
22
|
+
element[tbNoShowSymbol] = hide;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const tbNoShowSymbol = Symbol('tb_no_show');
|
|
29
|
+
|
|
30
|
+
function compareT<T>(criteria: TableBuilderSort[]) {
|
|
31
|
+
const transforms = criteria.reduce((acc, c) => {
|
|
32
|
+
acc[c.active] = {
|
|
33
|
+
transform: c.sortBy ? c.sortBy : getFactory(c.active), nulls: c.nulls === 'first' ? -1 : 1};
|
|
34
|
+
return acc;
|
|
35
|
+
}, {} as Record<string, { transform: (t: T) => any, nulls: 1 | -1}>);
|
|
36
|
+
|
|
37
|
+
return function (a: T, b: T): number {
|
|
38
|
+
for (let index = 0; index < criteria.length; index++) {
|
|
39
|
+
const c = criteria[index];
|
|
40
|
+
const d = transforms[c.active];
|
|
41
|
+
const nullValue = d.nulls;
|
|
42
|
+
if (a == null) {
|
|
43
|
+
if (b == null) return 0;
|
|
44
|
+
return nullValue;
|
|
45
|
+
}
|
|
46
|
+
if (b == null) return -nullValue;
|
|
47
|
+
const transform = d.transform;
|
|
48
|
+
const aVal = transform(a);
|
|
49
|
+
const bVal = transform(b);
|
|
50
|
+
if (aVal == null) {
|
|
51
|
+
if (bVal == null) return 0;
|
|
52
|
+
return nullValue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (bVal == null) return -nullValue;
|
|
56
|
+
if (aVal < bVal) return c.direction === 'asc' ? -1 : 1;
|
|
57
|
+
if (aVal > bVal) return c.direction === 'asc' ? 1 : -1;
|
|
58
|
+
}
|
|
59
|
+
return 0;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function getFactory(b: string){
|
|
64
|
+
if(typeof b !== 'string') return (a) => a[b];
|
|
65
|
+
if(!b.includes('.')) return (a) => {
|
|
66
|
+
if(!a) return a;
|
|
67
|
+
return a[b];
|
|
68
|
+
};
|
|
69
|
+
const arr = b.split('.');
|
|
70
|
+
return (a) => {
|
|
71
|
+
let val = a;
|
|
72
|
+
if(!a) return a;
|
|
73
|
+
for (let index = 0; index < arr.length; index++) {
|
|
74
|
+
val = val[arr[index]];
|
|
75
|
+
if(val == undefined) return undefined;
|
|
76
|
+
if(typeof val !== 'object' && index + 1 < arr.length) return undefined;
|
|
77
|
+
}
|
|
78
|
+
return val;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { FilterFunc, FilterFuncs, FilterInfo } from '../classes/filter-info';
|
|
2
|
+
import { EnumFilterTypes, FilterType, StringFilterTypes } from '../enums/filterTypes';
|
|
3
|
+
import { isNull } from './null-filter-function';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
const stringEqualFunc:FilterFunc<string> = (filterInfo:FilterInfo) => {
|
|
7
|
+
const equalsVal = prepareForStringCompare(filterInfo.filterValue);
|
|
8
|
+
return ((val)=> prepareForStringCompare(val) === equalsVal );
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const stringContainsFunc:FilterFunc<string> = (filterInfo:FilterInfo) => {
|
|
12
|
+
const containsVal = prepareForStringCompare(filterInfo.filterValue);
|
|
13
|
+
return ((val)=>prepareForStringCompare(val).includes(containsVal));
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const stringDoesNotContainFunc:FilterFunc<string> = (filterInfo:FilterInfo) => {
|
|
17
|
+
const doesNotContainVal = prepareForStringCompare(filterInfo.filterValue);
|
|
18
|
+
return ((val)=> !prepareForStringCompare(val)?.includes(doesNotContainVal));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const stringStartsWithFunc:FilterFunc<string> = (filterInfo:FilterInfo) => {
|
|
22
|
+
const startsWith = prepareForStringCompare(filterInfo.filterValue);
|
|
23
|
+
return ((val)=> prepareForStringCompare(val).startsWith(startsWith));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const stringEndsWithFunc:FilterFunc<string> = (filterInfo:FilterInfo) => {
|
|
27
|
+
const startsWith = prepareForStringCompare(filterInfo.filterValue);
|
|
28
|
+
return ((val)=> prepareForStringCompare(val).endsWith(startsWith));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const multipleStringValuesEqualsFunc:FilterFunc<string[],string> = (filterInfo:FilterInfo) => {
|
|
32
|
+
const filterVals = filterInfo.filterValue.map( (v: string) => prepareForStringCompare(v));
|
|
33
|
+
return ((val)=> filterVals.some((s:string) => prepareForStringCompare(val) === s));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const StringFilterFuncs: FilterFuncs<StringFilterTypes> = {
|
|
37
|
+
[FilterType.StringEquals]: stringEqualFunc,
|
|
38
|
+
[FilterType.StringContains]: stringContainsFunc,
|
|
39
|
+
[FilterType.StringDoesNotContain]: stringDoesNotContainFunc,
|
|
40
|
+
[FilterType.StringStartWith]: stringStartsWithFunc,
|
|
41
|
+
[FilterType.StringEndsWith]: stringEndsWithFunc,
|
|
42
|
+
[FilterType.IsNull]: isNull,
|
|
43
|
+
[FilterType.In]: multipleStringValuesEqualsFunc,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const EnumFilterFuncs: FilterFuncs<EnumFilterTypes> = {
|
|
47
|
+
[FilterType.IsNull]: isNull,
|
|
48
|
+
[FilterType.In] : multipleStringValuesEqualsFunc,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const prepareForStringCompare = (val: any):string => (val?.toString().trim().toLowerCase());
|
package/{table-builder/interfaces/ColumnInfo.d.ts → src/table-builder/interfaces/ColumnInfo.ts}
RENAMED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { CustomCellDirective } from "../directives/custom-cell-directive";
|
|
2
|
-
import { MetaData } from "./report-def";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { CustomCellDirective } from "../directives/custom-cell-directive";
|
|
2
|
+
import { MetaData } from "./report-def";
|
|
3
|
+
|
|
4
|
+
export interface ColumnInfo {
|
|
5
|
+
metaData: MetaData;
|
|
6
|
+
customCell?: CustomCellDirective;
|
|
7
|
+
}
|
package/{table-builder/interfaces/dictionary.d.ts → src/table-builder/interfaces/dictionary.ts}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export interface Dictionary<T> {
|
|
2
|
-
|
|
3
|
-
}
|
|
1
|
+
export interface Dictionary<T> {
|
|
2
|
+
[key: string]: T;
|
|
3
|
+
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { Dictionary } from './dictionary';
|
|
2
|
+
import { PipeTransform, Predicate, TemplateRef } from '@angular/core';
|
|
3
|
+
import { TableBuilderExport } from '../classes/TableBuilderConfig';
|
|
4
|
+
import { QueryParamsHandling } from '@angular/router';
|
|
5
|
+
import { StylerStyle } from '../../utilities/directives/styler';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export enum FieldType {
|
|
9
|
+
Unknown = 0,
|
|
10
|
+
Date = 1,
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated If `additional.link` is set the column will be treated as a link.
|
|
13
|
+
*/
|
|
14
|
+
Link = 2,
|
|
15
|
+
ImageUrl = 3,
|
|
16
|
+
Currency = 4,
|
|
17
|
+
Array = 5,
|
|
18
|
+
Hidden = 6,
|
|
19
|
+
Number = 7,
|
|
20
|
+
String = 8,
|
|
21
|
+
Boolean = 9,
|
|
22
|
+
PhoneNumber = 10,
|
|
23
|
+
/**
|
|
24
|
+
* @deprecated For mapped properties use proper type (for sorting and filtering) with `map`.
|
|
25
|
+
* For unmapped properties use `FieldType.NotMapped` with map.
|
|
26
|
+
*/
|
|
27
|
+
Expression = 11,
|
|
28
|
+
Enum = 12,
|
|
29
|
+
DateTime = 13,
|
|
30
|
+
NotMapped = 14,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export enum SortDirection {
|
|
34
|
+
asc= 'asc',
|
|
35
|
+
desc= 'desc'
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export enum Target {
|
|
39
|
+
Blank = '_blank',
|
|
40
|
+
Self = '_self',
|
|
41
|
+
Parent = '_parent',
|
|
42
|
+
Top = '_top'
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
interface BaseMeta <T = any> {
|
|
46
|
+
displayName?: string;
|
|
47
|
+
additional?: Additional<T>;
|
|
48
|
+
order?: number;
|
|
49
|
+
preSort?: SortDef;
|
|
50
|
+
sortLogic?: {
|
|
51
|
+
/**
|
|
52
|
+
* defaults to last
|
|
53
|
+
*/
|
|
54
|
+
nulls?: 'first' | 'last';
|
|
55
|
+
sortBy?: ((t: T) => any) | 'use map';
|
|
56
|
+
}
|
|
57
|
+
noSort?: boolean;
|
|
58
|
+
width?: string;
|
|
59
|
+
noExport?: boolean;
|
|
60
|
+
filterLogic?: {
|
|
61
|
+
filterBy?: ((t: T) => any) | 'use map';
|
|
62
|
+
/**
|
|
63
|
+
* defaults to the MetaData's Field type
|
|
64
|
+
*/
|
|
65
|
+
filterType?: FieldType;
|
|
66
|
+
},
|
|
67
|
+
noFilter?: boolean;
|
|
68
|
+
customCell?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated Please use map instead
|
|
71
|
+
*/
|
|
72
|
+
transform?: ((o: T, ...args: any[])=> any) | ((o: string, ...args: any[])=> any) | PipeTransform;
|
|
73
|
+
click?: (element: T, key: string ) => void;
|
|
74
|
+
template?: TemplateRef<any>;
|
|
75
|
+
classes?: Dictionary<Predicate<T> | true>;
|
|
76
|
+
toolTip?: string | ((t:T) => string);
|
|
77
|
+
useIcon?: boolean;
|
|
78
|
+
map? : (t:T) => any;
|
|
79
|
+
}
|
|
80
|
+
type Path<T, U = never, P = never> = (T extends P ? never : T extends object ?
|
|
81
|
+
{ [K in keyof T]: K extends string | number ? `${K}` | (T[K] extends (Array<any> | undefined) ? `${K}.${keyof Array<any> & (string | number)}` : `${K}.${Path<T[K], T[K], P | U >}`) : never; }[keyof T]
|
|
82
|
+
: never)
|
|
83
|
+
|
|
84
|
+
export interface MappedMetaData<T = any, AdditionalFields extends string[] = []> extends BaseMeta<T> {
|
|
85
|
+
key: (Path<T> | AdditionalFields[number]) & string;
|
|
86
|
+
fieldType: Exclude<typeof FieldType[keyof typeof FieldType], FieldType.NotMapped | FieldType.Expression>;
|
|
87
|
+
/**
|
|
88
|
+
* if used with map, `mapItem` will only be used where the row is not available, ex. group header
|
|
89
|
+
*/
|
|
90
|
+
mapItem?: (i: string) => any;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export type MetaData<T = any, AdditionalFields extends string[] = []> = MappedMetaData<T, AdditionalFields> | NotMappedMetaData<T>;
|
|
94
|
+
|
|
95
|
+
export interface NotMappedMetaData<T = any> extends BaseMeta<T> {
|
|
96
|
+
key: string;
|
|
97
|
+
fieldType: FieldType.NotMapped | FieldType.Expression;
|
|
98
|
+
}
|
|
99
|
+
export interface ReportDef<DataType = any> {
|
|
100
|
+
data: DataType[];
|
|
101
|
+
metaData: MetaData [];
|
|
102
|
+
totalRecords?: number;
|
|
103
|
+
count: number;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface SortDef {
|
|
107
|
+
direction: SortDirection;
|
|
108
|
+
precedence?: number;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface FilterOptions {
|
|
112
|
+
filterableValues : string[]
|
|
113
|
+
}
|
|
114
|
+
export interface DateTimeOptions {
|
|
115
|
+
format?: string;
|
|
116
|
+
includeSeconds?: boolean;
|
|
117
|
+
includeMilliseconds: boolean;
|
|
118
|
+
}
|
|
119
|
+
type interpolatedRoute = string;
|
|
120
|
+
export interface Additional<T = any> {
|
|
121
|
+
link? : {
|
|
122
|
+
base?: string;
|
|
123
|
+
urlKey?: string;
|
|
124
|
+
target?: Target;
|
|
125
|
+
useRouterLink?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* If you want to use a route with interpolated params, you can use this. Wrap the property name in curly braces.
|
|
128
|
+
* For example, if interpolatedRoute = /users/{id}/edit, {id} will be replaced with the value of the element's id property.
|
|
129
|
+
*/
|
|
130
|
+
interpolatedRoute?: interpolatedRoute | ((t: T) => string);
|
|
131
|
+
routerLinkOptions?:{
|
|
132
|
+
queryParams?: [string, interpolatedRoute | ((t: T) => string)][];
|
|
133
|
+
fragment?: string;
|
|
134
|
+
preserveFragment?: boolean;
|
|
135
|
+
queryParamsHandling?: QueryParamsHandling;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
footer?: { type: 'sum' };
|
|
139
|
+
export?: TableBuilderExport;
|
|
140
|
+
dateFormat?: string;
|
|
141
|
+
dateTimeOptions?: DateTimeOptions;
|
|
142
|
+
filterOptions?: FilterOptions;
|
|
143
|
+
styles?: StylerStyle<T>;
|
|
144
|
+
columnPartStyles?: {
|
|
145
|
+
header?: Dictionary<string>,
|
|
146
|
+
body?: StylerStyle<T>,
|
|
147
|
+
innerBody?: StylerStyle<T>,
|
|
148
|
+
footer?: Dictionary<string>,
|
|
149
|
+
}
|
|
150
|
+
columnPartClasses?: {
|
|
151
|
+
header?: Dictionary<Predicate<T> | true>,
|
|
152
|
+
footer?: Dictionary<Predicate<T> | true>,
|
|
153
|
+
}
|
|
154
|
+
enumMap?: {[key:number]:string};
|
|
155
|
+
boolean? : {
|
|
156
|
+
showForFalse? : true | { icon : string },
|
|
157
|
+
forTrue? : { icon : string }
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export enum ArrayStyle {
|
|
162
|
+
CommaDelimited,
|
|
163
|
+
NewLine
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface ArrayAdditional extends Additional {
|
|
167
|
+
limit?: number;
|
|
168
|
+
arrayStyle?: ArrayStyle;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
export function metaDataArrToDict<T = MetaData>(arr: MetaData[], transform?: (m : MetaData) => T): Dictionary<T>{
|
|
174
|
+
const dict = {};
|
|
175
|
+
if(transform){
|
|
176
|
+
arr.forEach(e => dict[e.key] = transform(e));
|
|
177
|
+
} else {
|
|
178
|
+
arr.forEach(e => dict[e.key] = e);
|
|
179
|
+
}
|
|
180
|
+
return dict;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export interface CustomCellMeta extends Pick<MetaData, 'key' | 'displayName' | 'preSort' | 'fieldType' | 'order' | 'width'>{
|
|
184
|
+
customCell: true;
|
|
185
|
+
noExport?: boolean;
|
|
186
|
+
}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { ComponentStore } from "@ngrx/component-store";
|
|
2
|
+
import { Injectable, Signal } from "@angular/core";
|
|
3
|
+
import { Dictionary } from "../interfaces/dictionary";
|
|
4
|
+
import { PersistedTableState } from "../classes/TableState";
|
|
5
|
+
|
|
6
|
+
@Injectable({ providedIn: 'root'})
|
|
7
|
+
export class TableBuilderStateStore extends ComponentStore<GlobalStorageState> {
|
|
8
|
+
constructor(){
|
|
9
|
+
super(loadGlobalStorageState() || defaultStorageState)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//selectors
|
|
13
|
+
$selectLocalTableProfile = (profileKey:string): Signal<Profile | undefined> => this.selectSignal(state =>
|
|
14
|
+
state.localProfiles[profileKey]);
|
|
15
|
+
|
|
16
|
+
$selectLocalTableStateForView = (tableId: string) => this.selectSignal(
|
|
17
|
+
this.$selectLocalTableProfile(tableId),
|
|
18
|
+
(profile) => {
|
|
19
|
+
if(profile?.current) {
|
|
20
|
+
return profile.states[profile.current];
|
|
21
|
+
}
|
|
22
|
+
if(profile?.localSavedState) return profile.localSavedState;
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
$selectLocalProfileCurrentKey = (key:string) => this.selectSignal(
|
|
28
|
+
this.$selectLocalTableProfile(key),
|
|
29
|
+
(profile) => profile?.current);
|
|
30
|
+
|
|
31
|
+
$selectLocalProfileDefaultKey = (key:string) => this.selectSignal(
|
|
32
|
+
this.$selectLocalTableProfile(key),
|
|
33
|
+
(profile) => profile?.default);
|
|
34
|
+
|
|
35
|
+
$selectLocalProfileKeys = (tableId:string) => this.selectSignal(
|
|
36
|
+
this.$selectLocalTableProfile(tableId),
|
|
37
|
+
(profile) => Object.keys(profile?.states || {})
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
// reducers
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
saveTableSettingsToLocalAndStorage = (tableId: string, stateName: string, tableState: PersistedTableState, asDefault?: boolean) => {
|
|
45
|
+
this.saveTableStateToStorage(tableId, stateName, tableState, asDefault);
|
|
46
|
+
this.saveTableStateToLocal({ tableId, tableState, stateName, asDefault });
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
saveTableStateToLocal = this.updater((state, props: { tableId: string, tableState: PersistedTableState, stateName?: string, asDefault?: boolean }) => {
|
|
50
|
+
let profile = state.localProfiles[props.tableId];
|
|
51
|
+
if(!profile?.states) {
|
|
52
|
+
profile = {states:{}};
|
|
53
|
+
}
|
|
54
|
+
if(!props.stateName){
|
|
55
|
+
profile = {...profile, localSavedState: props.tableState };
|
|
56
|
+
} else {
|
|
57
|
+
profile = {...profile, states: {...profile.states, [props.stateName] : props.tableState} };
|
|
58
|
+
}
|
|
59
|
+
if(props.asDefault){
|
|
60
|
+
profile.default = props.stateName;
|
|
61
|
+
}
|
|
62
|
+
return {...state, localProfiles: {...state.localProfiles, [props.tableId]: profile} }
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
saveTableStateToStorage = (tableId: string, stateName: string, tableState: PersistedTableState, asDefault = false) => {
|
|
66
|
+
const globalSavedState: PersistedGlobalStorageSate = JSON.parse(localStorage.getItem('global-state-storage') ?? JSON.stringify(defaultStorageState) );
|
|
67
|
+
globalSavedState.localProfiles[tableId] ??= { states : {}}
|
|
68
|
+
globalSavedState.localProfiles[tableId].states[stateName] = tableState;
|
|
69
|
+
if(asDefault){
|
|
70
|
+
globalSavedState.localProfiles[tableId].default = stateName;
|
|
71
|
+
}
|
|
72
|
+
localStorage.setItem('global-state-storage', JSON.stringify( globalSavedState));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
addNewStateToLocalAndStorage = (tableId: string, newStateName: string, tableState: PersistedTableState, asDefault?: boolean) => {
|
|
76
|
+
this.saveTableSettingsToLocalAndStorage(tableId, newStateName, tableState, asDefault);
|
|
77
|
+
this.setLocalCurrentState({ tableId: tableId, currentStateKey: newStateName});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
setLocalCurrentState = this.updater((state, props: { tableId: string, currentStateKey: string }) => {
|
|
81
|
+
const profile = state.localProfiles[props.tableId] || { states: {}};
|
|
82
|
+
profile.current = props.currentStateKey;
|
|
83
|
+
return {...state, localProfiles: {...state.localProfiles, [props.tableId]: {...profile}}};
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
setDefaultInLocalAndStorage = (tableId: string, newDefault: string) => {
|
|
87
|
+
this.setDefaultInLocal({ default: newDefault, key: tableId });
|
|
88
|
+
this.setDefaultInStorage(tableId, newDefault);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
setDefaultInLocal = this.updater((state, props: { key: string, default: string }) => {
|
|
92
|
+
if(state.localProfiles[props.key]?.states[props.default]) {
|
|
93
|
+
return ({...state, localProfiles: {...state.localProfiles, [props.key]: {...state.localProfiles[props.key], default: props.default} } });
|
|
94
|
+
}
|
|
95
|
+
return state;
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
unsetDefaultFromLocalAndStorage = (tableId: string) => {
|
|
99
|
+
this.unsetDefaultFromLocal(tableId);
|
|
100
|
+
this.unsetDefaultFromStorage(tableId);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
unsetDefaultFromLocal = (tableId: string) => {
|
|
104
|
+
this.patchState(tables => {
|
|
105
|
+
const profile = { ...tables.localProfiles[tableId] };
|
|
106
|
+
if(profile) {
|
|
107
|
+
delete profile.default;
|
|
108
|
+
}
|
|
109
|
+
return { ...tables, localProfiles: { ...tables.localProfiles, [tableId]: profile } };
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
unsetDefaultFromStorage = (tableId: string) => {
|
|
114
|
+
const globalSavedState: GlobalStorageState = JSON.parse(localStorage.getItem('global-state-storage') ?? JSON.stringify(defaultStorageState) );
|
|
115
|
+
if(globalSavedState.localProfiles[tableId]) {
|
|
116
|
+
delete globalSavedState.localProfiles[tableId].default;
|
|
117
|
+
localStorage.setItem('global-state-storage', JSON.stringify( globalSavedState));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
setDefaultInStorage = (tableId: string, stateName: string) => {
|
|
122
|
+
const tableProfile = this.$selectLocalTableProfile(tableId)();
|
|
123
|
+
const globalSavedState: GlobalStorageState = JSON.parse(localStorage.getItem('global-state-storage') ?? JSON.stringify(defaultStorageState) );
|
|
124
|
+
let savedProfile = globalSavedState.localProfiles[stateName];
|
|
125
|
+
if(!savedProfile?.states) {
|
|
126
|
+
savedProfile = { default: stateName, states : tableProfile!.states };
|
|
127
|
+
} else {
|
|
128
|
+
savedProfile.default = stateName;
|
|
129
|
+
}
|
|
130
|
+
globalSavedState.localProfiles[tableId] = savedProfile;
|
|
131
|
+
localStorage.setItem('global-state-storage', JSON.stringify( globalSavedState));
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
deleteLocalProfilesState = this.updater((state, props: { key: string, stateKey: string }) => {
|
|
135
|
+
let profile = state.localProfiles[props.key];
|
|
136
|
+
if(profile) {
|
|
137
|
+
const current = profile.current === props.stateKey ? profile.default : profile.current;
|
|
138
|
+
profile = {...profile,current, states: { ...profile.states}};
|
|
139
|
+
delete profile.states[props.stateKey];
|
|
140
|
+
if(current === props.stateKey) {
|
|
141
|
+
profile.current = undefined;
|
|
142
|
+
}
|
|
143
|
+
return {...state, localProfiles: {...state.localProfiles, [props.key]: profile} };
|
|
144
|
+
} else {
|
|
145
|
+
return state;
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
deleteProfileFromLocalAndStorage = (key: string, stateKey: string) => {
|
|
150
|
+
const globalSavedState: GlobalStorageState = JSON.parse(localStorage.getItem('global-state-storage') ?? JSON.stringify(defaultStorageState) );
|
|
151
|
+
if(!globalSavedState.localProfiles[key]) {
|
|
152
|
+
return;
|
|
153
|
+
} else {
|
|
154
|
+
delete (globalSavedState.localProfiles[key].states ?? {})[stateKey];
|
|
155
|
+
}
|
|
156
|
+
if(globalSavedState.localProfiles[key].default === stateKey) {
|
|
157
|
+
globalSavedState.localProfiles[key].default = undefined;
|
|
158
|
+
}
|
|
159
|
+
localStorage.setItem('global-state-storage', JSON.stringify( globalSavedState));
|
|
160
|
+
this.deleteLocalProfilesState({ key, stateKey })
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function loadGlobalStorageState() : GlobalStorageState | void {
|
|
165
|
+
const storage = localStorage.getItem('global-state-storage');
|
|
166
|
+
|
|
167
|
+
if(storage) {
|
|
168
|
+
const s: GlobalStorageState = (JSON.parse(storage) as PersistedGlobalStorageSate);
|
|
169
|
+
s.localProfiles ??= {};
|
|
170
|
+
for(const key in s.localProfiles){
|
|
171
|
+
const profile = s.localProfiles[key];
|
|
172
|
+
s.localProfiles[key] = { ...profile, current: profile.default } as Profile
|
|
173
|
+
}
|
|
174
|
+
return {...defaultStorageState, ...s};
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
interface PersistedProfile {
|
|
179
|
+
states: Dictionary<PersistedTableState>;
|
|
180
|
+
default?: string;
|
|
181
|
+
}
|
|
182
|
+
export interface Profile extends PersistedProfile {
|
|
183
|
+
current?: string;
|
|
184
|
+
localSavedState?: PersistedTableState;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export interface GlobalStorageState {
|
|
188
|
+
localProfiles: Dictionary<Profile>;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
interface PersistedGlobalStorageSate {
|
|
192
|
+
localProfiles: Dictionary<PersistedProfile>;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export const defaultStorageState: GlobalStorageState = {
|
|
196
|
+
localProfiles: {}
|
|
197
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Pipe, PipeTransform } from '@angular/core';
|
|
2
|
+
import { MetaData } from '../interfaces/report-def';
|
|
3
|
+
import {sumBy} from 'lodash';
|
|
4
|
+
|
|
5
|
+
@Pipe({
|
|
6
|
+
name: 'columnTotal',
|
|
7
|
+
})
|
|
8
|
+
export class ColumnTotalPipe implements PipeTransform {
|
|
9
|
+
transform(data: any[], metaData: MetaData) {
|
|
10
|
+
const dataToCalculate = data.filter(d => !d.isGroupHeader)
|
|
11
|
+
switch (metaData.additional!.footer!.type) {
|
|
12
|
+
case 'sum':
|
|
13
|
+
return sumBy(dataToCalculate, metaData.key);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Pipe, PipeTransform } from '@angular/core';
|
|
2
|
+
import { FilterType } from '../enums/filterTypes';
|
|
3
|
+
|
|
4
|
+
@Pipe({name: 'formatFilterType' })
|
|
5
|
+
export class FormatFilterTypePipe implements PipeTransform {
|
|
6
|
+
transform(filterType: FilterType, value: any){
|
|
7
|
+
if(filterType === FilterType.IsNull){
|
|
8
|
+
return value ? filterType : 'Is Not Blank'
|
|
9
|
+
}
|
|
10
|
+
return filterType;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Pipe, PipeTransform, computed, inject } from '@angular/core';
|
|
2
|
+
import { TableStore } from '../classes/table-store';
|
|
3
|
+
import { FieldType, MetaData } from '../interfaces/report-def';
|
|
4
|
+
import { DatePipe } from '@angular/common';
|
|
5
|
+
import { FilterType } from '../enums/filterTypes';
|
|
6
|
+
import { spaceCase } from '../../utilities/pipes/space-case.pipes';
|
|
7
|
+
import { DateTimeFilterFuncs } from '../functions/date-filter-function';
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@Pipe({name: 'formatFilterValue' })
|
|
11
|
+
export class FormatFilterValuePipe implements PipeTransform {
|
|
12
|
+
tableState = inject(TableStore);
|
|
13
|
+
private datePipe = inject(DatePipe);
|
|
14
|
+
|
|
15
|
+
transform(value: any, key: string, filterType: FilterType) {
|
|
16
|
+
return computed(() => transform(value, this.tableState.$getMetaData(key)(), filterType));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const transform = (value: any, meta: MetaData, filterType: FilterType): string => {
|
|
21
|
+
if(filterType === FilterType.IsNull) {
|
|
22
|
+
return '';
|
|
23
|
+
}
|
|
24
|
+
if(value && (filterType === FilterType.In )){
|
|
25
|
+
if(meta.fieldType === FieldType.Enum) {
|
|
26
|
+
return value.map( (v: any) => spaceCase(meta.additional!.enumMap![v])).join(', ') ?? value;
|
|
27
|
+
}
|
|
28
|
+
return value.join(', ') ?? value;
|
|
29
|
+
}
|
|
30
|
+
if(filterType === FilterType.NumberBetween){
|
|
31
|
+
return value.Start + ' - ' + value.End;
|
|
32
|
+
}
|
|
33
|
+
if(meta.fieldType === FieldType.Date){
|
|
34
|
+
return new DatePipe('en-US').transform(value, 'MM/dd/yy') || '';
|
|
35
|
+
}
|
|
36
|
+
if(meta.fieldType === FieldType.DateTime){
|
|
37
|
+
return (!!DateTimeFilterFuncs[filterType] ? new DatePipe('en-US').transform(value, 'short') : new DatePipe('en-US').transform(value, 'MM/dd/yy')) || '';
|
|
38
|
+
}
|
|
39
|
+
return value
|
|
40
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Pipe, PipeTransform, computed, inject } from '@angular/core';
|
|
2
|
+
import { TableStore } from '../classes/table-store';
|
|
3
|
+
import { spaceCase } from '../../utilities/pipes/space-case.pipes';
|
|
4
|
+
import { Observable } from 'rxjs';
|
|
5
|
+
import { map } from 'rxjs/operators';
|
|
6
|
+
|
|
7
|
+
@Pipe({name: 'keyDisplay' })
|
|
8
|
+
export class KeyDisplayPipe implements PipeTransform {
|
|
9
|
+
tableState = inject(TableStore);
|
|
10
|
+
|
|
11
|
+
transform = (key: string) =>
|
|
12
|
+
computed(() => this.tableState.$getMetaData(key)()?.displayName || spaceCase(key))
|
|
13
|
+
}
|