@sankhyalabs/sankhyablocks 0.0.0-bugfix-dev-KB-49448.0 → 0.0.0-bugfix-dev-KB-50737.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{ConfigStorage-34be11ce.js → ConfigStorage-8d4e9d53.js} +1 -1
- package/dist/cjs/{SnkFormConfigManager-6211fb28.js → SnkFormConfigManager-33995e92.js} +16 -13
- package/dist/cjs/{SnkMultiSelectionListDataSource-5213120b.js → SnkMultiSelectionListDataSource-1438f8f2.js} +1 -1
- package/dist/cjs/{auth-fetcher-5161d082.js → auth-fetcher-bb8e9ae4.js} +1 -1
- package/dist/cjs/{form-config-fetcher-9f1a13ca.js → form-config-fetcher-d73f4449.js} +12 -0
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-actions-button_4.cjs.entry.js +2 -2
- package/dist/cjs/snk-application.cjs.entry.js +3 -3
- package/dist/cjs/snk-attach.cjs.entry.js +2 -2
- package/dist/cjs/snk-crud.cjs.entry.js +2 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +4 -4
- package/dist/cjs/snk-filter-bar.cjs.entry.js +18 -6
- package/dist/cjs/snk-filter-detail.cjs.entry.js +4 -1
- package/dist/cjs/snk-filter-item.cjs.entry.js +2 -1
- package/dist/cjs/snk-filter-modal-item.cjs.entry.js +2 -2
- package/dist/cjs/snk-form-config.cjs.entry.js +1 -1
- package/dist/cjs/snk-form.cjs.entry.js +3 -3
- package/dist/cjs/snk-grid.cjs.entry.js +4 -7
- package/dist/cjs/{snk-guides-viewer-508bb6fe.js → snk-guides-viewer-25721856.js} +2 -2
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +4 -4
- package/dist/cjs/snk-personalized-filter.cjs.entry.js +2 -2
- package/dist/cjs/snk-simple-crud.cjs.entry.js +85 -48
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +22 -1
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +20 -1
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.css +2 -1
- package/dist/collection/components/snk-filter-bar/snk-filter-bar.js +15 -3
- package/dist/collection/components/snk-form-config/SnkFormConfigManager.js +14 -11
- package/dist/collection/components/snk-grid/snk-grid.js +1 -4
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +119 -45
- package/dist/collection/lib/http/data-fetcher/fetchers/form-config-fetcher.js +12 -0
- package/dist/components/SnkFormConfigManager.js +14 -11
- package/dist/components/form-config-fetcher.js +12 -0
- package/dist/components/snk-filter-bar2.js +16 -4
- package/dist/components/snk-filter-detail2.js +5 -1
- package/dist/components/snk-filter-item2.js +3 -1
- package/dist/components/snk-grid2.js +1 -4
- package/dist/components/snk-simple-crud2.js +84 -45
- package/dist/esm/{ConfigStorage-101a2b4c.js → ConfigStorage-6e241cd7.js} +1 -1
- package/dist/esm/{SnkFormConfigManager-d86ba46f.js → SnkFormConfigManager-7a4e678f.js} +16 -13
- package/dist/esm/{SnkMultiSelectionListDataSource-7e7eada5.js → SnkMultiSelectionListDataSource-aad5d4ff.js} +1 -1
- package/dist/esm/{auth-fetcher-17dc5b5e.js → auth-fetcher-8ec448b0.js} +1 -1
- package/dist/esm/{form-config-fetcher-f121f880.js → form-config-fetcher-765b8498.js} +12 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-actions-button_4.entry.js +2 -2
- package/dist/esm/snk-application.entry.js +3 -3
- package/dist/esm/snk-attach.entry.js +2 -2
- package/dist/esm/snk-crud.entry.js +2 -2
- package/dist/esm/snk-detail-view.entry.js +4 -4
- package/dist/esm/snk-filter-bar.entry.js +18 -6
- package/dist/esm/snk-filter-detail.entry.js +4 -1
- package/dist/esm/snk-filter-item.entry.js +2 -1
- package/dist/esm/snk-filter-modal-item.entry.js +2 -2
- package/dist/esm/snk-form-config.entry.js +1 -1
- package/dist/esm/snk-form.entry.js +3 -3
- package/dist/esm/snk-grid.entry.js +4 -7
- package/dist/esm/{snk-guides-viewer-18859840.js → snk-guides-viewer-b94752f2.js} +2 -2
- package/dist/esm/snk-guides-viewer.entry.js +4 -4
- package/dist/esm/snk-personalized-filter.entry.js +2 -2
- package/dist/esm/snk-simple-crud.entry.js +85 -48
- package/dist/sankhyablocks/p-004c356e.js +26 -0
- package/dist/sankhyablocks/{p-5c0b53ce.js → p-0624f62d.js} +1 -1
- package/dist/sankhyablocks/{p-d01ceda6.entry.js → p-0bba5c9f.entry.js} +1 -1
- package/dist/sankhyablocks/{p-64c1b368.entry.js → p-1048bd26.entry.js} +1 -1
- package/dist/sankhyablocks/p-125bb902.js +1 -0
- package/dist/sankhyablocks/{p-7ddd95b6.entry.js → p-24ed6ad6.entry.js} +1 -1
- package/dist/sankhyablocks/{p-1fa5a18c.entry.js → p-400097f2.entry.js} +1 -1
- package/dist/sankhyablocks/p-54a5d52a.entry.js +1 -0
- package/dist/sankhyablocks/p-5c8b136d.entry.js +1 -0
- package/dist/sankhyablocks/{p-2897fb8c.js → p-6c9adfca.js} +1 -1
- package/dist/sankhyablocks/p-85af23fe.entry.js +1 -0
- package/dist/sankhyablocks/{p-b41a622a.entry.js → p-85ba3d6b.entry.js} +1 -1
- package/dist/sankhyablocks/{p-5dbc1a3f.js → p-88b29791.js} +1 -1
- package/dist/sankhyablocks/{p-ba4871b5.entry.js → p-9e8618ec.entry.js} +1 -1
- package/dist/sankhyablocks/p-a043314f.entry.js +1 -0
- package/dist/sankhyablocks/{p-7f97fee2.entry.js → p-a1642e7c.entry.js} +1 -1
- package/dist/sankhyablocks/{p-6b28cc74.entry.js → p-ac77949b.entry.js} +1 -1
- package/dist/sankhyablocks/{p-b4de81ac.entry.js → p-b47c2963.entry.js} +1 -1
- package/dist/sankhyablocks/{p-7e05bd83.entry.js → p-bf39bdb8.entry.js} +1 -1
- package/dist/sankhyablocks/{p-e4fb3308.entry.js → p-d5cb4b5a.entry.js} +1 -1
- package/dist/sankhyablocks/{p-60fa6c7a.js → p-efeca7ba.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +4 -0
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-item.d.ts +4 -0
- package/dist/types/components/snk-filter-bar/snk-filter-bar.d.ts +2 -0
- package/dist/types/components/snk-form-config/SnkFormConfigManager.d.ts +1 -1
- package/dist/types/components/snk-grid/snk-grid.d.ts +0 -1
- package/dist/types/components/snk-simple-crud/snk-simple-crud.d.ts +17 -6
- package/dist/types/components.d.ts +32 -0
- package/dist/types/lib/http/data-fetcher/fetchers/form-config-fetcher.d.ts +2 -0
- package/package.json +1 -1
- package/dist/sankhyablocks/p-1f3174cb.entry.js +0 -1
- package/dist/sankhyablocks/p-42ea9a35.entry.js +0 -1
- package/dist/sankhyablocks/p-50783a8b.js +0 -1
- package/dist/sankhyablocks/p-86801b08.entry.js +0 -1
- package/dist/sankhyablocks/p-a13ccb86.js +0 -26
- package/dist/sankhyablocks/p-d6317851.entry.js +0 -1
|
@@ -2,6 +2,7 @@ import { DataUnit, Record, UnitMetadata } from '@sankhyalabs/core';
|
|
|
2
2
|
import { EventEmitter } from '../../stencil-public-runtime';
|
|
3
3
|
import { SIMPLE_CRUD_MODE, VIEW_MODE } from '../../lib/utils/constants';
|
|
4
4
|
import { DataState } from '../snk-data-unit/snk-data-unit';
|
|
5
|
+
import { FormConfigFetcher } from '../../lib';
|
|
5
6
|
import TaskbarProcessor from '../snk-taskbar/processor/taskbar-processor';
|
|
6
7
|
import { Action, TaskbarManager } from '../snk-taskbar/snk-taskbar';
|
|
7
8
|
import InMemoryLoader from '../../lib/dataUnit/InMemoryLoader';
|
|
@@ -26,6 +27,9 @@ export declare class SnkSimpleCrud {
|
|
|
26
27
|
_keyDownHandler: (event: KeyboardEvent) => Promise<void>;
|
|
27
28
|
_resourceID: string;
|
|
28
29
|
_formConfigManager: SnkFormConfigManager;
|
|
30
|
+
_gridConfigAlreadyLoaded: boolean;
|
|
31
|
+
_formConfigAlreadyLoaded: boolean;
|
|
32
|
+
_formConfigFetcher: FormConfigFetcher;
|
|
29
33
|
private _element;
|
|
30
34
|
_showPopUpGridConfig: boolean;
|
|
31
35
|
_showFormConfig: boolean;
|
|
@@ -44,6 +48,10 @@ export declare class SnkSimpleCrud {
|
|
|
44
48
|
*/
|
|
45
49
|
multipleSelection: boolean;
|
|
46
50
|
useCancelConfirm: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Identificador de recursos como configurações e acesso.
|
|
53
|
+
*/
|
|
54
|
+
resourceID: string;
|
|
47
55
|
/**
|
|
48
56
|
* Emitido quando há qualquer mudança de estado no DataUnit.
|
|
49
57
|
*/
|
|
@@ -101,6 +109,11 @@ export declare class SnkSimpleCrud {
|
|
|
101
109
|
* Chave da configuração legado do formulário.
|
|
102
110
|
*/
|
|
103
111
|
formLegacyConfigName: string;
|
|
112
|
+
/**
|
|
113
|
+
* Ignora os campos "somente leitura" no modo de inserção.
|
|
114
|
+
*/
|
|
115
|
+
ignoreReadOnlyFormFields: boolean;
|
|
116
|
+
handleResourceIDChanged(newValue: string, oldValue: string): void;
|
|
104
117
|
_taskbarProcessor: TaskbarProcessor;
|
|
105
118
|
private getButtons;
|
|
106
119
|
private addConfigButton;
|
|
@@ -113,20 +126,17 @@ export declare class SnkSimpleCrud {
|
|
|
113
126
|
actionClickListener(evt: CustomEvent): void;
|
|
114
127
|
onModeChange(): void;
|
|
115
128
|
observeDataState(newValue: DataState, oldValue: DataState): void;
|
|
116
|
-
observeFormLegacy(): Promise<void>;
|
|
117
|
-
observeGridLegacy(): Promise<void>;
|
|
129
|
+
observeFormLegacy(newValue: string, oldValue: string): Promise<void>;
|
|
130
|
+
observeGridLegacy(newValue: string, oldValue: string): Promise<void>;
|
|
118
131
|
private handleUpdateGridLegacyConfig;
|
|
119
132
|
private handleUpdateFormLegacyConfig;
|
|
120
|
-
private buildLegacyConfig;
|
|
121
|
-
private fetchFormLegacyConfig;
|
|
122
133
|
private openConfig;
|
|
123
134
|
private openGridConfig;
|
|
124
135
|
private openFormConfig;
|
|
125
136
|
private addGridLegacyConfigName;
|
|
126
137
|
private loadGridConfig;
|
|
127
|
-
private
|
|
138
|
+
private formConfigIsLoaded;
|
|
128
139
|
private loadFormConfig;
|
|
129
|
-
private isFormConfigLoaded;
|
|
130
140
|
componentWillRender(): Promise<void>;
|
|
131
141
|
componentWillLoad(): void;
|
|
132
142
|
configDatasource(): void;
|
|
@@ -170,5 +180,6 @@ export declare class SnkSimpleCrud {
|
|
|
170
180
|
private closeGridConfig;
|
|
171
181
|
private closeFormConfig;
|
|
172
182
|
private handleShowFormConfig;
|
|
183
|
+
private resolveResourceID;
|
|
173
184
|
render(): any;
|
|
174
185
|
}
|
|
@@ -852,6 +852,10 @@ export namespace Components {
|
|
|
852
852
|
* Exibe o componente snk-filter-detail.
|
|
853
853
|
*/
|
|
854
854
|
"show": () => Promise<void>;
|
|
855
|
+
/**
|
|
856
|
+
* Controla a visibilidade do botão de fixar elemento
|
|
857
|
+
*/
|
|
858
|
+
"showHardFixed": boolean;
|
|
855
859
|
}
|
|
856
860
|
interface SnkFilterFieldSearch {
|
|
857
861
|
/**
|
|
@@ -888,6 +892,10 @@ export namespace Components {
|
|
|
888
892
|
* Oculta os detalhes de um item da lista.
|
|
889
893
|
*/
|
|
890
894
|
"hideDetail": () => Promise<void>;
|
|
895
|
+
/**
|
|
896
|
+
* Usado para controlar a visibilidade dos chips de filtros
|
|
897
|
+
*/
|
|
898
|
+
"showChips": boolean;
|
|
891
899
|
/**
|
|
892
900
|
* Exibe os detalhes de um item da lista.
|
|
893
901
|
*/
|
|
@@ -1498,6 +1506,10 @@ export namespace Components {
|
|
|
1498
1506
|
* Chave da configuração legado da grade.
|
|
1499
1507
|
*/
|
|
1500
1508
|
"gridLegacyConfigName": string;
|
|
1509
|
+
/**
|
|
1510
|
+
* Ignora os campos "somente leitura" no modo de inserção.
|
|
1511
|
+
*/
|
|
1512
|
+
"ignoreReadOnlyFormFields": boolean;
|
|
1501
1513
|
/**
|
|
1502
1514
|
* Responsável por flexibilizar e padronizar o uso de mensagens nos blocos de construção.
|
|
1503
1515
|
*/
|
|
@@ -1511,6 +1523,10 @@ export namespace Components {
|
|
|
1511
1523
|
* Usado para abrir o configurator do CRUD
|
|
1512
1524
|
*/
|
|
1513
1525
|
"openConfigurator": () => Promise<void>;
|
|
1526
|
+
/**
|
|
1527
|
+
* Identificador de recursos como configurações e acesso.
|
|
1528
|
+
*/
|
|
1529
|
+
"resourceID": string;
|
|
1514
1530
|
"setMetadata": (metadata: UnitMetadata) => Promise<void>;
|
|
1515
1531
|
"setRecords": (records: Array<Record>) => Promise<void>;
|
|
1516
1532
|
/**
|
|
@@ -2772,6 +2788,10 @@ declare namespace LocalJSX {
|
|
|
2772
2788
|
* Emitido quando há uma alteração nos filtros.
|
|
2773
2789
|
*/
|
|
2774
2790
|
"onFilterChange"?: (event: SnkFilterDetailCustomEvent<SnkFilterItemConfig>) => void;
|
|
2791
|
+
/**
|
|
2792
|
+
* Controla a visibilidade do botão de fixar elemento
|
|
2793
|
+
*/
|
|
2794
|
+
"showHardFixed"?: boolean;
|
|
2775
2795
|
}
|
|
2776
2796
|
interface SnkFilterFieldSearch {
|
|
2777
2797
|
/**
|
|
@@ -2805,6 +2825,10 @@ declare namespace LocalJSX {
|
|
|
2805
2825
|
* Emitido quando o detalhe de um item da lista é aberto ou fechado.
|
|
2806
2826
|
*/
|
|
2807
2827
|
"onVisibleChanged"?: (event: SnkFilterItemCustomEvent<boolean>) => void;
|
|
2828
|
+
/**
|
|
2829
|
+
* Usado para controlar a visibilidade dos chips de filtros
|
|
2830
|
+
*/
|
|
2831
|
+
"showChips"?: boolean;
|
|
2808
2832
|
}
|
|
2809
2833
|
interface SnkFilterList {
|
|
2810
2834
|
/**
|
|
@@ -3435,6 +3459,10 @@ declare namespace LocalJSX {
|
|
|
3435
3459
|
* Chave da configuração legado da grade.
|
|
3436
3460
|
*/
|
|
3437
3461
|
"gridLegacyConfigName"?: string;
|
|
3462
|
+
/**
|
|
3463
|
+
* Ignora os campos "somente leitura" no modo de inserção.
|
|
3464
|
+
*/
|
|
3465
|
+
"ignoreReadOnlyFormFields"?: boolean;
|
|
3438
3466
|
/**
|
|
3439
3467
|
* Responsável por flexibilizar e padronizar o uso de mensagens nos blocos de construção.
|
|
3440
3468
|
*/
|
|
@@ -3468,6 +3496,10 @@ declare namespace LocalJSX {
|
|
|
3468
3496
|
* Responsável por notificar quando ocorrer a renderização de itens do formulário.
|
|
3469
3497
|
*/
|
|
3470
3498
|
"onFormItemsReady"?: (event: SnkSimpleCrudCustomEvent<Array<HTMLElement>>) => void;
|
|
3499
|
+
/**
|
|
3500
|
+
* Identificador de recursos como configurações e acesso.
|
|
3501
|
+
*/
|
|
3502
|
+
"resourceID"?: string;
|
|
3471
3503
|
/**
|
|
3472
3504
|
* Usado para exibir os botões de ação do snk-configurator.
|
|
3473
3505
|
*/
|
|
@@ -12,6 +12,8 @@ export declare class FormConfigFetcher extends ResourceFetcher {
|
|
|
12
12
|
fetchLegacyConfig(formName: string, resourceID: string): Promise<IFormConfig>;
|
|
13
13
|
fetchDefaultConfig(formName: string, resourceID: string): Promise<IFormConfig>;
|
|
14
14
|
private getPath;
|
|
15
|
+
fetchLegacyConfigurableForm(configName: string): Promise<IFormConfig>;
|
|
16
|
+
private buildLegacyConfigurableForm;
|
|
15
17
|
}
|
|
16
18
|
export declare enum UserConfigType {
|
|
17
19
|
USER = "USER",
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,c as e,h as i,H as r,g as s}from"./p-d2d301a6.js";import{DataType as a,StringUtils as n,ObjectUtils as l,ElementIDUtils as o,ErrorException as d,ApplicationContext as h}from"@sankhyalabs/core";import{EzScrollDirection as c}from"@sankhyalabs/ezui/dist/collection/components/ez-scroller/EzScrollDirection";import{C as f}from"./p-5c0b53ce.js";import{toString as m}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{F as u}from"./p-ff1990ad.js";import{F as p}from"./p-933c0c0b.js";import{F as b}from"./p-fa80e546.js";import{ApplicationUtils as v}from"@sankhyalabs/ezui/dist/collection/utils";import{P as k}from"./p-057fad05.js";import"./p-a13ccb86.js";import"./p-be75153c.js";import"./p-8d884fab.js";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";function g(t){let e="";return t.forEach(((t,i)=>{var r;e+=` ${i>0?null!==(r=t.operand)&&void 0!==r?r:"OR":""} ${t.expression}`})),e.trim()}class _{constructor({filterConfig:t,configName:e,onComplete:i,getMessage:r,disablePersonalizedFilter:s,onAddPersonalizedFilter:a,onEditPersonalizedFilter:n,onDeletePersonalizedFilter:l}){this._filterConfig=t,this._configName=e,this._onComplete=i,this._getMessage=r,this._disablePersonalizedFilter=s,this._addPersonalizedFilterFn=a,this._editPersonalizedFilterFn=n,this._onDeletePersonalizedFilter=l}applyFilters(t){this._onComplete(t),this._closeModal()}buildFilterModal(){const t=document.createElement("snk-filter-modal");return t.className="ez-size-height--full",t.filters=this._filterConfig,t.configName=this._configName,t.disablePersonalizedFilter=this._disablePersonalizedFilter,t.getMessage=this._getMessage.bind(this),t.applyFilters=this.applyFilters.bind(this),t.closeModal=()=>this._closeModal(),t.addPersonalizedFilter=()=>this._addPersonalizedFilterFn(),t.editPersonalizedFilter=t=>this._editPersonalizedFilterFn(t),t.deletePersonalizedFilter=(t,e)=>this._onDeletePersonalizedFilter(t,e),t}async showModal(){const t={content:this.buildFilterModal(),position:"left",heightMode:"full",closeOutsideClick:!1,useScrimLight:!0};this._closeModal=await v.showModal(t)}async closeModal(){this._closeModal()}}const x=class{constructor(i){t(this,i),this.configUpdated=e(this,"configUpdated",7),this._updateSequence=[],this._loadingPending=!1,this._configUpdated=!1,this._firstLoad=!0,this._pendingVariables=!1,this._customfiltersToBeUpdated=[],this._calculateSortIndex=t=>{let e=t.hardFixed?1e6:0;return t.hardFixed||(e+=t.fixed?1e5:0,e+=null==t.value?0:1e4,e+=this._updateSequence.lastIndexOf(t.id)+1),e},this._filtersComparator=(t,e)=>this._calculateSortIndex(e)-this._calculateSortIndex(t),this.dataUnit=void 0,this.title=void 0,this.configName=void 0,this.resourceID=void 0,this.mode="regular",this.filterConfig=void 0,this.messagesBuilder=void 0,this.disablePersonalizedFilter=void 0,this.filterBarLegacyConfigName=void 0,this.allowDefault=void 0,this.scrollerLocked=!1,this.showPersonalizedFilter=!1,this.personalizedFilterId=void 0}observeFilterConfig(t,e){if(null!=e&&null==t)this._loadingPending=!0,this._configUpdated=!0;else{const i=new Map(e?e.map((t=>[t.id,t])):void 0);0===i.size&&t.length>0?(this._loadingPending=!0,this._configUpdated=!1):t.forEach((t=>{const e=i.get(t.id);if(null!=e){if(this._configUpdated=this._configUpdated||l.objectToString(e)!=l.objectToString(t),this._loadingPending=this._loadingPending||l.objectToString(e.value)!==l.objectToString(t.value),!this._loadingPending){const i=l.objectToString(e.groupedItems)!=l.objectToString(t.groupedItems);this._configUpdated=this._configUpdated||i,this._loadingPending=this._loadingPending||i}}else this._configUpdated=!0,this._loadingPending=this._loadingPending||null!=t.value}))}(this._loadingPending||this._configUpdated)&&this.configUpdated.emit(t),this.processAfterUpdateConfig()}async reload(){this.loadConfigFromStorage(!0)}async getFilterItem(t){const e=this.filterConfig.find((e=>e.id===t));return Promise.resolve(l.copy(e))}async updateFilterItem(t){return-1==this.filterConfig.findIndex((e=>e.id===t.id))?(console.warn("[SnkFilterBar.updateFilterItem] FilterItem não encontrado, o mesmo não será atualizado."),Promise.resolve()):(this._loadingPending=!0,this.updateFilter(t),Promise.resolve())}async addFilterItem(t){return this.filterConfig.findIndex((e=>e.id===t.id))>-1?(console.warn("[SnkFilterBar.addFilterItem] FilterItem já existe , o mesmo não será adicionado novamente."),Promise.resolve()):(this.filterConfig.push(t),this._loadingPending=!0,this.updateFilter(t),Promise.resolve())}async removeFilterItem(t){const e=this.filterConfig.findIndex((e=>e.id===t));if(-1==e)return console.warn("[SnkFilterBar.removeFilterItem] FilterItem não encontrado"),Promise.resolve(void 0);const i=this.filterConfig[e];return this.filterConfig=this.filterConfig.filter((e=>e.id!==t)),Promise.resolve(i)}componentDidLoad(){this._element&&o.addIDInfo(this._element,null,{dataUnit:this.dataUnit})}processPendingFilter(){if(this._pendingVariables){const t=this._element.querySelector("#filter-PERSONALIZED_FILTER_GROUP");t&&t.showUp(!0).then((()=>{this.processAfterUpdateConfig()}))}else this.processAfterUpdateConfig()}getPersonalizedFilterItem(){return this.filterConfig.find((t=>t.type===u.PERSONALIZED))}async processAfterUpdateConfig(){if(this._loadingPending){if(await this._application.isLoadedByPk()&&!this._configUpdated)return;const t=this.getPersonalizedFilterItem();if(this._pendingVariables=!k.validateVariableValues(t),this._pendingVariables)return;this._loadingPending=!1,this.doLoadData(null!=this.dataUnit.getLastLoadRequest())}this._configUpdated&&(this._configUpdated=!1,f.saveFilterBarConfig(this.filterConfig,this.configName,this.resourceID))}async doLoadData(t=!1){try{if(this._firstLoad&&!t&&!await this._application.getBooleanParam("global.carregar.registros.iniciar.tela"))return;this.dataUnit.loadData(void 0,void 0,!0)}finally{this._firstLoad=!1}}getMessage(t,e,i){var r;return null==this.messagesBuilder&&this._application&&(this.messagesBuilder=this._application.messagesBuilder),(null===(r=this.messagesBuilder)||void 0===r?void 0:r.getMessage(t,e))||i}getFilter(t){var e;const i=[];return null===(e=this.filterConfig)||void 0===e||e.filter((t=>this.isActiveFilter(t))).forEach((t=>{const e=(t=>{switch(t.type){case u.DEFAULT_FILTER:return function(t){return{name:t.id,expression:t.props.expression,params:[]}}(t);case u.BINARY_SELECT:return function(t){const{id:e,value:i,props:r}=t;return{name:e,expression:r.options.find((t=>t.name===i)).expression,params:[]}}(t);case u.MULTI_SELECT:return function(t){const{id:e,value:i,props:r}=t;return{name:e,expression:r.expression,params:[{name:e,dataType:a.TEXT,value:i}]}}(t);case u.MULTI_LIST:return function(t){const{id:e,value:i,props:r}=t,s=(null!==(o=null!==(l=null==(n=i)?void 0:n.elements)&&void 0!==l?l:null==n?void 0:n.members)&&void 0!==o?o:n).filter((t=>null==t?void 0:t.check)).map((({id:t})=>Number.isNaN(+t)?String(t):Number(t)));var n,l,o;if(s.length>0)return{name:e,expression:r.expression,params:[{name:e,dataType:a.TEXT,value:JSON.stringify(s)}]}}(t);case u.PERIOD:return function(t){const{id:e,value:i,props:r}=t;let{end:s,start:n}=i;"string"==typeof s&&(s=new Date(s)),"string"==typeof n&&(n=new Date(n));const l=[];let o;return s&&n?(o=r.expression.fullfill,l.push({name:`${e}.START`,dataType:a.DATE,value:m(a.DATE,n)},{name:`${e}.END`,dataType:a.DATE,value:m(a.DATE,s)})):n?(o=r.expression.onlystart,l.push({name:e,dataType:a.DATE,value:m(a.DATE,n)})):(o=r.expression.onlyend,l.push({name:e,dataType:a.DATE,value:m(a.DATE,s)})),{name:e,expression:o,params:l}}(t);case u.SEARCH:return function(t){const{id:e,value:i,props:r}=t;return{name:e,expression:r.expression,params:[{name:e,dataType:a.TEXT,value:m(a.TEXT,i.value)}]}}(t);case u.TEXT:return function(t){let{id:e,value:i,props:r}=t;const s=r.expression;var l,o;return n.isEmpty(r.likeAs)||(l=i,i="CONTANIS"===(o=r.likeAs)?`%${l}%`:"STARTS_WITH"===o?`${l}%`:"ENDS_WITH"===o?`%${l}`:l),{name:e,expression:s,params:[{name:e,dataType:a.TEXT,value:m(a.TEXT,i)}]}}(t);case u.NUMBER:return function(t){const{id:e,value:i,props:r}=t;if(r.variation===b.INTERVAL){const{start:t,end:s}=null!=i?i:{start:0,end:0};if(t&&s)return{name:e,expression:r.intervalExpression.fullfill,params:[{name:`${e}.START`,dataType:a.NUMBER,value:m(a.NUMBER,t)},{name:`${e}.END`,dataType:a.NUMBER,value:m(a.NUMBER,s)}]};if(t)return{name:e,expression:r.intervalExpression.onlystart,params:[{name:e,dataType:a.NUMBER,value:m(a.NUMBER,t)}]};if(s)return{name:e,expression:r.intervalExpression.onlyend,params:[{name:e,dataType:a.NUMBER,value:m(a.NUMBER,s)}]}}return{name:e,expression:r.expression,params:[{name:e,dataType:a.NUMBER,value:m(a.NUMBER,i)}]}}(t);case u.PERSONALIZED:return function(t){const{id:e,groupedItems:i=[]}=t,r=i.filter((t=>!!t.visible)).map((t=>{var e;const i=t.props.expression,r=((null===(e=t.props.personalizedFilter)||void 0===e?void 0:e.parameters)||[]).map(((e,i)=>{const r=Array.from(t.value||0),s=e.dataType;let n=i>=0&&i<r.length?r[i]:null;return null!=n&&"object"==typeof n&&"value"in n&&(n=n.value),null==n&&s===a.BOOLEAN&&(n=!1),{name:e.name,dataType:s,value:"string"==typeof n?n:m(s,n)}}));return{expression:i,name:t.id,params:r}}));return{name:e,expression:r.map((t=>`(${t.expression})`)).join(` ${p.AND} `),params:r.flatMap((t=>t.params))}}(t);case u.CHECK_BOX_LIST:return function(t){var e;const{id:i,value:r,props:s}=t,a=Object.entries(null!=r?r:{}).filter((([t,e])=>!0===e)).map((([t,e])=>t));return{name:i,expression:g(null===(e=s.options)||void 0===e?void 0:e.filter((t=>a.includes(t.name)))),params:[]}}(t);default:return}})(t);e&&i.push(e)})),i}isActiveFilter(t){return t.type===u.DEFAULT_FILTER||this.filterActiveFilter(t)&&(t.groupedItems||null!=t.value)}registryFilterProvider(){this.dataUnit.addFilterProvider(this),this.filterConfig&&this.doLoadData()}itemFocused(t){this._element.querySelectorAll("snk-filter-item,snk-filter-list").forEach((e=>{e.id===t?"snk-filter-item"===e.tagName.toLowerCase()&&e.getClientRects()[0].x<0&&e.scrollIntoView({behavior:"auto",inline:"nearest"}):e.hideDetail()}))}filterActiveFilter(t){return t.visible||t.removalBlocked}getFilterItems(){const t=[],e=[];this.filterConfig.filter(this.filterActiveFilter).forEach(((r,s)=>{const a=`filter-${(r=l.copy(r)).id}`,n=i("snk-filter-item",{onVisibleChanged:t=>this.scrollerLocked=t.detail,onFilterChange:t=>this.updateFilter(t.detail),onFocusin:()=>this.itemFocused(a),id:a,config:r,class:s>0?"ez-padding-left--medium":"",getMessage:(t,e)=>this.getMessage(t,e),key:r.id});return r.fixed||r.hardFixed?t.push(n):e.push(n),n}));const r=[];return r.push(...t),t.length>0&&e.length>0&&r.push(i("hr",{class:"ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-filter-bar__divider"})),r.push(...e),r}calculateUpdateSequence(t){t&&(this._updateSequence=this._updateSequence.filter((e=>t.id!==e)),this._updateSequence.push(t.id))}normalizeItem(t){const e=Object.assign({},t);return["props","value","hardFixed","fixed"].forEach((t=>{null==e[t]&&delete e[t]})),""===t.value&&delete t.value,e}updateFilter(t){this.filterConfig=this.filterConfig.map((e=>(t=this.normalizeItem(t),e.id===t.id?(l.objectToString(e)!=l.objectToString(t)&&this.calculateUpdateSequence(t),t):e))).sort(((t,e)=>this._filtersComparator(t,e)))}loadPermitions(){this._application.isUserSup().then((t=>this.allowDefault=t))}addFilterBarLegacyConfigName(){this.filterBarLegacyConfigName&&this.configName&&f.addFilterBarLegacyConfig(this.configName,this.filterBarLegacyConfigName)}async loadConfigFromStorage(t){return t&&await f.deleteFilterBarConfigCache(this.configName,this.resourceID),new Promise((t=>{f.loadFilterBarConfig(this.configName,this.resourceID,{contextURI:this.dataUnit.name}).then((e=>{t(),this.filterConfig=e.map((t=>this.normalizeItem(t)))})).catch((t=>{throw new d(this.getMessage("snkFilterBar.failToLoadConfig"),t)}))}))}attachDataUnit(){if(null==this.dataUnit){let t=this._element.parentElement;for(;t;)if("SNK-DATA-UNIT"===t.tagName.toUpperCase()){const e=t;this.dataUnit=e.dataUnit,this.dataUnit?this.registryFilterProvider():e.addEventListener("dataUnitReady",(t=>{this.dataUnit=t.detail,this.registryFilterProvider()}));break}t=t.parentElement}else this.registryFilterProvider()}filterChangeListener(t){this.updateFilter(t.detail)}async showFilterModal(){let t=l.copy(this.filterConfig);t=t.sort(((t,e)=>t.originOrder-e.originOrder)),this._filterModalFactory=new _({filterConfig:t,configName:this.configName,onComplete:t=>{this.filterConfig=t.map(this.normalizeItem).sort(((t,e)=>this._filtersComparator(t,e)))},disablePersonalizedFilter:this.disablePersonalizedFilter,getMessage:(t,e)=>this.getMessage(t,e),onAddPersonalizedFilter:()=>this.addPersonalizedFilter(),onEditPersonalizedFilter:t=>this.editPersonalizedFilter(t),onDeletePersonalizedFilter:(t,e)=>this.deletePersonalizedFilter(t,u.PERSONALIZED,e)}),await this._filterModalFactory.showModal()}addPersonalizedFilter(){this._filterModalFactory.closeModal(),this.personalizedFilterId=void 0,this.showPersonalizedFilter=!0,window.requestAnimationFrame((()=>{this._elPersonalizedFilter.createPersonalizedFilter()}))}editPersonalizedFilter(t){this._filterModalFactory.closeModal(),this.showPersonalizedFilter=!0,this.personalizedFilterId=t}deletePersonalizedFilter(t,e,i){e===u.PERSONALIZED&&f.removePersonalizedFilter(t,this.resourceID,i)}handleHidePersonalizedFilter(t){t?this.loadConfigFromStorage().then((()=>{this.hidePersonalizedFilter()})):this.hidePersonalizedFilter()}hidePersonalizedFilter(){this.personalizedFilterId=void 0,this.showPersonalizedFilter=!1}componentWillLoad(){this._application=h.getContextValue("__SNK__APPLICATION__"),this._application&&(this.loadPermitions(),this.addFilterBarLegacyConfigName(),this.loadConfigFromStorage()),this.attachDataUnit()}componentDidRender(){this.processPendingFilter()}render(){if(this.dataUnit&&this.filterConfig&&0!==this.filterConfig.length)return this.showPersonalizedFilter?i("snk-personalized-filter",{class:"filter-bar__personalized-filter",filterId:this.personalizedFilterId,ref:t=>this._elPersonalizedFilter=t,onEzCancel:()=>this.handleHidePersonalizedFilter(!1),onEzAfterSave:()=>this.handleHidePersonalizedFilter(!0),entityUri:this.dataUnit.name,configName:this.configName,resourceID:this.resourceID}):"button"===this.mode?i(r,{"data-mode":this.mode},i("ez-button",{class:"ez-margin-left--medium",size:"small",label:this.getMessage("snkFilterBar.filters",void 0,"Filtros"),onClick:this.showFilterModal.bind(this)})):i(r,{"data-mode":this.mode},i("div",null,i("span",{class:"snk-filter-bar__title",title:this.title,"data-tooltip":this.title,"data-flow":"bottom"},this.title)),i("ez-scroller",{class:"snk-filter-bar__scroller",direction:c.HORIZONTAL,activeShadow:!0,locked:this.scrollerLocked},i("section",{class:"snk-filter-bar__filter-item-container"},this.getFilterItems())),i("ez-button",{class:"ez-padding-left--medium",size:"small",label:this.getMessage("snkFilterBar.filters",void 0,"Filtros"),onClick:this.showFilterModal.bind(this)},i("ez-icon",{slot:"leftIcon",iconName:"plus",class:"ez-padding-right--small"})))}get _element(){return s(this)}static get watchers(){return{filterConfig:["observeFilterConfig"]}}};x.style='.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{display:none}[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-self:center}.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%}';export{x as snk_filter_bar}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as i,c as t,h as s,g as e}from"./p-d2d301a6.js";import{StringUtils as o,ApplicationContext as n,ObjectUtils as a,DataType as h,UserInterface as r,JSUtils as d,FloatingManager as l,ElementIDUtils as c}from"@sankhyalabs/core";import{d as u,S as m}from"./p-b0ef4383.js";import{T as g}from"./p-ae4fc9a9.js";import"./p-be75153c.js";import{I as p}from"./p-d78d4062.js";import{S as f,C as v}from"./p-2897fb8c.js";import{P as C}from"./p-38289a55.js";import"./p-21749402.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import"./p-ff1990ad.js";import"./p-a13ccb86.js";import{T as S,b as k,o as b}from"./p-c2495304.js";import{C as y}from"./p-5c0b53ce.js";import{S as w}from"./p-60fa6c7a.js";import"./p-6dc031de.js";import"./p-8d884fab.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import"./p-688dcb4c.js";import"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";const T=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","MORE_OPTIONS"],E=["INSERT","REFRESH","PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","DIVIDER","MORE_OPTIONS"],_=class{constructor(s){i(this,s),this.dataStateChange=t(this,"dataStateChange",3),this.dataUnitReady=t(this,"dataUnitReady",3),this.actionClick=t(this,"actionClick",7),this.formItemsReady=t(this,"formItemsReady",7),this.configuratorSave=t(this,"configuratorSave",7),this.configuratorCancel=t(this,"configuratorCancel",7),this._multiSelectionListDataSource=new f,this._keyDownHandler=i=>this.keyDownListener(i),this._taskbarProcessor=new S({"snkSimpleCrudTaskbar.form_regular":this.getButtons(!1,g.GRID_MODE),"snkSimpleCrudTaskbar.grid_regular":this.getButtons(!1,g.FORM_MODE),"snkSimpleCrudTaskbar.form_selected":this.getButtons(!0,g.GRID_MODE),"snkSimpleCrudTaskbar.grid_selected":this.getButtons(!0,g.FORM_MODE),"snkSimpleCrudTaskbar.finish_edition":["CANCEL","SAVE"]}),this._showPopUpGridConfig=!1,this._showFormConfig=!1,this._currentViewMode=u.GRID,this._config=void 0,this._fieldToGetFocus=void 0,this._customContainerId=`SNK-SIMPLE-CRUD-CUSTOM-CONTAINER-${o.generateUUID()}`,this.dataState=void 0,this.dataUnit=void 0,this.mode=m.SERVER,this.gridConfig=void 0,this.formConfig=void 0,this._formFields=[],this.multipleSelection=void 0,this.useCancelConfirm=!0,this.taskbarManager=void 0,this.messagesBuilder=void 0,this.useEnterLikeTab=!1,this.actionsList=void 0,this.configName=void 0,this.showConfiguratorButtons=void 0,this.gridLegacyConfigName=void 0,this.formLegacyConfigName=void 0}getButtons(i,t){return this.addConfigButton(this.resolveInMemoryBtns(i?E:T).concat(t))}addConfigButton(i){return void 0===this.configName?i:i.concat(g.CONFIGURATOR)}get application(){return n.getContextValue("__SNK__APPLICATION__")}resolveInMemoryBtns(i){const t=[...i];return this.mode===m.IN_MEMORY&&t.splice(1,1),t}async goToView(i){this._currentViewMode=i,this._viewStack&&this._viewStack.show(i)}actionClickListener(i){const t=i.detail;t===g.CONFIGURATOR?this._snkConfigurator.open():t===g.GRID_MODE?this.goToView(u.GRID):t===g.FORM_MODE&&this.goToView(u.FORM),i.stopPropagation()}onModeChange(){this.mode==m.IN_MEMORY&&this.initInMemoryDataUnit()}observeDataState(i,t){a.objectToString(t)!=a.objectToString(i)&&this.dataStateChange.emit(i)}async observeFormLegacy(){await this.handleUpdateFormLegacyConfig()}async observeGridLegacy(){await this.handleUpdateGridLegacyConfig()}async handleUpdateGridLegacyConfig(){this.gridLegacyConfigName&&await this.loadGridConfig(!0)}async handleUpdateFormLegacyConfig(){if(!this.formLegacyConfigName)return;const i=await this.fetchFormLegacyConfig();if(!i)return;const t=this.buildLegacyConfig(i);this.setFormConfig(t,!0),this._formConfigManager||(this._formConfigManager=new w(this.configName,this._resourceID)),this._formConfigManager.setConfig(t)}buildLegacyConfig(i){var t,s,e;const o=null!==(e=null===(s=null===(t=null==i?void 0:i.formConfig)||void 0===t?void 0:t.layout)||void 0===s?void 0:s.field)&&void 0!==e?e:[];return{emptyConfig:!1,fields:Array.isArray(o)?o:[o]}}async fetchFormLegacyConfig(){const i={requestBody:{config:{chave:this.formLegacyConfigName,tipo:"T"}}};return await this.application.callServiceBroker("SystemUtilsSP.getConf",JSON.stringify(i))}openConfig(i){this._snkConfigurator.close(),i===u.GRID?this.openGridConfig():i===u.FORM&&this.openFormConfig()}openGridConfig(){this._grid.getColumnsState().then((i=>{this._snkGridConfig.columns=i.filter((i=>i.name)),this._snkGridConfig.selectedIndex=0,this._showPopUpGridConfig=!0}))}openFormConfig(){this.formLegacyConfigName||(this._showFormConfig=!0)}addGridLegacyConfigName(){this.gridLegacyConfigName&&this.configName&&y.addGridLegacyConfig(this.configName,this.gridLegacyConfigName)}async loadGridConfig(i){await this.addGridLegacyConfigName(),this.isGridConfigLoaded()&&!i||this.setGridConfig(await y.loadGridConfig(this.configName,this._resourceID))}isGridConfigLoaded(){return this.gridConfig}async loadFormConfig(){this.isFormConfigLoaded()||(this._formConfigManager=new w(this.configName,this._resourceID),this._formConfigManager.setConfig(this.formConfig),this.setFormConfig(await this._formConfigManager.loadConfig()))}isFormConfigLoaded(){return this._formConfigManager&&this.formConfig}async componentWillRender(){this._resourceID=await this.application.getResourceID(),this._taskbarProcessor.process(this.getTaskBarId(),this.taskbarManager,this.dataState,this.getTaskBarDisabledButtons()),await Promise.allSettled([this.loadGridConfig.bind(this),this.loadFormConfig.bind(this)])}componentWillLoad(){this.processMetadata(),this.onModeChange(),this.configDatasource()}configDatasource(){this._multiSelectionListDataSource.setApplication(this.application),this._multiSelectionListDataSource.setDataUnit(this.dataUnit)}getTaskBarId(){var i,t,s;return(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"snkSimpleCrudTaskbar.finish_edition":(null===(t=this.dataState)||void 0===t?void 0:t.selectionInfo)&&!this.dataState.selectionInfo.isAllRecords()&&(null===(s=this.dataState.selectionInfo.records)||void 0===s?void 0:s.length)>0?this._currentViewMode===u.GRID?"snkSimpleCrudTaskbar.grid_selected":"snkSimpleCrudTaskbar.form_selected":this._currentViewMode===u.GRID?"snkSimpleCrudTaskbar.grid_regular":"snkSimpleCrudTaskbar.form_regular"}initInMemoryDataUnit(){this._inMemoryLoader=new p(this._metadata),this.dataUnit=this._inMemoryLoader.dataUnit,this.dataUnitReady.emit(this.dataUnit)}setMetadata(i){return this._inMemoryLoader?this._inMemoryLoader.metadata=i:this.dataUnit&&(this.dataUnit.metadata=i),Promise.resolve()}setRecords(i){return this._inMemoryLoader?this._inMemoryLoader.records=i:this.dataUnit&&(this.dataUnit.records=i),Promise.resolve()}getRecords(){return Promise.resolve(this.dataUnit.records)}async openConfigurator(){var i;null===(i=this._snkConfigurator)||void 0===i||i.open()}async closeConfigurator(){var i;null===(i=this._snkConfigurator)||void 0===i||i.close()}processMetadata(){const i=this._element.querySelectorAll("snk-field-metadata"),t=[],s={fields:[],emptyConfig:!1};i.forEach((i=>{const e={name:i.getAttribute("name")||i.getAttribute("label"),label:i.getAttribute("label"),dataType:h[i.getAttribute("dataType")]||h.TEXT,userInterface:r[i.getAttribute("userInterface")]||r.SHORTTEXT,readOnly:"true"==i.getAttribute("readOnly"),required:"true"==i.getAttribute("required"),tab:i.getAttribute("tab")||void 0,visible:"false"!=i.getAttribute("visible")};s.fields.push({name:e.name,tab:e.tab,visible:e.visible}),t.push(e)})),t.length>0&&(this.formConfig||(this.formConfig=s),this._metadata={name:"SimpleCrud",label:"SimpleCrud",fields:t})}onDataStateChange(i){this.dataState=Object.assign({},i.detail)}getTaskBarDisabledButtons(){var i,t,s,e;const o=[];return(null===(i=this.dataState)||void 0===i?void 0:i.hasNext)||o.push(g.NEXT),(null===(t=this.dataState)||void 0===t?void 0:t.hasPrevious)||o.push(g.PREVIOUS),(null===(e=null===(s=this.dataState)||void 0===s?void 0:s.selectionInfo)||void 0===e?void 0:e.isEmpty())&&o.push(g.FORM_MODE),o}handleCancelEdit(){var i;(null===(i=this.dataState)||void 0===i?void 0:i.recordsIsEmpty)&&(this.goToView(u.GRID),this.dataUnit.clearSelection())}handleConfiguratorEvent(i,t){i.stopImmediatePropagation(),"SAVE"!==t?this.configuratorCancel.emit():this.configuratorSave.emit()}getColumnSearch(i,t){return null!=this._columnSearch||(this._moreOptions=i,this._columnSearch=k(t,(({argument:i})=>new Promise((t=>{this._grid.filterColumns(i).then((i=>{t(i.filter((i=>!i.hidden)).map((i=>({label:i.label,value:i.name}))))}))}))),(t=>{var s;null!=t&&(this._grid.locateColumn(t.value),null===(s=i.hideActions)||void 0===s||s.call(i))}))),this._columnSearch}onSelectField(i,t){null!=i&&(this._fieldToGetFocus=i.value,t.hideActions())}getFieldSearch(i,t){return null!=this._fieldSearch||(this._moreOptions=i,i.addEventListener("ezPopoverOpen",(()=>this.findField())),this._fieldSearch=k(t,(({argument:i})=>this.fieldsOptionLoader(i)),(t=>this.onSelectField(t,i)))),this._fieldSearch}getFormFields(){var i,t;return null!==(t=null===(i=this.formConfig)||void 0===i?void 0:i.fields)&&void 0!==t?t:this._formFields}handleFormSetFields(i){a.equals(this._formFields,i)||(this._formFields=null!=i?i:[])}fieldsOptionLoader(i){const t=null==i?void 0:i.toLowerCase(),s=this.getFormFields().map((i=>{var t;return null===(t=this.dataUnit)||void 0===t?void 0:t.getField(i.name)})).filter((i=>{var s,e;return(null===(s=i.name)||void 0===s?void 0:s.toLowerCase().includes(t))||(null===(e=i.label)||void 0===e?void 0:e.toLowerCase().includes(t))})).map((i=>({value:i.name,label:i.label})));return Promise.resolve(s)}getActionsList(){var i,t;const s=[{value:o.generateUUID(),label:null!==(t=null===(i=this.messagesBuilder)||void 0===i?void 0:i.getMessage("snkSimpleCrud.findColumn",void 0))&&void 0!==t?t:"Buscar",disableCloseOnSelect:!0,eagerInitialize:!0,itemBuilder:(i,t)=>this._currentViewMode===u.GRID?this.getColumnSearch(i,t):this.getFieldSearch(i,t)}];if(null!=this.taskbarManager&&null!=this.taskbarManager.getMoreOptions){const i=this.getTopTaskBarId();return s.concat(this.taskbarManager.getMoreOptions(i,this.configName,this.dataState,this.actionsList))}return s.concat(this.actionsList)}getTopTaskBarId(){var i;return(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?`snkGridTopTaskbar.finish_edition${C.PRIMARY}`:`snkGridTopTaskbar.regular${C.PRIMARY}`}async keyDownListener(i){i.ctrlKey&&null!=i.key&&"F"===i.key.toUpperCase()&&null!=this._element&&(d.isHiddenElement(this._element)||(l.closeAll(),this._currentViewMode===u.GRID?await this.findColumn():await this.findField(),i.preventDefault()))}async findField(){await this.openSeach(this._fieldSearch)}async findColumn(){await this.openSeach(this._columnSearch)}async openSeach(i){await b(this._moreOptions,i)}clearFieldToFocusHandler(){this._fieldToGetFocus=void 0}connectedCallback(){window.addEventListener("keydown",this._keyDownHandler,{capture:!0})}disconnectedCallback(){window.removeEventListener("keydown",this._keyDownHandler)}gridConfigChangeHandler(i){y.saveGridConfig(i.detail,this.configName,this._resourceID),i.stopPropagation()}modalConfigChangeHandler(i){const t=i.detail;this._grid.setColumnsState(t.columns).then((()=>{this.setGridConfig(t),this.closeGridConfig()})),i.stopPropagation()}setGridConfig(i){this.gridConfig=i,v.assertDefaultSorting(this.gridConfig,this.dataUnit)}setFormConfig(i,t){this.formConfig&&!t||(this.formConfig=i)}closeGridConfig(){this._showPopUpGridConfig=!1}closeFormConfig(){this._showFormConfig=!1}handleShowFormConfig(){return this._showFormConfig&&!this.formLegacyConfigName}render(){var i,t,e;if(null!=this.dataUnit)return s("snk-data-unit",{class:"simple-crud__container",dataUnit:this.dataUnit,useCancelConfirm:this.useCancelConfirm,onDataStateChange:i=>this.onDataStateChange(i),onCancelEdition:this.handleCancelEdit.bind(this),onInsertionMode:()=>this.goToView(u.FORM),onDataUnitReady:i=>this.dataUnitReady.emit(i.detail),ignoreSaveMessage:this._currentViewMode===u.GRID,onMessagesBuilderUpdated:i=>this.messagesBuilder=i.detail},s("header",null,s("slot",{name:"snkSimpleCrudHeader"})),s("section",{class:"ez-box ez-box--shadow simple-crud__container-section"},s("snk-taskbar",{class:"ez-box ez-box--shadow ez-padding--medium",dataUnit:this.dataUnit,primaryButton:(null===(i=this.dataState)||void 0===i?void 0:i.isDirty)?"SAVE":"INSERT","data-element-id":"grid_left",messagesBuilder:this.messagesBuilder,buttons:this._taskbarProcessor.buttons,actionsList:this.getActionsList(),disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,slot:"leftButtons",presentationMode:C.SECONDARY},s("slot",{name:"TASKBAR_CUSTOM_ELEMENTS"})),s("ez-view-stack",{ref:i=>this._viewStack=i,"data-element-id":"simple-crud"},s("stack-item",null,s("ez-grid",{class:"ez-margin-bottom--large",ref:i=>this._grid=i,dataUnit:this.dataUnit,config:this.gridConfig,"no-header":!0,multipleSelection:this.multipleSelection,onEzDoubleClick:()=>this.goToView(u.FORM),onConfigChange:i=>this.gridConfigChangeHandler(i),columnfilterDataSource:this.dataUnit.name&&this.dataUnit.name.includes(p.IN_MEMORY_DATA_UNIT_NAME)?void 0:this._multiSelectionListDataSource,useEnterLikeTab:this.useEnterLikeTab},s("div",{slot:"footer"},s("slot",{name:"snkSimpleCrudFooter"})))),s("stack-item",null,s("ez-form",{class:"ez-margin-top--large "+(this.handleShowFormConfig()?"simple-crud__form--hidden":""),dataUnit:this.dataUnit,config:null===(t=this._formConfigManager)||void 0===t?void 0:t.getConfig(null===(e=this.dataState)||void 0===e?void 0:e.insertionMode,this.dataUnit),fieldToFocus:this._fieldToGetFocus,onEzFormSetFields:i=>this.handleFormSetFields(i.detail),onEzFormRequestClearFieldToFocus:this.clearFieldToFocusHandler.bind(this)}),this.handleShowFormConfig()&&s("snk-form-config",{messagesBuilder:this.messagesBuilder,dataUnit:this.dataUnit,configManager:this._formConfigManager,onConfigClose:()=>this.closeFormConfig()})),this.messagesBuilder&&s("snk-configurator",{ref:i=>this._snkConfigurator=i,viewMode:this._currentViewMode,messagesBuilder:this.messagesBuilder,onConfigSelected:i=>this.goToView(i.detail),onOpenConfig:i=>this.openConfig(i.detail),showActionButtons:this.showConfiguratorButtons,onSave:i=>this.handleConfiguratorEvent(i,"SAVE"),onCancel:i=>this.handleConfiguratorEvent(i,"CANCEL"),resourceID:this._resourceID,customContainerId:this._customContainerId})),s("div",{id:`${this._customContainerId}`},s("slot",{name:"SnkConfigContainerSlot"}))),s("ez-modal",{modalSize:"small",closeEsc:!1,closeOutsideClick:!1,opened:this._showPopUpGridConfig,onEzCloseModal:()=>this.closeGridConfig()},s("snk-grid-config",{ref:i=>this._snkGridConfig=i,config:this.gridConfig,"data-element-id":this._element.getAttribute(c.DATA_ELEMENT_ID_ATTRIBUTE_NAME),selectedIndex:0,configName:this.configName,onConfigChange:i=>this.modalConfigChangeHandler(i),onConfigCancel:()=>this.closeGridConfig(),resourceID:this._resourceID})))}get _element(){return e(this)}static get watchers(){return{mode:["onModeChange"],dataState:["observeDataState"],formLegacyConfigName:["observeFormLegacy"],gridLegacyConfigName:["observeGridLegacy"]}}};_.style=".sc-snk-simple-crud-h{display:flex;height:100%;width:100%}.simple-crud__container.sc-snk-simple-crud{display:grid;grid-template-rows:max-content;row-gap:12px;height:100%;width:100%}.simple-crud__container-section.sc-snk-simple-crud{flex-wrap:unset;flex-direction:column}.simple-crud__form--hidden.sc-snk-simple-crud{display:none}ez-grid.sc-snk-simple-crud{--ez-grid__container--shadow:none;min-height:300px}ez-form.sc-snk-simple-crud{min-height:300px}";export{_ as snk_simple_crud}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ObjectUtils as t}from"@sankhyalabs/core";import{R as a}from"./p-a13ccb86.js";class s extends a{getData(a){const s=`cfg://auth/${a}`;return new Promise(((a,e)=>{this.loadResource(s).then((s=>{let e=t.stringToObject(s);e&&"object"==typeof e&&a(e)})).catch((t=>{e(t)}))}))}}var e;!function(t){t.INSERT="I",t.UPDATE="A",t.REMOVE="E",t.SHOW="C",t.CONFIG="F",t.CONFIG_NUMBER="N",t.CLONE="D",t.CONFIG_GRID="G"}(e||(e={}));export{e as A,s as a}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,c as i,h as e,H as s,g as r}from"./p-d2d301a6.js";import{FloatingManager as n,DateUtils as l,ElementIDUtils as o}from"@sankhyalabs/core";import{F as h}from"./p-ff1990ad.js";import{F as a}from"./p-fa80e546.js";const c=class{constructor(e){t(this,e),this.visibleChanged=i(this,"visibleChanged",7),this.filterChange=i(this,"filterChange",3),this.innerClickCheck=(t,i)=>i.id!=n.MODAL_ELEMENT_ID||(this.detailIsVisible=!1,!1),this.detailIsVisible=void 0,this.config=void 0,this.getMessage=void 0}observeDetailIsVisible(t){this.visibleChanged.emit(t)}async showUp(t=!1){return new Promise((i=>{this._filterItemElement.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"}),t&&(this._closeCallback=i,window.requestAnimationFrame((()=>{this._floatingID=n.float(this._popover,this._popoverContainer,this.getFloatOptions()),this._popover.show(),this.detailIsVisible=!0})))}))}updatePosition(){null!=this._floatingID&&n.updateFloatPosition(this._popover,this._popoverContainer,this.getFloatOptions())}getFloatOptions(){return{autoClose:!0,innerClickTest:this.innerClickCheck,backClickListener:()=>this.onDetailCloseCallback(),left:this.getScrollOffsetLeft(),top:this.getScrollOffsetTop(),useOverlay:!0,overlayClassName:"ez-scrim ez-scrim--light",isFixed:!0}}getScrollOffsetLeft(){const t=getComputedStyle(this._filterItemElement).getPropertyValue("padding-left");return`calc(${this._filterItemElement.getBoundingClientRect().x}px + ${t})`}getScrollOffsetTop(){const t=this._filterItemElement.getBoundingClientRect();return t.y+t.height+"px"}controlScrollPage(){window.removeEventListener("scroll",this.updatePosition.bind(this)),window.addEventListener("scroll",this.updatePosition.bind(this))}getConfigChanges(){var t;const i=this.config;(null===(t=i.groupedItems)||void 0===t?void 0:t.length)&&(i.visible=!1,i.groupedItems=i.groupedItems.map((t=>Object.assign(Object.assign({},t),{visible:!1}))));const e=i.type===h.MULTI_LIST&&Array.isArray(i.value)?i.value.map((t=>Object.assign(Object.assign({},t),{check:!1}))):void 0;return Object.assign(Object.assign({},i),{value:e})}async hideDetail(){this.detailIsVisible&&null!=this._floatingID&&n.close(this._floatingID)}onDetailCloseCallback(){this._floatingID=void 0,this.detailIsVisible=!1,this._closeCallback&&(this._closeCallback(),this._closeCallback=void 0)}clickListener(t){if([this._chipElement,this._leftIconElement,this._rightIconElement].includes(t.target)){if(t.target===this._rightIconElement&&this.canClearFilter()){const t=this.getConfigChanges();this.filterChange.emit(t)}else this.detailIsVisible?this.hideDetail():this.showUp(!0);t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation()}}mouseDownListener(t){this.detailIsVisible&&[this._chipElement,this._leftIconElement,this._rightIconElement].includes(t.target)&&(t.preventDefault(),t.stopImmediatePropagation(),t.stopPropagation())}getLabel(t=!1){var i,e;const{type:s,value:r,label:n,props:o,groupedItems:c=[]}=this.config;if(r||c.length){if(s===h.BINARY_SELECT){const[i,e]=o.options,s=this.getMessage("snkFilterBar.binarySelectTooltip");if(i.name===r)return t?`${s} ${String(i.label).toLowerCase()}`:i.label;if(e.name===r)return t?`${s} ${String(e.label).toLowerCase()}`:e.label}if(s===h.MULTI_SELECT)return`${n}: ${o.options.find((t=>t.value===r)).label}`;if(s===h.PERIOD){let{end:i,start:e}=r;"string"==typeof i&&(i=new Date(i),i.setMinutes(i.getMinutes()+i.getTimezoneOffset())),"string"==typeof e&&(e=new Date(e),e.setMinutes(e.getMinutes()+e.getTimezoneOffset()));const s=new Intl.DateTimeFormat("pt-BR");if(i&&e){const s=e.getFullYear()===i.getFullYear(),r=Object.assign({day:"2-digit",month:"2-digit"},(!s||t)&&{year:"2-digit"}),o=l.formatDate(e,r),h=l.formatDate(i,r);return t?this.getMessage("snkFilterBar.fullPeriodTooltip",{LABEL:n,START_LABEL:o,END_LABEL:h}):`${n}: ${o} → ${h}`}return e?`${n}: ${this.getMessage("snkFilterBar.onlyStartToltip")} ${s.format(e)}`:i?`${n}: ${this.getMessage("snkFilterBar.onlyEndToltip")} ${s.format(i)}`:n}if(s===h.SEARCH)return`${n}: ${r.value} - ${r.label}`;if(s===h.PERSONALIZED){const t=this.calculateActiveCount(c);return t<=0?n:`${n}: ${this.getMessage("snkFilterBar.personalizedCount",{activeCount:t})}`}if(s===h.MULTI_LIST){const e=(null!==(i=r.elements)&&void 0!==i?i:r).filter((t=>null==t?void 0:t.check));return this.getLabelFromCheckedOptions(e,n,t)}if(s===h.CHECK_BOX_LIST){const i=Object.entries(null!=r?r:{}).filter((([t,i])=>!0===i)).map((([t,i])=>t)),s=(null!==(e=o.options)&&void 0!==e?e:[]).filter((t=>i.includes(t.name)));return this.getLabelFromCheckedOptions(s,n,t)}if(s===h.NUMBER&&o.variation===a.INTERVAL){const{start:t,end:i}=r;if(t&&i)return this.getMessage("snkFilterBar.fullIntervalTooltip",{LABEL:n,START_LABEL:t,END_LABEL:i});if(t)return`${n}: ${this.getMessage("snkFilterBar.onlyStartToltip")} ${Number(t)}`;if(i)return`${n}: ${this.getMessage("snkFilterBar.onlyEndToltip")} ${Number(i)}`}return`${n}: ${r}`}return n}getLabelFromCheckedOptions(t,i,e){const s=t.length;return 0===s?`${i}`:s>1?e?`${i}: ${t.map((t=>t.label)).join(",")}`:`${i}: ${s} ${this.getMessage("snkFilterBar.multiListToltip")}`:`${i}: ${t[0].label}`}calculateActiveCount(t){return t.reduce(((t,i)=>i.visible?t+1:t),0)}componentDidLoad(){this._filterItemElement&&(o.addIDInfo(this._filterItemElement),this._idSnkFilterDetail=`filterDetail_${this.config.id}`),this.controlScrollPage()}componentDidRender(){null==this._floatingID&&this._popover&&this._popover.remove()}filterChangeListener(){this.hideDetail()}canClearFilter(){const{value:t,groupedItems:i=[]}=this.config;return null!=t&&this.config.type===h.MULTI_LIST?t.some((t=>t.check)):void 0!==t||i.some((t=>t.visible))}getRightIconName(){return this.canClearFilter()?"close":this.detailIsVisible?"chevron-up":"chevron-down"}getLeftIconName(){switch(this.config.type){case h.PERIOD:return"calendar";case h.PERSONALIZED:return"tune"}}hasActiveElements(t){var i,e,s;return(null===(s=null===(e=null!==(i=null==t?void 0:t.elements)&&void 0!==i?i:t)||void 0===e?void 0:e.filter((t=>null==t?void 0:t.check)))||void 0===s?void 0:s.length)>0}hasActiveValue(t){return t.type!==h.MULTI_LIST&&void 0!==t.value||this.hasActiveElements(t.value)}getEnabledChip(){if(this.config.type===h.PERSONALIZED){const{groupedItems:t=[]}=this.config;return t.some((t=>t.visible))}return this.hasActiveValue(this.config)}render(){const t=this.getLeftIconName();return e(s,null,e("ez-chip",{id:this.config.id,ref:t=>this._chipElement=t,label:this.getLabel(),value:this.getEnabledChip()},t?e("ez-icon",{ref:t=>this._leftIconElement=t,iconName:t,class:"ez-padding-right--small",slot:"leftIcon"}):void 0,e("ez-icon",{ref:t=>this._rightIconElement=t,iconName:this.getRightIconName(),class:"ez-padding-left--small",slot:"rightIcon",id:"removeFilter"})),e("section",{class:"ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container",ref:t=>this._popoverContainer=t},e("snk-filter-detail",{config:this.config,getMessage:this.getMessage,class:"sc-snk-filter-bar snk-filter__popover ez-padding--small ez-elevation--16",ref:t=>this._popover=t,key:this.config.id,"data-element-id":this._idSnkFilterDetail})))}get _filterItemElement(){return r(this)}static get watchers(){return{detailIsVisible:["observeDetailIsVisible"]}}};export{c as snk_filter_item}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import{d as e,D as s}from"./p-be75153c.js";import{ObjectUtils as t}from"@sankhyalabs/core";class r{constructor(){this.templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchResource",e.gql`query($name: String!) {
|
|
2
|
-
$queryAlias$: fetchResource(name: $name){
|
|
3
|
-
resource
|
|
4
|
-
}
|
|
5
|
-
}`),this.templateByQuery.set("saveResource",e.gql`mutation($resource: InputResource!) {
|
|
6
|
-
$queryAlias$: saveResource(resource: $resource){
|
|
7
|
-
name
|
|
8
|
-
resource
|
|
9
|
-
}
|
|
10
|
-
}`)}loadResource(e){if(r._loadingResource.has(e))return r._loadingResource.get(e);const t=new Promise(((t,n)=>{s.get().callGraphQL({values:{name:e},query:this.templateByQuery.get("fetchResource")}).then((s=>{t(null==s?void 0:s.resource),r._loadingResource.delete(e)})).catch((s=>{n(s),r._loadingResource.delete(e)}))}));return r._loadingResource.set(e,t),t}saveResource(e,t){return new Promise(((r,n)=>{s.get().callGraphQL({values:{resource:{name:t,resource:JSON.stringify(e)}},query:this.templateByQuery.get("saveResource")}).then((e=>{r(e)})).catch((e=>{n(e)}))}))}}r._loadingResource=new Map;class n extends r{constructor(){super(),this.queryConfig=new Map,this.buildTemplatesConfig()}buildTemplatesConfig(){this.queryConfig.set("fetchUserAvailableConfigs",e.gql`query($name: String!) {
|
|
11
|
-
$queryAlias$: fetchUserAvailableConfigs(name: $name){
|
|
12
|
-
name
|
|
13
|
-
origin
|
|
14
|
-
key
|
|
15
|
-
}
|
|
16
|
-
}`),this.queryConfig.set("fetchLegacyConfig",e.gql`query($name: String!) {
|
|
17
|
-
$queryAlias$: fetchLegacyConfig(name: $name){
|
|
18
|
-
name
|
|
19
|
-
resource
|
|
20
|
-
}
|
|
21
|
-
}`),this.queryConfig.set("fetchDefaultConfig",e.gql`query($name: String!) {
|
|
22
|
-
$queryAlias$: fetchDefaultConfig(name: $name){
|
|
23
|
-
name
|
|
24
|
-
resource
|
|
25
|
-
}
|
|
26
|
-
}`)}loadFormConfig(e,s){return new Promise(((t,r)=>{Promise.all([this.loadResource(this.getPath(s,e)),this.loadResource(this.getPath(`FormCardState:${s}`,e,"form-card")),this.loadResource(this.getPath(s,e,"summary")),this.loadResource(this.getPath(s,e,"defaultValues"))]).then((([e,s,r,n])=>{let a;if(null!=e){a=Object.assign(Object.assign({},JSON.parse(e)),{emptyConfig:!1});const{tabs:s,fields:t}=a;if(s){const e=new Map(s.map((e=>[e.label,e])));null==t||t.forEach((s=>{var t;return s.tab=(null===(t=e.get(this.getTabName(s.tab)))||void 0===t?void 0:t.label)||e.get(this.getTabName(s.tab))}))}a.fields=null==t?void 0:t.map((e=>{if("readonly"in e){const s=!0===e.readonly;delete e.readonly,e.readOnly=s}return e}))}null!=s&&(null==a&&(a={emptyConfig:!0,fields:[]}),a.cardsState=new Map(JSON.parse(s))),null!=r&&(null==a&&(a={emptyConfig:!0,fields:[]}),a.summary=new Map(Object.entries(JSON.parse(r)))),null!=n&&(null==a&&(a={emptyConfig:!0,fields:[]}),a.defaultVars=new Map(Object.entries(JSON.parse(n)))),t(a)})).catch((e=>{r(e)}))}))}getTabName(e){return"object"==typeof e?e.label:e}saveCardState(e,s,t){const r=this.getPath(`FormCardState:${t}`,s,"form-card");return new Promise(((s,t)=>{this.saveResource(Array.from(e.entries()),r).then((e=>{s(new Map(JSON.parse(e.resource)))})).catch((e=>{t(e)}))}))}saveConfig(e,s,t){delete e.cardsState,delete e.defaultVars,delete e.summary;const r=this.getPath(t,s);return new Promise(((s,t)=>{this.saveResource(e,r).then((e=>{s(JSON.parse(e.resource))})).catch((e=>{t(e)}))}))}fetchUserAvailableConfigs(e,t){const r=this.getPath(t,e);return new Promise(((e,t)=>{s.get().callGraphQL({values:{name:r},query:this.queryConfig.get("fetchUserAvailableConfigs")}).then((s=>{e(s)})).catch((e=>{t(e)}))}))}fetchLegacyConfig(e,r){const n=this.getPath(r,e);return new Promise(((e,r)=>{s.get().callGraphQL({values:{name:n},query:this.queryConfig.get("fetchLegacyConfig")}).then((s=>{e(t.stringToObject((null==s?void 0:s.resource)||""))})).catch((e=>{r(e)}))}))}fetchDefaultConfig(e,r){const n=this.getPath(r,e);return new Promise(((e,r)=>{s.get().callGraphQL({values:{name:n},query:this.queryConfig.get("fetchDefaultConfig")}).then((s=>{e(t.stringToObject((null==s?void 0:s.resource)||""))})).catch((e=>{r(e)}))}))}getPath(e,s,t="form"){return s?`cfg://${t}/${e}/${s}`:`cfg://${t}/${e}`}}var a;!function(e){e.USER="USER",e.DEFAULT="DEFAULT",e.SHARED="SHARED"}(a||(a={}));export{n as F,r as R,a as U}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as t,c as i,h as e,F as s,H as l,g as r}from"./p-d2d301a6.js";import{ApplicationUtils as n}from"@sankhyalabs/ezui/dist/collection/utils";import{F as a}from"./p-ff1990ad.js";import{ElementIDUtils as o,ObjectUtils as h}from"@sankhyalabs/core";import{E as c}from"./p-1a68fb59.js";import{P as d}from"./p-057fad05.js";import"./p-933c0c0b.js";const u=class{constructor(e){t(this,e),this.filterChange=i(this,"filterChange",7),this.config=void 0,this.getMessage=void 0}async show(){var t,i;null===(i=null===(t=this._editor)||void 0===t?void 0:t.show)||void 0===i||i.call(t)}observeConfig(t){var i,e;this._editor&&(this._editor.config=t),null===(e=null===(i=this._editor)||void 0===i?void 0:i.reloadList)||void 0===e||e.call(i)}componentDidLoad(){if(this._element){o.addIDInfo(this._element);const t=this._element.getAttribute(o.DATA_ELEMENT_ID_ATTRIBUTE_NAME);this._idContentEditor=`${t}_${this.config.id}`}}changeConfig(t){this.filterChange.emit(t)}getContentEditor(){switch(this.config.type){case a.BINARY_SELECT:return{tag:"snk-filter-binary-select"};case a.MULTI_SELECT:return{tag:"snk-filter-multi-select"};case a.PERIOD:return{tag:"snk-filter-period"};case a.SEARCH:return{tag:"snk-filter-search"};case a.NUMBER:return{tag:"snk-filter-number"};case a.PERSONALIZED:return{tag:"snk-personalized-filter-editor",props:{presentationMode:c.CHIP,onValueChanged:t=>this.handleValueChanged(t)}};case a.CHECK_BOX_LIST:return{tag:"snk-filter-checkbox-list",props:{onValueChanged:t=>this.config=Object.assign(Object.assign({},this.config),{value:t.detail})}};case a.MULTI_LIST:return{tag:"snk-entity-list",props:{onValueChanged:t=>this.config=Object.assign(Object.assign({},this.config),{value:t.detail})}}}return{tag:"snk-filter-text"}}handleValueChanged({detail:t}){const i=(null==t?void 0:t.items)||this.config.groupedItems;this.config=Object.assign(Object.assign({},this.config),{groupedItems:i,visible:(i||[]).filter((t=>t.visible)).length>0})}removeItem(){const t=this.config.type===a.MULTI_LIST&&Array.isArray(this.config.value)?this.config.value.map((t=>Object.assign(Object.assign({},t),{check:!1}))):void 0,i=Object.assign(Object.assign({},this.config),{visible:!1,fixed:!1,value:t});null!=i.groupedItems&&(i.groupedItems=i.groupedItems.map((t=>Object.assign(Object.assign({},t),{visible:!1,fixed:!1,value:void 0})))),this.changeConfig(i)}removeItemFromGroup(t){return Object.assign(Object.assign({},t),{visible:!1,fixed:!1,value:void 0})}getPopUpHeaderButtons(){return e(s,null,!this.config.removalBlocked&&this.buildIcon(this.getMessage("snkFilterBar.removeFilter"),"delete",(()=>this.removeItem())),!this.config.hardFixed&&this.buildIcon(this.getMessage(this.config.fixed?"snkFilterBar.unpinFilter":"snkFilterBar.pinFilter"),this.config.fixed?"un-pin":"push-pin",(()=>this.changeConfig(Object.assign(Object.assign({},this.config),{fixed:!this.config.fixed})))))}buildIcon(t,i,s){return e("button",{onClick:()=>s(),class:"sc-snk-filter-bar snk-filter-item__editor-header-button",ref:i=>i&&this.buildIdButton(i,t)},e("ez-icon",Object.assign({title:t,iconName:i},{[o.DATA_ELEMENT_ID_ATTRIBUTE_NAME]:`${o.getInternalIDInfo(`_${t}`)}`})))}buildIdButton(t,i){if(!t)return;const e={id:i};t.removeAttribute(o.DATA_ELEMENT_ID_ATTRIBUTE_NAME),o.addIDInfoIfNotExists(t,"button",e)}clearBinarySelectValues(){var t;const i=this._editor||{};null===(t=i.resetValues)||void 0===t||t.call(i),this.config=h.copy(this.originalConfig),this.changeConfig(Object.assign(Object.assign({},this.config),{value:void 0}))}apply(){if(!d.validateVariableValues(this.config,this._editor.value))return n.alert(this.getMessage("snkFilterBar.filterModal.validations.notFullFilled.title"),this.getMessage("snkFilterBar.filterModal.validations.notFullFilled.message"));const t=void 0!==this._editor.value?this._editor.value:this.config.value;this.changeConfig(Object.assign(Object.assign({},this.config),{visible:this.isVisible(),value:t}))}isVisible(){return!(this.config.groupedItems&&this.config.groupedItems.length>0)||this.config.groupedItems.filter((t=>t.visible)).length>0}clear(){var t;if(this.config.type!==a.BINARY_SELECT){if(a.MULTI_LIST===this.config.type){const i=h.copy(this.config);return null===(t=i.value)||void 0===t||t.forEach((t=>!!t&&(t.check=!1))),void(this.config=h.copy(i))}this.changeConfig(Object.assign(Object.assign({},this.config),{value:void 0}))}else this.clearBinarySelectValues()}filterCanBeCleared(){return this.config.type!==a.PERSONALIZED}onKeyDonwListener(t){"Enter"===t.key&&this._applyButton.setFocus().then((()=>this.apply()))}buildRightSlot(t){return e("ez-icon",{iconName:"delete",onClick:()=>this.removeValueFromConfig(t)})}removeValueFromConfig(t){var i,e;if(this.config){const s=h.copy(this.config),l=null===(i=s.value)||void 0===i?void 0:i.findIndex((i=>(null==i?void 0:i.id)===t.id));null===(e=s.value)||void 0===e||e.splice(l,1),this.config=h.copy(s)}}componentWillLoad(){this.originalConfig=h.copy(this.config)}render(){const{tag:t,props:i}=this.getContentEditor();return e(l,null,e("div",{class:"col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center"},e("div",{class:"ez-text ez-title ez-title--small ez-padding--small sc-snk-filter-bar snk-filter-item__editor-header"},this.config.detailTitle),this.getPopUpHeaderButtons()),e(t,Object.assign({maxHeightList:"240px",ref:t=>this._editor=t,value:this.config.value,config:this.config,onKeyDown:t=>this.onKeyDonwListener(t),"data-element-id":this._idContentEditor,getMessage:this.getMessage,rightListSlotBuilder:t=>this.buildRightSlot(t)},i)),e("hr",{class:"sc-snk-filter-bar snk-filter__popover-rule"}),e("div",{class:"ez-col ez-col--sd-12 ez-align--right"},this.filterCanBeCleared()&&e("ez-button",{label:this.getMessage("snkFilterBar.cleanFilter"),onClick:()=>this.clear(),size:"small"}),e("ez-button",{ref:t=>this._applyButton=t,label:this.getMessage("snkFilterBar.applyFilter"),onClick:()=>this.apply(),size:"small",class:"ez-button--primary ez-padding-left--medium"})))}get _element(){return r(this)}static get watchers(){return{config:["observeConfig"]}}};export{u as snk_filter_detail}
|