@sankhyalabs/sankhyablocks 8.16.0-dev.4 → 8.16.0-dev.40
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/{ConfigStorage-942ce74b.js → ConfigStorage-ecc0ed20.js} +3 -2
- package/dist/cjs/{IExporterProvider-597949f9.js → ContinuousInsertUtils-c7e35e3b.js} +39 -6
- package/dist/cjs/{DataFetcher-313debd8.js → DataFetcher-cadeef8e.js} +21 -15
- package/dist/cjs/{RecordIDUtils-3735135c.js → GetSelectedRecordsIDsInfo-bd50caf1.js} +10 -10
- package/dist/cjs/{SnkFormConfigManager-1b13bacd.js → SnkFormConfigManager-f1c92f79.js} +74 -20
- package/dist/cjs/{SnkMessageBuilder-722b104e.js → SnkMessageBuilder-bae64d0d.js} +7 -3
- package/dist/cjs/{auth-fetcher-54f5ff9d.js → auth-fetcher-d68841bc.js} +1 -1
- package/dist/cjs/{dataunit-fetcher-688d3f05.js → dataunit-fetcher-a36ae041.js} +48 -20
- package/dist/cjs/{field-search-f56aa7d6.js → field-search-68e34bf4.js} +5 -1
- package/dist/cjs/{form-config-fetcher-2dd00e5b.js → form-config-fetcher-ed497282.js} +5 -2
- package/dist/cjs/index-f9e81701.js +8 -28
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{pesquisa-fetcher-680e198f.js → pesquisa-fetcher-490a86c3.js} +7 -2
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +17 -14
- package/dist/cjs/snk-application.cjs.entry.js +7 -7
- package/dist/cjs/snk-attach.cjs.entry.js +38 -29
- package/dist/cjs/{snk-form-config.cjs.entry.js → snk-config-options_3.cjs.entry.js} +381 -7
- package/dist/cjs/snk-crud.cjs.entry.js +16 -7
- package/dist/cjs/snk-data-exporter.cjs.entry.js +19 -18
- package/dist/cjs/{snk-data-unit-685272e7.js → snk-data-unit-b460f1da.js} +42 -22
- package/dist/cjs/snk-data-unit.cjs.entry.js +5 -5
- package/dist/cjs/snk-detail-view.cjs.entry.js +12 -13
- package/dist/cjs/snk-exporter-email-sender.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-bar_4.cjs.entry.js +1411 -0
- package/dist/cjs/snk-filter-binary-select.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-checkbox-list.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +3 -3
- package/dist/cjs/snk-grid.cjs.entry.js +58 -21
- package/dist/cjs/{snk-guides-viewer-67605336.js → snk-guides-viewer-de0a5c57.js} +27 -14
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +9 -9
- package/dist/cjs/snk-personalized-filter-editor.cjs.entry.js +1 -1
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +3 -3
- package/dist/cjs/snk-print-selector.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-bar.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +66 -27
- package/dist/cjs/snk-taskbar.cjs.entry.js +24 -1
- package/dist/collection/collection-manifest.json +11 -31
- package/dist/collection/components/snk-actions-button/actions/index.js +12 -9
- package/dist/collection/components/snk-attach/snk-attach.js +25 -16
- package/dist/collection/components/snk-attach/structure/fetcher/factory/attach-fetcher-data-unit.factory.js +2 -4
- package/dist/collection/components/snk-crud/snk-crud.js +97 -2
- package/dist/collection/components/snk-crud/subcomponents/snk-detail-view/snk-detail-view.js +3 -4
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.css +6 -6
- package/dist/collection/components/snk-crud/subcomponents/snk-guides-viewer.js +70 -7
- package/dist/collection/components/snk-data-exporter/exporter-email-sender/options-step.js +1 -1
- package/dist/collection/components/snk-data-exporter/exporter-strategy/ClientSideExporterStrategy.js +4 -4
- package/dist/collection/components/snk-data-exporter/exporter-strategy/ServerSideExporterStrategy.js +5 -5
- package/dist/collection/components/snk-data-exporter/providers/ClientSideExporterProvider.js +1 -1
- package/dist/collection/components/snk-data-exporter/providers/ServerSideExporterProvider.js +1 -1
- package/dist/collection/components/snk-data-exporter/snk-data-exporter.js +2 -2
- package/dist/collection/components/snk-data-exporter/structure/ItemBuilder.js +2 -2
- package/dist/collection/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.js +4 -4
- package/dist/collection/components/snk-data-unit/snk-data-unit.js +57 -20
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-binary-select.js +1 -1
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-checkbox-list.js +1 -1
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-personalized-filter-editor/snk-personalized-filter-editor.js +1 -1
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +1 -1
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +59 -21
- package/dist/collection/components/snk-form/snk-form.js +2 -2
- package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +72 -18
- package/dist/collection/components/snk-form-config/snk-form-config.css +8 -3
- package/dist/collection/components/snk-form-config/snk-form-config.js +32 -3
- package/dist/collection/components/snk-grid/snk-grid.css +2 -0
- package/dist/collection/components/snk-grid/snk-grid.js +74 -8
- package/dist/collection/components/snk-print-selector/snk-print-selector.js +1 -1
- package/dist/collection/components/snk-simple-bar/snk-simple-bar.js +1 -1
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.css +0 -1
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +91 -16
- package/dist/collection/components/snk-taskbar/processor/taskbar-processor.js +5 -1
- package/dist/collection/components/snk-taskbar/snk-taskbar.js +65 -0
- package/dist/collection/lib/DefaultCustomFormatters/RmPrecisionCustomValueFormatter.js +3 -3
- package/dist/collection/lib/configs/ConfigStorage.js +1 -0
- package/dist/collection/lib/dataUnit/InMemoryLoader.js +2 -4
- package/dist/collection/lib/dataUnit/dataUnitInMemoryUtils.js +34 -9
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +22 -16
- package/dist/collection/lib/http/data-fetcher/fetchers/AttachFetcher/anexo-sistema-fetcher.js +7 -5
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/DataUnitDataLoader.js +2 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/loadstrategy/DatasetStrategy.js +9 -2
- package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +4 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/pesquisa-fetcher.js +6 -1
- package/dist/collection/lib/message/resources/snk-data-unit.msg.js +1 -1
- package/dist/collection/lib/message/resources/snk-exporter.msg.js +1 -1
- package/dist/collection/lib/message/resources/snk-grid.msg.js +5 -1
- package/dist/collection/lib/utils/ContinuousInsertUtils.js +31 -0
- package/dist/collection/{components/snk-data-exporter/utils/RecordIDUtils.js → lib/utils/GetSelectedRecordsIDsInfo.js} +9 -9
- package/dist/collection/sw.js +46 -0
- package/dist/components/ConfigStorage.js +1 -0
- package/dist/components/{IExporterProvider.js → ContinuousInsertUtils.js} +40 -5
- package/dist/components/DataFetcher.js +22 -16
- package/dist/{esm/RecordIDUtils-87d02110.js → components/GetSelectedRecordsIDsInfo.js} +10 -10
- package/dist/components/SnkFormConfigManager.js +72 -18
- package/dist/components/SnkMessageBuilder.js +7 -3
- package/dist/components/dataunit-fetcher.js +47 -17
- package/dist/components/form-config-fetcher.js +4 -1
- package/dist/components/pesquisa-fetcher.js +6 -1
- package/dist/components/snk-actions-button2.js +12 -9
- package/dist/components/snk-attach2.js +34 -25
- package/dist/components/snk-crud.js +15 -2
- package/dist/components/snk-data-exporter2.js +12 -11
- package/dist/components/snk-data-unit2.js +44 -60
- package/dist/components/snk-detail-view2.js +28 -13
- package/dist/components/snk-exporter-email-sender2.js +1 -1
- package/dist/components/snk-filter-bar2.js +35 -22
- package/dist/components/snk-filter-binary-select.js +1 -1
- package/dist/components/snk-filter-checkbox-list.js +1 -1
- package/dist/components/snk-form-config2.js +17 -4
- package/dist/components/snk-form.js +2 -2
- package/dist/components/snk-grid2.js +51 -12
- package/dist/components/snk-personalized-filter-editor.js +1 -1
- package/dist/components/snk-print-selector.js +1 -1
- package/dist/components/snk-simple-bar2.js +1 -1
- package/dist/components/snk-simple-crud2.js +59 -16
- package/dist/components/snk-taskbar2.js +25 -2
- package/dist/esm/{ConfigStorage-86187da3.js → ConfigStorage-7b36d041.js} +3 -2
- package/dist/esm/{IExporterProvider-63a188b6.js → ContinuousInsertUtils-3e520a07.js} +40 -8
- package/dist/esm/{DataFetcher-c1baf61d.js → DataFetcher-a9c598f2.js} +22 -16
- package/dist/esm/GetSelectedRecordsIDsInfo-9fa41508.js +41 -0
- package/dist/esm/{SnkFormConfigManager-d4554df9.js → SnkFormConfigManager-f1a0fc92.js} +74 -20
- package/dist/esm/{SnkMessageBuilder-89925609.js → SnkMessageBuilder-6fff4a4c.js} +7 -3
- package/dist/esm/{auth-fetcher-039abba3.js → auth-fetcher-749d880f.js} +1 -1
- package/dist/esm/{constants-8457af36.js → constants-7302ee87.js} +1 -1
- package/dist/esm/{dataunit-fetcher-264191b2.js → dataunit-fetcher-fd58c640.js} +48 -18
- package/dist/esm/{field-search-efbe307f.js → field-search-f8b1d91e.js} +5 -1
- package/dist/esm/{form-config-fetcher-30fb808f.js → form-config-fetcher-adbe5d34.js} +5 -2
- package/dist/esm/index-a7d3d3f1.js +8 -28
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{pesquisa-fetcher-03c8f919.js → pesquisa-fetcher-50fc7e6b.js} +7 -2
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_4.entry.js +18 -15
- package/dist/esm/snk-application.entry.js +7 -7
- package/dist/esm/snk-attach.entry.js +39 -30
- package/dist/esm/{snk-form-config.entry.js → snk-config-options_3.entry.js} +382 -10
- package/dist/esm/snk-configurator.entry.js +1 -1
- package/dist/esm/snk-crud.entry.js +17 -8
- package/dist/esm/snk-data-exporter.entry.js +20 -19
- package/dist/esm/{snk-data-unit-63f83504.js → snk-data-unit-590225b5.js} +42 -22
- package/dist/esm/snk-data-unit.entry.js +5 -5
- package/dist/esm/snk-detail-view.entry.js +13 -14
- package/dist/esm/snk-exporter-email-sender.entry.js +1 -1
- package/dist/esm/snk-field-config.entry.js +1 -1
- package/dist/esm/snk-filter-bar_4.entry.js +1404 -0
- package/dist/esm/snk-filter-binary-select.entry.js +1 -1
- package/dist/esm/snk-filter-checkbox-list.entry.js +1 -1
- package/dist/esm/snk-filter-modal-item.entry.js +3 -3
- package/dist/esm/snk-grid.entry.js +53 -16
- package/dist/esm/{snk-guides-viewer-151f6091.js → snk-guides-viewer-2f4dcdc5.js} +28 -15
- package/dist/esm/snk-guides-viewer.entry.js +9 -9
- package/dist/esm/snk-personalized-filter-editor.entry.js +1 -1
- package/dist/esm/snk-personalized-filter.entry.js +3 -3
- package/dist/esm/snk-print-selector.entry.js +1 -1
- package/dist/esm/snk-simple-bar.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +63 -24
- package/dist/esm/snk-tab-config.entry.js +1 -1
- package/dist/esm/snk-taskbar.entry.js +24 -1
- package/dist/sankhyablocks/p-052213ba.entry.js +1 -0
- package/dist/sankhyablocks/{p-df5451c7.js → p-06421fdb.js} +2 -2
- package/dist/sankhyablocks/p-0b6cd238.entry.js +1 -0
- package/dist/sankhyablocks/p-0e320bd2.entry.js +1 -0
- package/dist/sankhyablocks/p-16a1dd18.entry.js +1 -0
- package/dist/sankhyablocks/p-17425c72.js +1 -0
- package/dist/sankhyablocks/{p-a1d72395.entry.js → p-212213d9.entry.js} +1 -1
- package/dist/sankhyablocks/p-23736d75.js +1 -0
- package/dist/sankhyablocks/p-275de842.entry.js +1 -0
- package/dist/sankhyablocks/p-2aae03a1.entry.js +1 -0
- package/dist/sankhyablocks/{p-8eb67fa4.entry.js → p-2d3f9482.entry.js} +1 -1
- package/dist/sankhyablocks/{p-7663f597.entry.js → p-41793e17.entry.js} +1 -1
- package/dist/sankhyablocks/{p-72fc257b.entry.js → p-434817f0.entry.js} +1 -1
- package/dist/sankhyablocks/p-47bce500.js +60 -0
- package/dist/sankhyablocks/{p-aff76a53.js → p-4d9549cf.js} +2 -2
- package/dist/sankhyablocks/p-583517ba.entry.js +1 -0
- package/dist/sankhyablocks/p-5b51491f.entry.js +1 -0
- package/dist/sankhyablocks/p-5e51e833.entry.js +1 -0
- package/dist/sankhyablocks/{p-aaa3ee68.entry.js → p-5f157b09.entry.js} +1 -1
- package/dist/sankhyablocks/p-656f0e51.entry.js +1 -0
- package/dist/sankhyablocks/p-72c10005.entry.js +1 -0
- package/dist/sankhyablocks/p-7bd9683d.js +1 -0
- package/dist/sankhyablocks/p-7dd49d15.js +1 -0
- package/dist/sankhyablocks/{p-af8efd95.js → p-8a9638ae.js} +2 -2
- package/dist/sankhyablocks/{p-95df461f.entry.js → p-8b4fc28f.entry.js} +1 -1
- package/dist/sankhyablocks/{p-41f8bfa3.entry.js → p-8c235d4c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-b0ef4383.js → p-95ce311a.js} +1 -1
- package/dist/sankhyablocks/p-9f9b99d9.js +1 -0
- package/dist/sankhyablocks/p-ab1645fb.entry.js +1 -0
- package/dist/sankhyablocks/p-c2e468c9.entry.js +1 -0
- package/dist/sankhyablocks/{p-913a9979.js → p-ca5ec380.js} +1 -1
- package/dist/sankhyablocks/p-cefb0ee1.entry.js +1 -0
- package/dist/sankhyablocks/{p-82a0bfb0.entry.js → p-dbe6174a.entry.js} +2 -2
- package/dist/sankhyablocks/p-f3434fc4.js +1 -0
- package/dist/sankhyablocks/p-fa6c5826.entry.js +1 -0
- package/dist/sankhyablocks/p-fadc8339.js +1 -0
- package/dist/sankhyablocks/{p-eae7a817.entry.js → p-fb34e0cf.entry.js} +1 -1
- package/dist/sankhyablocks/p-fd13b4d2.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-actions-button/actions/index.d.ts +1 -0
- package/dist/types/components/snk-attach/snk-attach.d.ts +1 -0
- package/dist/types/components/snk-crud/snk-crud.d.ts +17 -0
- package/dist/types/components/snk-crud/subcomponents/snk-guides-viewer.d.ts +15 -0
- package/dist/types/components/snk-data-exporter/test/resources/ClientSideExporterStrategyResources.d.ts +3 -3
- package/dist/types/components/snk-data-unit/snk-data-unit.d.ts +7 -0
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +5 -0
- package/dist/types/components/snk-form-config/SnkFormConfigManager.d.ts +9 -4
- package/dist/types/components/snk-form-config/snk-form-config.d.ts +4 -0
- package/dist/types/components/snk-grid/snk-grid.d.ts +11 -0
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +13 -0
- package/dist/types/components/snk-taskbar/processor/taskbar-processor.d.ts +1 -0
- package/dist/types/components/snk-taskbar/snk-taskbar.d.ts +11 -0
- package/dist/types/components.d.ts +113 -0
- package/dist/types/lib/dataUnit/dataUnitInMemoryUtils.d.ts +12 -2
- package/dist/types/lib/http/data-fetcher/fetchers/AttachFetcher/anexo-sistema-fetcher.d.ts +3 -2
- package/dist/types/lib/http/data-fetcher/fetchers/fetchDataExporter/interfaces/IFetchDataExporterParams.d.ts +1 -1
- package/dist/types/lib/utils/ContinuousInsertUtils.d.ts +10 -0
- package/dist/types/lib/utils/GetSelectedRecordsIDsInfo.d.ts +3 -0
- package/package.json +4 -3
- package/dist/cjs/snk-config-options.cjs.entry.js +0 -239
- package/dist/cjs/snk-filter-bar.cjs.entry.js +0 -714
- package/dist/cjs/snk-filter-item.cjs.entry.js +0 -312
- package/dist/cjs/snk-filter-list.cjs.entry.js +0 -152
- package/dist/cjs/snk-filter-modal.cjs.entry.js +0 -249
- package/dist/cjs/snk-form.cjs.entry.js +0 -143
- package/dist/esm/snk-config-options.entry.js +0 -235
- package/dist/esm/snk-filter-bar.entry.js +0 -710
- package/dist/esm/snk-filter-item.entry.js +0 -308
- package/dist/esm/snk-filter-list.entry.js +0 -148
- package/dist/esm/snk-filter-modal.entry.js +0 -245
- package/dist/esm/snk-form.entry.js +0 -139
- package/dist/sankhyablocks/p-14a08904.entry.js +0 -1
- package/dist/sankhyablocks/p-14b9f964.entry.js +0 -1
- package/dist/sankhyablocks/p-219f888d.entry.js +0 -1
- package/dist/sankhyablocks/p-3a212712.js +0 -1
- package/dist/sankhyablocks/p-3a216b81.entry.js +0 -1
- package/dist/sankhyablocks/p-3b60db06.entry.js +0 -1
- package/dist/sankhyablocks/p-47b60deb.entry.js +0 -1
- package/dist/sankhyablocks/p-70a4af56.entry.js +0 -1
- package/dist/sankhyablocks/p-7505da04.entry.js +0 -1
- package/dist/sankhyablocks/p-75f83d1d.entry.js +0 -1
- package/dist/sankhyablocks/p-7a337364.js +0 -1
- package/dist/sankhyablocks/p-829d4045.js +0 -1
- package/dist/sankhyablocks/p-88aa931b.entry.js +0 -1
- package/dist/sankhyablocks/p-8fc470e5.entry.js +0 -1
- package/dist/sankhyablocks/p-941bf3ef.entry.js +0 -1
- package/dist/sankhyablocks/p-9863d682.js +0 -1
- package/dist/sankhyablocks/p-b11aa1e0.entry.js +0 -1
- package/dist/sankhyablocks/p-b4b21558.entry.js +0 -1
- package/dist/sankhyablocks/p-bad55caa.entry.js +0 -1
- package/dist/sankhyablocks/p-c053256c.entry.js +0 -1
- package/dist/sankhyablocks/p-c2495304.js +0 -1
- package/dist/sankhyablocks/p-c5268346.entry.js +0 -1
- package/dist/sankhyablocks/p-cefba299.js +0 -1
- package/dist/sankhyablocks/p-d3f53df2.entry.js +0 -1
- package/dist/sankhyablocks/p-dc7c9047.js +0 -1
- package/dist/sankhyablocks/p-e8763234.entry.js +0 -1
- package/dist/sankhyablocks/p-f2809746.entry.js +0 -1
- package/dist/sankhyablocks/p-fcac4dfc.js +0 -1
- package/dist/sankhyablocks/p-fe79f83a.js +0 -60
- package/dist/types/components/snk-data-exporter/utils/RecordIDUtils.d.ts +0 -3
@@ -0,0 +1,1411 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
4
|
+
|
5
|
+
const index$1 = require('./index-f9e81701.js');
|
6
|
+
const core = require('@sankhyalabs/core');
|
7
|
+
const EzScrollDirection = require('@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection');
|
8
|
+
const ConfigStorage = require('./ConfigStorage-ecc0ed20.js');
|
9
|
+
const DataType = require('@sankhyalabs/core/dist/dataunit/metadata/DataType');
|
10
|
+
const filterItemType_enum = require('./filter-item-type.enum-a7ffdaa6.js');
|
11
|
+
const index = require('./index-c5771aba.js');
|
12
|
+
const filterNumberVariation = require('./filterNumberVariation-d65332da.js');
|
13
|
+
const utils = require('@sankhyalabs/ezui/dist/collection/utils');
|
14
|
+
const PersonalizedFilterUtils = require('./PersonalizedFilterUtils-0184ffbb.js');
|
15
|
+
const ezModalContainer = require('@sankhyalabs/ezui/dist/collection/components/ez-modal-container');
|
16
|
+
const filterType_enum = require('./filter-type.enum-b14ce507.js');
|
17
|
+
require('./form-config-fetcher-ed497282.js');
|
18
|
+
require('./DataFetcher-cadeef8e.js');
|
19
|
+
require('./PrintUtils-bcaeb82f.js');
|
20
|
+
require('@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata');
|
21
|
+
|
22
|
+
const buildFilter = (item) => {
|
23
|
+
switch (item.type) {
|
24
|
+
case filterItemType_enum.FilterItemType.DEFAULT_FILTER:
|
25
|
+
return buildDefault(item);
|
26
|
+
case filterItemType_enum.FilterItemType.BINARY_SELECT:
|
27
|
+
return buildBinary(item);
|
28
|
+
case filterItemType_enum.FilterItemType.MULTI_SELECT:
|
29
|
+
return buildMultSelect(item);
|
30
|
+
case filterItemType_enum.FilterItemType.MULTI_LIST:
|
31
|
+
return buildMultiList(item);
|
32
|
+
case filterItemType_enum.FilterItemType.PERIOD:
|
33
|
+
return buildPeriod(item);
|
34
|
+
case filterItemType_enum.FilterItemType.SEARCH:
|
35
|
+
return buildSearch(item);
|
36
|
+
case filterItemType_enum.FilterItemType.TEXT:
|
37
|
+
return buildText(item);
|
38
|
+
case filterItemType_enum.FilterItemType.NUMBER:
|
39
|
+
return buildNumber(item);
|
40
|
+
case filterItemType_enum.FilterItemType.PERSONALIZED:
|
41
|
+
return buildPersonalized(item);
|
42
|
+
case filterItemType_enum.FilterItemType.CHECK_BOX_LIST:
|
43
|
+
return buildCheckboxList(item);
|
44
|
+
default:
|
45
|
+
return undefined;
|
46
|
+
}
|
47
|
+
};
|
48
|
+
function buildDefault(item) {
|
49
|
+
return { name: item.id, expression: item.props.expression, params: [] };
|
50
|
+
}
|
51
|
+
function buildBinary(item) {
|
52
|
+
const { id, value, props } = item;
|
53
|
+
const options = props.options;
|
54
|
+
const selectedOption = options.find(opt => opt.name === value);
|
55
|
+
return { name: id, expression: selectedOption.expression, params: [] };
|
56
|
+
}
|
57
|
+
function buildMultSelect(item) {
|
58
|
+
const { id, value, props } = item;
|
59
|
+
return { name: id, expression: props.expression, params: [{ name: id, dataType: core.DataType.TEXT, value }] };
|
60
|
+
}
|
61
|
+
function buildMultiList(item) {
|
62
|
+
const { id, value, props } = item;
|
63
|
+
const parsedValues = parseMultiListValues(value);
|
64
|
+
if (parsedValues.length > 0) {
|
65
|
+
return {
|
66
|
+
name: id,
|
67
|
+
expression: props.expression,
|
68
|
+
params: [{
|
69
|
+
name: id,
|
70
|
+
dataType: core.DataType.TEXT,
|
71
|
+
value: JSON.stringify(parsedValues)
|
72
|
+
}]
|
73
|
+
};
|
74
|
+
}
|
75
|
+
}
|
76
|
+
function buildCheckboxList(item) {
|
77
|
+
var _a;
|
78
|
+
const { id, value, props } = item;
|
79
|
+
const selectedOptionNames = Object.entries(value !== null && value !== void 0 ? value : {})
|
80
|
+
.filter(([_, valueChecked]) => valueChecked === true)
|
81
|
+
.map(([key, _]) => key);
|
82
|
+
const selectedOptionsObject = (_a = props.options) === null || _a === void 0 ? void 0 : _a.filter(option => selectedOptionNames.includes(option.name));
|
83
|
+
return { name: id, expression: buildCheckboxListExpression(selectedOptionsObject), params: [] };
|
84
|
+
}
|
85
|
+
function buildCheckboxListExpression(options) {
|
86
|
+
let expression = "";
|
87
|
+
options.forEach((option, index) => {
|
88
|
+
var _a;
|
89
|
+
expression += ` ${index > 0 ? ((_a = option.operand) !== null && _a !== void 0 ? _a : 'OR') : ''} ${option.expression}`;
|
90
|
+
});
|
91
|
+
return expression.trim();
|
92
|
+
}
|
93
|
+
function parseMultiListValues(multiListValue) {
|
94
|
+
var _a, _b;
|
95
|
+
const value = (_b = (_a = multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.elements) !== null && _a !== void 0 ? _a : multiListValue === null || multiListValue === void 0 ? void 0 : multiListValue.members) !== null && _b !== void 0 ? _b : multiListValue;
|
96
|
+
return value.filter(item => item === null || item === void 0 ? void 0 : item.check).map(({ id }) => Number.isNaN(+id) ? String(id) : Number(id));
|
97
|
+
}
|
98
|
+
function buildPeriod(item) {
|
99
|
+
const { id, value, props } = item;
|
100
|
+
let { end, start } = value;
|
101
|
+
if (typeof end === "string") {
|
102
|
+
end = new Date(end);
|
103
|
+
}
|
104
|
+
if (typeof start === "string") {
|
105
|
+
start = new Date(start);
|
106
|
+
}
|
107
|
+
const params = [];
|
108
|
+
let expression;
|
109
|
+
if (end && start) {
|
110
|
+
expression = props.expression.fullfill;
|
111
|
+
params.push({ name: `${id}.START`, dataType: core.DataType.DATE, value: DataType.toString(core.DataType.DATE, start) }, { name: `${id}.END`, dataType: core.DataType.DATE, value: DataType.toString(core.DataType.DATE, end) });
|
112
|
+
}
|
113
|
+
else {
|
114
|
+
if (start) {
|
115
|
+
expression = props.expression.onlystart;
|
116
|
+
params.push({ name: id, dataType: core.DataType.DATE, value: DataType.toString(core.DataType.DATE, start) });
|
117
|
+
}
|
118
|
+
else {
|
119
|
+
expression = props.expression.onlyend;
|
120
|
+
params.push({ name: id, dataType: core.DataType.DATE, value: DataType.toString(core.DataType.DATE, end) });
|
121
|
+
}
|
122
|
+
}
|
123
|
+
return { name: id, expression, params };
|
124
|
+
}
|
125
|
+
function buildSearch(item) {
|
126
|
+
const { id, value, props } = item;
|
127
|
+
const expression = props.expression;
|
128
|
+
return { name: id, expression, params: [{ name: id, dataType: core.DataType.TEXT, value: DataType.toString(core.DataType.TEXT, value.value) }] };
|
129
|
+
}
|
130
|
+
function buildText(item) {
|
131
|
+
let { id, value, props } = item;
|
132
|
+
const expression = props.expression;
|
133
|
+
if (!core.StringUtils.isEmpty(props.likeAs)) {
|
134
|
+
value = buildLikeValue(value, props.likeAs);
|
135
|
+
}
|
136
|
+
return { name: id, expression, params: [{ name: id, dataType: core.DataType.TEXT, value: DataType.toString(core.DataType.TEXT, value) }] };
|
137
|
+
}
|
138
|
+
function buildNumber(item) {
|
139
|
+
const { id, value, props } = item;
|
140
|
+
const variation = props.variation;
|
141
|
+
if (variation === filterNumberVariation.FilterNumberVariation.INTERVAL) {
|
142
|
+
const { start, end } = value !== null && value !== void 0 ? value : { start: 0, end: 0 };
|
143
|
+
if (start && end) {
|
144
|
+
return {
|
145
|
+
name: id,
|
146
|
+
expression: props.intervalExpression.fullfill,
|
147
|
+
params: [
|
148
|
+
{ name: `${id}.START`, dataType: core.DataType.NUMBER, value: DataType.toString(core.DataType.NUMBER, start) },
|
149
|
+
{ name: `${id}.END`, dataType: core.DataType.NUMBER, value: DataType.toString(core.DataType.NUMBER, end) }
|
150
|
+
]
|
151
|
+
};
|
152
|
+
}
|
153
|
+
if (start) {
|
154
|
+
return {
|
155
|
+
name: id,
|
156
|
+
expression: props.intervalExpression.onlystart,
|
157
|
+
params: [
|
158
|
+
{ name: id, dataType: core.DataType.NUMBER, value: DataType.toString(core.DataType.NUMBER, start) }
|
159
|
+
]
|
160
|
+
};
|
161
|
+
}
|
162
|
+
if (end) {
|
163
|
+
return {
|
164
|
+
name: id,
|
165
|
+
expression: props.intervalExpression.onlyend,
|
166
|
+
params: [
|
167
|
+
{ name: id, dataType: core.DataType.NUMBER, value: DataType.toString(core.DataType.NUMBER, end) }
|
168
|
+
]
|
169
|
+
};
|
170
|
+
}
|
171
|
+
}
|
172
|
+
const expression = props.expression;
|
173
|
+
return { name: id, expression, params: [{ name: id, dataType: core.DataType.NUMBER, value: DataType.toString(core.DataType.NUMBER, value) }] };
|
174
|
+
}
|
175
|
+
function buildLikeValue(valueAsString, likeAs) {
|
176
|
+
if (likeAs === "CONTANIS") {
|
177
|
+
return `%${valueAsString}%`;
|
178
|
+
}
|
179
|
+
else if (likeAs === "STARTS_WITH") {
|
180
|
+
return `${valueAsString}%`;
|
181
|
+
}
|
182
|
+
else if (likeAs === "ENDS_WITH") {
|
183
|
+
return `%${valueAsString}`;
|
184
|
+
}
|
185
|
+
return valueAsString;
|
186
|
+
}
|
187
|
+
function buildPersonalized(item) {
|
188
|
+
const { id, groupedItems = [] } = item;
|
189
|
+
const activeFilters = groupedItems.filter(groupItem => !!groupItem.visible);
|
190
|
+
const filters = activeFilters.map(item => {
|
191
|
+
var _a;
|
192
|
+
const expression = item.props.expression;
|
193
|
+
const params = (((_a = item.props.personalizedFilter) === null || _a === void 0 ? void 0 : _a.parameters) || []).map((param, index) => {
|
194
|
+
const valuesArray = Array.from(item.value || 0);
|
195
|
+
const dataType = param.dataType;
|
196
|
+
let paramValue = (index >= 0 && index < valuesArray.length ? valuesArray[index] : null);
|
197
|
+
if (paramValue != undefined && typeof paramValue === "object" && "value" in paramValue) {
|
198
|
+
paramValue = paramValue["value"];
|
199
|
+
}
|
200
|
+
if (paramValue == undefined && dataType === core.DataType.BOOLEAN) {
|
201
|
+
paramValue = false;
|
202
|
+
}
|
203
|
+
return { name: param.name, dataType, value: typeof paramValue === "string" ? paramValue : DataType.toString(dataType, paramValue) };
|
204
|
+
});
|
205
|
+
return { expression, name: item.id, params };
|
206
|
+
});
|
207
|
+
const expression = filters.map(filter => `(${filter.expression})`).join(` ${index.FilterOperand.AND} `);
|
208
|
+
const params = filters.flatMap(filter => filter.params);
|
209
|
+
return { name: id, expression, params };
|
210
|
+
}
|
211
|
+
|
212
|
+
class SnkFilterModalFactory {
|
213
|
+
constructor({ filterConfig, configName, onComplete, getMessage, disablePersonalizedFilter, onAddPersonalizedFilter, onEditPersonalizedFilter, onDeletePersonalizedFilter }) {
|
214
|
+
this._filterConfig = filterConfig;
|
215
|
+
this._configName = configName;
|
216
|
+
this._onComplete = onComplete;
|
217
|
+
this._getMessage = getMessage;
|
218
|
+
this._disablePersonalizedFilter = disablePersonalizedFilter;
|
219
|
+
this._addPersonalizedFilterFn = onAddPersonalizedFilter;
|
220
|
+
this._editPersonalizedFilterFn = onEditPersonalizedFilter;
|
221
|
+
this._onDeletePersonalizedFilter = onDeletePersonalizedFilter;
|
222
|
+
}
|
223
|
+
applyFilters(newFilterConfig) {
|
224
|
+
this._onComplete(newFilterConfig);
|
225
|
+
this._closeModal();
|
226
|
+
}
|
227
|
+
buildFilterModal() {
|
228
|
+
const filterModal = document.createElement("snk-filter-modal");
|
229
|
+
filterModal.className = "ez-size-height--full";
|
230
|
+
filterModal.filters = this._filterConfig;
|
231
|
+
filterModal.configName = this._configName;
|
232
|
+
filterModal.disablePersonalizedFilter = this._disablePersonalizedFilter;
|
233
|
+
filterModal.getMessage = this._getMessage.bind(this);
|
234
|
+
filterModal.applyFilters = this.applyFilters.bind(this);
|
235
|
+
filterModal.closeModal = () => this._closeModal();
|
236
|
+
filterModal.addPersonalizedFilter = () => this._addPersonalizedFilterFn();
|
237
|
+
filterModal.editPersonalizedFilter = (id) => this._editPersonalizedFilterFn(id);
|
238
|
+
filterModal.deletePersonalizedFilter = (filter, configName) => this._onDeletePersonalizedFilter(filter, configName);
|
239
|
+
return filterModal;
|
240
|
+
}
|
241
|
+
async showModal() {
|
242
|
+
const filterModal = this.buildFilterModal();
|
243
|
+
const modalProps = {
|
244
|
+
content: filterModal,
|
245
|
+
position: 'left',
|
246
|
+
heightMode: 'full',
|
247
|
+
closeOutsideClick: false,
|
248
|
+
useScrimLight: true
|
249
|
+
};
|
250
|
+
this._closeModal = await utils.ApplicationUtils.showModal(modalProps);
|
251
|
+
}
|
252
|
+
async closeModal() {
|
253
|
+
this._closeModal();
|
254
|
+
}
|
255
|
+
}
|
256
|
+
|
257
|
+
const snkFilterBarCss = ".sc-snk-filter-bar-h{display:grid;grid-template-columns:1fr minmax(100px, 100%) 1fr 1fr;--snk-personalized-filter--z-index:var(--elevation--20, 20);--snk-personalized-filter--background-color:var(--background--xlight, #fff)}.snk-filter-bar__title.sc-snk-filter-bar{max-width:260px;display:inline-block;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;font-size:16px;font-family:var(--font-pattern, Arial);font-weight:var(--text-weight--large, 600);color:var(--color--title-primary, #2B3A54);margin-top:8px}[data-mode=\"hidden\"].sc-snk-filter-bar-h{width:0px;height:0px}[data-mode=\"button\"].sc-snk-filter-bar-h{grid-template-columns:1fr;width:fit-content}.snk-filter__popover-container.sc-snk-filter-bar{display:flex;cursor:auto}.filter-bar__personalized-filter.sc-snk-filter-bar{display:flex;flex-direction:column;position:fixed;top:0;left:0;width:100%;height:100%;overflow:auto;z-index:var(--snk-personalized-filter--z-index);background-color:var(--snk-personalized-filter--background-color)}.snk-filter__popover.sc-snk-filter-bar{display:flex;flex-direction:column;position:absolute;width:fit-content;height:fit-content;min-width:265px;background-color:var(--background--xlight, #fff);border-radius:var(--border--radius-medium, 12px);box-shadow:var(--shadow, 0px 0px 16px 0px #000)}.snk-filter-item__editor-header.sc-snk-filter-bar{flex-grow:1;font-weight:var(--text-weight--medium, 400);color:var(--color--title-primary, #2B3A54)}.snk-filter__popover-rule.sc-snk-filter-bar{border-style:solid;border-color:var(--color--disable-secondary, #F2F5F8);border-radius:1px;border-width:1px;width:100%}.editor__ez-check.sc-snk-filter-bar{--ez-check__label--padding-left:0}.snk-filter-item__editor-header-button.sc-snk-filter-bar{cursor:pointer;background-color:transparent;border:none;padding:3px;outline-color:var(--color--primary)}.snk-filter-bar__divider.sc-snk-filter-bar{margin-bottom:var(--space--small)}.snk-filter-bar__scroller.sc-snk-filter-bar{height:calc(100% + var(--space-extra-small, 3px))}.snk-filter-bar__filter-item-container.sc-snk-filter-bar{display:flex;align-items:start}.snk-filter-bar__scroller.sc-snk-filter-bar .sc-snk-filter-bar:first-child{margin-left:var(--space-extra-small, 3px)}.snk-filter-bar__filter-list-items-container.sc-snk-filter-bar{overflow-y:auto;max-height:360px;margin-top:var(--space--small, 6px)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar{cursor:pointer;border-radius:var(--border--radius-small, 6px);border:none;background-color:transparent}.snk-filter-bar__filter-list-item__label.sc-snk-filter-bar{color:var(--title--primary)}.snk-filter-bar__filter-list-item__label--secondary.sc-snk-filter-bar{color:var(--text--primary)}.snk-filter-bar__filter-list-item__icon.sc-snk-filter-bar{--ez-icon--color:var(--title--primary)}.snk-filter-bar__filter-list-item__icon--secondary.sc-snk-filter-bar{--ez-icon--color:var(--text--secondary)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar:focus-visible{outline:none;background-color:var(--background--medium)}.snk-filter-bar__filter-list-item.sc-snk-filter-bar:hover{background-color:var(--background--medium)}.snk-filter-bar__filter-list-items-container--empty.sc-snk-filter-bar{width:100%;height:100px;display:flex;justify-content:center;align-self:center;align-items:center}.snk-filter-bar__filter-list-items-button--active.sc-snk-filter-bar{position:relative}.snk-filter-bar__filter-list-items-button--active.sc-snk-filter-bar::after{display:flex;position:absolute;content:\"\";width:8px;height:8px;top:7px;left:17px;background-color:var(--icon--alert--color, #008561);border-radius:50%}.snk-filter-bar__filter-modal-item.sc-snk-filter-bar{--modal-item-border-width:2px;display:flex;flex-direction:row;margin-left:var(--modal-item-border-width);border-radius:var(--border--radius-medium, 12px);background-color:var(--background--medium, #f0f3f7);border:none;width:100%}.snk-filter-bar__filter-modal-item.sc-snk-filter-bar:focus-visible{outline:var(--color--primary) solid var(--modal-item-border-width)}.snk-filter-bar__filter-modal-item__check.sc-snk-filter-bar{width:auto}.snk-filter-bar__filter-modal-item__label.sc-snk-filter-bar{font-weight:var(--text-weight--medium)}.snk-filter-bar__filter-modal-content.sc-snk-filter-bar{display:grid;grid-template-rows:auto auto 1fr auto;width:99%;height:100%}";
|
258
|
+
|
259
|
+
const SnkFilterBar = class {
|
260
|
+
constructor(hostRef) {
|
261
|
+
index$1.registerInstance(this, hostRef);
|
262
|
+
this.configUpdated = index$1.createEvent(this, "configUpdated", 7);
|
263
|
+
this._updateSequence = [];
|
264
|
+
this._loadingPending = false;
|
265
|
+
this._configUpdated = false;
|
266
|
+
this._firstLoad = true;
|
267
|
+
this._pendingVariables = false;
|
268
|
+
this._customfiltersToBeUpdated = [];
|
269
|
+
this._calculateSortIndex = (item) => {
|
270
|
+
if (!item.visible)
|
271
|
+
return 0;
|
272
|
+
if (item.hardFixed)
|
273
|
+
return 1000000; //campos Hard Fixed não variam a ordem
|
274
|
+
let index = item.fixed ? 100000 : 0;
|
275
|
+
index += this.hasValidValue(item) ? 10000 : 0;
|
276
|
+
index += this._updateSequence.lastIndexOf(item.id) + 1;
|
277
|
+
return index;
|
278
|
+
};
|
279
|
+
this._filtersComparator = (a, b) => {
|
280
|
+
return this._calculateSortIndex(b) - this._calculateSortIndex(a);
|
281
|
+
};
|
282
|
+
this.customFilterBarConfig = undefined;
|
283
|
+
this.dataUnit = undefined;
|
284
|
+
this.title = undefined;
|
285
|
+
this.configName = undefined;
|
286
|
+
this.resourceID = undefined;
|
287
|
+
this.mode = "regular";
|
288
|
+
this.filterConfig = undefined;
|
289
|
+
this.messagesBuilder = undefined;
|
290
|
+
this.disablePersonalizedFilter = undefined;
|
291
|
+
this.filterBarLegacyConfigName = undefined;
|
292
|
+
this.autoLoad = undefined;
|
293
|
+
this.allowDefault = undefined;
|
294
|
+
this.scrollerLocked = false;
|
295
|
+
this.showPersonalizedFilter = false;
|
296
|
+
this.personalizedFilterId = undefined;
|
297
|
+
}
|
298
|
+
hasValidValue(item) {
|
299
|
+
if (item.value === undefined || item.value === null)
|
300
|
+
return false;
|
301
|
+
if (!Array.isArray(item.value))
|
302
|
+
return true;
|
303
|
+
return item.value.some(filterItem => filterItem.check === true);
|
304
|
+
}
|
305
|
+
observeFilterConfig(newValue, oldValue) {
|
306
|
+
if (core.ObjectUtils.equals(newValue, oldValue))
|
307
|
+
return;
|
308
|
+
this.handleFilterConfigsChanged(oldValue, newValue);
|
309
|
+
}
|
310
|
+
handleFilterConfigsChanged(oldValue, newValue) {
|
311
|
+
if (oldValue != undefined && newValue == undefined) {
|
312
|
+
this._loadingPending = true;
|
313
|
+
this._configUpdated = true;
|
314
|
+
}
|
315
|
+
else {
|
316
|
+
const oldItems = new Map(oldValue ? oldValue.map(item => [item.id, item]) : undefined);
|
317
|
+
if (oldItems.size === 0 && newValue.length > 0) {
|
318
|
+
this._loadingPending = true;
|
319
|
+
this._configUpdated = false;
|
320
|
+
}
|
321
|
+
else {
|
322
|
+
newValue.forEach(newItem => {
|
323
|
+
const oldItem = oldItems.get(newItem.id);
|
324
|
+
if (oldItem != undefined) {
|
325
|
+
this._configUpdated = this._configUpdated || core.ObjectUtils.objectToString(oldItem) != core.ObjectUtils.objectToString(newItem);
|
326
|
+
this._loadingPending = this._loadingPending || core.ObjectUtils.objectToString(oldItem.value) !== core.ObjectUtils.objectToString(newItem.value);
|
327
|
+
if (!this._loadingPending) {
|
328
|
+
const groupedChanged = core.ObjectUtils.objectToString(oldItem.groupedItems) != core.ObjectUtils.objectToString(newItem.groupedItems);
|
329
|
+
this._configUpdated = this._configUpdated || groupedChanged;
|
330
|
+
this._loadingPending = this._loadingPending || groupedChanged;
|
331
|
+
}
|
332
|
+
}
|
333
|
+
else {
|
334
|
+
this._configUpdated = true;
|
335
|
+
this._loadingPending = this._loadingPending || newItem.value != undefined;
|
336
|
+
}
|
337
|
+
});
|
338
|
+
}
|
339
|
+
}
|
340
|
+
if (this._loadingPending || this._configUpdated)
|
341
|
+
this.configUpdated.emit(newValue);
|
342
|
+
this.processAfterUpdateConfig();
|
343
|
+
}
|
344
|
+
/**
|
345
|
+
* Faz o recarregamento da filterbar buscando o state no servidor.
|
346
|
+
*/
|
347
|
+
async reload() {
|
348
|
+
this.loadConfigFromStorage(true);
|
349
|
+
}
|
350
|
+
/**
|
351
|
+
* Retorna um item de filtro pelo ID.
|
352
|
+
*/
|
353
|
+
async getFilterItem(id) {
|
354
|
+
const item = this.filterConfig.find(item => item.id === id);
|
355
|
+
return Promise.resolve(core.ObjectUtils.copy(item));
|
356
|
+
}
|
357
|
+
/**
|
358
|
+
* Atualiza um item do filtro.
|
359
|
+
*
|
360
|
+
* @param filterItem - Item com as informações atualizadas, caso o item não seja encontrado no array ele mão será modificado
|
361
|
+
*/
|
362
|
+
async updateFilterItem(newFilterItem) {
|
363
|
+
const itemIndex = this.filterConfig.findIndex(item => item.id === newFilterItem.id);
|
364
|
+
if (itemIndex == -1) {
|
365
|
+
console.warn("[SnkFilterBar.updateFilterItem] FilterItem não encontrado, o mesmo não será atualizado.");
|
366
|
+
return Promise.resolve();
|
367
|
+
}
|
368
|
+
this._loadingPending = true;
|
369
|
+
this.updateFilter(newFilterItem);
|
370
|
+
return Promise.resolve();
|
371
|
+
}
|
372
|
+
/**
|
373
|
+
* Adiciona um item de filtro.
|
374
|
+
*
|
375
|
+
* @param filterItem - Item a ser adicionado, caso o item já exista com o ID ele não será adicionado novamente
|
376
|
+
*/
|
377
|
+
async addFilterItem(filterItem) {
|
378
|
+
const itemIndex = this.filterConfig.findIndex(item => item.id === filterItem.id);
|
379
|
+
if (itemIndex > -1) {
|
380
|
+
console.warn("[SnkFilterBar.addFilterItem] FilterItem já existe , o mesmo não será adicionado novamente.");
|
381
|
+
return Promise.resolve();
|
382
|
+
}
|
383
|
+
this.filterConfig.push(filterItem);
|
384
|
+
this._loadingPending = true;
|
385
|
+
this.updateFilter(filterItem);
|
386
|
+
return Promise.resolve();
|
387
|
+
}
|
388
|
+
/**
|
389
|
+
* Remove um item de filtro.
|
390
|
+
*
|
391
|
+
* @param filterID - ID do a ser adicionado
|
392
|
+
*
|
393
|
+
* @returns {Promise<SnkFilterItemConfig|undefined>} - Retorna o item de filtro removido, ou undefined caso não encontrado.
|
394
|
+
*/
|
395
|
+
async removeFilterItem(filterID) {
|
396
|
+
const itemIndex = this.filterConfig.findIndex(item => item.id === filterID);
|
397
|
+
if (itemIndex == -1) {
|
398
|
+
console.warn("[SnkFilterBar.removeFilterItem] FilterItem não encontrado");
|
399
|
+
return Promise.resolve(undefined);
|
400
|
+
}
|
401
|
+
const itemToRemove = this.filterConfig[itemIndex];
|
402
|
+
this.filterConfig = this.filterConfig.filter(item => item.id !== filterID);
|
403
|
+
return Promise.resolve(itemToRemove);
|
404
|
+
}
|
405
|
+
componentDidLoad() {
|
406
|
+
if (this._element) {
|
407
|
+
const dataInfo = { dataUnit: this.dataUnit };
|
408
|
+
core.ElementIDUtils.addIDInfo(this._element, null, dataInfo);
|
409
|
+
}
|
410
|
+
}
|
411
|
+
processPendingFilter() {
|
412
|
+
if (this._pendingVariables) {
|
413
|
+
const popUp = this._element.querySelector("#filter-PERSONALIZED_FILTER_GROUP");
|
414
|
+
if (popUp) {
|
415
|
+
popUp.showUp(true).then(() => {
|
416
|
+
this.processAfterUpdateConfig();
|
417
|
+
});
|
418
|
+
}
|
419
|
+
}
|
420
|
+
else {
|
421
|
+
this.processAfterUpdateConfig();
|
422
|
+
}
|
423
|
+
}
|
424
|
+
getPersonalizedFilterItem() {
|
425
|
+
return this.filterConfig.find(item => item.type === filterItemType_enum.FilterItemType.PERSONALIZED);
|
426
|
+
}
|
427
|
+
async processAfterUpdateConfig() {
|
428
|
+
if (this._loadingPending) {
|
429
|
+
if (await this._application.isLoadedByPk() && !this._configUpdated)
|
430
|
+
return;
|
431
|
+
const personalizedFilter = this.getPersonalizedFilterItem();
|
432
|
+
this._pendingVariables = !PersonalizedFilterUtils.PersonalizedFilterUtils.validateVariableValues(personalizedFilter);
|
433
|
+
if (this._pendingVariables) {
|
434
|
+
return;
|
435
|
+
}
|
436
|
+
this._loadingPending = false;
|
437
|
+
this.doLoadData(this.dataUnit.getLastLoadRequest() != undefined);
|
438
|
+
}
|
439
|
+
if (this._configUpdated) {
|
440
|
+
this._configUpdated = false;
|
441
|
+
ConfigStorage.ConfigStorage.saveFilterBarConfig(this.filterConfig, this.configName, this.resourceID);
|
442
|
+
}
|
443
|
+
}
|
444
|
+
async doLoadData(forceReload = false) {
|
445
|
+
try {
|
446
|
+
if (this._firstLoad && this.autoLoad === false) {
|
447
|
+
return;
|
448
|
+
}
|
449
|
+
if (this._firstLoad && !forceReload && this.autoLoad === undefined) {
|
450
|
+
let autoLoad = await this._application.getBooleanParam("global.carregar.registros.iniciar.tela");
|
451
|
+
if (!autoLoad) {
|
452
|
+
return;
|
453
|
+
}
|
454
|
+
}
|
455
|
+
this.dataUnit.loadData(undefined, undefined, true);
|
456
|
+
}
|
457
|
+
finally {
|
458
|
+
this._firstLoad = false;
|
459
|
+
}
|
460
|
+
}
|
461
|
+
/**
|
462
|
+
* Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
|
463
|
+
* através de um pequeno modulo na estrutura da aplicação:
|
464
|
+
* - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
|
465
|
+
* Para conhecer os detalhes do módulo, vide o arquivo neste projeto "/src/lib/message/resources/snk-filter-bar.msg.ts"
|
466
|
+
*/
|
467
|
+
getMessage(key, params, defaultValue) {
|
468
|
+
var _a;
|
469
|
+
if (this.messagesBuilder == undefined && this._application) {
|
470
|
+
this.messagesBuilder = this._application.messagesBuilder;
|
471
|
+
}
|
472
|
+
return ((_a = this.messagesBuilder) === null || _a === void 0 ? void 0 : _a.getMessage(key, params)) || defaultValue;
|
473
|
+
}
|
474
|
+
getFilter(_dataUnit) {
|
475
|
+
var _a;
|
476
|
+
const filters = [];
|
477
|
+
(_a = this.filterConfig) === null || _a === void 0 ? void 0 : _a.filter(item => this.isActiveFilter(item)).forEach(item => {
|
478
|
+
const filter = buildFilter(item);
|
479
|
+
if (filter) {
|
480
|
+
filters.push(filter);
|
481
|
+
}
|
482
|
+
});
|
483
|
+
return filters;
|
484
|
+
}
|
485
|
+
isActiveFilter(item) {
|
486
|
+
/*
|
487
|
+
- O filtro padrão também deve sempre ser condiderado ativo, pois, sempre deve
|
488
|
+
ser aplicado.
|
489
|
+
*/
|
490
|
+
if (item.type === filterItemType_enum.FilterItemType.DEFAULT_FILTER) {
|
491
|
+
return true;
|
492
|
+
}
|
493
|
+
return this.filterActiveFilter(item) && (item.groupedItems || item.value != undefined);
|
494
|
+
}
|
495
|
+
registryFilterProvider() {
|
496
|
+
this.dataUnit.addFilterProvider(this);
|
497
|
+
if (this.filterConfig) {
|
498
|
+
this.doLoadData();
|
499
|
+
}
|
500
|
+
}
|
501
|
+
itemFocused(selectedItem) {
|
502
|
+
this._element.querySelectorAll("snk-filter-item,snk-filter-list").forEach(item => {
|
503
|
+
if (item.id === selectedItem) {
|
504
|
+
if (item.tagName.toLowerCase() === "snk-filter-item" && item.getClientRects()[0].x < 0) {
|
505
|
+
item.scrollIntoView({ behavior: "auto", inline: 'nearest' });
|
506
|
+
}
|
507
|
+
}
|
508
|
+
else {
|
509
|
+
item["hideDetail"]();
|
510
|
+
}
|
511
|
+
});
|
512
|
+
}
|
513
|
+
filterActiveFilter(item) {
|
514
|
+
return item.visible || item.removalBlocked;
|
515
|
+
}
|
516
|
+
filterPersonalizedItems(item) {
|
517
|
+
return item.type === filterItemType_enum.FilterItemType.PERSONALIZED;
|
518
|
+
}
|
519
|
+
getPersonalizedFilterVariableItems() {
|
520
|
+
return this.filterConfig
|
521
|
+
.filter(this.filterPersonalizedItems)
|
522
|
+
.map(item => {
|
523
|
+
const itemId = `filter-${item.id}`;
|
524
|
+
return (index$1.h("snk-filter-item", { key: item.id, id: itemId, config: Object.assign({}, item), onFocusin: () => this.itemFocused(itemId), onVisibleChanged: (evt) => this.scrollerLocked = evt.detail, onFilterChange: (event) => this.updateFilter(event.detail), getMessage: (key, props) => this.getMessage(key, props), showChips: false }));
|
525
|
+
});
|
526
|
+
}
|
527
|
+
getFilterItems() {
|
528
|
+
const pinnedItems = [];
|
529
|
+
const unpinnedItems = [];
|
530
|
+
this.filterConfig.sort((a, b) => this._filtersComparator(a, b))
|
531
|
+
.filter(this.filterActiveFilter)
|
532
|
+
.forEach((item, index) => {
|
533
|
+
item = core.ObjectUtils.copy(item);
|
534
|
+
const itemId = `filter-${item.id}`;
|
535
|
+
const filterItem = (index$1.h("snk-filter-item", { onVisibleChanged: (evt) => this.scrollerLocked = evt.detail, onFilterChange: (event) => this.updateFilter(event.detail), onFocusin: () => this.itemFocused(itemId), id: itemId, config: item, class: index > 0 ? "ez-padding-left--medium" : "", getMessage: (key, props) => this.getMessage(key, props), key: item.id }));
|
536
|
+
if (item.fixed || item.hardFixed) {
|
537
|
+
pinnedItems.push(filterItem);
|
538
|
+
}
|
539
|
+
else {
|
540
|
+
unpinnedItems.push(filterItem);
|
541
|
+
}
|
542
|
+
return filterItem;
|
543
|
+
});
|
544
|
+
const elements = [];
|
545
|
+
elements.push(...pinnedItems);
|
546
|
+
if (pinnedItems.length > 0 && unpinnedItems.length > 0) {
|
547
|
+
elements.push(index$1.h("hr", { class: "ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-filter-bar__divider" }));
|
548
|
+
}
|
549
|
+
elements.push(...unpinnedItems);
|
550
|
+
return elements;
|
551
|
+
}
|
552
|
+
calculateUpdateSequence(item) {
|
553
|
+
if (item) {
|
554
|
+
this._updateSequence = this._updateSequence.filter(itemId => item.id !== itemId);
|
555
|
+
this._updateSequence.push(item.id);
|
556
|
+
}
|
557
|
+
}
|
558
|
+
normalizeItem(item) {
|
559
|
+
const normalized = Object.assign({}, item);
|
560
|
+
const optionals = ["props", "value", "hardFixed", "fixed"];
|
561
|
+
optionals.forEach(prop => {
|
562
|
+
if (normalized[prop] == undefined) {
|
563
|
+
delete normalized[prop];
|
564
|
+
}
|
565
|
+
});
|
566
|
+
if (item.value === "") {
|
567
|
+
delete item.value;
|
568
|
+
}
|
569
|
+
return normalized;
|
570
|
+
}
|
571
|
+
updateFilter(newItem) {
|
572
|
+
this.filterConfig = this.filterConfig.map(item => {
|
573
|
+
newItem = this.normalizeItem(newItem);
|
574
|
+
if (item.id === newItem.id) {
|
575
|
+
if (core.ObjectUtils.objectToString(item) != core.ObjectUtils.objectToString(newItem)) {
|
576
|
+
this.calculateUpdateSequence(newItem);
|
577
|
+
}
|
578
|
+
return newItem;
|
579
|
+
}
|
580
|
+
return item;
|
581
|
+
}).sort((a, b) => this._filtersComparator(a, b));
|
582
|
+
}
|
583
|
+
loadPermitions() {
|
584
|
+
this._application.isUserSup().then(value => this.allowDefault = value);
|
585
|
+
}
|
586
|
+
addFilterBarLegacyConfigName() {
|
587
|
+
if (this.filterBarLegacyConfigName && this.configName) {
|
588
|
+
ConfigStorage.ConfigStorage.addFilterBarLegacyConfig(this.configName, this.filterBarLegacyConfigName);
|
589
|
+
}
|
590
|
+
}
|
591
|
+
async loadConfigFromStorage(clearCache) {
|
592
|
+
try {
|
593
|
+
if (clearCache) {
|
594
|
+
await ConfigStorage.ConfigStorage.deleteFilterBarConfigCache(this.configName, this.resourceID);
|
595
|
+
}
|
596
|
+
let config;
|
597
|
+
if (this.customFilterBarConfig) {
|
598
|
+
config = await this.customFilterBarConfig(this.configName, this.resourceID, { contextURI: this.dataUnit.name });
|
599
|
+
}
|
600
|
+
else {
|
601
|
+
config = await ConfigStorage.ConfigStorage.loadFilterBarConfig(this.configName, this.resourceID, { contextURI: this.dataUnit.name });
|
602
|
+
}
|
603
|
+
this.filterConfig = config.map(item => this.normalizeItem(item));
|
604
|
+
this.filterConfig.sort((a, b) => this._filtersComparator(a, b));
|
605
|
+
}
|
606
|
+
catch (e) {
|
607
|
+
throw new core.ErrorException(this.getMessage("snkFilterBar.failToLoadConfig"), e);
|
608
|
+
}
|
609
|
+
}
|
610
|
+
attachDataUnit() {
|
611
|
+
if (this.dataUnit == undefined) {
|
612
|
+
let parent = this._element.parentElement;
|
613
|
+
while (parent) {
|
614
|
+
if (parent.tagName.toUpperCase() === "SNK-DATA-UNIT") {
|
615
|
+
const snkDataUnit = parent;
|
616
|
+
this.dataUnit = snkDataUnit.dataUnit;
|
617
|
+
if (this.dataUnit) {
|
618
|
+
this.registryFilterProvider();
|
619
|
+
}
|
620
|
+
else {
|
621
|
+
snkDataUnit.addEventListener("dataUnitReady", (evt) => {
|
622
|
+
this.dataUnit = evt.detail;
|
623
|
+
this.registryFilterProvider();
|
624
|
+
});
|
625
|
+
}
|
626
|
+
break;
|
627
|
+
}
|
628
|
+
}
|
629
|
+
parent = parent.parentElement;
|
630
|
+
}
|
631
|
+
else {
|
632
|
+
this.registryFilterProvider();
|
633
|
+
}
|
634
|
+
}
|
635
|
+
/**
|
636
|
+
* Emitido quando acontece a alteração do estado do filtro.
|
637
|
+
*/
|
638
|
+
filterChangeListener(evt) {
|
639
|
+
this.updateFilter(evt.detail);
|
640
|
+
}
|
641
|
+
/**
|
642
|
+
* Abre o modal de filtros
|
643
|
+
*/
|
644
|
+
async showFilterModal() {
|
645
|
+
const callbackOnApplyFilter = (filters) => {
|
646
|
+
this.filterConfig = filters.map(this.normalizeItem).sort((a, b) => this._filtersComparator(a, b));
|
647
|
+
};
|
648
|
+
let filtersConfigCopy = core.ObjectUtils.copy(this.filterConfig);
|
649
|
+
filtersConfigCopy = filtersConfigCopy.sort((itemA, itemB) => {
|
650
|
+
return itemA.originOrder - itemB.originOrder;
|
651
|
+
});
|
652
|
+
const factoryParams = {
|
653
|
+
filterConfig: filtersConfigCopy,
|
654
|
+
configName: this.configName,
|
655
|
+
onComplete: callbackOnApplyFilter,
|
656
|
+
disablePersonalizedFilter: this.disablePersonalizedFilter,
|
657
|
+
getMessage: (key, props) => this.getMessage(key, props),
|
658
|
+
onAddPersonalizedFilter: () => this.addPersonalizedFilter(),
|
659
|
+
onEditPersonalizedFilter: (id) => this.editPersonalizedFilter(id),
|
660
|
+
onDeletePersonalizedFilter: (filter, configName) => this.deletePersonalizedFilter(filter, filterItemType_enum.FilterItemType.PERSONALIZED, configName),
|
661
|
+
};
|
662
|
+
this._filterModalFactory = new SnkFilterModalFactory(factoryParams);
|
663
|
+
await this._filterModalFactory.showModal();
|
664
|
+
}
|
665
|
+
addPersonalizedFilter() {
|
666
|
+
this._filterModalFactory.closeModal();
|
667
|
+
this.personalizedFilterId = undefined;
|
668
|
+
this.showPersonalizedFilter = true;
|
669
|
+
window.requestAnimationFrame(() => {
|
670
|
+
this._elPersonalizedFilter.createPersonalizedFilter();
|
671
|
+
});
|
672
|
+
}
|
673
|
+
editPersonalizedFilter(id) {
|
674
|
+
this._filterModalFactory.closeModal();
|
675
|
+
this.showPersonalizedFilter = true;
|
676
|
+
this.personalizedFilterId = id;
|
677
|
+
}
|
678
|
+
deletePersonalizedFilter(filter, filterItemType, configName) {
|
679
|
+
if (filterItemType === filterItemType_enum.FilterItemType.PERSONALIZED) {
|
680
|
+
ConfigStorage.ConfigStorage.removePersonalizedFilter(filter, this.resourceID, configName);
|
681
|
+
}
|
682
|
+
}
|
683
|
+
handleHidePersonalizedFilter(reloadFilterBar) {
|
684
|
+
if (reloadFilterBar) {
|
685
|
+
this.loadConfigFromStorage().then(() => {
|
686
|
+
this.hidePersonalizedFilter();
|
687
|
+
});
|
688
|
+
}
|
689
|
+
else {
|
690
|
+
this.hidePersonalizedFilter();
|
691
|
+
}
|
692
|
+
}
|
693
|
+
hidePersonalizedFilter() {
|
694
|
+
this.personalizedFilterId = undefined;
|
695
|
+
this.showPersonalizedFilter = false;
|
696
|
+
}
|
697
|
+
componentWillLoad() {
|
698
|
+
this._application = core.ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
699
|
+
if (this._application) {
|
700
|
+
this.loadPermitions();
|
701
|
+
this.addFilterBarLegacyConfigName();
|
702
|
+
this.loadConfigFromStorage();
|
703
|
+
}
|
704
|
+
this.attachDataUnit();
|
705
|
+
}
|
706
|
+
componentDidRender() {
|
707
|
+
this.processPendingFilter();
|
708
|
+
}
|
709
|
+
render() {
|
710
|
+
if (!this.dataUnit || !this.filterConfig || this.filterConfig.length === 0) {
|
711
|
+
return undefined;
|
712
|
+
}
|
713
|
+
if (this.showPersonalizedFilter) {
|
714
|
+
return index$1.h("snk-personalized-filter", { class: "filter-bar__personalized-filter", filterId: this.personalizedFilterId, ref: (el) => this._elPersonalizedFilter = el, onEzCancel: () => this.handleHidePersonalizedFilter(false), onEzAfterSave: () => this.handleHidePersonalizedFilter(true), entityUri: this.dataUnit.name, configName: this.configName, resourceID: this.resourceID });
|
715
|
+
}
|
716
|
+
if (this.mode !== "regular") {
|
717
|
+
return (index$1.h(index$1.Host, { "data-mode": this.mode }, this.getPersonalizedFilterVariableItems(), this.mode === 'button' && (index$1.h("ez-button", { class: "ez-margin-left--medium", size: "small", label: this.getMessage('snkFilterBar.filters', undefined, 'Filtros'), onClick: this.showFilterModal.bind(this) }))));
|
718
|
+
}
|
719
|
+
return (index$1.h(index$1.Host, null, index$1.h("div", null, index$1.h("span", { class: "snk-filter-bar__title", title: this.title, "data-tooltip": this.title, "data-flow": "bottom" }, this.title)), index$1.h("ez-scroller", { class: "snk-filter-bar__scroller", direction: EzScrollDirection.EzScrollDirection.HORIZONTAL, activeShadow: true, locked: this.scrollerLocked }, index$1.h("section", { class: "snk-filter-bar__filter-item-container" }, this.getFilterItems())), index$1.h("ez-button", { class: "ez-padding-left--medium", size: "small", label: this.getMessage('snkFilterBar.filters', undefined, 'Filtros'), onClick: this.showFilterModal.bind(this) }, index$1.h("ez-icon", { slot: "leftIcon", iconName: "plus", class: "ez-padding-right--small" }))));
|
720
|
+
}
|
721
|
+
get _element() { return index$1.getElement(this); }
|
722
|
+
static get watchers() { return {
|
723
|
+
"filterConfig": ["observeFilterConfig"]
|
724
|
+
}; }
|
725
|
+
};
|
726
|
+
SnkFilterBar.style = snkFilterBarCss;
|
727
|
+
|
728
|
+
const SnkFilterItem = class {
|
729
|
+
constructor(hostRef) {
|
730
|
+
index$1.registerInstance(this, hostRef);
|
731
|
+
this.visibleChanged = index$1.createEvent(this, "visibleChanged", 7);
|
732
|
+
this.filterChange = index$1.createEvent(this, "filterChange", 3);
|
733
|
+
this.innerClickCheck = (_floatingContainer, node) => {
|
734
|
+
if (node.id != core.FloatingManager.MODAL_ELEMENT_ID) {
|
735
|
+
return true;
|
736
|
+
}
|
737
|
+
this.detailIsVisible = false;
|
738
|
+
return false;
|
739
|
+
};
|
740
|
+
this.detailIsVisible = undefined;
|
741
|
+
this.config = undefined;
|
742
|
+
this.getMessage = undefined;
|
743
|
+
this.showChips = true;
|
744
|
+
}
|
745
|
+
observeDetailIsVisible(value) {
|
746
|
+
this.visibleChanged.emit(value);
|
747
|
+
}
|
748
|
+
/**
|
749
|
+
* Exibe os detalhes de um item da lista.
|
750
|
+
*/
|
751
|
+
async showUp(open = false) {
|
752
|
+
return new Promise(resolve => {
|
753
|
+
this._filterItemElement.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" });
|
754
|
+
if (open) {
|
755
|
+
this._closeCallback = resolve;
|
756
|
+
window.requestAnimationFrame(() => {
|
757
|
+
this._floatingID = core.FloatingManager.float(this._popover, this._popoverContainer, this.getFloatOptions());
|
758
|
+
this._popover.show();
|
759
|
+
this.detailIsVisible = true;
|
760
|
+
});
|
761
|
+
}
|
762
|
+
});
|
763
|
+
}
|
764
|
+
updatePosition() {
|
765
|
+
if (this._floatingID == undefined) {
|
766
|
+
return;
|
767
|
+
}
|
768
|
+
core.FloatingManager.updateFloatPosition(this._popover, this._popoverContainer, this.getFloatOptions());
|
769
|
+
}
|
770
|
+
getFloatOptions() {
|
771
|
+
return {
|
772
|
+
autoClose: true,
|
773
|
+
innerClickTest: this.innerClickCheck,
|
774
|
+
backClickListener: () => this.onDetailCloseCallback(),
|
775
|
+
left: this.getOffsetLeft(),
|
776
|
+
top: this.getOffsetTop(),
|
777
|
+
useOverlay: true,
|
778
|
+
overlayClassName: 'ez-scrim ez-scrim--light',
|
779
|
+
isFixed: true
|
780
|
+
};
|
781
|
+
}
|
782
|
+
getOffsetLeft() {
|
783
|
+
const padding = getComputedStyle(this._filterItemElement).getPropertyValue("padding-left");
|
784
|
+
const rect = this._filterItemElement.getBoundingClientRect();
|
785
|
+
// Width baseado no conteudo do snk-filter-detail. Nesse momento ele retorna 0px pois ainda não foi criado em tela.
|
786
|
+
const filterDetailWidth = 430;
|
787
|
+
const adjustRightPosition = filterDetailWidth - (document.body.clientWidth - rect.left);
|
788
|
+
return `calc(${rect.x}px + ${padding} - ${adjustRightPosition > 0 ? adjustRightPosition : 0}px)`;
|
789
|
+
}
|
790
|
+
getOffsetTop() {
|
791
|
+
const rect = this._filterItemElement.getBoundingClientRect();
|
792
|
+
return (rect.y + rect.height) + "px";
|
793
|
+
}
|
794
|
+
controlScrollPage() {
|
795
|
+
window.removeEventListener("scroll", this.updatePosition.bind(this));
|
796
|
+
window.addEventListener("scroll", this.updatePosition.bind(this));
|
797
|
+
}
|
798
|
+
getConfigChanges() {
|
799
|
+
var _a;
|
800
|
+
const configToBeCleared = this.config;
|
801
|
+
if (!!((_a = configToBeCleared.groupedItems) === null || _a === void 0 ? void 0 : _a.length)) {
|
802
|
+
configToBeCleared.visible = false;
|
803
|
+
configToBeCleared.groupedItems = configToBeCleared.groupedItems.map(item => (Object.assign(Object.assign({}, item), { visible: false })));
|
804
|
+
}
|
805
|
+
const hasMultiValues = configToBeCleared.type === filterItemType_enum.FilterItemType.MULTI_LIST && Array.isArray(configToBeCleared.value);
|
806
|
+
const newValue = hasMultiValues ? configToBeCleared.value.map((valueItem) => (Object.assign(Object.assign({}, valueItem), { check: false }))) : undefined;
|
807
|
+
return Object.assign(Object.assign({}, configToBeCleared), { value: newValue });
|
808
|
+
}
|
809
|
+
/**
|
810
|
+
* Oculta os detalhes de um item da lista.
|
811
|
+
*/
|
812
|
+
async hideDetail() {
|
813
|
+
if (this.detailIsVisible) {
|
814
|
+
if (this._floatingID != undefined) {
|
815
|
+
core.FloatingManager.close(this._floatingID);
|
816
|
+
}
|
817
|
+
}
|
818
|
+
}
|
819
|
+
onDetailCloseCallback() {
|
820
|
+
this._floatingID = undefined;
|
821
|
+
this.detailIsVisible = false;
|
822
|
+
if (this._closeCallback) {
|
823
|
+
this._closeCallback();
|
824
|
+
this._closeCallback = undefined;
|
825
|
+
}
|
826
|
+
}
|
827
|
+
//---------------------------------------------
|
828
|
+
// Event handlers
|
829
|
+
//---------------------------------------------
|
830
|
+
clickListener(evt) {
|
831
|
+
if ([this._chipElement, this._leftIconElement, this._rightIconElement].includes(evt.target)) {
|
832
|
+
if (evt.target === this._rightIconElement && this.canClearFilter()) {
|
833
|
+
const configChanged = this.getConfigChanges();
|
834
|
+
this.filterChange.emit(configChanged);
|
835
|
+
}
|
836
|
+
else {
|
837
|
+
if (this.detailIsVisible) {
|
838
|
+
this.hideDetail();
|
839
|
+
}
|
840
|
+
else {
|
841
|
+
this.showUp(true);
|
842
|
+
}
|
843
|
+
}
|
844
|
+
evt.preventDefault();
|
845
|
+
evt.stopImmediatePropagation();
|
846
|
+
evt.stopPropagation();
|
847
|
+
}
|
848
|
+
}
|
849
|
+
mouseDownListener(evt) {
|
850
|
+
if (this.detailIsVisible && [this._chipElement, this._leftIconElement, this._rightIconElement].includes(evt.target)) {
|
851
|
+
evt.preventDefault();
|
852
|
+
evt.stopImmediatePropagation();
|
853
|
+
evt.stopPropagation();
|
854
|
+
}
|
855
|
+
}
|
856
|
+
getLabel(isTooltipLabel = false) {
|
857
|
+
var _a, _b;
|
858
|
+
const { type, value, label, props, groupedItems = [] } = this.config;
|
859
|
+
if (value || groupedItems.length) {
|
860
|
+
if (type === filterItemType_enum.FilterItemType.BINARY_SELECT) {
|
861
|
+
const [optOne, optTwo] = props.options;
|
862
|
+
const tooltip = this.getMessage('snkFilterBar.binarySelectTooltip');
|
863
|
+
if (optOne.name === value) {
|
864
|
+
return isTooltipLabel ? `${tooltip} ${String(optOne.label).toLowerCase()}` : optOne.label;
|
865
|
+
}
|
866
|
+
if (optTwo.name === value) {
|
867
|
+
return isTooltipLabel ? `${tooltip} ${String(optTwo.label).toLowerCase()}` : optTwo.label;
|
868
|
+
}
|
869
|
+
}
|
870
|
+
if (type === filterItemType_enum.FilterItemType.MULTI_SELECT) {
|
871
|
+
const opt = props.options.find(opt => opt.value === value);
|
872
|
+
return `${label}: ${opt.label}`;
|
873
|
+
}
|
874
|
+
if (type === filterItemType_enum.FilterItemType.PERIOD) {
|
875
|
+
let { end, start } = value;
|
876
|
+
if (typeof end === "string") {
|
877
|
+
end = new Date(end);
|
878
|
+
end.setMinutes(end.getMinutes() + end.getTimezoneOffset());
|
879
|
+
}
|
880
|
+
if (typeof start === "string") {
|
881
|
+
start = new Date(start);
|
882
|
+
start.setMinutes(start.getMinutes() + start.getTimezoneOffset());
|
883
|
+
}
|
884
|
+
const dateFormater = new Intl.DateTimeFormat("pt-BR");
|
885
|
+
if (end && start) {
|
886
|
+
const isSameYear = start.getFullYear() === end.getFullYear();
|
887
|
+
const formatOptions = Object.assign({ day: '2-digit', month: '2-digit' }, ((!isSameYear || isTooltipLabel) && { year: '2-digit' }));
|
888
|
+
const startLabel = core.DateUtils.formatDate(start, formatOptions);
|
889
|
+
const endLabel = core.DateUtils.formatDate(end, formatOptions);
|
890
|
+
if (isTooltipLabel) {
|
891
|
+
return this.getMessage('snkFilterBar.fullPeriodTooltip', { LABEL: label, START_LABEL: startLabel, END_LABEL: endLabel });
|
892
|
+
}
|
893
|
+
return `${label}: ${startLabel} \u2192 ${endLabel}`;
|
894
|
+
}
|
895
|
+
else {
|
896
|
+
if (start) {
|
897
|
+
return `${label}: ${this.getMessage('snkFilterBar.onlyStartToltip')} ${dateFormater.format(start)}`;
|
898
|
+
}
|
899
|
+
else if (end) {
|
900
|
+
return `${label}: ${this.getMessage('snkFilterBar.onlyEndToltip')} ${dateFormater.format(end)}`;
|
901
|
+
}
|
902
|
+
else {
|
903
|
+
return label;
|
904
|
+
}
|
905
|
+
}
|
906
|
+
}
|
907
|
+
if (type === filterItemType_enum.FilterItemType.SEARCH) {
|
908
|
+
return `${label}: ${value.value} - ${value.label}`;
|
909
|
+
}
|
910
|
+
if (type === filterItemType_enum.FilterItemType.PERSONALIZED) {
|
911
|
+
const activeCount = this.calculateActiveCount(groupedItems);
|
912
|
+
if (activeCount <= 0)
|
913
|
+
return label;
|
914
|
+
return `${label}: ${this.getMessage('snkFilterBar.personalizedCount', { activeCount })}`;
|
915
|
+
}
|
916
|
+
if (type === filterItemType_enum.FilterItemType.MULTI_LIST) {
|
917
|
+
const selectedOptions = ((_a = value.elements) !== null && _a !== void 0 ? _a : value).filter(item => item === null || item === void 0 ? void 0 : item.check);
|
918
|
+
return this.getLabelFromCheckedOptions(selectedOptions, label, isTooltipLabel);
|
919
|
+
}
|
920
|
+
if (type === filterItemType_enum.FilterItemType.CHECK_BOX_LIST) {
|
921
|
+
const selectedValues = Object.entries(value !== null && value !== void 0 ? value : {})
|
922
|
+
.filter(([_, value]) => value === true)
|
923
|
+
.map(([key, _]) => key);
|
924
|
+
const options = (_b = props.options) !== null && _b !== void 0 ? _b : [];
|
925
|
+
const selectedOptions = options.filter(option => selectedValues.includes(option.name));
|
926
|
+
return this.getLabelFromCheckedOptions(selectedOptions, label, isTooltipLabel);
|
927
|
+
}
|
928
|
+
if (type === filterItemType_enum.FilterItemType.NUMBER && props.variation === filterNumberVariation.FilterNumberVariation.INTERVAL) {
|
929
|
+
const { start, end } = value;
|
930
|
+
if (start && end) {
|
931
|
+
return this.getMessage('snkFilterBar.fullIntervalTooltip', { LABEL: label, START_LABEL: start, END_LABEL: end });
|
932
|
+
}
|
933
|
+
if (start) {
|
934
|
+
return `${label}: ${this.getMessage('snkFilterBar.onlyStartToltip')} ${Number(start)}`;
|
935
|
+
}
|
936
|
+
if (end) {
|
937
|
+
return `${label}: ${this.getMessage('snkFilterBar.onlyEndToltip')} ${Number(end)}`;
|
938
|
+
}
|
939
|
+
}
|
940
|
+
return `${label}: ${value}`;
|
941
|
+
}
|
942
|
+
return label;
|
943
|
+
}
|
944
|
+
getLabelFromCheckedOptions(selectedOptions, label, isTooltipLabel) {
|
945
|
+
const checkedAmount = selectedOptions.length;
|
946
|
+
if (checkedAmount === 0) {
|
947
|
+
return `${label}`;
|
948
|
+
}
|
949
|
+
if (checkedAmount > 1) {
|
950
|
+
if (isTooltipLabel) {
|
951
|
+
const selectedOptionsDescrptions = selectedOptions.map(item => item.label);
|
952
|
+
return `${label}: ${selectedOptionsDescrptions.join(',')}`;
|
953
|
+
}
|
954
|
+
return `${label}: ${checkedAmount} ${this.getMessage('snkFilterBar.multiListToltip')}`;
|
955
|
+
}
|
956
|
+
return `${label}: ${selectedOptions[0].label}`;
|
957
|
+
}
|
958
|
+
calculateActiveCount(groupedItems) {
|
959
|
+
return groupedItems.reduce((total, item) => {
|
960
|
+
if (!!item.visible)
|
961
|
+
return total + 1;
|
962
|
+
return total;
|
963
|
+
}, 0);
|
964
|
+
}
|
965
|
+
componentDidLoad() {
|
966
|
+
if (this._filterItemElement) {
|
967
|
+
core.ElementIDUtils.addIDInfo(this._filterItemElement);
|
968
|
+
this._idSnkFilterDetail = `filterDetail_${this.config.id}`;
|
969
|
+
}
|
970
|
+
this.controlScrollPage();
|
971
|
+
}
|
972
|
+
componentDidRender() {
|
973
|
+
if (this._floatingID == undefined) {
|
974
|
+
if (this._popover) {
|
975
|
+
this._popover.remove();
|
976
|
+
}
|
977
|
+
}
|
978
|
+
}
|
979
|
+
/**
|
980
|
+
* Emitido quando o estado do filtro é alterado.
|
981
|
+
*/
|
982
|
+
filterChangeListener() {
|
983
|
+
this.hideDetail();
|
984
|
+
}
|
985
|
+
canClearFilter() {
|
986
|
+
const { value, groupedItems = [] } = this.config;
|
987
|
+
if (value != undefined && this.config.type === filterItemType_enum.FilterItemType.MULTI_LIST) {
|
988
|
+
return value.some((item) => item.check);
|
989
|
+
}
|
990
|
+
return value !== undefined || groupedItems.some(item => item.visible);
|
991
|
+
}
|
992
|
+
getRightIconName() {
|
993
|
+
if (this.canClearFilter())
|
994
|
+
return "close";
|
995
|
+
return this.detailIsVisible ? "chevron-up" : "chevron-down";
|
996
|
+
}
|
997
|
+
getLeftIconName() {
|
998
|
+
switch (this.config.type) {
|
999
|
+
case filterItemType_enum.FilterItemType.PERIOD:
|
1000
|
+
return "calendar";
|
1001
|
+
case filterItemType_enum.FilterItemType.PERSONALIZED:
|
1002
|
+
return "tune";
|
1003
|
+
}
|
1004
|
+
return undefined;
|
1005
|
+
}
|
1006
|
+
hasActiveElements(value) {
|
1007
|
+
var _a, _b, _c;
|
1008
|
+
return ((_c = (_b = ((_a = value === null || value === void 0 ? void 0 : value.elements) !== null && _a !== void 0 ? _a : value)) === null || _b === void 0 ? void 0 : _b.filter(val => val === null || val === void 0 ? void 0 : val.check)) === null || _c === void 0 ? void 0 : _c.length) > 0;
|
1009
|
+
}
|
1010
|
+
hasActiveValue(config) {
|
1011
|
+
return (config.type !== filterItemType_enum.FilterItemType.MULTI_LIST && config.value !== undefined) || this.hasActiveElements(config.value);
|
1012
|
+
}
|
1013
|
+
getEnabledChip() {
|
1014
|
+
if (this.config.type === filterItemType_enum.FilterItemType.PERSONALIZED) {
|
1015
|
+
const { groupedItems = [] } = this.config;
|
1016
|
+
return groupedItems.some(item => item.visible);
|
1017
|
+
}
|
1018
|
+
return this.hasActiveValue(this.config);
|
1019
|
+
}
|
1020
|
+
render() {
|
1021
|
+
const leftIcon = this.getLeftIconName();
|
1022
|
+
return (index$1.h(index$1.Host, null, this.showChips && (index$1.h("ez-chip", { id: this.config.id, ref: ref => this._chipElement = ref, label: this.getLabel(), value: this.getEnabledChip() }, leftIcon && (index$1.h("ez-icon", { ref: ref => this._leftIconElement = ref, iconName: leftIcon, class: "ez-padding-right--small", slot: "leftIcon" })), index$1.h("ez-icon", { ref: ref => this._rightIconElement = ref, iconName: this.getRightIconName(), class: "ez-padding-left--small", slot: "rightIcon", id: "removeFilter" }))), index$1.h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, index$1.h("snk-filter-detail", { config: this.config, getMessage: this.getMessage, class: "sc-snk-filter-bar snk-filter__popover ez-padding--small ez-elevation--16", ref: elem => this._popover = elem, key: this.config.id, "data-element-id": this._idSnkFilterDetail, showHardFixed: this.showChips }))));
|
1023
|
+
}
|
1024
|
+
get _filterItemElement() { return index$1.getElement(this); }
|
1025
|
+
static get watchers() { return {
|
1026
|
+
"detailIsVisible": ["observeDetailIsVisible"]
|
1027
|
+
}; }
|
1028
|
+
};
|
1029
|
+
|
1030
|
+
const SHOW_MORE_ITEM_NAME = "__SHOWMORE__";
|
1031
|
+
const MAX_FILTERS = 5;
|
1032
|
+
const SnkFilterList = class {
|
1033
|
+
constructor(hostRef) {
|
1034
|
+
index$1.registerInstance(this, hostRef);
|
1035
|
+
this.snkItemSelected = index$1.createEvent(this, "snkItemSelected", 7);
|
1036
|
+
this._preselection = -1;
|
1037
|
+
this.innerClickCheck = (_floatingContainer, node) => {
|
1038
|
+
if (node.id != core.FloatingManager.MODAL_ELEMENT_ID) {
|
1039
|
+
return true;
|
1040
|
+
}
|
1041
|
+
this._detailIsVisible = false;
|
1042
|
+
return false;
|
1043
|
+
};
|
1044
|
+
this._filterArgument = undefined;
|
1045
|
+
this._showAll = undefined;
|
1046
|
+
this.label = undefined;
|
1047
|
+
this.iconName = undefined;
|
1048
|
+
this.items = undefined;
|
1049
|
+
this.getMessage = undefined;
|
1050
|
+
this.emptyText = undefined;
|
1051
|
+
this.findFilterText = undefined;
|
1052
|
+
this.buttonClass = undefined;
|
1053
|
+
}
|
1054
|
+
showDetail() {
|
1055
|
+
this._preselection = -1;
|
1056
|
+
this._floatingID = core.FloatingManager.float(this._popover, this._popoverContainer, {
|
1057
|
+
autoClose: true,
|
1058
|
+
innerClickTest: this.innerClickCheck,
|
1059
|
+
backClickListener: () => this.onListCloseCallback(),
|
1060
|
+
useOverlay: true
|
1061
|
+
});
|
1062
|
+
this._detailIsVisible = true;
|
1063
|
+
this._showAll = false;
|
1064
|
+
this._filterArgument = "";
|
1065
|
+
this._filterInput.setFocus();
|
1066
|
+
}
|
1067
|
+
/**
|
1068
|
+
* Oculta os detalhes do componente snk-filter-list.
|
1069
|
+
*/
|
1070
|
+
async hideDetail() {
|
1071
|
+
if (this._floatingID != undefined) {
|
1072
|
+
core.FloatingManager.close(this._floatingID);
|
1073
|
+
}
|
1074
|
+
}
|
1075
|
+
onListCloseCallback() {
|
1076
|
+
this._floatingID = undefined;
|
1077
|
+
this._detailIsVisible = false;
|
1078
|
+
}
|
1079
|
+
buttonClick() {
|
1080
|
+
if (this._detailIsVisible) {
|
1081
|
+
this.hideDetail();
|
1082
|
+
}
|
1083
|
+
else {
|
1084
|
+
this.showDetail();
|
1085
|
+
}
|
1086
|
+
}
|
1087
|
+
componentDidLoad() {
|
1088
|
+
if (this._element) {
|
1089
|
+
core.ElementIDUtils.addIDInfo(this._element);
|
1090
|
+
}
|
1091
|
+
}
|
1092
|
+
componentDidRender() {
|
1093
|
+
if (this._floatingID == undefined) {
|
1094
|
+
if (this._popover) {
|
1095
|
+
this._popover.remove();
|
1096
|
+
}
|
1097
|
+
}
|
1098
|
+
}
|
1099
|
+
buildIdElement(buttonElement, name) {
|
1100
|
+
if (!buttonElement)
|
1101
|
+
return;
|
1102
|
+
const dataElement = { id: name };
|
1103
|
+
buttonElement.removeAttribute(core.ElementIDUtils.DATA_ELEMENT_ID_ATTRIBUTE_NAME);
|
1104
|
+
core.ElementIDUtils.addIDInfoIfNotExists(buttonElement, "filterItemList", dataElement);
|
1105
|
+
}
|
1106
|
+
buildItemElement(item) {
|
1107
|
+
const itemId = ++this._selectableItemsCount;
|
1108
|
+
return (index$1.h("button", { ref: elem => elem && this.buildIdElement(elem, item.label), id: `filter-item${itemId}`, onFocusin: () => this._preselection = itemId, class: `ez-col ez-col--sd-12 ez-align--middle ez-padding--small sc-snk-filter-bar snk-filter-bar__filter-list-item`, onClick: () => this.itemSelected(item.name), name: item.label, key: itemId }, item.iconName ? index$1.h("ez-icon", { iconName: item.iconName, size: "small", class: `ez-padding-right--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__icon ${item.iconClass || ""}` }) : undefined, index$1.h("div", { class: `ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__label ${item.labelClass || ""}` }, item.label)));
|
1109
|
+
}
|
1110
|
+
itemSelected(itemName) {
|
1111
|
+
if (itemName === SHOW_MORE_ITEM_NAME) {
|
1112
|
+
this._showAll = true;
|
1113
|
+
}
|
1114
|
+
else {
|
1115
|
+
this.hideDetail();
|
1116
|
+
this.snkItemSelected.emit(itemName);
|
1117
|
+
}
|
1118
|
+
}
|
1119
|
+
getFilterItems() {
|
1120
|
+
const items = this.items ? core.ArrayUtils.applyStringFilter(this._filterArgument, this.items.filter(item => item.kind === "FILTER")) : [];
|
1121
|
+
if (items.length === 0) {
|
1122
|
+
return index$1.h("div", { class: "ez-text ez-text--medium ez-text--primary ez-padding--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-items-container--empty" }, this.emptyText);
|
1123
|
+
}
|
1124
|
+
const hideItems = !this._filterArgument && !this._showAll && (items.length > MAX_FILTERS + 1);
|
1125
|
+
if (hideItems) {
|
1126
|
+
items.splice(MAX_FILTERS);
|
1127
|
+
items.push({ kind: "INTERNAL", label: "Mostrar mais", iconName: "dots-horizontal", name: SHOW_MORE_ITEM_NAME, iconClass: "snk-filter-bar__filter-list-item__icon--secondary", labelClass: "snk-filter-bar__filter-list-item__label--secondary" });
|
1128
|
+
}
|
1129
|
+
this._selectableItemsCount = 0;
|
1130
|
+
return index$1.h("div", { class: "sc-snk-filter-bar snk-filter-bar__filter-list-items-container" }, items.map(item => this.buildItemElement(item)));
|
1131
|
+
}
|
1132
|
+
getFooterItems() {
|
1133
|
+
return this.items.filter(item => item.kind === "FOOTER");
|
1134
|
+
}
|
1135
|
+
keyDownHandler(event) {
|
1136
|
+
switch (event.key) {
|
1137
|
+
case "ArrowDown":
|
1138
|
+
this.changePreselection(this._preselection + 1);
|
1139
|
+
//Paramos a propagação do evento para evitar scroll indesejado
|
1140
|
+
event.stopImmediatePropagation();
|
1141
|
+
event.stopPropagation();
|
1142
|
+
event.preventDefault();
|
1143
|
+
break;
|
1144
|
+
case "ArrowUp":
|
1145
|
+
this.changePreselection(this._preselection - 1);
|
1146
|
+
//Paramos a propagação do evento para evitar scroll indesejado
|
1147
|
+
event.stopImmediatePropagation();
|
1148
|
+
event.stopPropagation();
|
1149
|
+
event.preventDefault();
|
1150
|
+
break;
|
1151
|
+
}
|
1152
|
+
}
|
1153
|
+
changePreselection(newSelection) {
|
1154
|
+
if (newSelection < 0) {
|
1155
|
+
newSelection = this._selectableItemsCount;
|
1156
|
+
}
|
1157
|
+
this._preselection = newSelection > this._selectableItemsCount ? 0 : newSelection;
|
1158
|
+
if (this._preselection === 0) {
|
1159
|
+
this._filterInput.setFocus();
|
1160
|
+
}
|
1161
|
+
else {
|
1162
|
+
const item = this._element.querySelector(`#filter-item${this._preselection}`);
|
1163
|
+
if (item) {
|
1164
|
+
item.focus();
|
1165
|
+
}
|
1166
|
+
}
|
1167
|
+
}
|
1168
|
+
render() {
|
1169
|
+
return (index$1.h(index$1.Host, { class: "ez-flex ez-flex--column" }, index$1.h("ez-button", { class: this.buttonClass, label: this.label, onClick: () => this.buttonClick(), mode: this.iconName ? "icon" : undefined, iconName: this.iconName, size: "small" }, index$1.h("slot", { name: "leftIcon" })), index$1.h("section", { class: "ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container", ref: elem => this._popoverContainer = elem }, index$1.h("div", { class: "sc-snk-filter-bar snk-filter__popover ez-padding--small ez-elevation--4", ref: elem => this._popover = elem }, index$1.h("ez-filter-input", { ref: ref => this._filterInput = ref, "data-element-id": "serachFilters", mode: "slim", label: this.findFilterText, value: this._filterArgument, onEzChange: (evt) => this._filterArgument = evt.detail, onFocus: () => this._preselection = 0 }), this.getFilterItems(), index$1.h("hr", { class: "sc-snk-filter-bar snk-filter__popover-rule" }), this.items ? this.getFooterItems().map(item => this.buildItemElement(item)) : undefined))));
|
1170
|
+
}
|
1171
|
+
get _element() { return index$1.getElement(this); }
|
1172
|
+
};
|
1173
|
+
|
1174
|
+
const snkFilterModalCss = "ez-modal{--ez-modal-content-padding:24px 12px}.snk-filter-modal__container{width:344px;max-width:344px;min-width:344px;overflow:hidden}.snk-filter-modal__content{display:flex;flex-direction:column;gap:var(--space--medium, 12px);padding-right:var(--space--3xs, 4px)}.snk-filter-modal__collapsible-box{border:var(--border--small, 1px solid) var(--color--strokes, #DCE0E8);border-radius:var(--border--radius-medium);padding:var(--space--medium, 12px) var(--space--small, 6px)}.snk-filter-modal__rendered-items{max-height:760px;overflow-x:clip;overflow-y:auto}.snk-filter-modal__rendered-items::-webkit-scrollbar{width:var(--space--small);min-width:var(--space--small);max-width:var(--space--small)}";
|
1175
|
+
|
1176
|
+
const SnkFilterModal = class {
|
1177
|
+
constructor(hostRef) {
|
1178
|
+
index$1.registerInstance(this, hostRef);
|
1179
|
+
this.getMessage = undefined;
|
1180
|
+
this.configName = undefined;
|
1181
|
+
this.filters = undefined;
|
1182
|
+
this.applyFilters = undefined;
|
1183
|
+
this.closeModal = undefined;
|
1184
|
+
this.addPersonalizedFilter = undefined;
|
1185
|
+
this.editPersonalizedFilter = undefined;
|
1186
|
+
this.deletePersonalizedFilter = undefined;
|
1187
|
+
this.filtersToDelete = [];
|
1188
|
+
this.disablePersonalizedFilter = undefined;
|
1189
|
+
}
|
1190
|
+
/**
|
1191
|
+
* Emitido quando um filtro personalizado é deletado.
|
1192
|
+
*/
|
1193
|
+
deletePersonalizedFilterListener(event) {
|
1194
|
+
this.filtersToDelete.push(event.detail);
|
1195
|
+
}
|
1196
|
+
getCustomMessage(key, params) {
|
1197
|
+
var _a;
|
1198
|
+
return (_a = this.getMessage) === null || _a === void 0 ? void 0 : _a.call(this, `snkFilterBar.filterModal.${key}`, params);
|
1199
|
+
}
|
1200
|
+
//TODO: tratar clear all dos filtros personalizados
|
1201
|
+
handleClearAll() {
|
1202
|
+
const { customFilters, quickFilters, otherFilters, multiListFilters } = this.filters.reduce((acc, filter) => {
|
1203
|
+
if (filter.type === filterItemType_enum.FilterItemType.MULTI_LIST) {
|
1204
|
+
acc.multiListFilters.push(filter);
|
1205
|
+
return acc;
|
1206
|
+
}
|
1207
|
+
if (filter.filterType === filterType_enum.FilterType.QUICK_FILTER) {
|
1208
|
+
acc.quickFilters.push(filter);
|
1209
|
+
return acc;
|
1210
|
+
}
|
1211
|
+
if (filter.filterType === filterType_enum.FilterType.CUSTOM_FILTER) {
|
1212
|
+
acc.customFilters.push(filter);
|
1213
|
+
return acc;
|
1214
|
+
}
|
1215
|
+
if (filter.filterType === filterType_enum.FilterType.OTHER_FILTERS) {
|
1216
|
+
acc.otherFilters.push(filter);
|
1217
|
+
return acc;
|
1218
|
+
}
|
1219
|
+
return acc;
|
1220
|
+
}, { quickFilters: [], customFilters: [], otherFilters: [], multiListFilters: [] });
|
1221
|
+
this.handleClearFilterList(quickFilters);
|
1222
|
+
this.handleClearCustomFilters(customFilters);
|
1223
|
+
this.handleClearOthersFilters(otherFilters);
|
1224
|
+
multiListFilters.forEach(multiListFilter => this.handleClearSigleFilter(multiListFilter));
|
1225
|
+
}
|
1226
|
+
handleClearOthersFilters(otherFilters) {
|
1227
|
+
this.filters = this.filters.map(filter => otherFilters.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
|
1228
|
+
}
|
1229
|
+
handleClearCustomFilters(customFilters) {
|
1230
|
+
this.filters.forEach((filter, index) => {
|
1231
|
+
if (filter.filterType === filterType_enum.FilterType.CUSTOM_FILTER)
|
1232
|
+
this.filters[index] = this.clearAllCustomFilter(customFilters).shift();
|
1233
|
+
});
|
1234
|
+
}
|
1235
|
+
clearAllCustomFilter(filterConfigSnapshot) {
|
1236
|
+
return filterConfigSnapshot.map(filterItem => {
|
1237
|
+
const copy = Object.assign({}, filterItem);
|
1238
|
+
delete copy.value;
|
1239
|
+
copy.visible = false;
|
1240
|
+
if (copy.groupedItems) {
|
1241
|
+
copy.groupedItems = this.clearAllCustomFilter(copy.groupedItems);
|
1242
|
+
}
|
1243
|
+
return copy;
|
1244
|
+
});
|
1245
|
+
}
|
1246
|
+
handleClose() {
|
1247
|
+
const hasChangesToSave = core.ObjectUtils.objectToString(this.filters) !== core.ObjectUtils.objectToString(this._originalFilterConfig);
|
1248
|
+
if (!hasChangesToSave) {
|
1249
|
+
this.closeModal();
|
1250
|
+
return;
|
1251
|
+
}
|
1252
|
+
return utils.ApplicationUtils.confirm(this.getCustomMessage('validations.notSaved.title'), this.getCustomMessage('validations.notSaved.message')).then((cancelAction) => {
|
1253
|
+
if (cancelAction)
|
1254
|
+
this.closeModal();
|
1255
|
+
});
|
1256
|
+
}
|
1257
|
+
handleApplyFilters() {
|
1258
|
+
const filterPersonalized = this.filters.find(filter => filter.filterType === filterType_enum.FilterType.CUSTOM_FILTER);
|
1259
|
+
if (this.isValidCustomFilter(filterPersonalized)) {
|
1260
|
+
this.applyFilters(this.filters);
|
1261
|
+
}
|
1262
|
+
if (this.filtersToDelete.length > 0) {
|
1263
|
+
this.filtersToDelete.forEach(filter => {
|
1264
|
+
this.deletePersonalizedFilter(filter, this.configName);
|
1265
|
+
});
|
1266
|
+
this.filtersToDelete = [];
|
1267
|
+
}
|
1268
|
+
}
|
1269
|
+
isValidCustomFilter(filterPersonalized) {
|
1270
|
+
const isValid = PersonalizedFilterUtils.PersonalizedFilterUtils.validateVariableValues(filterPersonalized);
|
1271
|
+
if (!isValid) {
|
1272
|
+
utils.ApplicationUtils.alert(this.getCustomMessage('validations.notFullFilled.title'), this.getCustomMessage('validations.notFullFilled.message'));
|
1273
|
+
return false;
|
1274
|
+
}
|
1275
|
+
return true;
|
1276
|
+
}
|
1277
|
+
modalActionListener(evt) {
|
1278
|
+
const modalAction = evt.detail;
|
1279
|
+
switch (modalAction) {
|
1280
|
+
case ezModalContainer.ModalAction.CANCEL:
|
1281
|
+
this.handleClearAll();
|
1282
|
+
break;
|
1283
|
+
case ezModalContainer.ModalAction.OK:
|
1284
|
+
this.handleApplyFilters();
|
1285
|
+
break;
|
1286
|
+
case ezModalContainer.ModalAction.CLOSE:
|
1287
|
+
this.handleClose();
|
1288
|
+
break;
|
1289
|
+
}
|
1290
|
+
}
|
1291
|
+
handleFilterChange(filterConfig) {
|
1292
|
+
this.filters = this.filters.map(filter => filter.id === filterConfig.id ? filterConfig : filter);
|
1293
|
+
}
|
1294
|
+
handleClearFilterList(filterList) {
|
1295
|
+
this.filters = this.filters.map(filter => filterList.includes(filter) ? (Object.assign(Object.assign({}, filter), { value: undefined })) : filter);
|
1296
|
+
}
|
1297
|
+
handleClearSigleFilter(filterItem) {
|
1298
|
+
if (filterItemType_enum.FilterItemType.MULTI_LIST === filterItem.type) {
|
1299
|
+
let filterItemCopy = core.ObjectUtils.copy(filterItem);
|
1300
|
+
this.uncheckFilterValues(filterItemCopy.value);
|
1301
|
+
const filterListCopy = core.ObjectUtils.copy(this.filters);
|
1302
|
+
const index = filterListCopy.findIndex(item => item.id === filterItem.id);
|
1303
|
+
filterListCopy.splice(index, 1, filterItemCopy);
|
1304
|
+
this.filters = core.ObjectUtils.copy(filterListCopy);
|
1305
|
+
return;
|
1306
|
+
}
|
1307
|
+
if (filterItemType_enum.FilterItemType.CHECK_BOX_LIST === filterItem.type) {
|
1308
|
+
const filterListCopy = core.ObjectUtils.copy(this.filters);
|
1309
|
+
filterListCopy.find(filter => filter.id === filterItem.id).value = undefined;
|
1310
|
+
this.filters = core.ObjectUtils.copy(filterListCopy);
|
1311
|
+
return;
|
1312
|
+
}
|
1313
|
+
this.filters.find(filter => filter.id === filterItem.id).value = undefined;
|
1314
|
+
}
|
1315
|
+
uncheckFilterValues(valueList) {
|
1316
|
+
valueList.forEach(value => {
|
1317
|
+
if (!!value) {
|
1318
|
+
value.check = false;
|
1319
|
+
}
|
1320
|
+
});
|
1321
|
+
return valueList;
|
1322
|
+
}
|
1323
|
+
renderFilterItem(filterItem, fullRow) {
|
1324
|
+
return (index$1.h("snk-filter-modal-item", { class: fullRow ? 'ez-col ez-col--sd-12' : 'ez-col ez-col--sd-6 ez-padding--small', filterItem: filterItem, configName: this.configName, onFilterChange: (event) => this.handleFilterChange(event.detail), onEditPersonalizedFilter: evt => this.editPersonalizedFilter(evt.detail), onAddPersonalizedFilter: () => this.addPersonalizedFilter() }));
|
1325
|
+
}
|
1326
|
+
isDefaultFilterNumberVariation(filter) {
|
1327
|
+
var _a;
|
1328
|
+
return filter.type === filterItemType_enum.FilterItemType.NUMBER
|
1329
|
+
&& (!filter.props.variation || ((_a = filter.props) === null || _a === void 0 ? void 0 : _a.variation) === filterNumberVariation.FilterNumberVariation.DEFAULT);
|
1330
|
+
}
|
1331
|
+
mountFiltersLines(filters) {
|
1332
|
+
const MAX_LINE_LENGTH = 2;
|
1333
|
+
let currentLine = 0;
|
1334
|
+
let forceAddCurrent = false;
|
1335
|
+
const filtersLines = {};
|
1336
|
+
for (let curr = 0; curr < filters.length; curr++) {
|
1337
|
+
filtersLines[currentLine] = filtersLines[currentLine] || [];
|
1338
|
+
const item = filters[curr];
|
1339
|
+
const isLast = curr === filters.length - 1;
|
1340
|
+
const currentItemMatch = item.type === filterItemType_enum.FilterItemType.TEXT || this.isDefaultFilterNumberVariation(item);
|
1341
|
+
const nextItemMatch = isLast ? false : filters[curr + 1].type === filterItemType_enum.FilterItemType.TEXT || this.isDefaultFilterNumberVariation(filters[curr + 1]);
|
1342
|
+
if ((currentItemMatch && nextItemMatch) || forceAddCurrent) {
|
1343
|
+
filtersLines[currentLine].push(item);
|
1344
|
+
forceAddCurrent = filtersLines[currentLine].length < MAX_LINE_LENGTH;
|
1345
|
+
if (filtersLines[currentLine].length === MAX_LINE_LENGTH)
|
1346
|
+
++currentLine;
|
1347
|
+
continue;
|
1348
|
+
}
|
1349
|
+
filtersLines[currentLine] = filtersLines[currentLine] || [];
|
1350
|
+
filtersLines[currentLine].push(item);
|
1351
|
+
++currentLine;
|
1352
|
+
}
|
1353
|
+
return Object.values(filtersLines);
|
1354
|
+
}
|
1355
|
+
renderFilterLine(filters) {
|
1356
|
+
const fullLine = filters.length === 1;
|
1357
|
+
return filters.map((filter) => this.renderFilterItem(filter, fullLine));
|
1358
|
+
}
|
1359
|
+
getIformedFiltersCount(listItems) {
|
1360
|
+
let countInformedItens = 0;
|
1361
|
+
listItems.forEach(item => {
|
1362
|
+
var _a, _b, _c, _d, _e, _f;
|
1363
|
+
if (filterItemType_enum.FilterItemType.MULTI_LIST === item.type) {
|
1364
|
+
countInformedItens += (_e = (_d = (_c = ((_b = (_a = item.value) === null || _a === void 0 ? void 0 : _a.elements) !== null && _b !== void 0 ? _b : item.value)) === null || _c === void 0 ? void 0 : _c.filter(value => value === null || value === void 0 ? void 0 : value.check)) === null || _d === void 0 ? void 0 : _d.length) !== null && _e !== void 0 ? _e : 0;
|
1365
|
+
return;
|
1366
|
+
}
|
1367
|
+
if (filterItemType_enum.FilterItemType.CHECK_BOX_LIST === item.type) {
|
1368
|
+
countInformedItens += Object.entries((_f = item.value) !== null && _f !== void 0 ? _f : {})
|
1369
|
+
.filter(([_, value]) => value === true)
|
1370
|
+
.map(([key, _]) => key).length;
|
1371
|
+
return;
|
1372
|
+
}
|
1373
|
+
if (item.groupedItems != undefined) {
|
1374
|
+
countInformedItens = item.groupedItems.filter(item => item.visible).length;
|
1375
|
+
return;
|
1376
|
+
}
|
1377
|
+
if (!!item.value) {
|
1378
|
+
countInformedItens++;
|
1379
|
+
}
|
1380
|
+
});
|
1381
|
+
return countInformedItens;
|
1382
|
+
}
|
1383
|
+
renderCollapsibleFilterBox(label, listItems, isSingleItem, shouldRenderFooter = true) {
|
1384
|
+
if (!listItems.length)
|
1385
|
+
return null;
|
1386
|
+
const appliedFilters = this.getIformedFiltersCount(listItems);
|
1387
|
+
const lines = this.mountFiltersLines(listItems);
|
1388
|
+
return (index$1.h("ez-collapsible-box", { class: "snk-filter-modal__collapsible-box", headerSize: "medium", value: true, label: label }, !!appliedFilters && (index$1.h("ez-badge", { class: "ez-badge--primary-subtle", slot: "rightSlot", label: appliedFilters === null || appliedFilters === void 0 ? void 0 : appliedFilters.toString() })), index$1.h("div", { class: "ez-row snk-filter-modal__rendered-items" }, lines.map(this.renderFilterLine.bind(this))), shouldRenderFooter && (index$1.h("div", { class: "ez-flex ez-flex--justify-end grow" }, index$1.h("ez-button", { class: "ez-button--tertiary", size: "medium", label: "Limpar", onClick: () => isSingleItem ? this.handleClearSigleFilter(listItems[0]) : this.handleClearFilterList(listItems) })))));
|
1389
|
+
}
|
1390
|
+
componentWillRender() {
|
1391
|
+
this._modalTitle = this.getCustomMessage('title');
|
1392
|
+
this._okButtonLabel = this.getCustomMessage('okButtonLabel');
|
1393
|
+
this._cancelButtonLabel = this.getCustomMessage('cancelButtonLabel');
|
1394
|
+
}
|
1395
|
+
componentDidLoad() {
|
1396
|
+
if (!this._originalFilterConfig)
|
1397
|
+
this._originalFilterConfig = this.filters;
|
1398
|
+
}
|
1399
|
+
render() {
|
1400
|
+
const customFilters = this.filters.filter(filter => filter.filterType === filterType_enum.FilterType.CUSTOM_FILTER);
|
1401
|
+
const quickFilters = this.filters.filter(filter => filter.filterType === filterType_enum.FilterType.QUICK_FILTER);
|
1402
|
+
const otherFilters = this.filters.filter(filter => filter.filterType === filterType_enum.FilterType.OTHER_FILTERS);
|
1403
|
+
return (index$1.h("ez-modal-container", { class: "snk-filter-modal__container", modalTitle: this._modalTitle, cancelButtonLabel: this._cancelButtonLabel, okButtonLabel: this._okButtonLabel, onEzModalAction: this.modalActionListener.bind(this) }, index$1.h("div", { class: "snk-filter-modal__content ez-col--sd-12" }, !this.disablePersonalizedFilter && this.renderCollapsibleFilterBox(this.getCustomMessage('customFilters'), customFilters, false, false), this.renderCollapsibleFilterBox(this.getCustomMessage('quickFilters'), quickFilters, false), otherFilters.map(filter => this.renderCollapsibleFilterBox(filter.label, [filter], true)))));
|
1404
|
+
}
|
1405
|
+
};
|
1406
|
+
SnkFilterModal.style = snkFilterModalCss;
|
1407
|
+
|
1408
|
+
exports.snk_filter_bar = SnkFilterBar;
|
1409
|
+
exports.snk_filter_item = SnkFilterItem;
|
1410
|
+
exports.snk_filter_list = SnkFilterList;
|
1411
|
+
exports.snk_filter_modal = SnkFilterModal;
|