@one-paragon/angular-utilities 2.2.4 → 2.2.6
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 +7 -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 +14 -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 +66 -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 +50 -0
- package/src/table-builder/classes/TableBuilderDataSource.ts +64 -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 +125 -0
- package/src/table-builder/classes/table-builder-general-settings.ts +205 -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 +87 -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 +110 -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 +25 -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 +11 -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 +109 -0
- package/src/table-builder/components/filter/filter.component.scss +60 -0
- package/src/table-builder/components/filter/filter.component.spec.ts +86 -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 +102 -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 +97 -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 +403 -0
- package/src/table-builder/components/generic-table/paginator.component.ts +112 -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 +25 -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 +23 -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 +25 -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 +77 -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 +115 -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.component.html +81 -0
- package/src/table-builder/components/table-container/table-container.component.ts +403 -0
- package/src/table-builder/components/table-container/table-container.helpers/data-state.helpers.ts +113 -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 +122 -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.scss +47 -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 +35 -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 +40 -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 +50 -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 +57 -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 +78 -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 +53 -0
- package/{table-builder/interfaces/ColumnInfo.d.ts → src/table-builder/interfaces/ColumnInfo.ts} +7 -6
- package/{table-builder/interfaces/dictionary.d.ts → src/table-builder/interfaces/dictionary.ts} +3 -3
- package/src/table-builder/interfaces/report-def.ts +254 -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 +67 -0
- package/src/table-builder/pipes/key-display.ts +13 -0
- package/src/table-builder/services/export-to-csv.service.ts +113 -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 +53 -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 -6531
- 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 -10
- package/http-request-state/directives/http-inProgress-state-directive.d.ts +0 -10
- package/http-request-state/directives/http-notStarted-state-directive.d.ts +0 -10
- package/http-request-state/directives/http-success-state-directive.d.ts +0 -17
- 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 -119
- 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 -22
- 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 -85
- 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 -11
- 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.component.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 -223
- 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 -9
- 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,53 @@
|
|
|
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 as string[]).map((v) => prepareForStringCompare(v));
|
|
33
|
+
return ((val) => {
|
|
34
|
+
const v = prepareForStringCompare(val);
|
|
35
|
+
return filterVals.some((s) => v === s)});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const StringFilterFuncs: FilterFuncs<StringFilterTypes> = {
|
|
39
|
+
[FilterType.StringEquals]: stringEqualFunc,
|
|
40
|
+
[FilterType.StringContains]: stringContainsFunc,
|
|
41
|
+
[FilterType.StringDoesNotContain]: stringDoesNotContainFunc,
|
|
42
|
+
[FilterType.StringStartWith]: stringStartsWithFunc,
|
|
43
|
+
[FilterType.StringEndsWith]: stringEndsWithFunc,
|
|
44
|
+
[FilterType.IsNull]: isNull,
|
|
45
|
+
[FilterType.In]: multipleStringValuesEqualsFunc,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const EnumFilterFuncs: FilterFuncs<EnumFilterTypes> = {
|
|
49
|
+
[FilterType.IsNull]: isNull,
|
|
50
|
+
[FilterType.In]: multipleStringValuesEqualsFunc,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
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,254 @@
|
|
|
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
|
+
order?: number;
|
|
48
|
+
preSort?: SortDef;
|
|
49
|
+
sortLogic?: {
|
|
50
|
+
/**
|
|
51
|
+
* defaults to last
|
|
52
|
+
*/
|
|
53
|
+
nulls?: 'first' | 'last';
|
|
54
|
+
sortBy?: ((t: T) => any) | 'use map';
|
|
55
|
+
}
|
|
56
|
+
noSort?: boolean;
|
|
57
|
+
width?: string;
|
|
58
|
+
noExport?: boolean;
|
|
59
|
+
filterLogic?: {
|
|
60
|
+
filterBy?: ((t: T) => any) | 'use map';
|
|
61
|
+
/**
|
|
62
|
+
* defaults to the MetaData's Field type
|
|
63
|
+
*/
|
|
64
|
+
filterType?: FieldType;
|
|
65
|
+
},
|
|
66
|
+
noFilter?: boolean;
|
|
67
|
+
customCell?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* @deprecated Use `map`
|
|
70
|
+
*/
|
|
71
|
+
transform?: ((o: T, ...args: any[])=> any) | ((o: string, ...args: any[])=> any) | PipeTransform;
|
|
72
|
+
click?: (element: T, key?: string, event?: MouseEvent ) => void;
|
|
73
|
+
template?: TemplateRef<any>;
|
|
74
|
+
classes?: Dictionary<Predicate<T> | true>;
|
|
75
|
+
toolTip?: string | ((t:T) => string);
|
|
76
|
+
useIcon?: boolean;
|
|
77
|
+
map? : (t: T) => any;
|
|
78
|
+
}
|
|
79
|
+
type Path<T, U = never, P = never> =
|
|
80
|
+
(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 BaseMappedMetaData<T = any, AdditionalFields extends string[] = []> extends BaseMeta<T> {
|
|
85
|
+
key: (Path<T> | AdditionalFields[number]) & string;
|
|
86
|
+
/**
|
|
87
|
+
* if used with map, `mapItem` will only be used where the row is not available, ex. group header
|
|
88
|
+
*/
|
|
89
|
+
mapItem?: (i: any) => any;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface MappedMetaData<T = any, AdditionalFields extends string[] = []> extends BaseMappedMetaData<T, AdditionalFields> {
|
|
93
|
+
fieldType: FieldType.String | FieldType.PhoneNumber | FieldType.ImageUrl | FieldType.Link | FieldType.Hidden | FieldType.Unknown;
|
|
94
|
+
additional?: Additional<T>;
|
|
95
|
+
mapItem?: (i: string) => any;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface MappedNumberMetaData<T = any, AdditionalFields extends string[] = []> extends BaseMappedMetaData<T, AdditionalFields> {
|
|
99
|
+
fieldType: FieldType.Number | FieldType.Currency;
|
|
100
|
+
mapItem?: (i: number) => any;
|
|
101
|
+
additional?: NumberAdditional<T>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface MappedEnumMetaData<T = any, AdditionalFields extends string[] = []> extends BaseMappedMetaData<T, AdditionalFields> {
|
|
105
|
+
fieldType: FieldType.Enum;
|
|
106
|
+
mapItem?: (i: number) => any;
|
|
107
|
+
additional?: EnumAdditional<T>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface MappedDateMetaData<T = any, AdditionalFields extends string[] = []> extends BaseMappedMetaData<T, AdditionalFields> {
|
|
111
|
+
fieldType: FieldType.Date | FieldType.DateTime;
|
|
112
|
+
mapItem?: (i: Date) => any;
|
|
113
|
+
additional?: Additional<T, Date>;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface MappedBooleanMetaData<T = any, AdditionalFields extends string[] = []> extends BaseMappedMetaData<T, AdditionalFields> {
|
|
117
|
+
fieldType: FieldType.Boolean;
|
|
118
|
+
mapItem?: (i: boolean) => any;
|
|
119
|
+
additional?: BooleanAdditional<T>;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface MappedArrayMetaData<T = any, AdditionalFields extends string[] = []> extends BaseMappedMetaData<T, AdditionalFields> {
|
|
123
|
+
fieldType: FieldType.Array;
|
|
124
|
+
mapItem?: (i: string) => any;
|
|
125
|
+
additional?: ArrayAdditional<T>;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export type MetaData<T = any, AdditionalFields extends string[] = []> =
|
|
129
|
+
MappedMetaData<T, AdditionalFields>
|
|
130
|
+
| NotMappedMetaData<T>
|
|
131
|
+
| MappedNumberMetaData<T, AdditionalFields>
|
|
132
|
+
| MappedEnumMetaData<T, AdditionalFields>
|
|
133
|
+
| MappedBooleanMetaData<T, AdditionalFields>
|
|
134
|
+
| MappedDateMetaData<T, AdditionalFields>
|
|
135
|
+
| MappedArrayMetaData<T, AdditionalFields>
|
|
136
|
+
;
|
|
137
|
+
|
|
138
|
+
export interface NotMappedMetaData<T = any> extends BaseMeta<T> {
|
|
139
|
+
key: string;
|
|
140
|
+
fieldType: FieldType.NotMapped | FieldType.Expression;
|
|
141
|
+
additional?: Additional<T>;
|
|
142
|
+
}
|
|
143
|
+
export interface ReportDef<DataType = any> {
|
|
144
|
+
data: DataType[];
|
|
145
|
+
metaData: MetaData [];
|
|
146
|
+
totalRecords?: number;
|
|
147
|
+
count: number;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface SortDef {
|
|
151
|
+
direction: SortDirection;
|
|
152
|
+
precedence?: number;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface FilterOptions<T = string> {
|
|
156
|
+
filterableValues : T[]
|
|
157
|
+
}
|
|
158
|
+
export interface DateTimeOptions {
|
|
159
|
+
format?: string;
|
|
160
|
+
includeSeconds?: boolean;
|
|
161
|
+
includeMilliseconds: boolean;
|
|
162
|
+
}
|
|
163
|
+
type interpolatedRoute = string;
|
|
164
|
+
interface BaseAdditional<T = any> {
|
|
165
|
+
link? : {
|
|
166
|
+
base?: string;
|
|
167
|
+
urlKey?: string;
|
|
168
|
+
target?: Target;
|
|
169
|
+
useRouterLink?: boolean;
|
|
170
|
+
/**
|
|
171
|
+
* If you want to use a route with interpolated params, you can use this. Wrap the property name in curly braces.
|
|
172
|
+
* For example, if interpolatedRoute = /users/{id}/edit, {id} will be replaced with the value of the element's id property.
|
|
173
|
+
*/
|
|
174
|
+
interpolatedRoute?: interpolatedRoute | ((t: T) => string);
|
|
175
|
+
routerLinkOptions?:{
|
|
176
|
+
queryParams?: [string, interpolatedRoute | ((t: T) => string)][];
|
|
177
|
+
fragment?: string;
|
|
178
|
+
preserveFragment?: boolean;
|
|
179
|
+
queryParamsHandling?: QueryParamsHandling;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
export?: MetaDataExport<T>;
|
|
183
|
+
dateFormat?: string;
|
|
184
|
+
dateTimeOptions?: DateTimeOptions;
|
|
185
|
+
styles?: StylerStyle<T>;
|
|
186
|
+
columnPartStyles?: {
|
|
187
|
+
header?: Dictionary<string>,
|
|
188
|
+
body?: StylerStyle<T>,
|
|
189
|
+
innerBody?: StylerStyle<T>,
|
|
190
|
+
footer?: Dictionary<string>,
|
|
191
|
+
}
|
|
192
|
+
columnPartClasses?: {
|
|
193
|
+
header?: Dictionary<Predicate<T> | true>,
|
|
194
|
+
footer?: Dictionary<Predicate<T> | true>,
|
|
195
|
+
}
|
|
196
|
+
footer?: { type: any };
|
|
197
|
+
}
|
|
198
|
+
export interface Additional<T = any, V = string> extends BaseAdditional<T> {
|
|
199
|
+
filterOptions?: FilterOptions<V>;
|
|
200
|
+
footer?: { type: never };
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
interface NumberAdditional<T = any> extends BaseAdditional<T> {
|
|
204
|
+
filterOptions?: FilterOptions<number>;
|
|
205
|
+
footer?: { type: 'sum' };
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
interface EnumAdditional<T = any> extends BaseAdditional<T> {
|
|
209
|
+
filterOptions?: FilterOptions<number>;
|
|
210
|
+
enumMap?: {[key:number]:string};
|
|
211
|
+
footer?: { type: never };
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
interface BooleanAdditional<T = any> extends BaseAdditional<T> {
|
|
215
|
+
filterOptions?: FilterOptions<never>;
|
|
216
|
+
footer?: { type: never };
|
|
217
|
+
boolean? : {
|
|
218
|
+
showForFalse? : true | { icon : string },
|
|
219
|
+
forTrue? : { icon : string }
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export enum ArrayStyle {
|
|
224
|
+
CommaDelimited,
|
|
225
|
+
NewLine
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export interface ArrayAdditional<T = any> extends Additional<T> {
|
|
229
|
+
limit?: number;
|
|
230
|
+
arrayStyle?: ArrayStyle;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
interface MetaDataExport<T> extends TableBuilderExport {
|
|
234
|
+
/**
|
|
235
|
+
* This will supersede all other mappings when exporting.
|
|
236
|
+
*/
|
|
237
|
+
mapForExport?: (t: T) => string;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
export function metaDataArrToDict<T = MetaData>(arr: MetaData[], transform?: (m : MetaData) => T): Dictionary<T>{
|
|
242
|
+
const dict = {};
|
|
243
|
+
if(transform){
|
|
244
|
+
arr.forEach(e => dict[e.key] = transform(e));
|
|
245
|
+
} else {
|
|
246
|
+
arr.forEach(e => dict[e.key] = e);
|
|
247
|
+
}
|
|
248
|
+
return dict;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export interface CustomCellMeta extends Pick<MetaData, 'key' | 'displayName' | 'preSort' | 'fieldType' | 'order' | 'width'>{
|
|
252
|
+
customCell: true;
|
|
253
|
+
noExport?: boolean;
|
|
254
|
+
}
|
|
@@ -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,67 @@
|
|
|
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
|
+
import { currencyFormatter, dateFormatter } from '../services/transform-creator';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@Pipe({ name: 'formatFilterValue' })
|
|
12
|
+
export class FormatFilterValuePipe implements PipeTransform {
|
|
13
|
+
tableState = inject(TableStore);
|
|
14
|
+
private datePipe = inject(DatePipe);
|
|
15
|
+
|
|
16
|
+
transform(value: any, key: string, filterType: FilterType) {
|
|
17
|
+
return computed(() => transform(value, this.tableState.$getMetaData(key)(), filterType));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const transform = (value: any, meta: MetaData, filterType: FilterType): string => {
|
|
22
|
+
if(filterType === FilterType.IsNull) {
|
|
23
|
+
return '';
|
|
24
|
+
}
|
|
25
|
+
if(value && (filterType === FilterType.In )){
|
|
26
|
+
if(meta.fieldType === FieldType.Enum) {
|
|
27
|
+
return value.map( (v: any) => spaceCase(meta.additional!.enumMap![v])).join(', ') ?? value;
|
|
28
|
+
}
|
|
29
|
+
if(meta.fieldType === FieldType.Date || meta.fieldType === FieldType.DateTime) {
|
|
30
|
+
return value.map( (v: any) => mapDate(v, meta, filterType)).join(', ') ?? value;
|
|
31
|
+
}
|
|
32
|
+
if(meta.fieldType === FieldType.Number || meta.fieldType === FieldType.Currency) {
|
|
33
|
+
return value.map( (v: any) => mapNumber(v, meta)).join(', ') ?? value;
|
|
34
|
+
}
|
|
35
|
+
return value.join(', ') ?? value;
|
|
36
|
+
}
|
|
37
|
+
if(filterType === FilterType.NumberBetween && (meta.fieldType === FieldType.Number || meta.fieldType === FieldType.Currency)){
|
|
38
|
+
return mapNumber(value.Start, meta) + ' - ' + mapNumber(value.End, meta);
|
|
39
|
+
}
|
|
40
|
+
if(filterType === FilterType.DateBetween){
|
|
41
|
+
return mapDate(value.Start, meta, filterType) + ' - ' + mapDate(value.End, meta, filterType);
|
|
42
|
+
}
|
|
43
|
+
if(meta.fieldType === FieldType.Date || meta.fieldType === FieldType.DateTime){
|
|
44
|
+
return mapDate(value, meta, filterType);
|
|
45
|
+
}
|
|
46
|
+
if(meta.fieldType === FieldType.Currency){
|
|
47
|
+
return mapNumber(value, meta);
|
|
48
|
+
}
|
|
49
|
+
return value
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function mapDate(value: any, meta: MetaData, filterType: FilterType){
|
|
53
|
+
if(meta.fieldType === FieldType.Date){
|
|
54
|
+
return dateFormatter(value, 'shortDate');
|
|
55
|
+
}
|
|
56
|
+
if(meta.fieldType === FieldType.DateTime){
|
|
57
|
+
return (!!DateTimeFilterFuncs[filterType] ? dateFormatter(value, 'shortDate') : dateFormatter(value, 'short')) || '';
|
|
58
|
+
}
|
|
59
|
+
return value
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function mapNumber(value: any, meta: MetaData){
|
|
63
|
+
if(meta.fieldType === FieldType.Currency){
|
|
64
|
+
return currencyFormatter(value);
|
|
65
|
+
}
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
@@ -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
|
+
}
|