@revolist/revogrid 3.2.0 → 3.2.4
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/dist/revo-grid/_baseIteratee-af30b221.js +2070 -0
- package/dist/{collection/global/global.js → revo-grid/app-globals-7e6866ba.js} +11 -2
- package/dist/{collection/components/data/columnService.js → revo-grid/columnService-91e552ba.js} +11 -6
- package/dist/revo-grid/consts-ef824e6f.js +46 -0
- package/dist/revo-grid/css-shim-5387c708.js +7 -0
- package/dist/revo-grid/data.store-3263fff9.js +557 -0
- package/dist/revo-grid/debounce-aaa4b4da.js +217 -0
- package/dist/revo-grid/dimension.helpers-a7944fc4.js +340 -0
- package/dist/{collection/plugins/dispatcher.js → revo-grid/dispatcher-891af82e.js} +7 -2
- package/dist/{cjs/dom-c8b6d1a7.js → revo-grid/dom-21bd1807.js} +4 -3
- package/dist/revo-grid/each-0378e5a3.js +180 -0
- package/dist/{collection/plugins/filter/filter.button.js → revo-grid/filter.button-74c1cd9c.js} +16 -10
- package/dist/revo-grid/identity-c8c7d3d8.js +26 -0
- package/dist/revo-grid/index-8a604c17.js +3067 -0
- package/dist/revo-grid/index.esm.js +3 -0
- package/dist/revo-grid/isString-a51066b5.js +34 -0
- package/dist/revo-grid/isSymbol-e4b5dafe.js +247 -0
- package/dist/revo-grid/keyCodes.utils-bd06e3ba.js +299 -0
- package/dist/revo-grid/keys-70b7c240.js +561 -0
- package/dist/{collection/services/localScrollService.js → revo-grid/localScrollService-e9b73323.js} +8 -2
- package/dist/{esm/revo-grid_11.entry.js → revo-grid/lodash-a0ab4cdd.js} +13773 -24835
- package/dist/{cjs/resize-observer-8dc80084.js → revo-grid/resize-observer-00c48d78.js} +25 -14
- package/dist/revo-grid/revo-grid.entry.js +3484 -0
- package/dist/revo-grid/revo-grid.esm.js +133 -1
- package/dist/revo-grid/revogr-clipboard.entry.js +52 -1
- package/dist/revo-grid/revogr-data.entry.js +152 -0
- package/dist/revo-grid/revogr-edit.entry.js +105 -0
- package/dist/revo-grid/revogr-filter-panel.entry.js +277 -1
- package/dist/revo-grid/revogr-focus.entry.js +41 -0
- package/dist/revo-grid/revogr-header.entry.js +560 -0
- package/dist/revo-grid/revogr-order-editor.entry.js +175 -0
- package/dist/revo-grid/revogr-overlay-selection.entry.js +711 -0
- package/dist/revo-grid/revogr-row-headers.entry.js +73 -0
- package/dist/revo-grid/revogr-scroll-virtual.entry.js +114 -0
- package/dist/revo-grid/revogr-temp-range.entry.js +73 -0
- package/dist/revo-grid/revogr-viewport-scroll.entry.js +340 -0
- package/dist/revo-grid/selection.store.connector-2b613fd0.js +503 -0
- package/dist/{collection/components/overlay/selection.utils.js → revo-grid/selection.utils-a9932db6.js} +15 -9
- package/dist/revo-grid/shadow-css-602a09db.js +390 -0
- package/dist/{collection/themeManager/themeService.js → revo-grid/themeService-ddaaa364.js} +26 -6
- package/dist/revo-grid/toInteger-9e6cbfd2.js +107 -0
- package/dist/revo-grid/toNumber-913b0b72.js +105 -0
- package/dist/{collection/utils/utils.js → revo-grid/utils-2c3b3857.js} +13 -8
- package/dist/revo-grid/viewport.helpers-49d3f031.js +16 -0
- package/dist/{collection/store/viewPort/viewport.helpers.js → revo-grid/viewport.store-ffaaab6d.js} +135 -9
- package/dist/types/components.d.ts +100 -56
- package/dist/types/stencil-public-runtime.d.ts +189 -186
- package/package.json +22 -20
- package/custom-element/index.js +0 -29210
- package/custom-element/resize-observer.js +0 -489
- package/dist/cjs/css-shim-e33df79c.js +0 -6
- package/dist/cjs/debounce-e9b040d9.js +0 -575
- package/dist/cjs/index-d3f67f2e.js +0 -1729
- package/dist/cjs/index.cjs.js +0 -2
- package/dist/cjs/loader.cjs.js +0 -35
- package/dist/cjs/revo-grid.cjs.js +0 -73
- package/dist/cjs/revo-grid_11.cjs.entry.js +0 -28294
- package/dist/cjs/revogr-clipboard.cjs.entry.js +0 -53
- package/dist/cjs/revogr-filter-panel.cjs.entry.js +0 -275
- package/dist/collection/collection-manifest.json +0 -25
- package/dist/collection/components/button/button.js +0 -4
- package/dist/collection/components/clipboard/revogr-clipboard.js +0 -121
- package/dist/collection/components/data/cellRenderer.js +0 -24
- package/dist/collection/components/data/revogr-data-style.css +0 -135
- package/dist/collection/components/data/revogr-data.js +0 -322
- package/dist/collection/components/data/rowRenderer.js +0 -6
- package/dist/collection/components/header/headerCellRenderer.js +0 -26
- package/dist/collection/components/header/headerRenderer.js +0 -45
- package/dist/collection/components/header/revogr-header-style.css +0 -198
- package/dist/collection/components/header/revogr-header.js +0 -297
- package/dist/collection/components/order/orderRenderer.js +0 -50
- package/dist/collection/components/order/revogr-order-editor.js +0 -358
- package/dist/collection/components/order/rowOrderService.js +0 -68
- package/dist/collection/components/overlay/autofill.service.js +0 -182
- package/dist/collection/components/overlay/clipboard.service.js +0 -39
- package/dist/collection/components/overlay/editors/edit.utils.js +0 -5
- package/dist/collection/components/overlay/editors/text.js +0 -35
- package/dist/collection/components/overlay/keyboard.service.js +0 -128
- package/dist/collection/components/overlay/revogr-edit-style.css +0 -86
- package/dist/collection/components/overlay/revogr-edit.js +0 -159
- package/dist/collection/components/overlay/revogr-overlay-selection.js +0 -726
- package/dist/collection/components/overlay/revogr-overlay-style.css +0 -98
- package/dist/collection/components/revo-grid/revo-grid-style.css +0 -544
- package/dist/collection/components/revo-grid/revo-grid.js +0 -2224
- package/dist/collection/components/revo-grid/viewport.helpers.js +0 -11
- package/dist/collection/components/revo-grid/viewport.interfaces.js +0 -1
- package/dist/collection/components/revo-grid/viewport.js +0 -18
- package/dist/collection/components/revo-grid/viewport.resize.service.js +0 -21
- package/dist/collection/components/revo-grid/viewport.scrolling.service.js +0 -60
- package/dist/collection/components/revo-grid/viewport.section.js +0 -28
- package/dist/collection/components/revo-grid/viewport.service.js +0 -209
- package/dist/collection/components/rowHeaders/revogr-row-headers.js +0 -210
- package/dist/collection/components/rowHeaders/row-header-render.js +0 -1
- package/dist/collection/components/scroll/revogr-viewport-scroll-style.css +0 -137
- package/dist/collection/components/scroll/revogr-viewport-scroll.js +0 -399
- package/dist/collection/components/scrollable/revogr-scroll-style.css +0 -104
- package/dist/collection/components/scrollable/revogr-scroll-virtual.js +0 -253
- package/dist/collection/components/selection-focus/revogr-focus-style.css +0 -77
- package/dist/collection/components/selection-focus/revogr-focus.js +0 -103
- package/dist/collection/components/selection-temp-range/revogr-temp-range-style.css +0 -98
- package/dist/collection/components/selection-temp-range/revogr-temp-range.js +0 -138
- package/dist/collection/index.js +0 -1
- package/dist/collection/plugins/autoSizeColumn.js +0 -230
- package/dist/collection/plugins/basePlugin.js +0 -27
- package/dist/collection/plugins/export/csv.js +0 -68
- package/dist/collection/plugins/export/export.plugin.js +0 -165
- package/dist/collection/plugins/export/types.js +0 -1
- package/dist/collection/plugins/filter/conditions/equal.js +0 -17
- package/dist/collection/plugins/filter/conditions/number/greaterThan.js +0 -10
- package/dist/collection/plugins/filter/conditions/number/greaterThanOrEqual.js +0 -7
- package/dist/collection/plugins/filter/conditions/number/lessThan.js +0 -12
- package/dist/collection/plugins/filter/conditions/number/lessThanOrEqual.js +0 -7
- package/dist/collection/plugins/filter/conditions/set.js +0 -3
- package/dist/collection/plugins/filter/conditions/string/beginswith.js +0 -17
- package/dist/collection/plugins/filter/conditions/string/contains.js +0 -18
- package/dist/collection/plugins/filter/filter.plugin.js +0 -256
- package/dist/collection/plugins/filter/filter.pop.js +0 -485
- package/dist/collection/plugins/filter/filter.service.js +0 -44
- package/dist/collection/plugins/filter/filter.style.css +0 -239
- package/dist/collection/plugins/filter/filter.types.js +0 -1
- package/dist/collection/plugins/groupingColumn/columnGroupsRenderer.js +0 -30
- package/dist/collection/plugins/groupingColumn/grouping.col.plugin.js +0 -36
- package/dist/collection/plugins/groupingColumn/headerGroupRenderer.js +0 -21
- package/dist/collection/plugins/groupingRow/grouping.const.js +0 -10
- package/dist/collection/plugins/groupingRow/grouping.row.expand.service.js +0 -76
- package/dist/collection/plugins/groupingRow/grouping.row.plugin.js +0 -258
- package/dist/collection/plugins/groupingRow/grouping.row.renderer.js +0 -29
- package/dist/collection/plugins/groupingRow/grouping.row.types.js +0 -1
- package/dist/collection/plugins/groupingRow/grouping.service.js +0 -155
- package/dist/collection/plugins/groupingRow/grouping.trimmed.service.js +0 -57
- package/dist/collection/plugins/moveColumn/columnDragPlugin.js +0 -145
- package/dist/collection/plugins/moveColumn/columnOrderHandler.js +0 -60
- package/dist/collection/plugins/sorting/sorting.plugin.js +0 -181
- package/dist/collection/plugins/sorting/sorting.sign.js +0 -6
- package/dist/collection/plugins/stretchPlugin.js +0 -68
- package/dist/collection/plugins/trimmed/trimmed.plugin.js +0 -32
- package/dist/collection/services/cell.helpers.js +0 -7
- package/dist/collection/services/column.data.provider.js +0 -188
- package/dist/collection/services/data.provider.js +0 -47
- package/dist/collection/services/dimension.provider.js +0 -78
- package/dist/collection/services/resizable.directive.js +0 -250
- package/dist/collection/services/selection.store.connector.js +0 -213
- package/dist/collection/services/viewport.provider.js +0 -14
- package/dist/collection/store/dataSource/data.proxy.js +0 -34
- package/dist/collection/store/dataSource/data.store.js +0 -127
- package/dist/collection/store/dimension/dimension.helpers.js +0 -107
- package/dist/collection/store/dimension/dimension.store.js +0 -59
- package/dist/collection/store/selection/selection.helpers.js +0 -53
- package/dist/collection/store/selection/selection.store.js +0 -68
- package/dist/collection/store/selection/selection.store.service.js +0 -35
- package/dist/collection/store/storeTypes.js +0 -5
- package/dist/collection/store/viewPort/viewport.store.js +0 -121
- package/dist/collection/themeManager/theme.compact.js +0 -5
- package/dist/collection/themeManager/theme.default.js +0 -5
- package/dist/collection/themeManager/theme.material.js +0 -5
- package/dist/collection/utils/closestPolifill.js +0 -18
- package/dist/collection/utils/consts.js +0 -19
- package/dist/collection/utils/generateAlphabetHeader.js +0 -20
- package/dist/collection/utils/keyCodes.js +0 -70
- package/dist/collection/utils/keyCodes.utils.js +0 -64
- package/dist/collection/utils/platform.js +0 -5
- package/dist/collection/utils/resizeObserver.js +0 -6
- package/dist/collection/utils/store.utils.js +0 -7
- package/dist/collection/utilsExternal/generate-data.js +0 -132
- package/dist/esm/css-shim-8d75038b.js +0 -4
- package/dist/esm/debounce-45985ae0.js +0 -558
- package/dist/esm/dom-1b195079.js +0 -73
- package/dist/esm/index-42c84e7c.js +0 -1694
- package/dist/esm/index.js +0 -1
- package/dist/esm/loader.js +0 -31
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/esm/resize-observer-56b7b34f.js +0 -489
- package/dist/esm/revo-grid.js +0 -71
- package/dist/esm/revogr-clipboard.entry.js +0 -49
- package/dist/esm/revogr-filter-panel.entry.js +0 -271
- package/dist/esm-es5/css-shim-8d75038b.js +0 -1
- package/dist/esm-es5/debounce-45985ae0.js +0 -1
- package/dist/esm-es5/dom-1b195079.js +0 -21
- package/dist/esm-es5/index-42c84e7c.js +0 -1
- package/dist/esm-es5/index.js +0 -0
- package/dist/esm-es5/loader.js +0 -1
- package/dist/esm-es5/resize-observer-56b7b34f.js +0 -1
- package/dist/esm-es5/revo-grid.js +0 -1
- package/dist/esm-es5/revo-grid_11.entry.js +0 -1
- package/dist/esm-es5/revogr-clipboard.entry.js +0 -1
- package/dist/esm-es5/revogr-filter-panel.entry.js +0 -1
- package/dist/index.cjs.js +0 -1
- package/dist/index.js +0 -1
- package/dist/revo-grid/css-shim-88bfb262.system.js +0 -1
- package/dist/revo-grid/css-shim-8d75038b.js +0 -1
- package/dist/revo-grid/debounce-6c911037.js +0 -1
- package/dist/revo-grid/debounce-a345f98e.system.js +0 -1
- package/dist/revo-grid/dom-1b195079.js +0 -19
- package/dist/revo-grid/dom-ee2dd1b3.system.js +0 -21
- package/dist/revo-grid/index-a15e7527.system.js +0 -1
- package/dist/revo-grid/index-a7f99799.js +0 -1
- package/dist/revo-grid/index.system.js +0 -1
- package/dist/revo-grid/resize-observer-56b7b34f.js +0 -1
- package/dist/revo-grid/resize-observer-7a7b9757.system.js +0 -1
- package/dist/revo-grid/revo-grid.js +0 -132
- package/dist/revo-grid/revo-grid.system.js +0 -1
- package/dist/revo-grid/revo-grid_11.entry.js +0 -1
- package/dist/revo-grid/revo-grid_11.system.entry.js +0 -1
- package/dist/revo-grid/revogr-clipboard.system.entry.js +0 -1
- package/dist/revo-grid/revogr-filter-panel.system.entry.js +0 -1
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const beginsWith = (value, extra) => {
|
|
2
|
-
if (!value) {
|
|
3
|
-
return false;
|
|
4
|
-
}
|
|
5
|
-
if (!extra) {
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
if (typeof value !== 'string') {
|
|
9
|
-
value = JSON.stringify(value);
|
|
10
|
-
}
|
|
11
|
-
if (typeof extra !== 'string') {
|
|
12
|
-
extra = JSON.stringify(extra);
|
|
13
|
-
}
|
|
14
|
-
return value.toLocaleLowerCase().indexOf(extra.toLocaleLowerCase()) === 0;
|
|
15
|
-
};
|
|
16
|
-
beginsWith.extra = 'input';
|
|
17
|
-
export default beginsWith;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
const contains = (value, extra) => {
|
|
2
|
-
if (!value) {
|
|
3
|
-
return false;
|
|
4
|
-
}
|
|
5
|
-
if (extra) {
|
|
6
|
-
if (typeof value !== 'string') {
|
|
7
|
-
value = JSON.stringify(value);
|
|
8
|
-
}
|
|
9
|
-
return value.toLocaleLowerCase().indexOf(extra.toString().toLowerCase()) > -1;
|
|
10
|
-
}
|
|
11
|
-
return true;
|
|
12
|
-
};
|
|
13
|
-
export const notContains = (value, extra) => {
|
|
14
|
-
return !contains(value, extra);
|
|
15
|
-
};
|
|
16
|
-
notContains.extra = 'input';
|
|
17
|
-
contains.extra = 'input';
|
|
18
|
-
export default contains;
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
import { h } from '@stencil/core';
|
|
2
|
-
import BasePlugin from '../basePlugin';
|
|
3
|
-
import { FILTER_PROP, isFilterBtn } from './filter.button';
|
|
4
|
-
import { filterEntities, filterNames, filterTypes } from './filter.service';
|
|
5
|
-
export const FILTER_TRIMMED_TYPE = 'filter';
|
|
6
|
-
export default class FilterPlugin extends BasePlugin {
|
|
7
|
-
constructor(revogrid, uiid, config) {
|
|
8
|
-
var _a;
|
|
9
|
-
super(revogrid);
|
|
10
|
-
this.revogrid = revogrid;
|
|
11
|
-
this.filterCollection = {};
|
|
12
|
-
this.multiFilterItems = {};
|
|
13
|
-
this.possibleFilters = Object.assign({}, filterTypes);
|
|
14
|
-
this.possibleFilterNames = Object.assign({}, filterNames);
|
|
15
|
-
this.possibleFilterEntities = Object.assign({}, filterEntities);
|
|
16
|
-
if (config) {
|
|
17
|
-
this.initConfig(config);
|
|
18
|
-
}
|
|
19
|
-
const headerclick = (e) => this.headerclick(e);
|
|
20
|
-
const aftersourceset = async () => {
|
|
21
|
-
const filterCollectionProps = Object.keys(this.filterCollection);
|
|
22
|
-
if (filterCollectionProps.length > 0) {
|
|
23
|
-
// handle old way of filtering by reworking FilterCollection to new MultiFilterItem
|
|
24
|
-
filterCollectionProps.forEach((prop, index) => {
|
|
25
|
-
if (!this.multiFilterItems[prop]) {
|
|
26
|
-
this.multiFilterItems[prop] = [
|
|
27
|
-
{
|
|
28
|
-
id: index,
|
|
29
|
-
type: this.filterCollection[prop].type,
|
|
30
|
-
value: this.filterCollection[prop].value,
|
|
31
|
-
relation: 'and',
|
|
32
|
-
},
|
|
33
|
-
];
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
await this.runFiltering();
|
|
38
|
-
};
|
|
39
|
-
this.addEventListener('headerclick', headerclick);
|
|
40
|
-
this.addEventListener('aftersourceset', aftersourceset);
|
|
41
|
-
this.revogrid.registerVNode([
|
|
42
|
-
h("revogr-filter-panel", { uuid: `filter-${uiid}`, filterItems: this.multiFilterItems, filterNames: this.possibleFilterNames, filterEntities: this.possibleFilterEntities, filterCaptions: (_a = config === null || config === void 0 ? void 0 : config.localization) === null || _a === void 0 ? void 0 : _a.captions, onFilterChange: e => this.onFilterChange(e.detail), disableDynamicFiltering: config === null || config === void 0 ? void 0 : config.disableDynamicFiltering, ref: e => (this.pop = e) }),
|
|
43
|
-
]);
|
|
44
|
-
}
|
|
45
|
-
initConfig(config) {
|
|
46
|
-
if (config.collection) {
|
|
47
|
-
this.filterCollection = Object.assign({}, config.collection);
|
|
48
|
-
}
|
|
49
|
-
if (config.multiFilterItems) {
|
|
50
|
-
this.multiFilterItems = Object.assign({}, config.multiFilterItems);
|
|
51
|
-
}
|
|
52
|
-
if (config.customFilters) {
|
|
53
|
-
for (let cType in config.customFilters) {
|
|
54
|
-
const cFilter = config.customFilters[cType];
|
|
55
|
-
if (!this.possibleFilters[cFilter.columnFilterType]) {
|
|
56
|
-
this.possibleFilters[cFilter.columnFilterType] = [];
|
|
57
|
-
}
|
|
58
|
-
this.possibleFilters[cFilter.columnFilterType].push(cType);
|
|
59
|
-
this.possibleFilterEntities[cType] = cFilter.func;
|
|
60
|
-
this.possibleFilterNames[cType] = cFilter.name;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* which filters has to be included/excluded
|
|
65
|
-
* convinient way to exclude system filters
|
|
66
|
-
*/
|
|
67
|
-
if (config.include) {
|
|
68
|
-
const filters = {};
|
|
69
|
-
for (let t in this.possibleFilters) {
|
|
70
|
-
// validate filters, if appropriate function present
|
|
71
|
-
const newTypes = this.possibleFilters[t].filter(f => config.include.indexOf(f) > -1);
|
|
72
|
-
if (newTypes.length) {
|
|
73
|
-
filters[t] = newTypes;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
// if any valid filters provided show them
|
|
77
|
-
if (Object.keys(filters).length > 0) {
|
|
78
|
-
this.possibleFilters = filters;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (config.localization) {
|
|
82
|
-
if (config.localization.filterNames) {
|
|
83
|
-
Object.entries(config.localization.filterNames).forEach(([k, v]) => {
|
|
84
|
-
if (this.possibleFilterNames[k] != void 0) {
|
|
85
|
-
this.possibleFilterNames[k] = v;
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
async headerclick(e) {
|
|
92
|
-
var _a;
|
|
93
|
-
const el = (_a = e.detail.originalEvent) === null || _a === void 0 ? void 0 : _a.target;
|
|
94
|
-
if (!isFilterBtn(el)) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
e.preventDefault();
|
|
98
|
-
// close if same
|
|
99
|
-
const changes = await this.pop.getChanges();
|
|
100
|
-
if (changes && (changes === null || changes === void 0 ? void 0 : changes.prop) === e.detail.prop) {
|
|
101
|
-
this.pop.show();
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
// filter button clicked, open filter dialog
|
|
105
|
-
const gridPos = this.revogrid.getBoundingClientRect();
|
|
106
|
-
const buttonPos = el.getBoundingClientRect();
|
|
107
|
-
const prop = e.detail.prop;
|
|
108
|
-
this.pop.filterTypes = this.getColumnFilter(e.detail.filter);
|
|
109
|
-
this.pop.show(Object.assign(Object.assign({}, this.filterCollection[prop]), { x: buttonPos.x - gridPos.x, y: buttonPos.y - gridPos.y + buttonPos.height, prop }));
|
|
110
|
-
}
|
|
111
|
-
getColumnFilter(type) {
|
|
112
|
-
let filterType = 'string';
|
|
113
|
-
if (!type) {
|
|
114
|
-
return { [filterType]: this.possibleFilters[filterType] };
|
|
115
|
-
}
|
|
116
|
-
// if custom column filter
|
|
117
|
-
if (this.isValidType(type)) {
|
|
118
|
-
filterType = type;
|
|
119
|
-
// if multiple filters applied
|
|
120
|
-
}
|
|
121
|
-
else if (typeof type === 'object' && type.length) {
|
|
122
|
-
return type.reduce((r, multiType) => {
|
|
123
|
-
if (this.isValidType(multiType)) {
|
|
124
|
-
r[multiType] = this.possibleFilters[multiType];
|
|
125
|
-
}
|
|
126
|
-
return r;
|
|
127
|
-
}, {});
|
|
128
|
-
}
|
|
129
|
-
return { [filterType]: this.possibleFilters[filterType] };
|
|
130
|
-
}
|
|
131
|
-
isValidType(type) {
|
|
132
|
-
return !!(typeof type === 'string' && this.possibleFilters[type]);
|
|
133
|
-
}
|
|
134
|
-
// called on internal component change
|
|
135
|
-
async onFilterChange(filterItems) {
|
|
136
|
-
this.multiFilterItems = filterItems;
|
|
137
|
-
this.runFiltering();
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Triggers grid filtering
|
|
141
|
-
*/
|
|
142
|
-
async doFiltering(collection, items, columns, filterItems) {
|
|
143
|
-
const columnsToUpdate = [];
|
|
144
|
-
columns.forEach(rgCol => {
|
|
145
|
-
const column = Object.assign({}, rgCol);
|
|
146
|
-
const hasFilter = filterItems[column.prop];
|
|
147
|
-
if (column[FILTER_PROP] && !hasFilter) {
|
|
148
|
-
delete column[FILTER_PROP];
|
|
149
|
-
columnsToUpdate.push(column);
|
|
150
|
-
}
|
|
151
|
-
if (!column[FILTER_PROP] && hasFilter) {
|
|
152
|
-
columnsToUpdate.push(column);
|
|
153
|
-
column[FILTER_PROP] = true;
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
const itemsToFilter = this.getRowFilter(items, filterItems);
|
|
157
|
-
// check is filter event prevented
|
|
158
|
-
const { defaultPrevented, detail } = this.emit('beforefiltertrimmed', { collection, itemsToFilter, source: items, filterItems });
|
|
159
|
-
if (defaultPrevented) {
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
// check is trimmed event prevented
|
|
163
|
-
const isAddedEvent = await this.revogrid.addTrimmed(detail.itemsToFilter, FILTER_TRIMMED_TYPE);
|
|
164
|
-
if (isAddedEvent.defaultPrevented) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
// applies the hasFilter to the columns to show filter icon
|
|
168
|
-
await this.revogrid.updateColumns(columnsToUpdate);
|
|
169
|
-
this.emit('afterFilterApply');
|
|
170
|
-
}
|
|
171
|
-
async clearFiltering() {
|
|
172
|
-
this.multiFilterItems = {};
|
|
173
|
-
await this.runFiltering();
|
|
174
|
-
}
|
|
175
|
-
async runFiltering() {
|
|
176
|
-
const collection = {};
|
|
177
|
-
// handle old filterCollection to return the first filter only (if any) from multiFilterItems
|
|
178
|
-
const filterProps = Object.keys(this.multiFilterItems);
|
|
179
|
-
for (const prop of filterProps) {
|
|
180
|
-
// check if we have any filter for a column
|
|
181
|
-
if (this.multiFilterItems[prop].length > 0) {
|
|
182
|
-
const firstFilterItem = this.multiFilterItems[prop][0];
|
|
183
|
-
collection[prop] = {
|
|
184
|
-
filter: filterEntities[firstFilterItem.type],
|
|
185
|
-
type: firstFilterItem.type,
|
|
186
|
-
value: firstFilterItem.value,
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
this.filterCollection = collection;
|
|
191
|
-
const { source, columns } = await this.getData();
|
|
192
|
-
const { defaultPrevented, detail } = this.emit('beforefilterapply', { collection: this.filterCollection, source, columns, filterItems: this.multiFilterItems });
|
|
193
|
-
if (defaultPrevented) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
this.doFiltering(detail.collection, detail.source, detail.columns, detail.filterItems);
|
|
197
|
-
}
|
|
198
|
-
async getData() {
|
|
199
|
-
const source = await this.revogrid.getSource();
|
|
200
|
-
const columns = await this.revogrid.getColumns();
|
|
201
|
-
return {
|
|
202
|
-
source,
|
|
203
|
-
columns,
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
getRowFilter(rows, filterItems) {
|
|
207
|
-
const propKeys = Object.keys(filterItems);
|
|
208
|
-
const trimmed = {};
|
|
209
|
-
let propFilterSatisfiedCount = 0;
|
|
210
|
-
let lastFilterResults = [];
|
|
211
|
-
// each rows
|
|
212
|
-
rows.forEach((model, rowIndex) => {
|
|
213
|
-
// working on all props
|
|
214
|
-
for (const prop of propKeys) {
|
|
215
|
-
const propFilters = filterItems[prop];
|
|
216
|
-
propFilterSatisfiedCount = 0;
|
|
217
|
-
lastFilterResults = [];
|
|
218
|
-
// testing each filter for a prop
|
|
219
|
-
for (const [filterIndex, filterData] of propFilters.entries()) {
|
|
220
|
-
// the filter LogicFunction based on the type
|
|
221
|
-
const filter = filterEntities[filterData.type];
|
|
222
|
-
// THE MAGIC OF FILTERING IS HERE
|
|
223
|
-
if (filterData.relation === 'or') {
|
|
224
|
-
lastFilterResults = [];
|
|
225
|
-
if (filter(model[prop], filterData.value)) {
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
propFilterSatisfiedCount++;
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
// 'and' relation will need to know the next filter
|
|
232
|
-
// so we save this current filter to include it in the next filter
|
|
233
|
-
lastFilterResults.push(!filter(model[prop], filterData.value));
|
|
234
|
-
// check first if we have a filter on the next index to pair it with this current filter
|
|
235
|
-
const nextFilterData = propFilters[filterIndex + 1];
|
|
236
|
-
// stop the sequence if there is no next filter or if the next filter is not an 'and' relation
|
|
237
|
-
if (!nextFilterData || nextFilterData.relation !== 'and') {
|
|
238
|
-
// let's just continue since for sure propFilterSatisfiedCount cannot be satisfied
|
|
239
|
-
if (lastFilterResults.indexOf(true) === -1) {
|
|
240
|
-
lastFilterResults = [];
|
|
241
|
-
continue;
|
|
242
|
-
}
|
|
243
|
-
// we need to add all of the lastFilterResults since we need to satisfy all
|
|
244
|
-
propFilterSatisfiedCount += lastFilterResults.length;
|
|
245
|
-
lastFilterResults = [];
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
} // end of propFilters forEach
|
|
249
|
-
// add to the list of removed/trimmed rows of filter condition is satisfied
|
|
250
|
-
if (propFilterSatisfiedCount === propFilters.length)
|
|
251
|
-
trimmed[rowIndex] = true;
|
|
252
|
-
} // end of for-of propKeys
|
|
253
|
-
});
|
|
254
|
-
return trimmed;
|
|
255
|
-
}
|
|
256
|
-
}
|