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