@zeedhi/teknisa-components-common 1.117.1 → 3.0.1
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/.package.json +43 -0
- package/dist/teknisa-components-common.js +3802 -0
- package/dist/teknisa-components-common.min.js +3802 -0
- package/dist/types/components/index.d.ts +7 -0
- package/{types → dist/types}/components/tek-breadcrumb-header/breadcrumb-header.d.ts +12 -12
- package/{types → dist/types}/components/tek-breadcrumb-header/interfaces.d.ts +6 -6
- package/dist/types/components/tek-datasource/index.d.ts +3 -0
- package/{types → dist/types}/components/tek-datasource/interfaces.d.ts +16 -16
- package/{types/components/tek-datasource/memory-datasource.d.ts → dist/types/components/tek-datasource/tek-memory-datasource.d.ts} +93 -100
- package/{types/components/tek-datasource/rest-datasource.d.ts → dist/types/components/tek-datasource/tek-rest-datasource.d.ts} +95 -103
- package/dist/types/components/tek-grid/columns-searcher.d.ts +5 -0
- package/dist/types/components/tek-grid/dynamic-filter-datasource-factory.d.ts +6 -0
- package/{types → dist/types}/components/tek-grid/filter-helper.d.ts +7 -7
- package/{types → dist/types}/components/tek-grid/grid-filter-button.d.ts +29 -31
- package/dist/types/components/tek-grid/grouped-data-manager.d.ts +82 -0
- package/dist/types/components/tek-grid/grouped-data-selector.d.ts +7 -0
- package/dist/types/components/tek-grid/grouped-view-navigator.d.ts +14 -0
- package/dist/types/components/tek-grid/index.d.ts +18 -0
- package/dist/types/components/tek-grid/interfaces.d.ts +259 -0
- package/dist/types/components/tek-grid/keymap-grouped.d.ts +6 -0
- package/{types → dist/types}/components/tek-grid/layout-options.d.ts +39 -31
- package/{types/components/tek-grid/grid-column.d.ts → dist/types/components/tek-grid/tek-grid-column.d.ts} +42 -45
- package/{types/components/tek-grid/grid-columns-button-controller.d.ts → dist/types/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button-controller.d.ts} +8 -8
- package/{types/components/tek-grid/grid-columns-button.d.ts → dist/types/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button.d.ts} +13 -12
- package/dist/types/components/tek-grid/tek-grid-controller.d.ts +31 -0
- package/dist/types/components/tek-grid/tek-grid-events.d.ts +31 -0
- package/{types/utils/grid-base → dist/types/components/tek-grid/tek-grid-toolbar-provider}/export-options/button-option.d.ts +17 -16
- package/{types/utils/grid-base → dist/types/components/tek-grid/tek-grid-toolbar-provider}/export-options/index.d.ts +3 -3
- package/dist/types/components/tek-grid/tek-grid-toolbar-provider/export-options/interfaces.d.ts +5 -0
- package/{types/utils/grid-base → dist/types/components/tek-grid/tek-grid-toolbar-provider}/export-options/multi-option.d.ts +12 -12
- package/dist/types/components/tek-grid/tek-grid-toolbar-provider/index.d.ts +2 -0
- package/dist/types/components/tek-grid/tek-grid-toolbar-provider/tek-grid-toolbar-provider.d.ts +22 -0
- package/dist/types/components/tek-grid/tek-grid.d.ts +216 -0
- package/{types → dist/types}/components/tek-user-info/TekUserInfoController.d.ts +22 -21
- package/{types → dist/types}/components/tek-user-info/interfaces.d.ts +27 -28
- package/{types → dist/types}/components/tek-user-info/tek-user-info-list.d.ts +32 -31
- package/{types → dist/types}/components/tek-user-info/tek-user-info.d.ts +37 -38
- package/{types → dist/types}/error/delete-rows-error.d.ts +6 -6
- package/dist/types/error/tek-grid-delete-rows-error.d.ts +7 -0
- package/dist/types/error/teknisa-common-error.d.ts +6 -0
- package/dist/types/index.d.ts +2 -0
- package/{types → dist/types}/utils/config/config.d.ts +7 -7
- package/dist/types/utils/index.d.ts +3 -0
- package/dist/types/utils/is-filled-object/is-filled-object.d.ts +2 -0
- package/dist/types/utils/is-nil.d.ts +1 -0
- package/environments.json +14 -0
- package/package.json +26 -18
- package/src/components/index.ts +101 -0
- package/src/components/tek-breadcrumb-header/breadcrumb-header.ts +29 -0
- package/src/components/tek-breadcrumb-header/interfaces.ts +7 -0
- package/src/components/tek-datasource/index.ts +3 -0
- package/src/components/tek-datasource/interfaces.ts +36 -0
- package/src/components/tek-datasource/tek-memory-datasource.ts +314 -0
- package/src/components/tek-datasource/tek-rest-datasource.ts +224 -0
- package/src/components/tek-grid/columns-searcher.ts +22 -0
- package/src/components/tek-grid/dynamic-filter-datasource-factory.ts +20 -0
- package/src/components/tek-grid/filter-helper.ts +20 -0
- package/src/components/tek-grid/grid-filter-button.ts +419 -0
- package/src/components/tek-grid/grouped-data-manager.ts +448 -0
- package/src/components/tek-grid/grouped-data-selector.ts +40 -0
- package/src/components/tek-grid/grouped-view-navigator.ts +84 -0
- package/src/components/tek-grid/index.ts +18 -0
- package/src/components/tek-grid/interfaces.ts +329 -0
- package/src/components/tek-grid/keymap-grouped.ts +20 -0
- package/src/components/tek-grid/layout-options.ts +248 -0
- package/src/components/tek-grid/tek-grid-column.ts +193 -0
- package/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button-controller.ts +28 -0
- package/src/components/tek-grid/tek-grid-columns-button/tek-grid-columns-button.ts +38 -0
- package/src/components/tek-grid/tek-grid-controller.ts +140 -0
- package/src/components/tek-grid/tek-grid-events.ts +105 -0
- package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/button-option.ts +26 -0
- package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/index.ts +3 -0
- package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/interfaces.ts +6 -0
- package/src/components/tek-grid/tek-grid-toolbar-provider/export-options/multi-option.ts +85 -0
- package/src/components/tek-grid/tek-grid-toolbar-provider/index.ts +2 -0
- package/src/components/tek-grid/tek-grid-toolbar-provider/tek-grid-toolbar-provider.ts +365 -0
- package/src/components/tek-grid/tek-grid.ts +1118 -0
- package/src/components/tek-user-info/TekUserInfoController.ts +87 -0
- package/src/components/tek-user-info/interfaces.ts +21 -0
- package/src/components/tek-user-info/tek-user-info-list.ts +64 -0
- package/src/components/tek-user-info/tek-user-info.ts +337 -0
- package/src/error/tek-grid-delete-rows-error.ts +15 -0
- package/src/error/teknisa-common-error.ts +8 -0
- package/src/index.ts +2 -0
- package/src/utils/config/config.ts +8 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/is-filled-object/is-filled-object.ts +5 -0
- package/src/utils/is-nil.ts +3 -0
- package/tests/__helpers__/component-event-helper.ts +1 -1
- package/tests/__helpers__/get-child-helper.ts +1 -1
- package/tests/__helpers__/mock-created-helper.ts +1 -1
- package/tests/unit/components/crud/crud-button.spec.ts +1 -1
- package/tests/unit/components/tek-datasource/memory-datasource.spec.ts +1 -11
- package/tests/unit/components/tek-datasource/rest-datasource.spec.ts +5 -7
- package/tests/unit/components/tek-drag-grid/tek-drag-grid.spec.ts +1 -1
- package/tests/unit/components/tek-grid/button-option.spec.ts +49 -0
- package/tests/unit/components/tek-grid/columns-searcher.spec.ts +112 -0
- package/tests/unit/components/tek-grid/dynamic-filter-datasource-factory.spec.ts +90 -0
- package/tests/unit/components/tek-grid/filter-helper.spec.ts +34 -130
- package/tests/unit/components/tek-grid/grid-filter-button.spec.ts +114 -239
- package/tests/unit/components/tek-grid/grouped-data-manager.spec.ts +593 -0
- package/tests/unit/components/tek-grid/grouped-data-selector.spec.ts +136 -0
- package/tests/unit/components/tek-grid/grouped-view-navigator.spec.ts +244 -0
- package/tests/unit/components/tek-grid/keymap-grouped.spec.ts +20 -0
- package/tests/unit/components/tek-grid/{layout_options.spec.ts → layout-options.spec.ts} +70 -30
- package/tests/unit/components/tek-grid/multi-option.spec.ts +139 -0
- package/tests/unit/components/tek-grid/{grid-column.spec.ts → tek-grid-column.spec.ts} +44 -2
- package/tests/unit/components/tek-grid/{grid-columns-button.spec.ts → tek-grid-columns-button.spec.ts} +42 -9
- package/tests/unit/components/tek-grid/tek-grid-controller.spec.ts +253 -0
- package/tests/unit/components/tek-grid/tek-grid-events.spec.ts +186 -0
- package/tests/unit/components/tek-grid/tek-grid-toolbar-provider.spec.ts +34 -0
- package/tests/unit/components/tek-grid/tek-grid.spec.ts +895 -0
- package/tests/unit/components/tek-grid/tek-memory-datasource.spec.ts +482 -0
- package/tests/unit/components/tek-grid/tek-rest-datasource.spec.ts +422 -0
- package/tests/unit/components/tek-user-info/tek-user-info-list.spec.ts +1 -1
- package/tests/unit/components/tek-user-info/tek-user-info.spec.ts +10 -14
- package/tests/unit/components/tree-grid/tree-grid.spec.ts +4 -28
- package/tests/unit/utils/grid-base/export-options/multi-option.spec.ts +2 -2
- package/tests/unit/utils/grid-base/grid-controller.spec.ts +17 -152
- package/tsconfig.build.json +7 -0
- package/coverage/clover.xml +0 -2007
- package/coverage/coverage-final.json +0 -48
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -431
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -210
- package/coverage/lcov-report/tests/__helpers__/component-event-helper.ts.html +0 -100
- package/coverage/lcov-report/tests/__helpers__/flush-promises-helper.ts.html +0 -94
- package/coverage/lcov-report/tests/__helpers__/get-child-helper.ts.html +0 -166
- package/coverage/lcov-report/tests/__helpers__/index.html +0 -176
- package/coverage/lcov-report/tests/__helpers__/index.ts.html +0 -94
- package/coverage/lcov-report/tests/__helpers__/mock-created-helper.ts.html +0 -121
- package/coverage/lcov.info +0 -3885
- package/dist/tek-components-common.esm.js +0 -4833
- package/dist/tek-components-common.umd.js +0 -4870
- package/tests/unit/components/tek-grid/grid.spec.ts +0 -3377
- package/tests/unit/utils/grid-base/delete-rows-error.spec.ts +0 -24
- package/types/components/crud/crud-add-button.d.ts +0 -38
- package/types/components/crud/crud-button.d.ts +0 -27
- package/types/components/crud/crud-cancel-button.d.ts +0 -28
- package/types/components/crud/crud-delete-button.d.ts +0 -42
- package/types/components/crud/crud-form.d.ts +0 -46
- package/types/components/crud/crud-save-button.d.ts +0 -24
- package/types/components/crud/interfaces.d.ts +0 -15
- package/types/components/index.d.ts +0 -41
- package/types/components/tek-card-title/card-title.d.ts +0 -14
- package/types/components/tek-card-title/interfaces.d.ts +0 -9
- package/types/components/tek-drag-grid/interfaces.d.ts +0 -7
- package/types/components/tek-drag-grid/tek-drag-grid.d.ts +0 -36
- package/types/components/tek-grid/grid.d.ts +0 -267
- package/types/components/tek-grid/interfaces.d.ts +0 -203
- package/types/components/tek-image/image.d.ts +0 -55
- package/types/components/tek-image/interfaces.d.ts +0 -12
- package/types/components/tek-iterable-carousel/interfaces.d.ts +0 -5
- package/types/components/tek-iterable-carousel/iterable-carousel.d.ts +0 -13
- package/types/components/tek-iterable-component-render/interfaces.d.ts +0 -3
- package/types/components/tek-iterable-component-render/iterable-component-render.d.ts +0 -10
- package/types/components/tek-loading/interfaces.d.ts +0 -6
- package/types/components/tek-loading/loading.d.ts +0 -24
- package/types/components/tek-notifications/interfaces.d.ts +0 -22
- package/types/components/tek-notifications/notifications.d.ts +0 -35
- package/types/components/tek-product-card/interfaces.d.ts +0 -19
- package/types/components/tek-product-card/product-card.d.ts +0 -66
- package/types/components/tek-tree-grid/interfaces.d.ts +0 -30
- package/types/components/tek-tree-grid/tree-grid.d.ts +0 -102
- package/types/error/incomplete-groups-error.d.ts +0 -8
- package/types/index.d.ts +0 -2
- package/types/utils/extract-properties.d.ts +0 -7
- package/types/utils/grid-base/export-options/interfaces.d.ts +0 -5
- package/types/utils/grid-base/grid-base.d.ts +0 -59
- package/types/utils/grid-base/grid-controller.d.ts +0 -27
- package/types/utils/index.d.ts +0 -6
- package/types/utils/report-filter/report-filter.d.ts +0 -12
package/package.json
CHANGED
|
@@ -1,36 +1,44 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeedhi/teknisa-components-common",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Teknisa Components Common",
|
|
5
5
|
"author": "Zeedhi <zeedhi@teknisa.com>",
|
|
6
6
|
"license": "ISC",
|
|
7
|
-
"main": "
|
|
8
|
-
"
|
|
9
|
-
"
|
|
7
|
+
"main": "src/index.ts",
|
|
8
|
+
"types": "dist/types/index.d.ts",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"module": "dist/teknisa-components-common.js",
|
|
11
|
+
"packageManager": "npm@8.19.2",
|
|
10
12
|
"publishConfig": {
|
|
11
13
|
"access": "public"
|
|
12
14
|
},
|
|
13
15
|
"scripts": {
|
|
14
16
|
"build": "rollup -c",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"watch": "npm run build -- -w"
|
|
17
|
+
"clean": "rm -rf ./dist",
|
|
18
|
+
"test": "jest --verbose=false",
|
|
19
|
+
"watch": "rollup -cw"
|
|
19
20
|
},
|
|
20
21
|
"dependencies": {
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"lodash.
|
|
24
|
-
"lodash.get": "4.4.*",
|
|
25
|
-
"lodash.merge": "4.6.*"
|
|
22
|
+
"lodash.debounce": "^4.0.8",
|
|
23
|
+
"lodash.get": "^4.4.2",
|
|
24
|
+
"lodash.merge": "^4.6.2"
|
|
26
25
|
},
|
|
27
26
|
"devDependencies": {
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
-
"@
|
|
27
|
+
"@rollup/plugin-commonjs": "^24.0.1",
|
|
28
|
+
"@rollup/plugin-json": "^6.0.0",
|
|
29
|
+
"@rollup/plugin-typescript": "^11.1.1",
|
|
30
|
+
"@types/lodash.debounce": "^4.0.7",
|
|
31
|
+
"@types/lodash.get": "^4.4.7",
|
|
32
|
+
"@types/lodash.merge": "^4.6.7",
|
|
33
|
+
"@zeedhi/common": "^3.0.0",
|
|
34
|
+
"@zeedhi/core": "^3.0.0"
|
|
31
35
|
},
|
|
32
36
|
"peerDependencies": {
|
|
33
|
-
"@zeedhi/
|
|
37
|
+
"@zeedhi/common": "^3.0.0",
|
|
38
|
+
"@zeedhi/core": "^3.0.0"
|
|
34
39
|
},
|
|
35
|
-
"
|
|
40
|
+
"env": {
|
|
41
|
+
"NODE_ENV": "production"
|
|
42
|
+
},
|
|
43
|
+
"gitHead": "1c6ee6c23a7e75036a459ada909c934d00f63373"
|
|
36
44
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Messages } from '@zeedhi/core';
|
|
2
|
+
|
|
3
|
+
Messages.add({
|
|
4
|
+
'pt-BR': {
|
|
5
|
+
translation: {
|
|
6
|
+
NO_NOTIFICATIONS: 'Nenhuma Notificação',
|
|
7
|
+
MARK_ALL_AS_READ: 'Marcar todas como lidas',
|
|
8
|
+
NOTIFICATIONS: 'Notificações',
|
|
9
|
+
SEE_ALL_NOTIFICATIONS: 'Ver todas notificações',
|
|
10
|
+
UNAVAILABLE_IMAGE: 'Imagem indisponível',
|
|
11
|
+
REFRESH: 'Atualizar',
|
|
12
|
+
ACTIONS: 'Ações',
|
|
13
|
+
FILTER: 'Filtro',
|
|
14
|
+
LAYOUT: 'Layout: ',
|
|
15
|
+
NEW_LAYOUT: 'Novo layout',
|
|
16
|
+
DEFAULT_LAYOUT: 'Padrão',
|
|
17
|
+
LAYOUT_MODIFIED: 'O layout atual foi modificado. Crie um novo layout, sobrescreva um existente ou descarte as alterações', // eslint-disable-line
|
|
18
|
+
LAYOUT_NOT_MODIFIED: 'Crie um novo layout ou aplique um dos layouts já existentes',
|
|
19
|
+
LAYOUT_DISCART_CHANGES: 'Descartar alterações',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
'en-US': {
|
|
23
|
+
translation: {
|
|
24
|
+
NO_NOTIFICATIONS: 'No Notifications',
|
|
25
|
+
MARK_ALL_AS_READ: 'Mark all as read',
|
|
26
|
+
NOTIFICATIONS: 'Notifications',
|
|
27
|
+
SEE_ALL_NOTIFICATIONS: 'See all notifications',
|
|
28
|
+
UNAVAILABLE_IMAGE: 'Unavailable image',
|
|
29
|
+
REFRESH: 'Refresh',
|
|
30
|
+
ACTIONS: 'Actions',
|
|
31
|
+
FILTER: 'Filter',
|
|
32
|
+
LAYOUT: 'Layout: ',
|
|
33
|
+
NEW_LAYOUT: 'New layout',
|
|
34
|
+
DEFAULT_LAYOUT: 'Default',
|
|
35
|
+
LAYOUT_MODIFIED: 'The current layout has been modified. Create a new layout, overwrite an existing one or discard changes', // eslint-disable-line
|
|
36
|
+
LAYOUT_NOT_MODIFIED: 'Create a new layout or apply one of the existing layouts',
|
|
37
|
+
LAYOUT_DISCART_CHANGES: 'Discard changes',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
'es-CL': {
|
|
41
|
+
translation: {
|
|
42
|
+
NO_NOTIFICATIONS: 'Sin Notificación',
|
|
43
|
+
MARK_ALL_AS_READ: 'Marcar todo como leído',
|
|
44
|
+
NOTIFICATIONS: 'Notificaciones',
|
|
45
|
+
SEE_ALL_NOTIFICATIONS: 'Ver todas las notificaciones',
|
|
46
|
+
UNAVAILABLE_IMAGE: 'Imagen no disponible',
|
|
47
|
+
REFRESH: 'Actualizar',
|
|
48
|
+
ACTIONS: 'Acciones',
|
|
49
|
+
FILTER: 'Filtro',
|
|
50
|
+
LAYOUT: 'Disposición: ',
|
|
51
|
+
NEW_LAYOUT: 'Nueva disposición',
|
|
52
|
+
DEFAULT_LAYOUT: 'Default',
|
|
53
|
+
LAYOUT_MODIFIED: 'La disposición actual ha sido modificada. Cree una nueva disposición, sobrescriba una existente o descarte los cambios', // eslint-disable-line
|
|
54
|
+
LAYOUT_NOT_MODIFIED: 'Cree una nueva disposición o aplique una de las disposiciones existentes',
|
|
55
|
+
LAYOUT_DISCART_CHANGES: 'Descartar los cambios',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// export * from './crud/crud-form';
|
|
61
|
+
// export * from './crud/crud-button';
|
|
62
|
+
// export * from './crud/crud-add-button';
|
|
63
|
+
// export * from './crud/crud-cancel-button';
|
|
64
|
+
// export * from './crud/crud-delete-button';
|
|
65
|
+
// export * from './crud/crud-save-button';
|
|
66
|
+
// export * from './crud/interfaces';
|
|
67
|
+
|
|
68
|
+
export * from './tek-breadcrumb-header/breadcrumb-header';
|
|
69
|
+
export * from './tek-breadcrumb-header/interfaces';
|
|
70
|
+
|
|
71
|
+
// export * from './tek-card-title/card-title';
|
|
72
|
+
// export * from './tek-card-title/interfaces';
|
|
73
|
+
|
|
74
|
+
// export * from './tek-image/image';
|
|
75
|
+
// export * from './tek-image/interfaces';
|
|
76
|
+
|
|
77
|
+
// export * from './tek-product-card/product-card';
|
|
78
|
+
// export * from './tek-product-card/interfaces';
|
|
79
|
+
|
|
80
|
+
// export * from './tek-iterable-component-render/iterable-component-render';
|
|
81
|
+
// export * from './tek-iterable-component-render/interfaces';
|
|
82
|
+
|
|
83
|
+
// export * from './tek-iterable-carousel/iterable-carousel';
|
|
84
|
+
// export * from './tek-iterable-carousel/interfaces';
|
|
85
|
+
|
|
86
|
+
// export * from './tek-loading/loading';
|
|
87
|
+
// export * from './tek-loading/interfaces';
|
|
88
|
+
|
|
89
|
+
// export * from './tek-notifications/notifications';
|
|
90
|
+
// export * from './tek-notifications/interfaces';
|
|
91
|
+
|
|
92
|
+
export * from './tek-grid';
|
|
93
|
+
|
|
94
|
+
export * from './tek-datasource';
|
|
95
|
+
|
|
96
|
+
// export * from './tek-tree-grid/interfaces';
|
|
97
|
+
// export * from './tek-tree-grid/tree-grid';
|
|
98
|
+
|
|
99
|
+
export * from './tek-user-info/interfaces';
|
|
100
|
+
export * from './tek-user-info/tek-user-info';
|
|
101
|
+
export * from './tek-user-info/tek-user-info-list';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type IBreadcrumbs, ComponentRender, type IComponentRender } from '@zeedhi/common';
|
|
2
|
+
import type { IBreadcrumbHeader } from './interfaces';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* BreadcrumbHeader join breadcrumb and title
|
|
6
|
+
*/
|
|
7
|
+
export class BreadcrumbHeader extends ComponentRender implements IBreadcrumbHeader {
|
|
8
|
+
public breadcrumb: IBreadcrumbs;
|
|
9
|
+
|
|
10
|
+
public title = '';
|
|
11
|
+
|
|
12
|
+
public rightSlot: IComponentRender[] = [];
|
|
13
|
+
|
|
14
|
+
public constructor(props: IBreadcrumbHeader) {
|
|
15
|
+
super(props);
|
|
16
|
+
this.breadcrumb = this.getBreadcrumbProperties(props.breadcrumb);
|
|
17
|
+
this.title = this.getInitValue('title', props.title, this.title);
|
|
18
|
+
this.rightSlot = props.rightSlot || this.rightSlot;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private getBreadcrumbProperties(breadcrumb: any): IBreadcrumbs {
|
|
22
|
+
return {
|
|
23
|
+
...breadcrumb,
|
|
24
|
+
name: breadcrumb.name,
|
|
25
|
+
component: 'ZdBreadcrumb',
|
|
26
|
+
divider: '>',
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IDictionary, IMemoryDatasource, IRestDatasource } from '@zeedhi/core';
|
|
2
|
+
|
|
3
|
+
export interface ITekMemoryDatasource extends IMemoryDatasource {
|
|
4
|
+
dynamicFilter?: IDictionary<any>;
|
|
5
|
+
searchJoin?: IDictionary<Array<string | number>>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ITekRestDatasource extends IRestDatasource {
|
|
9
|
+
dynamicFilter?: IDictionary<any>;
|
|
10
|
+
searchJoin?: IDictionary<Array<string | number>>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface IDynamicFilterItem {
|
|
14
|
+
relation: string;
|
|
15
|
+
operation: string;
|
|
16
|
+
value: any;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export const DynamicFilterOperations: IDictionary<boolean> = {
|
|
20
|
+
CONTAINS: true,
|
|
21
|
+
NOT_CONTAINS: true,
|
|
22
|
+
EQUALS: true,
|
|
23
|
+
NOT_EQUALS: true,
|
|
24
|
+
GREATER_THAN: true,
|
|
25
|
+
LESS_THAN: true,
|
|
26
|
+
GREATER_THAN_EQUALS: true,
|
|
27
|
+
LESS_THAN_EQUALS: true,
|
|
28
|
+
IN: true,
|
|
29
|
+
NOT_IN: true,
|
|
30
|
+
BETWEEN: true,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const DynamicFilterRelations: IDictionary<boolean> = {
|
|
34
|
+
AND: true,
|
|
35
|
+
OR: true,
|
|
36
|
+
};
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { DatasourceFactory, IDatasource, IDictionary, MemoryDatasource, URL, Utils } from '@zeedhi/core';
|
|
2
|
+
import {
|
|
3
|
+
DynamicFilterOperations,
|
|
4
|
+
DynamicFilterRelations,
|
|
5
|
+
IDynamicFilterItem,
|
|
6
|
+
ITekMemoryDatasource,
|
|
7
|
+
} from './interfaces';
|
|
8
|
+
|
|
9
|
+
export class TekMemoryDatasource extends MemoryDatasource implements ITekMemoryDatasource {
|
|
10
|
+
/** Dynamic filter data */
|
|
11
|
+
public dynamicFilter!: IDictionary<IDynamicFilterItem[]>;
|
|
12
|
+
|
|
13
|
+
/** Search Join data */
|
|
14
|
+
public searchJoin!: IDictionary<Array<string | number>>;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Dynamic Filter Operations
|
|
18
|
+
*/
|
|
19
|
+
public dynamicFilterOperations = DynamicFilterOperations;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Dynamic Filter Relations
|
|
23
|
+
*/
|
|
24
|
+
public dynamicFilterRelations = DynamicFilterRelations;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Dynamic Filter applied flag
|
|
28
|
+
*/
|
|
29
|
+
protected dynamicFilterApplied = '';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Create new datasource
|
|
33
|
+
* @param props Datasource properties
|
|
34
|
+
*/
|
|
35
|
+
constructor(props: ITekMemoryDatasource) {
|
|
36
|
+
super(props);
|
|
37
|
+
|
|
38
|
+
if (!this.watchUrl) {
|
|
39
|
+
this.dynamicFilter = this.getInitValue('dynamicFilter', props.dynamicFilter, {});
|
|
40
|
+
this.searchJoin = this.getInitValue('searchJoin', props.searchJoin, {});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this.createAccessors();
|
|
44
|
+
this.createObjAccessors(this.dynamicFilter, 'dynamicFilter');
|
|
45
|
+
this.createObjAccessors(this.searchJoin, 'searchJoin');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
protected updateReservedKeys() {
|
|
49
|
+
this.reservedKeys.dynamic_filter = true;
|
|
50
|
+
this.reservedKeys.search_join = true;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
protected updateInternalProperties(datasource: IDatasource = {}) {
|
|
54
|
+
if (!this.watchUrl) return;
|
|
55
|
+
this.updateReservedKeys();
|
|
56
|
+
super.updateInternalProperties(datasource);
|
|
57
|
+
const queryString = URL.getParsedQueryStringFromUrl();
|
|
58
|
+
this.dynamicFilter = this.getEncodedParam(queryString.dynamic_filter, datasource.dynamicFilter);
|
|
59
|
+
this.searchJoin = this.getEncodedParam(queryString.search_join, datasource.searchJoin);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
protected getEncodedParam(urlParam: string, datasourceParam: IDictionary<any> = {}): IDictionary<any> {
|
|
63
|
+
return urlParam ? JSON.parse(atob(urlParam)) : datasourceParam;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
protected getQueryStringValues(): IDictionary<any> {
|
|
67
|
+
const values = super.getQueryStringValues();
|
|
68
|
+
if (this.dynamicFilter && Object.keys(this.dynamicFilter).length) {
|
|
69
|
+
values.dynamic_filter = btoa(JSON.stringify(this.dynamicFilter));
|
|
70
|
+
}
|
|
71
|
+
if (this.searchJoin && Object.keys(this.searchJoin).length) {
|
|
72
|
+
values.search_join = btoa(JSON.stringify(this.searchJoin));
|
|
73
|
+
}
|
|
74
|
+
return values;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
protected getUrlQueryString() {
|
|
78
|
+
const superQueryString = super.getUrlQueryString();
|
|
79
|
+
const query = URL.getParsedQueryStringFromUrl();
|
|
80
|
+
|
|
81
|
+
let dynamicFilterQuerystring = '';
|
|
82
|
+
if (query.dynamic_filter) {
|
|
83
|
+
dynamicFilterQuerystring = `&${URL.getFormattedQueryString({
|
|
84
|
+
dynamic_filter: query.dynamic_filter,
|
|
85
|
+
})}`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let searchJoinQuerystring = '';
|
|
89
|
+
if (query.search_join) {
|
|
90
|
+
searchJoinQuerystring = `&${URL.getFormattedQueryString({
|
|
91
|
+
search_join: query.search_join,
|
|
92
|
+
})}`;
|
|
93
|
+
}
|
|
94
|
+
return superQueryString + dynamicFilterQuerystring + searchJoinQuerystring;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Adds a new dynamic filter position or replace if exists
|
|
99
|
+
* @param column Dynamic Filter column name
|
|
100
|
+
* @param value Dynamic Filter value
|
|
101
|
+
* @returns Promise with data collection
|
|
102
|
+
*/
|
|
103
|
+
public addDynamicFilter(column: string, value: any) {
|
|
104
|
+
if (this.isValidDynamicFilterValue(column, value)) {
|
|
105
|
+
this.dynamicFilter[column] = value;
|
|
106
|
+
return this.updateDynamicFilter();
|
|
107
|
+
}
|
|
108
|
+
return this.removeDynamicFilter(column);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Removes a dynamic filter position
|
|
113
|
+
* @param column Dynamic Filter column name
|
|
114
|
+
* @returns Promise with data collection
|
|
115
|
+
*/
|
|
116
|
+
public removeDynamicFilter(column: string) {
|
|
117
|
+
delete this.dynamicFilter[column];
|
|
118
|
+
return this.updateDynamicFilter();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Sets new dynamic filter value
|
|
123
|
+
* @param filter Dynamic Filter value
|
|
124
|
+
* @returns Promise with data collection
|
|
125
|
+
*/
|
|
126
|
+
public setDynamicFilter(filter: IDictionary<any>) {
|
|
127
|
+
this.dynamicFilter = {};
|
|
128
|
+
Object.keys(filter).forEach((column: string) => {
|
|
129
|
+
if (this.isValidDynamicFilterValue(column, filter[column])) {
|
|
130
|
+
this.dynamicFilter[column] = filter[column];
|
|
131
|
+
} else {
|
|
132
|
+
delete this.dynamicFilter[column];
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
return this.updateDynamicFilter();
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Clears Dynamic filter value
|
|
140
|
+
* @returns Promise with data collection
|
|
141
|
+
*/
|
|
142
|
+
public clearDynamicFilter() {
|
|
143
|
+
this.dynamicFilter = {};
|
|
144
|
+
return this.updateDynamicFilter();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Resets page and selected rows and tries to update the url
|
|
149
|
+
* @returns Promise with data collection
|
|
150
|
+
*/
|
|
151
|
+
public async updateDynamicFilter() {
|
|
152
|
+
this.page = this.firstPage;
|
|
153
|
+
this.selectedRows = [];
|
|
154
|
+
this.visibleSelectedRows = [];
|
|
155
|
+
if (this.watchUrl) {
|
|
156
|
+
if (this.dynamicFilter && Object.keys(this.dynamicFilter).length) {
|
|
157
|
+
URL.updateQueryString({
|
|
158
|
+
dynamic_filter: btoa(JSON.stringify(this.dynamicFilter)),
|
|
159
|
+
});
|
|
160
|
+
} else {
|
|
161
|
+
URL.updateQueryString({
|
|
162
|
+
dynamic_filter: undefined,
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return this.get();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Checks if a filter value is valid
|
|
171
|
+
* @param value Filter value
|
|
172
|
+
* @returns Is valid filter value
|
|
173
|
+
*/
|
|
174
|
+
protected isValidDynamicFilterValue(column: string, value?: IDictionary<any>[]) {
|
|
175
|
+
return (
|
|
176
|
+
!this.reservedKeys[column] &&
|
|
177
|
+
value &&
|
|
178
|
+
value.length > 0 &&
|
|
179
|
+
value.every(
|
|
180
|
+
(filterValue) =>
|
|
181
|
+
this.dynamicFilterOperations[filterValue.operation] &&
|
|
182
|
+
this.dynamicFilterRelations[filterValue.relation] &&
|
|
183
|
+
filterValue.value !== '' &&
|
|
184
|
+
filterValue.value !== null,
|
|
185
|
+
)
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
public clone() {
|
|
190
|
+
return {
|
|
191
|
+
...super.clone(),
|
|
192
|
+
dynamicFilter: this.dynamicFilter,
|
|
193
|
+
searchJoin: this.searchJoin,
|
|
194
|
+
type: 'tek-memory',
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Updates filtered data
|
|
200
|
+
*/
|
|
201
|
+
protected updateFilteredData() {
|
|
202
|
+
// first apply filters (simple and dynamic)
|
|
203
|
+
this.filteredData = Object.keys(this.filter).length
|
|
204
|
+
? this.allData.filter((row) => this.getRowByFilter(row))
|
|
205
|
+
: Array.from(this.allData);
|
|
206
|
+
|
|
207
|
+
if (this.dynamicFilter && Object.keys(this.dynamicFilter).length) {
|
|
208
|
+
this.filteredData = this.filteredData.filter((row) => this.getRowByDynamicFilter(row));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const searchWithoutSearchJoin = (row: IDictionary<any>) => {
|
|
212
|
+
const searchRow = { ...row };
|
|
213
|
+
if (this.searchJoin) {
|
|
214
|
+
// do not search on columns with searchJoin
|
|
215
|
+
Object.keys(this.searchJoin).forEach((key) => delete searchRow[key]);
|
|
216
|
+
}
|
|
217
|
+
return this.getRowBySearch(searchRow);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
// only after do the search
|
|
221
|
+
const searchData = this.search ? this.filteredData.filter(searchWithoutSearchJoin) : this.filteredData;
|
|
222
|
+
|
|
223
|
+
let searchIds = searchData.map((row) => row[this.uniqueKey]);
|
|
224
|
+
|
|
225
|
+
if (this.searchJoin && Object.keys(this.searchJoin).length) {
|
|
226
|
+
const searchJoinData = this.filteredData.filter((row) => this.getRowBySearchJoin(row));
|
|
227
|
+
|
|
228
|
+
// get the ids from search and searchJoin
|
|
229
|
+
searchIds = searchIds.concat(searchJoinData.map((row) => row[this.uniqueKey])).sort();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// filter filteredData using searchIds
|
|
233
|
+
this.filteredData = this.allData.filter((row) => searchIds.indexOf(row[this.uniqueKey]) !== -1);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
protected getRowByDynamicFilter(row: IDictionary<any>) {
|
|
237
|
+
let filtered: any;
|
|
238
|
+
try {
|
|
239
|
+
Object.keys(this.dynamicFilter).forEach((key) => {
|
|
240
|
+
const filterItems = this.dynamicFilter[key];
|
|
241
|
+
filterItems.forEach((item) => {
|
|
242
|
+
if (filtered === false && item.relation === 'AND') return;
|
|
243
|
+
if (filtered === true && item.relation === 'OR') return;
|
|
244
|
+
|
|
245
|
+
const columnValue = Utils.normalize(row[key].toString());
|
|
246
|
+
let value: string | string[] = '';
|
|
247
|
+
if (Array.isArray(item.value)) {
|
|
248
|
+
value = item.value.map((val: string) => Utils.normalize(val.toString()));
|
|
249
|
+
|
|
250
|
+
switch (item.operation) {
|
|
251
|
+
case 'IN':
|
|
252
|
+
filtered = value.includes(columnValue);
|
|
253
|
+
break;
|
|
254
|
+
case 'NOT_IN':
|
|
255
|
+
filtered = !value.includes(columnValue);
|
|
256
|
+
break;
|
|
257
|
+
case 'BETWEEN':
|
|
258
|
+
filtered =
|
|
259
|
+
(Number(columnValue) || columnValue) >= (Number(value[0]) || value[0]) &&
|
|
260
|
+
(Number(columnValue) || columnValue) <= (Number(value[1]) || value[1]);
|
|
261
|
+
break;
|
|
262
|
+
default:
|
|
263
|
+
break;
|
|
264
|
+
}
|
|
265
|
+
} else {
|
|
266
|
+
value = Utils.normalize(item.value.toString());
|
|
267
|
+
|
|
268
|
+
switch (item.operation) {
|
|
269
|
+
case 'CONTAINS':
|
|
270
|
+
filtered = columnValue.indexOf(value) !== -1;
|
|
271
|
+
break;
|
|
272
|
+
case 'NOT_CONTAINS':
|
|
273
|
+
filtered = columnValue.indexOf(value) === -1;
|
|
274
|
+
break;
|
|
275
|
+
case 'EQUALS':
|
|
276
|
+
filtered = columnValue === value;
|
|
277
|
+
break;
|
|
278
|
+
case 'NOT_EQUALS':
|
|
279
|
+
filtered = columnValue !== value;
|
|
280
|
+
break;
|
|
281
|
+
case 'GREATER_THAN':
|
|
282
|
+
filtered = (Number(columnValue) || columnValue) > (Number(value) || value);
|
|
283
|
+
break;
|
|
284
|
+
case 'LESS_THAN':
|
|
285
|
+
filtered = (Number(columnValue) || columnValue) < (Number(value) || value);
|
|
286
|
+
break;
|
|
287
|
+
case 'GREATER_THAN_EQUALS':
|
|
288
|
+
filtered = (Number(columnValue) || columnValue) >= (Number(value) || value);
|
|
289
|
+
break;
|
|
290
|
+
case 'LESS_THAN_EQUALS':
|
|
291
|
+
filtered = (Number(columnValue) || columnValue) <= (Number(value) || value);
|
|
292
|
+
break;
|
|
293
|
+
default:
|
|
294
|
+
break;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
});
|
|
299
|
+
} catch {
|
|
300
|
+
// do nothing
|
|
301
|
+
}
|
|
302
|
+
return filtered;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
protected getRowBySearchJoin(row: IDictionary<any>) {
|
|
306
|
+
return Object.keys(this.searchJoin).some((key) => this.searchJoin[key].includes(row[key]));
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
public hasFilter(columnName: string): boolean {
|
|
310
|
+
return this.dynamicFilter[columnName] && this.dynamicFilter[columnName].length > 0;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
DatasourceFactory.register('tek-memory', TekMemoryDatasource);
|