@sankhyalabs/sankhyablocks 1.4.0-beta.3 → 1.4.0-beta.5
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/{SnkMessageBuilder-d8215915.js → SnkMessageBuilder-b54dfb89.js} +6 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sankhyablocks.cjs.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +11 -5
- package/dist/cjs/snk-crud.cjs.entry.js +6 -0
- package/dist/cjs/snk-data-unit.cjs.entry.js +1 -1
- package/dist/cjs/snk-filter-bar_5.cjs.entry.js +7 -26
- package/dist/cjs/snk-filter-detail.cjs.entry.js +30 -19
- package/dist/cjs/snk-filter-personalized.cjs.entry.js +0 -9
- package/dist/cjs/snk-filter-search.cjs.entry.js +0 -9
- package/dist/collection/components/snk-application/snk-application.js +11 -2
- package/dist/collection/components/snk-crud/snk-crud.js +29 -0
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.js +0 -39
- package/dist/collection/components/snk-filter-bar/filter-item/editors/snk-filter-search.js +0 -39
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-detail.js +30 -36
- package/dist/collection/components/snk-filter-bar/filter-item/snk-filter-item.js +3 -14
- package/dist/collection/components/snk-filter-bar/filter-list/snk-filter-list.js +4 -12
- package/dist/collection/lib/http/data-fetcher/DataFetcher.js +3 -3
- package/dist/collection/lib/index.js +1 -0
- package/dist/collection/lib/message/SnkMessageBuilder.js +3 -1
- package/dist/collection/lib/message/resources/crud-utils.msg.js +4 -0
- package/dist/collection/lib/utils/CrudUtils.js +73 -0
- package/dist/components/SnkMessageBuilder.js +6 -1
- package/dist/components/snk-application2.js +10 -4
- package/dist/components/snk-crud.js +8 -1
- package/dist/components/snk-filter-detail2.js +30 -20
- package/dist/components/snk-filter-item2.js +3 -14
- package/dist/components/snk-filter-list2.js +4 -12
- package/dist/components/snk-filter-personalized.js +1 -12
- package/dist/components/snk-filter-search.js +1 -12
- package/dist/esm/{SnkMessageBuilder-35a20271.js → SnkMessageBuilder-d440381c.js} +6 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sankhyablocks.js +1 -1
- package/dist/esm/snk-application.entry.js +11 -5
- package/dist/esm/snk-crud.entry.js +6 -0
- package/dist/esm/snk-data-unit.entry.js +1 -1
- package/dist/esm/snk-filter-bar_5.entry.js +7 -26
- package/dist/esm/snk-filter-detail.entry.js +30 -19
- package/dist/esm/snk-filter-personalized.entry.js +0 -9
- package/dist/esm/snk-filter-search.entry.js +0 -9
- package/dist/sankhyablocks/p-01823784.entry.js +1 -0
- package/dist/sankhyablocks/{p-8f3c5709.entry.js → p-2e49afef.entry.js} +1 -1
- package/dist/sankhyablocks/{p-586e2522.js → p-2eea7eea.js} +1 -1
- package/dist/sankhyablocks/{p-dc482a42.entry.js → p-6f8303f3.entry.js} +1 -1
- package/dist/sankhyablocks/p-746fc78b.entry.js +1 -0
- package/dist/sankhyablocks/p-77216252.entry.js +1 -0
- package/dist/sankhyablocks/{p-9be74b46.entry.js → p-c564f823.entry.js} +2 -2
- package/dist/sankhyablocks/p-eea6444c.entry.js +1 -0
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-application/snk-application.d.ts +1 -1
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-personalized.d.ts +0 -2
- package/dist/types/components/snk-filter-bar/filter-item/editors/snk-filter-search.d.ts +0 -2
- package/dist/types/components/snk-filter-bar/filter-item/snk-filter-detail.d.ts +1 -1
- package/dist/types/components/snk-filter-bar/filter-list/snk-filter-list.d.ts +1 -1
- package/dist/types/components.d.ts +5 -11
- package/dist/types/lib/index.d.ts +1 -0
- package/dist/types/lib/message/resources/crud-utils.msg.d.ts +2 -0
- package/dist/types/lib/utils/CrudUtils.d.ts +6 -0
- package/package.json +1 -1
- package/dist/sankhyablocks/p-322c0df2.entry.js +0 -1
- package/dist/sankhyablocks/p-473cedf9.entry.js +0 -1
- package/dist/sankhyablocks/p-a8b59c61.entry.js +0 -1
- package/dist/sankhyablocks/p-c78cb79a.entry.js +0 -1
|
@@ -465,21 +465,10 @@ const SnkFilterItem = class {
|
|
|
465
465
|
constructor(hostRef) {
|
|
466
466
|
registerInstance(this, hostRef);
|
|
467
467
|
this.filterChange = createEvent(this, "filterChange", 7);
|
|
468
|
-
this.innerClickCheck = (
|
|
469
|
-
if (
|
|
468
|
+
this.innerClickCheck = (_floatingContainer, node) => {
|
|
469
|
+
if (node.id != FloatingManager.MODAL_ELEMENT_ID) {
|
|
470
470
|
return true;
|
|
471
471
|
}
|
|
472
|
-
if (node && floatingContainer) {
|
|
473
|
-
if (!node.offsetParent) {
|
|
474
|
-
return true;
|
|
475
|
-
}
|
|
476
|
-
let current = node;
|
|
477
|
-
do {
|
|
478
|
-
if (current === floatingContainer) {
|
|
479
|
-
return true;
|
|
480
|
-
}
|
|
481
|
-
} while ((current = current.offsetParent) != null);
|
|
482
|
-
}
|
|
483
472
|
this.detailIsVisible = false;
|
|
484
473
|
this.executeCloseCallback();
|
|
485
474
|
return false;
|
|
@@ -497,7 +486,7 @@ const SnkFilterItem = class {
|
|
|
497
486
|
});
|
|
498
487
|
}
|
|
499
488
|
showDetail() {
|
|
500
|
-
this._floatingID = FloatingManager.float(this._popover, this._popoverContainer, { autoClose: true, innerClickTest: this.innerClickCheck, left: this.getScrollOffset() });
|
|
489
|
+
this._floatingID = FloatingManager.float(this._popover, this._popoverContainer, { autoClose: true, innerClickTest: this.innerClickCheck, left: this.getScrollOffset(), useOverlay: true });
|
|
501
490
|
this.detailIsVisible = true;
|
|
502
491
|
}
|
|
503
492
|
getScrollOffset() {
|
|
@@ -635,24 +624,16 @@ const SnkFilterList = class {
|
|
|
635
624
|
constructor(hostRef) {
|
|
636
625
|
registerInstance(this, hostRef);
|
|
637
626
|
this.snkItemSelected = createEvent(this, "snkItemSelected", 7);
|
|
638
|
-
this.innerClickCheck = (
|
|
639
|
-
if (node
|
|
640
|
-
|
|
641
|
-
return true;
|
|
642
|
-
}
|
|
643
|
-
let current = node;
|
|
644
|
-
do {
|
|
645
|
-
if (current === floatingContainer || current === this._element) {
|
|
646
|
-
return true;
|
|
647
|
-
}
|
|
648
|
-
} while ((current = current.offsetParent) != null);
|
|
627
|
+
this.innerClickCheck = (_floatingContainer, node) => {
|
|
628
|
+
if (node.id != FloatingManager.MODAL_ELEMENT_ID) {
|
|
629
|
+
return true;
|
|
649
630
|
}
|
|
650
631
|
this._detailIsVisible = false;
|
|
651
632
|
return false;
|
|
652
633
|
};
|
|
653
634
|
}
|
|
654
635
|
showList() {
|
|
655
|
-
this._floatingID = FloatingManager.float(this._popover, this._popoverContainer, { autoClose: true, innerClickTest: this.innerClickCheck });
|
|
636
|
+
this._floatingID = FloatingManager.float(this._popover, this._popoverContainer, { autoClose: true, innerClickTest: this.innerClickCheck, useOverlay: true });
|
|
656
637
|
this._detailIsVisible = true;
|
|
657
638
|
this._showAll = false;
|
|
658
639
|
this._filterArgument = "";
|
|
@@ -41,39 +41,50 @@ const SnkFilterDetail = class {
|
|
|
41
41
|
}
|
|
42
42
|
apply() {
|
|
43
43
|
var _a;
|
|
44
|
+
let value = this._editor["value"];
|
|
44
45
|
let isValid = true;
|
|
45
|
-
|
|
46
|
-
/* WARNING: Temporário. Isso só está sendo feito até desconsiderar os parametros não informados para PersonalizedFilter*/
|
|
47
|
-
if (value != undefined && this.config.type === FilterItemType.PERSONALIZED) {
|
|
46
|
+
if (this.config.type === FilterItemType.PERSONALIZED) {
|
|
48
47
|
const params = ((_a = this.config.props.personalizedFilter) === null || _a === void 0 ? void 0 : _a.parameters) || [];
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
else {
|
|
54
|
-
value.forEach(item => {
|
|
55
|
-
if (item == undefined) {
|
|
56
|
-
isValid = false;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
48
|
+
const paramsCount = params.length;
|
|
49
|
+
if (paramsCount === 0) {
|
|
50
|
+
//Valor do filtro personalizado sem parametros deve ser um array vazio
|
|
51
|
+
value = [];
|
|
60
52
|
}
|
|
61
|
-
|
|
62
|
-
this.
|
|
63
|
-
ApplicationUtils.alert("Filtro parcialmente preenchido", "Favor completar todas as informações do filtro.").then(() => setTimeout(() => this.keepOpened = false, 1));
|
|
53
|
+
else {
|
|
54
|
+
isValid = this.validateAllFilled(paramsCount, value);
|
|
64
55
|
}
|
|
65
56
|
}
|
|
66
|
-
/* WARNING: Temporário.*/
|
|
67
57
|
if (isValid) {
|
|
68
58
|
this.changeConfig(Object.assign(Object.assign({}, this.config), { value: value }));
|
|
69
59
|
}
|
|
70
60
|
}
|
|
61
|
+
/* WARNING: Temporário. Isso só está sendo feito até desconsiderar os parametros não informados para PersonalizedFilter*/
|
|
62
|
+
validateAllFilled(paramsCount, value) {
|
|
63
|
+
let isValid = true;
|
|
64
|
+
if (value != undefined && paramsCount > 1) {
|
|
65
|
+
if (paramsCount > value.length) {
|
|
66
|
+
isValid = false;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
value.forEach(item => {
|
|
70
|
+
if (item == undefined) {
|
|
71
|
+
isValid = false;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (!isValid) {
|
|
77
|
+
ApplicationUtils.alert("Filtro parcialmente preenchido", "Favor completar todas as informações do filtro.");
|
|
78
|
+
}
|
|
79
|
+
return isValid;
|
|
80
|
+
}
|
|
81
|
+
/* WARNING: Temporário.*/
|
|
71
82
|
clear() {
|
|
72
83
|
this.changeConfig(Object.assign(Object.assign({}, this.config), { value: undefined }));
|
|
73
84
|
}
|
|
74
85
|
render() {
|
|
75
86
|
const ContentEditor = this.getContentEditor();
|
|
76
|
-
return (h(Host, null, h("div", { class: "col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center" }, h("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()), h(ContentEditor, { ref: ref => this._editor = ref, value: this.config.value, config: this.config
|
|
87
|
+
return (h(Host, null, h("div", { class: "col ez-col--sd-12 ez-align--right ez-padding-medium ez-flex--align-items-center" }, h("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()), h(ContentEditor, { ref: ref => this._editor = ref, value: this.config.value, config: this.config }), h("hr", { class: "sc-snk-filter-bar snk-filter__popover-rule" }), h("div", { class: "ez-col ez-col--sd-12 ez-align--right" }, h("ez-button", { label: this.getMessage("snkFilterBar.cleanFilter"), onClick: () => this.clear(), size: "small" }), h("ez-button", { label: this.getMessage("snkFilterBar.applyFilter"), onClick: () => this.apply(), size: "small", class: "ez-button--primary ez-padding-left--medium" }))));
|
|
77
88
|
}
|
|
78
89
|
};
|
|
79
90
|
|
|
@@ -31,21 +31,12 @@ const SnkFilterPersonalized = class {
|
|
|
31
31
|
}
|
|
32
32
|
doSearch(mode, argument, param) {
|
|
33
33
|
const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
34
|
-
if (this.fix) {
|
|
35
|
-
this.fix();
|
|
36
|
-
}
|
|
37
34
|
return new Promise((resolve, reject) => {
|
|
38
35
|
application.executePreparedSearch(mode, argument, param.searchContext)
|
|
39
36
|
.then(result => {
|
|
40
37
|
resolve(result);
|
|
41
|
-
if (this.unfix) {
|
|
42
|
-
this.unfix();
|
|
43
|
-
}
|
|
44
38
|
}).catch(reason => {
|
|
45
39
|
reject(reason);
|
|
46
|
-
if (this.unfix) {
|
|
47
|
-
this.unfix();
|
|
48
|
-
}
|
|
49
40
|
});
|
|
50
41
|
});
|
|
51
42
|
}
|
|
@@ -11,21 +11,12 @@ const SnkFilterSearch = class {
|
|
|
11
11
|
}
|
|
12
12
|
doSearch(mode, argument) {
|
|
13
13
|
const application = ApplicationContext.getContextValue("__SNK__APPLICATION__");
|
|
14
|
-
if (this.fix) {
|
|
15
|
-
this.fix();
|
|
16
|
-
}
|
|
17
14
|
return new Promise((resolve, reject) => {
|
|
18
15
|
application.executePreparedSearch(mode, argument, this.config.props.searchContext)
|
|
19
16
|
.then(result => {
|
|
20
17
|
resolve(result);
|
|
21
|
-
if (this.unfix) {
|
|
22
|
-
this.unfix();
|
|
23
|
-
}
|
|
24
18
|
}).catch(reason => {
|
|
25
19
|
reject(reason);
|
|
26
|
-
if (this.unfix) {
|
|
27
|
-
this.unfix();
|
|
28
|
-
}
|
|
29
20
|
});
|
|
30
21
|
});
|
|
31
22
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as s,h as r}from"./p-fac2b6a9.js";import{ApplicationContext as t}from"@sankhyalabs/core";import{F as e}from"./p-9dd2b8cb.js";const i=class{constructor(r){s(this,r)}ezChangeListener(s){this.value=this._searchInput.value}doSearch(s,r){const e=t.getContextValue("__SNK__APPLICATION__");return new Promise(((t,i)=>{e.executePreparedSearch(s,r,this.config.props.searchContext).then((s=>{t(s)})).catch((s=>{i(s)}))}))}render(){if(this.config&&this.config.type===e.SEARCH)return r("ez-search",{suppressEmptyOption:!0,value:this.config.value,label:this.config.label,ref:s=>this._searchInput=s,optionLoader:({mode:s,argument:r})=>this.doSearch(s,r)})}};export{i as snk_filter_search}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,c as s,h as i,g as e,H as a}from"./p-fac2b6a9.js";import{Action as n,ApplicationContext as h}from"@sankhyalabs/core";import{ApplicationUtils as o,DialogType as r}from"@sankhyalabs/ezui/dist/collection/utils";import{O as c}from"./p-
|
|
1
|
+
import{r as t,c as s,h as i,g as e,H as a}from"./p-fac2b6a9.js";import{Action as n,ApplicationContext as h}from"@sankhyalabs/core";import{ApplicationUtils as o,DialogType as r}from"@sankhyalabs/ezui/dist/collection/utils";import{O as c}from"./p-2eea7eea.js";const l=class{constructor(i){t(this,i),this.dataStateChange=s(this,"dataStateChange",7),this.dataUnitReady=s(this,"dataUnitReady",7),this.insertionMode=s(this,"insertionMode",7),this.cancelEdition=s(this,"cancelEdition",7),this._onDataUnitResolve=[],this.pageSize=150,this._dataUnitObserver=t=>{const s={insertionMode:!1,hasNext:this.dataUnit.hasNext(),hasPrevious:this.dataUnit.hasPrevious(),copyMode:!1,isDirty:this.dataUnit.isDirty(),hasDirtyRecords:this.dataUnit.hasDirtyRecords(),selectedRecords:this.dataUnit.getSelectedRecords()};if(this.dataUnit.records.forEach((t=>{t.__record__id__.startsWith("NEW_")&&(s.insertionMode=!0,s.copyMode||(s.copyMode=null!=t.__record__source__id__))})),this.dataState=s,t.type===n.DATA_SAVED){const s=this.getMessage("snkDataUnit.saveInfo",t.payload.records[0]);null!=s&&this.showSuccessMessage(s)}if(t.type!==n.RECORDS_ADDED&&t.type!==n.RECORDS_COPIED||this.insertionMode.emit(),t.type===n.EDITION_CANCELED){this.cancelEdition.emit();const t=this.getMessage("snkDataUnit.cancelInfo");null!=t&&this.showSuccessMessage(t)}if(t.type===n.RECORDS_REMOVED){const s=this.getMessage("snkDataUnit.removeInfo",t.payload.cachedRecords[0]);null!=s&&this.showSuccessMessage(s)}this._application.messagesBuilder.currentOperation=this.getMessageOperation()}}observePageSize(){this.dataUnit&&(this.dataUnit.pageSize=this.pageSize)}observeDataUnitName(t,s){s!=t&&(this.dataUnit=void 0,this.dataUnitName=t,this.loadDataUnit())}observeEntityName(t,s){s!=t&&(this.dataUnit=void 0,this.entityName=t,this.loadDataUnit())}observeDataState(t,s){s!=t&&this.dataStateChange.emit(t)}observeDataUnit(){this.dataUnitReady.emit(this.dataUnit)}async getDataUnit(){return new Promise((t=>{this.dataUnit?t(this.dataUnit):this._onDataUnitResolve.push(t)}))}async interceptAction(t){return new Promise((s=>{switch(t.type){case n.RECORDS_ADDED:this.isAllowed("INSERT")?s(t):o.info(this.getMessage("snkDataUnit.forbiddenInsert"));break;case n.RECORDS_COPIED:this.isAllowed("CLONE")?s(t):o.info(this.getMessage("snkDataUnit.forbiddenClone"));break;case n.DATA_CHANGED:case n.CHANGING_DATA:this.isAllowed("UPDATE")?s(t):(this.dataUnit.cancelEdition(),o.alert(this.getMessage("snkDataUnit.forbidden"),this.getMessage("snkDataUnit.forbiddenUpdate")));break;case n.SAVING_DATA:if(this.beforeSave){const i=this.beforeSave(this.dataUnit);i instanceof Promise?i.then((i=>s(i?t:void 0))):s(i?t:void 0)}else s(t);break;case n.DATA_SAVED:this.afterSave?this.afterSave(this.dataUnit):s(t);break;case n.EDITION_CANCELED:if(this.dataState.hasDirtyRecords){const i=this.getMessage("snkDataUnit.cancelConfirmation");if(null==i)s(t);else{const e=this.getMessage("snkDataUnit.cancelConfirmationTitle");o.confirm(e,i).then((i=>s(i?t:void 0)))}}else s(t);break;case n.REMOVING_RECORDS:if(this.isAllowed("REMOVE")){const i=this.getMessage("snkDataUnit.removeConfirmation");if(null==i)s(t);else{const e=this.getMessage("snkDataUnit.removeConfirmationTitle");o.confirm(e,i,"delete",r.CRITICAL,{btnConfirmDanger:!0}).then((i=>s(i?t:void 0)))}}else o.info(this.getMessage("snkDataUnit.forbiddenRemove"));break;default:s(t)}}))}showSuccessMessage(t){o.info(t,{iconName:"check"})}isAllowed(t){return!!this._permissions&&(this._permissions.isSup||this._permissions[t])}getMessage(t,s){return s||(s=this.getMessageParams()),this._application.messagesBuilder.getMessage(t,s)}getMessageParams(){return this.dataState.selectedRecords?this.dataState.selectedRecords[0]:void 0}getMessageOperation(){return this.dataState.copyMode?c.CLONE:this.dataState.insertionMode?c.INSERT:this.dataState.isDirty?c.UPDATE:c.CLEAN}async loadDataUnit(){if(!this.dataUnit&&this._application&&this.entityName){const t=this.dataUnitName?this.dataUnitName:this.entityName;let s;for(this.dataUnit=await this._application.getDataUnit(this.entityName,t),this.dataUnit.pageSize=this.pageSize,this.dataUnit.unsubscribe(this._dataUnitObserver),this.dataUnit.addInterceptor(this),this.dataUnit.subscribe(this._dataUnitObserver);s=this._onDataUnitResolve.pop();)s(this.dataUnit)}}componentWillLoad(){this._application=h.getContextValue("__SNK__APPLICATION__"),this._application.getAllAccess().then((t=>this._permissions=t))}componentDidLoad(){this.loadDataUnit()}render(){return i(a,null)}get element(){return e(this)}static get watchers(){return{pageSize:["observePageSize"],dataUnitName:["observeDataUnitName"],entityName:["observeEntityName"],dataState:["observeDataState"],dataUnit:["observeDataUnit"]}}};l.style=".sc-snk-data-unit-h{display:flex;flex-direction:column;height:100%}";export{l as snk_data_unit}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e={saveInfo:{clone:"Duplicação realizada!",insert:"Inclusão realizada!",update:"Aleração realizada!"},cancelInfo:{clone:"Duplicação descartada!",insert:"A inclusão descartada!",update:"A edição foi descartada!"},removeInfo:"Registro removido com sucesso!",cancelConfirmationTitle:"Aviso",cancelConfirmation:"As alterações realizadas serão descartadas<br/><br/><b>Você realmente gostaria de cancelar?",removeConfirmationTitle:"Excluir",removeConfirmation:"Deseja realmente excluir o registro atual?",forbidden:"Sem permissão",forbiddenUpdate:"Não é possível fazer alterações. Verifique as permissões de acesso.",forbiddenInsert:"Não é possível incluir. Verifique as permissões de acesso.",forbiddenClone:"Não é possível duplicar. Verifique as permissões de acesso.",forbiddenRemove:"Não é possível remover. Verifique as permissões de acesso."},
|
|
1
|
+
const e={saveInfo:{clone:"Duplicação realizada!",insert:"Inclusão realizada!",update:"Aleração realizada!"},cancelInfo:{clone:"Duplicação descartada!",insert:"A inclusão descartada!",update:"A edição foi descartada!"},removeInfo:"Registro removido com sucesso!",cancelConfirmationTitle:"Aviso",cancelConfirmation:"As alterações realizadas serão descartadas<br/><br/><b>Você realmente gostaria de cancelar?",removeConfirmationTitle:"Excluir",removeConfirmation:"Deseja realmente excluir o registro atual?",forbidden:"Sem permissão",forbiddenUpdate:"Não é possível fazer alterações. Verifique as permissões de acesso.",forbiddenInsert:"Não é possível incluir. Verifique as permissões de acesso.",forbiddenClone:"Não é possível duplicar. Verifique as permissões de acesso.",forbiddenRemove:"Não é possível remover. Verifique as permissões de acesso."},r={addFilter:"Adicionar filtro",pinFilter:"Fixar filtro",unpinFilter:"Desfixar filtro",removeFilter:"Remover filtro",cleanFilter:"Limpar",applyFilter:"Aplicar",findFilter:"Buscar filtros...",findField:"Buscar filtros...",modalFindFilter:"Buscar filtro",emptyFiltersList:"Não há filtros disponíveis",emptyAppliedFiltersList:"Não há filtros aplicados",customFilter:"Filtro personalizado",defaultFilter:"Filtro padrão",failToLoadConfig:"Falha ao buscar configuração de filtros",clearAllFilters:"Limpar todos os filtros",successfullyCleaned:"Filtro limpo com sucesso!",activeFilter:"{{ACTIVE_FILTERS}} filtro aplicado",activeFilters:"{{ACTIVE_FILTERS}} filtros aplicados",noActiveFilters:"Nenhum filtro aplicado",modalDefaultFilterTitle:"Filtro padrão",modalInfoTextEditDefault:"Use o layout antigo para editar o seu filtro padrão, em breve traremos uma nova experiência.",modalInfoTextCreateDefault:"Use o layout antigo para criar o seu filtro padrão, em breve traremos uma nova experiência.",modalPersonalizedFilterTitle:"Filtro personalizado",modalPersonalizedFilterSubTitle:"Gerencie seus filtros",modalInfoTextCreateEditPersonalized:"Use o layout antigo para criar ou editar filtros, em breve traremos uma nova experiência",modalOkButtonLabel:"Aplicar",modalCancelButtonLabel:"Limpar"},i={title:{clone:"Duplicar registro",insert:"Cadastrar registro",update:"Alterar registro",clean:"{{ENTITY_NAME}}"},goBackTitle:"Voltar"},a={titleUpdate:"Editar",titlePrevious:"Anterior",titleNext:"Próximo",titleRefresh:"Atualizar",titleClone:"Duplicar",titleRemove:"Excluir",titleMoreOptions:"Mais Opções",titleInsert:"Cadastrar",titleCancel:"Cancelar",titleSave:"Salvar",titleGridMode:"Modo Grade",titleFormMode:"Modo Formulário",titleConfigGrid:"Configuração da grade",forbidden:"Permissão não liberada"},o={errorArray:"CrudUtils.find deve receber um array de fields, ou uma lista separada por virgula."};class t{constructor(){this._defaults={snkDataUnit:e,snkForm:i,snkTaskbar:a,snkFilterBar:r,crudUtils:o},this._currentOperation=s.CLEAN,this.loadAppMessages().then((e=>{this._appMessages=e}),(e=>{console.info("O arquivo de mensagens personalizadas não foi encontrado no caminho /messages/appmessages.js",e)}))}set currentOperation(e){this._currentOperation=e}getMessage(e,r){if(null==e)return;var i=e.split(".");let a=this.resolveMessage(i,this._appMessages);if(null==a&&(a=this.resolveMessage(i,this._defaults)),this.customMessageBuilder){const i=this.customMessageBuilder(e,a,r);a=i.message,r=i.params}return this.postProcess(a,r)}resolveMessage(e,r){if(null==r)return;const i=r[e[0]];return i?this.isOperationSensitive(i)?i[this._currentOperation]:1===e.length||null==i||"string"==typeof i?i:this.resolveMessage(e.slice(1),i):void 0}isOperationSensitive(e){return null!=e[s.CLONE]||null!=e[s.INSERT]||null!=e[s.UPDATE]||null!=e[s.CLEAN]}postProcess(e,r){if(e){const i=/(.*?)\{\{(.+?)\}\}/g;let a,o="",t=e;for(;null!==(a=i.exec(e));){const[i,s,l]=a,n=a.index+i.length;t=n<e.length?e.substring(n):"";let d=r?r[l]:void 0;null==d&&(d=""),o+=s+d}return o+t}return e}loadAppMessages(){return new Promise(((e,r)=>{const i="dev"!==window.applicationenv?`/${window.MGE_MODULE_NAME}/labsApps/${window.APPLICATION_NAME}/build/messages/appmessages.js`:"/messages/appmessages.js";import(i).then((r=>{e(r.default)})).catch((e=>{r(e)}))}))}}var s;!function(e){e.CLONE="clone",e.INSERT="insert",e.UPDATE="update",e.CLEAN="clean"}(s||(s={}));export{s as O,t as S}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as t,h as e,H as i,g as s,c as r}from"./p-fac2b6a9.js";import{DataType as l,ObjectUtils as a,StringUtils as n,ErrorException as o,ApplicationContext as h,FloatingManager as c,ArrayUtils as d}from"@sankhyalabs/core";import{F as f}from"./p-9dd2b8cb.js";import{ModalAction as m,ModalButtonStatus as u}from"@sankhyalabs/ezui/dist/collection/components/ez-modal-container";import{toString as b}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{T as k,V as p,A as _,b as v,a as g}from"./p-86f15ffe.js";const F=class{constructor(e){t(this,e),this._updateSequence=[],this._loadingPending=!1,this._configUpdated=!1,this._pendingFilters=[],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)}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);t.forEach((t=>{const e=i.get(t.id);null!=e?(this._configUpdated=this._configUpdated||a.objectToString(e)!=a.objectToString(t),this._loadingPending=this._loadingPending||a.objectToString(e.value)!==a.objectToString(t.value)):(this._configUpdated=!0,this._loadingPending=this._loadingPending||null!=t.value)}))}this.processAfterUpdateConfig()}processPendingFilter(){this._pendingFilters.length>0&&null==this._currentPendingFilter&&(this._currentPendingFilter=this._element.querySelector("#filter-"+this._pendingFilters.pop()),this._currentPendingFilter&&this._currentPendingFilter.showUp(!0).then((()=>{this._currentPendingFilter=void 0,this.processPendingFilter()}))),null==this._currentPendingFilter&&this.processAfterUpdateConfig()}processAfterUpdateConfig(){this._pendingFilters.length>0||(this._loadingPending&&(this._loadingPending=!1,this.dataUnit.loadData()),this._configUpdated&&(this._configUpdated=!1,this._application.saveFilterBarConfig(this.filterConfig,this.configName)))}getMessage(t,e){return this._application.messagesBuilder.getMessage(t,e)}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 f.DEFAULT_FILTER:return function(t){return{name:t.id,expression:t.props.expression,params:[]}}(t);case f.BINARY_SELECT:return function(t){const{id:e,value:i,props:s}=t;return{name:e,expression:s.options.find((t=>t.name===i)).expression,params:[]}}(t);case f.MULTI_SELECT:return function(t){const{id:e,value:i,props:s}=t;return{name:e,expression:s.expression,params:[{name:e,dataType:l.TEXT,value:i}]}}(t);case f.PERIOD:return function(t){const{id:e,value:i,props:s}=t;let{end:r,start:a}=i;"string"==typeof r&&(r=new Date(r)),"string"==typeof a&&(a=new Date(a));const n=[];let o;return r&&a?(o=s.expression.fullfill,n.push({name:`${e}.START`,dataType:l.DATE,value:b(l.DATE,a)},{name:`${e}.END`,dataType:l.DATE,value:b(l.DATE,r)})):a?(o=s.expression.onlystart,n.push({name:e,dataType:l.DATE,value:b(l.DATE,a)})):(o=s.expression.onlyend,n.push({name:e,dataType:l.DATE,value:b(l.DATE,r)})),{name:e,expression:o,params:n}}(t);case f.SEARCH:return function(t){const{id:e,value:i,props:s}=t;return{name:e,expression:s.expression,params:[{name:e,dataType:l.TEXT,value:b(l.TEXT,i.value)}]}}(t);case f.TEXT:return function(t){const{id:e,value:i,props:s}=t;return{name:e,expression:s.expression,params:[{name:e,dataType:l.TEXT,value:b(l.TEXT,i)}]}}(t);case f.NUMBER:return function(t){const{id:e,value:i,props:s}=t;return{name:e,expression:s.expression,params:[{name:e,dataType:l.NUMBER,value:b(l.NUMBER,i)}]}}(t);case f.PERSONALIZED:return function(t){var e;const{id:i,value:s,props:r}=t;return{name:i,expression:r.expression,params:((null===(e=r.personalizedFilter)||void 0===e?void 0:e.parameters)||[]).map(((t,e)=>{const i=Array.from(s),r=t.dataType;let a=e>=0&&e<i.length?i[e]:null;return null!=a&&"object"==typeof a&&"value"in a&&(a=a.value),null==a&&r===l.BOOLEAN&&(a=!1),{name:t.name,dataType:r,value:"string"==typeof a?a:b(r,a)}}))}}(t);default:return}})(t);e&&i.push(e)})),i}isActiveFilter(t){return t.visible&&null!=t.value||t.type===f.DEFAULT_FILTER}registryFilterProvider(){this.dataUnit.addFilterProvider(this),this.filterConfig&&this.dataUnit.loadData()}getFilterItems(){const t=[],i=[];this.filterConfig.filter((t=>t.visible)).forEach(((s,r)=>{const l=e("snk-filter-item",{id:`filter-${s.id}`,config:s,class:r>0?"ez-padding-left--medium":"",getMessage:(t,e)=>this.getMessage(t,e),key:s.id});return s.fixed||s.hardFixed?t.push(l):i.push(l),l}));const s=[];return s.push(...t),t.length>0&&i.length>0&&s.push(e("hr",{class:"ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-filter-bar__divider"})),s.push(...i),s}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?(a.objectToString(e)!=a.objectToString(t)&&this.calculateUpdateSequence(t),t):e))).sort(((t,e)=>this._filtersComparator(t,e)))}getAddListItems(){const t=this.filterConfig.filter((t=>!t.visible&&this.isListable(t))),e=[{name:"PERSONALIZED_FILTER",label:this.getMessage("snkFilterBar.customFilter"),iconName:"tune",kind:"FOOTER"}];return this.allowDefault&&e.push({name:"DEFAULT_FILTER",label:this.getMessage("snkFilterBar.defaultFilter"),iconName:"configuration",kind:"FOOTER"}),t.map((t=>({name:t.id,label:t.label,kind:"FILTER",iconName:null}))).concat(e)}getActiveClass(){return this.filterConfig.filter((t=>null!=t.value)).length>0?"sc-snk-filter-bar snk-filter-bar__filter-list-items-button--active":""}isListable(t,e=!1){return t.type!==f.DEFAULT_FILTER&&(e||t.type!==f.PERSONALIZED)}getAppliedListItems(){return this.filterConfig.filter((t=>this.isActiveFilter(t)&&this.isListable(t,!0))).map((t=>({name:t.id,label:t.label,kind:"FILTER",iconName:null}))).concat([{name:"CLEAR_ALL_FILTERS",label:this.getMessage("snkFilterBar.clearAllFilters"),iconName:"cleaning",kind:"FOOTER"}])}addPersonalizedFilters(t){const e={};t.forEach((t=>{t.active&&(e[t.id]=!0)})),this.filterConfig=this.filterConfig.map((t=>{var i,s;if(t.type===f.PERSONALIZED){const r=e[t.id];return!t.visible&&r&&(this.calculateUpdateSequence(t),null!=(null===(s=null===(i=t.props)||void 0===i?void 0:i.personalizedFilter)||void 0===s?void 0:s.parameters)&&this._pendingFilters.push(t.id)),this.normalizeItem(Object.assign(Object.assign({},t),r?{visible:r}:{visible:r,value:void 0,fixed:void 0}))}return t})).sort(((t,e)=>this._filtersComparator(t,e)))}openDefaultFilterModal(){const t=document.createElement("snk-filter-modal"),e=this.filterConfig.filter((t=>t.type===f.DEFAULT_FILTER));t.getMessage=(t,e)=>this.getMessage(t,e),t.modalTitle=this.getMessage("snkFilterBar.modalDefaultFilterTitle"),t.infoText=this.getMessage(0==e.length?"snkFilterBar.modalInfoTextCreateDefault":"snkFilterBar.modalInfoTextEditDefault"),t.items=e.map((t=>({id:t.id,active:!0,enabled:!1,label:t.label}))),t.processModalAction=()=>{this._application.closeModal()},this._application.showModal(t)}openPersonalizedModal(){const t=document.createElement("snk-filter-modal"),e=this.filterConfig.filter((t=>t.type===f.PERSONALIZED)).sort(((t,e)=>n.compare(t.label,e.label)));t.getMessage=(t,e)=>this.getMessage(t,e),t.modalTitle=this.getMessage("snkFilterBar.modalPersonalizedFilterTitle"),t.modalSubTitle=this.getMessage("snkFilterBar.modalPersonalizedFilterSubTitle"),t.okButtonLabel=this.getMessage("snkFilterBar.modalOkButtonLabel"),t.cancelButtonLabel=this.getMessage("snkFilterBar.modalCancelButtonLabel"),t.infoText=this.getMessage("snkFilterBar.modalInfoTextCreateEditPersonalized"),t.useSearch=!0,t.items=e.map((t=>({id:t.id,active:t.visible,enabled:!0,label:t.label}))),t.processModalAction=e=>{e===m.CANCEL?t.items=t.items.map((t=>Object.assign(Object.assign({},t),{active:!1}))):(e===m.OK&&this.addPersonalizedFilters(t.items),this._application.closeModal())},this._application.showModal(t)}clearFilters(){let t=!1;return this.filterConfig=this.filterConfig.map((e=>(null!=e.value&&(t=!0),Object.assign(Object.assign({},e),{value:void 0})))).sort(((t,e)=>this._filtersComparator(t,e))),t}loadPermitions(){this._application.isUserSup().then((t=>this.allowDefault=t))}loadConfigFromApplication(){this._application.getFilterBarConfig(this.configName).then((t=>{this.filterConfig=t.map((t=>this.normalizeItem(t))),this.dataUnit&&this.dataUnit.loadData()})).catch((t=>{throw new o(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)}addFilterHandler(t){const e=this.filterConfig.find((e=>e.id===t));"PERSONALIZED_FILTER"===t?this.openPersonalizedModal():"DEFAULT_FILTER"===t?this.openDefaultFilterModal():e&&(this.updateFilter(Object.assign(Object.assign({},e),{visible:!0})),window.requestAnimationFrame((()=>{const e=this._element.querySelector("#filter-"+t);e&&e.showUp()})))}appliedFilterHandler(t){if("CLEAR_ALL_FILTERS"===t)this.clearFilters()&&this._application.info(this.getMessage("snkFilterBar.successfullyCleaned"),{iconName:"check"});else{const e=this._element.querySelector("#filter-"+t);e&&e.showUp(!0)}}componentWillLoad(){this._application=h.getContextValue("__SNK__APPLICATION__"),this._application&&(this.loadPermitions(),this.loadConfigFromApplication()),this.attachDataUnit()}componentDidRender(){this.processPendingFilter()}render(){if(this.dataUnit&&this.filterConfig&&0!==this.filterConfig.length)return e(i,null,e("ez-scroller",{direction:"horizontal"},this.getFilterItems()),e("snk-filter-list",{items:this.getAppliedListItems(),getMessage:(t,e)=>this.getMessage(t,e),emptyText:this.getMessage("snkFilterBar.emptyAppliedFiltersList"),findFilterText:this.getMessage("snkFilterBar.findFilter"),iconName:"filter",class:"ez-padding-left--medium",buttonClass:this.getActiveClass(),onSnkItemSelected:t=>this.appliedFilterHandler(t.detail)}),e("snk-filter-list",{items:this.getAddListItems(),label:this.getMessage("snkFilterBar.addFilter"),getMessage:(t,e)=>this.getMessage(t,e),emptyText:this.getMessage("snkFilterBar.emptyFiltersList"),findFilterText:this.getMessage("snkFilterBar.findField"),class:"ez-padding-left--medium",onSnkItemSelected:t=>this.addFilterHandler(t.detail)},e("ez-icon",{slot:"leftIcon",class:"ez-padding-right--small",iconName:"plus"})))}get _element(){return s(this)}static get watchers(){return{filterConfig:["observeFilterConfig"]}}};F.style='.sc-snk-filter-bar-h{display:grid;grid-template-columns:minmax(100px, 100%) 1fr 1fr}.snk-filter__popover-container.sc-snk-filter-bar{display:flex;cursor:auto}.snk-filter__popover.sc-snk-filter-bar{display:flex;flex-direction:column;position:absolute;width:fit-content;height:fit-content;min-width:265px;z-index:var(--more-visible, 1);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;flex-grow:0}.snk-filter-bar__divider.sc-snk-filter-bar{margin-bottom:var(--space--small)}.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)}.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.preselected.sc-snk-filter-bar{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{display:flex;flex-direction:row;border-radius:var(--border--radius-medium, 12px);background-color:var(--background--medium, #f0f3f7)}.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);width:100%}.snk-filter-bar__filter-modal-content.sc-snk-filter-bar{display:grid;grid-template-rows:auto auto 1fr auto;width:100%;height:100%}';const x=class{constructor(e){t(this,e),this.filterChange=r(this,"filterChange",7),this.innerClickCheck=(t,e)=>{if(this._popover.keepOpened)return!0;if(e&&t){if(!e.offsetParent)return!0;let i=e;do{if(i===t)return!0}while(null!=(i=i.offsetParent))}return this.detailIsVisible=!1,this.executeCloseCallback(),!1}}async showUp(t=!1){return new Promise((e=>{this._filterItemElement.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"}),t&&window.requestAnimationFrame((()=>{this._closeCallback=e,this.showDetail()}))}))}showDetail(){this._floatingID=c.float(this._popover,this._popoverContainer,{autoClose:!0,innerClickTest:this.innerClickCheck,left:this.getScrollOffset()}),this.detailIsVisible=!0}getScrollOffset(){return`${this._filterItemElement.getBoundingClientRect().left+12}px`}hideDetail(){null!=this._floatingID&&c.close(this._floatingID),this._floatingID=void 0,this.detailIsVisible=!1,this.executeCloseCallback()}executeCloseCallback(){this._closeCallback&&(this._closeCallback(),this._closeCallback=void 0)}clickListener(t){[this._chipElement,this._leftIconElement,this._rightIconElement].includes(t.target)&&(t.target===this._rightIconElement&&null!=this.config.value?this.filterChange.emit(Object.assign(Object.assign({},this.config),{value:void 0})):this.detailIsVisible?this.hideDetail():this.showDetail(),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(){const{type:t,value:e,label:i,props:s}=this.config;if(e){if(t===f.BINARY_SELECT){const[t,i]=s.options;if(t.name===e)return t.label;if(i.name===e)return i.label}if(t===f.MULTI_SELECT)return`${i}: ${s.options.find((t=>t.value===e)).label}`;if(t===f.PERIOD){let{end:t,start:s}=e;"string"==typeof t&&(t=new Date(t),t.setMinutes(t.getMinutes()+t.getTimezoneOffset())),"string"==typeof s&&(s=new Date(s),s.setMinutes(s.getMinutes()+s.getTimezoneOffset()));const r=new Intl.DateTimeFormat("pt-BR");return t&&s?`${i}: ${r.format(s)} a ${r.format(t)}`:s?`${i}: A partir de ${r.format(s)}`:t?`${i}: Até ${r.format(t)}`:i}return t===f.SEARCH?`${i}: ${e.value} - ${e.label}`:t===f.PERSONALIZED?i:`${i}: ${e}`}return i}componentDidRender(){null==this._floatingID&&this._popover&&this._popover.remove()}filterChangeListener(){this.hideDetail()}getRightIconName(){return null!=this.config.value?"close":this.detailIsVisible?"chevron-up":"chevron-down"}getLeftIconName(){switch(this.config.type){case f.PERIOD:return"calendar";case f.PERSONALIZED:return"tune"}}render(){const t=this.getLeftIconName();return e(i,null,e("ez-chip",{ref:t=>this._chipElement=t,label:this.getLabel(),value:null!=this.config.value},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"})),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",ref:t=>this._popover=t,key:this.config.id})))}get _filterItemElement(){return s(this)}},z=class{constructor(e){t(this,e),this.snkItemSelected=r(this,"snkItemSelected",7),this.innerClickCheck=(t,e)=>{if(e&&t){if(!e.offsetParent)return!0;let i=e;do{if(i===t||i===this._element)return!0}while(null!=(i=i.offsetParent))}return this._detailIsVisible=!1,!1}}showList(){this._floatingID=c.float(this._popover,this._popoverContainer,{autoClose:!0,innerClickTest:this.innerClickCheck}),this._detailIsVisible=!0,this._showAll=!1,this._filterArgument=""}hideList(){null!=this._floatingID&&c.close(this._floatingID),this._floatingID=void 0,this._detailIsVisible=!1}buttonClick(){this._detailIsVisible?this.hideList():this.showList()}componentDidRender(){null==this._floatingID&&this._popover&&this._popover.remove()}buildItemElement(t){return e("div",{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(t.name)},t.iconName?e("ez-icon",{iconName:t.iconName,size:"small",class:`ez-padding-right--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__icon ${t.iconClass||""}`}):void 0,e("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 ${t.labelClass||""}`},t.label))}itemSelected(t){"__SHOWMORE__"===t?this._showAll=!0:(this.hideList(),this.snkItemSelected.emit(t))}getFilterItems(){const t=this.items?d.applyStringFilter(this._filterArgument,this.items.filter((t=>"FILTER"===t.kind))):[];return 0===t.length?e("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):(!this._filterArgument&&!this._showAll&&t.length>6&&(t.splice(5),t.push({kind:"INTERNAL",label:"Mostrar mais",iconName:"dots-horizontal",name:"__SHOWMORE__",iconClass:"snk-filter-bar__filter-list-item__icon--secondary",labelClass:"snk-filter-bar__filter-list-item__label--secondary"})),e("div",{class:"sc-snk-filter-bar snk-filter-bar__filter-list-items-container"},t.map((t=>this.buildItemElement(t)))))}getFooterItems(){return this.items.filter((t=>"FOOTER"===t.kind))}render(){return e(i,{class:"ez-flex ez-flex--column"},e("ez-button",{class:this.buttonClass,label:this.label,onClick:()=>this.buttonClick(),mode:this.iconName?"icon":void 0,iconName:this.iconName,size:"small"},e("slot",{name:"leftIcon"})),e("section",{class:"ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container",ref:t=>this._popoverContainer=t},e("div",{class:"sc-snk-filter-bar snk-filter__popover ez-padding--small",ref:t=>this._popover=t},e("ez-filter-input",{ref:t=>this._filterInput=t,mode:"slim",label:this.findFilterText,value:this._filterArgument,onEzChange:t=>this._filterArgument=t.detail}),this.getFilterItems(),e("hr",{class:"sc-snk-filter-bar snk-filter__popover-rule"}),this.items?this.getFooterItems().map((t=>this.buildItemElement(t))):void 0)))}get _element(){return s(this)}},T=class{constructor(e){t(this,e)}updateValue(t,e){this.items=this.items.map((i=>i.id===t?Object.assign(Object.assign({},i),{active:e}):i))}getActiveFiltersMsg(){const t=this.items.filter((t=>t.active)).length;return 0===t?this.getMessage("snkFilterBar.noActiveFilters"):this.getMessage(t>1?"snkFilterBar.activeFilters":"snkFilterBar.activeFilter",{ACTIVE_FILTERS:t})}getFilteredItems(){return this.items?d.applyStringFilter(this._filterArgument,this.items):[]}render(){const t=this.items.filter((t=>t.active)).length>0;return e("ez-modal-container",{modalTitle:this.modalTitle,modalSubTitle:this.modalSubTitle,cancelButtonLabel:this.cancelButtonLabel,okButtonLabel:this.okButtonLabel,onEzModalAction:t=>this.processModalAction(t.detail),cancelButtonStatus:t?u.ENABLED:u.DISABLED},e("div",{class:"sc-snk-filter-bar snk-filter-bar__filter-modal-content"},e("div",null,this.useSearch?e("ez-filter-input",{label:this.getMessage("snkFilterBar.modalFindFilter"),onEzChange:t=>this._filterArgument=t.detail}):void 0),this.getFilteredItems().length>0?e("div",{class:"ez-text ez-text--medium ez-text--primary ez-padding-bottom--small"},this.getActiveFiltersMsg()):void 0,e("div",null,this.getFilteredItems().map((t=>e("div",{class:"ez-padding--medium sc-snk-filter-bar snk-filter-bar__filter-modal-item ez-align--middle ez-margin-bottom--small"},e("ez-check",{class:"sc-snk-filter-bar snk-filter-bar__filter-modal-item__check",onEzChange:e=>this.updateValue(t.id,e.detail),enabled:t.enabled,value:t.active,mode:"switch"}),e("div",{class:"ez-text ez-title--primary ez-text--medium ez-margin-left--medium sc-snk-filter-bar snk-filter-bar__filter-modal-item__label"},t.label))))),e("div",{class:"ez-text ez-text--large ez-align--middle ez-text--secondary ez-text--center ez-padding-bottom--large"},this.infoText)))}},y=class{constructor(e){t(this,e),this.actionClick=r(this,"actionClick",7),this._titleKeyByElement={[k.UPDATE]:"snkTaskbar.titleUpdate",[k.PREVIOUS]:"snkTaskbar.titlePrevious",[k.NEXT]:"snkTaskbar.titleNext",[k.REFRESH]:"snkTaskbar.titleRefresh",[k.CLONE]:"snkTaskbar.titleClone",[k.REMOVE]:"snkTaskbar.titleRemove",[k.MORE_OPTIONS]:"snkTaskbar.titleMoreOptions",[k.INSERT]:"snkTaskbar.titleInsert",[k.CANCEL]:"snkTaskbar.titleCancel",[k.SAVE]:"snkTaskbar.titleSave",[k.GRID_MODE]:"snkTaskbar.titleGridMode",[k.CONFIG_GRID]:"snkTaskbar.titleConfigGrid",[k.FORM_MODE]:"snkTaskbar.titleFormMode"}}observeButtons(){this._definitions=void 0}elementsFromString(t){const e=[];return t&&t.split(",").forEach((t=>{t=t.trim(),(p[t]||this.isAllowed(t))&&e.push(t.trim())})),e}isAllowed(t){return!_[t]||!!this._permissions&&(this._permissions.isSup||this._permissions[t])}getTitle(t){let e;return e=this.isAllowed(t)?this._titleKeyByElement[t]:"snkTaskbar.forbidden",e?this._application.messagesBuilder.getMessage(e,{}):""}elementClick(t){if(this.dataUnit)switch(t){case k.PREVIOUS:this.dataUnit.previousRecord();break;case k.NEXT:this.dataUnit.nextRecord();break;case k.REFRESH:this.dataUnit.loadData();break;case k.CLONE:this.dataUnit.copySelected();break;case k.REMOVE:this.dataUnit.removeSelectedRecords();break;case k.INSERT:this.dataUnit.addRecord();break;case k.CANCEL:this.dataUnit.cancelEdition();break;case k.SAVE:this.dataUnit.saveData()}this.actionClick.emit(t)}isEnabled(t){return!(!this.isAllowed(t)||this.disabledButtons&&this.disabledButtons.includes(t))}getElement(t,e){let i=e===this.primaryButton?"ez-button--primary ":"";return t>1&&(i+="ez-padding-left--medium"),k[e.toString()]?v(e,i,(t=>this.getTitle(t)),(t=>this.elementClick(t)),(t=>this.isEnabled(t)),this.actionsList):g(e,i,(t=>this.elementClick(t)),(t=>this.isEnabled(t)))}componentWillLoad(){this._application=h.getContextValue("__SNK__APPLICATION__"),this._application?this._application.getAllAccess().then((t=>this._permissions=t)):this._permissions={}}componentWillRender(){null==this._definitions&&this._permissions&&(this._definitions=this.elementsFromString(this.buttons))}render(){if(void 0===this._definitions)return;let t=0;return e(i,null,this._definitions.map((i=>(i===k.DIVIDER?t=0:t++,k[i]?this.getElement(t,k[i]):this.customButtons.has(i)?this.getElement(t,this.customButtons.get(i)):e("slot",{name:i})))))}static get watchers(){return{buttons:["observeButtons"]}}};y.style=".sc-snk-taskbar-h{display:flex}";export{F as snk_filter_bar,x as snk_filter_item,z as snk_filter_list,T as snk_filter_modal,y as snk_taskbar}
|
|
1
|
+
import{r as t,h as e,H as i,g as s,c as r}from"./p-fac2b6a9.js";import{DataType as l,ObjectUtils as a,StringUtils as n,ErrorException as o,ApplicationContext as h,FloatingManager as c,ArrayUtils as d}from"@sankhyalabs/core";import{F as m}from"./p-9dd2b8cb.js";import{ModalAction as f,ModalButtonStatus as u}from"@sankhyalabs/ezui/dist/collection/components/ez-modal-container";import{toString as b}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{T as k,V as p,A as _,b as v,a as g}from"./p-86f15ffe.js";const F=class{constructor(e){t(this,e),this._updateSequence=[],this._loadingPending=!1,this._configUpdated=!1,this._pendingFilters=[],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)}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);t.forEach((t=>{const e=i.get(t.id);null!=e?(this._configUpdated=this._configUpdated||a.objectToString(e)!=a.objectToString(t),this._loadingPending=this._loadingPending||a.objectToString(e.value)!==a.objectToString(t.value)):(this._configUpdated=!0,this._loadingPending=this._loadingPending||null!=t.value)}))}this.processAfterUpdateConfig()}processPendingFilter(){this._pendingFilters.length>0&&null==this._currentPendingFilter&&(this._currentPendingFilter=this._element.querySelector("#filter-"+this._pendingFilters.pop()),this._currentPendingFilter&&this._currentPendingFilter.showUp(!0).then((()=>{this._currentPendingFilter=void 0,this.processPendingFilter()}))),null==this._currentPendingFilter&&this.processAfterUpdateConfig()}processAfterUpdateConfig(){this._pendingFilters.length>0||(this._loadingPending&&(this._loadingPending=!1,this.dataUnit.loadData()),this._configUpdated&&(this._configUpdated=!1,this._application.saveFilterBarConfig(this.filterConfig,this.configName)))}getMessage(t,e){return this._application.messagesBuilder.getMessage(t,e)}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 m.DEFAULT_FILTER:return function(t){return{name:t.id,expression:t.props.expression,params:[]}}(t);case m.BINARY_SELECT:return function(t){const{id:e,value:i,props:s}=t;return{name:e,expression:s.options.find((t=>t.name===i)).expression,params:[]}}(t);case m.MULTI_SELECT:return function(t){const{id:e,value:i,props:s}=t;return{name:e,expression:s.expression,params:[{name:e,dataType:l.TEXT,value:i}]}}(t);case m.PERIOD:return function(t){const{id:e,value:i,props:s}=t;let{end:r,start:a}=i;"string"==typeof r&&(r=new Date(r)),"string"==typeof a&&(a=new Date(a));const n=[];let o;return r&&a?(o=s.expression.fullfill,n.push({name:`${e}.START`,dataType:l.DATE,value:b(l.DATE,a)},{name:`${e}.END`,dataType:l.DATE,value:b(l.DATE,r)})):a?(o=s.expression.onlystart,n.push({name:e,dataType:l.DATE,value:b(l.DATE,a)})):(o=s.expression.onlyend,n.push({name:e,dataType:l.DATE,value:b(l.DATE,r)})),{name:e,expression:o,params:n}}(t);case m.SEARCH:return function(t){const{id:e,value:i,props:s}=t;return{name:e,expression:s.expression,params:[{name:e,dataType:l.TEXT,value:b(l.TEXT,i.value)}]}}(t);case m.TEXT:return function(t){const{id:e,value:i,props:s}=t;return{name:e,expression:s.expression,params:[{name:e,dataType:l.TEXT,value:b(l.TEXT,i)}]}}(t);case m.NUMBER:return function(t){const{id:e,value:i,props:s}=t;return{name:e,expression:s.expression,params:[{name:e,dataType:l.NUMBER,value:b(l.NUMBER,i)}]}}(t);case m.PERSONALIZED:return function(t){var e;const{id:i,value:s,props:r}=t;return{name:i,expression:r.expression,params:((null===(e=r.personalizedFilter)||void 0===e?void 0:e.parameters)||[]).map(((t,e)=>{const i=Array.from(s),r=t.dataType;let a=e>=0&&e<i.length?i[e]:null;return null!=a&&"object"==typeof a&&"value"in a&&(a=a.value),null==a&&r===l.BOOLEAN&&(a=!1),{name:t.name,dataType:r,value:"string"==typeof a?a:b(r,a)}}))}}(t);default:return}})(t);e&&i.push(e)})),i}isActiveFilter(t){return t.visible&&null!=t.value||t.type===m.DEFAULT_FILTER}registryFilterProvider(){this.dataUnit.addFilterProvider(this),this.filterConfig&&this.dataUnit.loadData()}getFilterItems(){const t=[],i=[];this.filterConfig.filter((t=>t.visible)).forEach(((s,r)=>{const l=e("snk-filter-item",{id:`filter-${s.id}`,config:s,class:r>0?"ez-padding-left--medium":"",getMessage:(t,e)=>this.getMessage(t,e),key:s.id});return s.fixed||s.hardFixed?t.push(l):i.push(l),l}));const s=[];return s.push(...t),t.length>0&&i.length>0&&s.push(e("hr",{class:"ez-divider-vertical ez-divider--dark ez-margin-left--medium snk-filter-bar__divider"})),s.push(...i),s}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?(a.objectToString(e)!=a.objectToString(t)&&this.calculateUpdateSequence(t),t):e))).sort(((t,e)=>this._filtersComparator(t,e)))}getAddListItems(){const t=this.filterConfig.filter((t=>!t.visible&&this.isListable(t))),e=[{name:"PERSONALIZED_FILTER",label:this.getMessage("snkFilterBar.customFilter"),iconName:"tune",kind:"FOOTER"}];return this.allowDefault&&e.push({name:"DEFAULT_FILTER",label:this.getMessage("snkFilterBar.defaultFilter"),iconName:"configuration",kind:"FOOTER"}),t.map((t=>({name:t.id,label:t.label,kind:"FILTER",iconName:null}))).concat(e)}getActiveClass(){return this.filterConfig.filter((t=>null!=t.value)).length>0?"sc-snk-filter-bar snk-filter-bar__filter-list-items-button--active":""}isListable(t,e=!1){return t.type!==m.DEFAULT_FILTER&&(e||t.type!==m.PERSONALIZED)}getAppliedListItems(){return this.filterConfig.filter((t=>this.isActiveFilter(t)&&this.isListable(t,!0))).map((t=>({name:t.id,label:t.label,kind:"FILTER",iconName:null}))).concat([{name:"CLEAR_ALL_FILTERS",label:this.getMessage("snkFilterBar.clearAllFilters"),iconName:"cleaning",kind:"FOOTER"}])}addPersonalizedFilters(t){const e={};t.forEach((t=>{t.active&&(e[t.id]=!0)})),this.filterConfig=this.filterConfig.map((t=>{var i,s;if(t.type===m.PERSONALIZED){const r=e[t.id];return!t.visible&&r&&(this.calculateUpdateSequence(t),null!=(null===(s=null===(i=t.props)||void 0===i?void 0:i.personalizedFilter)||void 0===s?void 0:s.parameters)&&this._pendingFilters.push(t.id)),this.normalizeItem(Object.assign(Object.assign({},t),r?{visible:r}:{visible:r,value:void 0,fixed:void 0}))}return t})).sort(((t,e)=>this._filtersComparator(t,e)))}openDefaultFilterModal(){const t=document.createElement("snk-filter-modal"),e=this.filterConfig.filter((t=>t.type===m.DEFAULT_FILTER));t.getMessage=(t,e)=>this.getMessage(t,e),t.modalTitle=this.getMessage("snkFilterBar.modalDefaultFilterTitle"),t.infoText=this.getMessage(0==e.length?"snkFilterBar.modalInfoTextCreateDefault":"snkFilterBar.modalInfoTextEditDefault"),t.items=e.map((t=>({id:t.id,active:!0,enabled:!1,label:t.label}))),t.processModalAction=()=>{this._application.closeModal()},this._application.showModal(t)}openPersonalizedModal(){const t=document.createElement("snk-filter-modal"),e=this.filterConfig.filter((t=>t.type===m.PERSONALIZED)).sort(((t,e)=>n.compare(t.label,e.label)));t.getMessage=(t,e)=>this.getMessage(t,e),t.modalTitle=this.getMessage("snkFilterBar.modalPersonalizedFilterTitle"),t.modalSubTitle=this.getMessage("snkFilterBar.modalPersonalizedFilterSubTitle"),t.okButtonLabel=this.getMessage("snkFilterBar.modalOkButtonLabel"),t.cancelButtonLabel=this.getMessage("snkFilterBar.modalCancelButtonLabel"),t.infoText=this.getMessage("snkFilterBar.modalInfoTextCreateEditPersonalized"),t.useSearch=!0,t.items=e.map((t=>({id:t.id,active:t.visible,enabled:!0,label:t.label}))),t.processModalAction=e=>{e===f.CANCEL?t.items=t.items.map((t=>Object.assign(Object.assign({},t),{active:!1}))):(e===f.OK&&this.addPersonalizedFilters(t.items),this._application.closeModal())},this._application.showModal(t)}clearFilters(){let t=!1;return this.filterConfig=this.filterConfig.map((e=>(null!=e.value&&(t=!0),Object.assign(Object.assign({},e),{value:void 0})))).sort(((t,e)=>this._filtersComparator(t,e))),t}loadPermitions(){this._application.isUserSup().then((t=>this.allowDefault=t))}loadConfigFromApplication(){this._application.getFilterBarConfig(this.configName).then((t=>{this.filterConfig=t.map((t=>this.normalizeItem(t))),this.dataUnit&&this.dataUnit.loadData()})).catch((t=>{throw new o(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)}addFilterHandler(t){const e=this.filterConfig.find((e=>e.id===t));"PERSONALIZED_FILTER"===t?this.openPersonalizedModal():"DEFAULT_FILTER"===t?this.openDefaultFilterModal():e&&(this.updateFilter(Object.assign(Object.assign({},e),{visible:!0})),window.requestAnimationFrame((()=>{const e=this._element.querySelector("#filter-"+t);e&&e.showUp()})))}appliedFilterHandler(t){if("CLEAR_ALL_FILTERS"===t)this.clearFilters()&&this._application.info(this.getMessage("snkFilterBar.successfullyCleaned"),{iconName:"check"});else{const e=this._element.querySelector("#filter-"+t);e&&e.showUp(!0)}}componentWillLoad(){this._application=h.getContextValue("__SNK__APPLICATION__"),this._application&&(this.loadPermitions(),this.loadConfigFromApplication()),this.attachDataUnit()}componentDidRender(){this.processPendingFilter()}render(){if(this.dataUnit&&this.filterConfig&&0!==this.filterConfig.length)return e(i,null,e("ez-scroller",{direction:"horizontal"},this.getFilterItems()),e("snk-filter-list",{items:this.getAppliedListItems(),getMessage:(t,e)=>this.getMessage(t,e),emptyText:this.getMessage("snkFilterBar.emptyAppliedFiltersList"),findFilterText:this.getMessage("snkFilterBar.findFilter"),iconName:"filter",class:"ez-padding-left--medium",buttonClass:this.getActiveClass(),onSnkItemSelected:t=>this.appliedFilterHandler(t.detail)}),e("snk-filter-list",{items:this.getAddListItems(),label:this.getMessage("snkFilterBar.addFilter"),getMessage:(t,e)=>this.getMessage(t,e),emptyText:this.getMessage("snkFilterBar.emptyFiltersList"),findFilterText:this.getMessage("snkFilterBar.findField"),class:"ez-padding-left--medium",onSnkItemSelected:t=>this.addFilterHandler(t.detail)},e("ez-icon",{slot:"leftIcon",class:"ez-padding-right--small",iconName:"plus"})))}get _element(){return s(this)}static get watchers(){return{filterConfig:["observeFilterConfig"]}}};F.style='.sc-snk-filter-bar-h{display:grid;grid-template-columns:minmax(100px, 100%) 1fr 1fr}.snk-filter__popover-container.sc-snk-filter-bar{display:flex;cursor:auto}.snk-filter__popover.sc-snk-filter-bar{display:flex;flex-direction:column;position:absolute;width:fit-content;height:fit-content;min-width:265px;z-index:var(--more-visible, 1);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;flex-grow:0}.snk-filter-bar__divider.sc-snk-filter-bar{margin-bottom:var(--space--small)}.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)}.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.preselected.sc-snk-filter-bar{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{display:flex;flex-direction:row;border-radius:var(--border--radius-medium, 12px);background-color:var(--background--medium, #f0f3f7)}.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);width:100%}.snk-filter-bar__filter-modal-content.sc-snk-filter-bar{display:grid;grid-template-rows:auto auto 1fr auto;width:100%;height:100%}';const x=class{constructor(e){t(this,e),this.filterChange=r(this,"filterChange",7),this.innerClickCheck=(t,e)=>e.id!=c.MODAL_ELEMENT_ID||(this.detailIsVisible=!1,this.executeCloseCallback(),!1)}async showUp(t=!1){return new Promise((e=>{this._filterItemElement.scrollIntoView({behavior:"auto",block:"nearest",inline:"nearest"}),t&&window.requestAnimationFrame((()=>{this._closeCallback=e,this.showDetail()}))}))}showDetail(){this._floatingID=c.float(this._popover,this._popoverContainer,{autoClose:!0,innerClickTest:this.innerClickCheck,left:this.getScrollOffset(),useOverlay:!0}),this.detailIsVisible=!0}getScrollOffset(){return`${this._filterItemElement.getBoundingClientRect().left+12}px`}hideDetail(){null!=this._floatingID&&c.close(this._floatingID),this._floatingID=void 0,this.detailIsVisible=!1,this.executeCloseCallback()}executeCloseCallback(){this._closeCallback&&(this._closeCallback(),this._closeCallback=void 0)}clickListener(t){[this._chipElement,this._leftIconElement,this._rightIconElement].includes(t.target)&&(t.target===this._rightIconElement&&null!=this.config.value?this.filterChange.emit(Object.assign(Object.assign({},this.config),{value:void 0})):this.detailIsVisible?this.hideDetail():this.showDetail(),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(){const{type:t,value:e,label:i,props:s}=this.config;if(e){if(t===m.BINARY_SELECT){const[t,i]=s.options;if(t.name===e)return t.label;if(i.name===e)return i.label}if(t===m.MULTI_SELECT)return`${i}: ${s.options.find((t=>t.value===e)).label}`;if(t===m.PERIOD){let{end:t,start:s}=e;"string"==typeof t&&(t=new Date(t),t.setMinutes(t.getMinutes()+t.getTimezoneOffset())),"string"==typeof s&&(s=new Date(s),s.setMinutes(s.getMinutes()+s.getTimezoneOffset()));const r=new Intl.DateTimeFormat("pt-BR");return t&&s?`${i}: ${r.format(s)} a ${r.format(t)}`:s?`${i}: A partir de ${r.format(s)}`:t?`${i}: Até ${r.format(t)}`:i}return t===m.SEARCH?`${i}: ${e.value} - ${e.label}`:t===m.PERSONALIZED?i:`${i}: ${e}`}return i}componentDidRender(){null==this._floatingID&&this._popover&&this._popover.remove()}filterChangeListener(){this.hideDetail()}getRightIconName(){return null!=this.config.value?"close":this.detailIsVisible?"chevron-up":"chevron-down"}getLeftIconName(){switch(this.config.type){case m.PERIOD:return"calendar";case m.PERSONALIZED:return"tune"}}render(){const t=this.getLeftIconName();return e(i,null,e("ez-chip",{ref:t=>this._chipElement=t,label:this.getLabel(),value:null!=this.config.value},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"})),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",ref:t=>this._popover=t,key:this.config.id})))}get _filterItemElement(){return s(this)}},z=class{constructor(e){t(this,e),this.snkItemSelected=r(this,"snkItemSelected",7),this.innerClickCheck=(t,e)=>e.id!=c.MODAL_ELEMENT_ID||(this._detailIsVisible=!1,!1)}showList(){this._floatingID=c.float(this._popover,this._popoverContainer,{autoClose:!0,innerClickTest:this.innerClickCheck,useOverlay:!0}),this._detailIsVisible=!0,this._showAll=!1,this._filterArgument=""}hideList(){null!=this._floatingID&&c.close(this._floatingID),this._floatingID=void 0,this._detailIsVisible=!1}buttonClick(){this._detailIsVisible?this.hideList():this.showList()}componentDidRender(){null==this._floatingID&&this._popover&&this._popover.remove()}buildItemElement(t){return e("div",{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(t.name)},t.iconName?e("ez-icon",{iconName:t.iconName,size:"small",class:`ez-padding-right--extra-small sc-snk-filter-bar snk-filter-bar__filter-list-item__icon ${t.iconClass||""}`}):void 0,e("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 ${t.labelClass||""}`},t.label))}itemSelected(t){"__SHOWMORE__"===t?this._showAll=!0:(this.hideList(),this.snkItemSelected.emit(t))}getFilterItems(){const t=this.items?d.applyStringFilter(this._filterArgument,this.items.filter((t=>"FILTER"===t.kind))):[];return 0===t.length?e("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):(!this._filterArgument&&!this._showAll&&t.length>6&&(t.splice(5),t.push({kind:"INTERNAL",label:"Mostrar mais",iconName:"dots-horizontal",name:"__SHOWMORE__",iconClass:"snk-filter-bar__filter-list-item__icon--secondary",labelClass:"snk-filter-bar__filter-list-item__label--secondary"})),e("div",{class:"sc-snk-filter-bar snk-filter-bar__filter-list-items-container"},t.map((t=>this.buildItemElement(t)))))}getFooterItems(){return this.items.filter((t=>"FOOTER"===t.kind))}render(){return e(i,{class:"ez-flex ez-flex--column"},e("ez-button",{class:this.buttonClass,label:this.label,onClick:()=>this.buttonClick(),mode:this.iconName?"icon":void 0,iconName:this.iconName,size:"small"},e("slot",{name:"leftIcon"})),e("section",{class:"ez-margin-top--small sc-snk-filter-bar snk-filter__popover-container",ref:t=>this._popoverContainer=t},e("div",{class:"sc-snk-filter-bar snk-filter__popover ez-padding--small",ref:t=>this._popover=t},e("ez-filter-input",{ref:t=>this._filterInput=t,mode:"slim",label:this.findFilterText,value:this._filterArgument,onEzChange:t=>this._filterArgument=t.detail}),this.getFilterItems(),e("hr",{class:"sc-snk-filter-bar snk-filter__popover-rule"}),this.items?this.getFooterItems().map((t=>this.buildItemElement(t))):void 0)))}get _element(){return s(this)}},T=class{constructor(e){t(this,e)}updateValue(t,e){this.items=this.items.map((i=>i.id===t?Object.assign(Object.assign({},i),{active:e}):i))}getActiveFiltersMsg(){const t=this.items.filter((t=>t.active)).length;return 0===t?this.getMessage("snkFilterBar.noActiveFilters"):this.getMessage(t>1?"snkFilterBar.activeFilters":"snkFilterBar.activeFilter",{ACTIVE_FILTERS:t})}getFilteredItems(){return this.items?d.applyStringFilter(this._filterArgument,this.items):[]}render(){const t=this.items.filter((t=>t.active)).length>0;return e("ez-modal-container",{modalTitle:this.modalTitle,modalSubTitle:this.modalSubTitle,cancelButtonLabel:this.cancelButtonLabel,okButtonLabel:this.okButtonLabel,onEzModalAction:t=>this.processModalAction(t.detail),cancelButtonStatus:t?u.ENABLED:u.DISABLED},e("div",{class:"sc-snk-filter-bar snk-filter-bar__filter-modal-content"},e("div",null,this.useSearch?e("ez-filter-input",{label:this.getMessage("snkFilterBar.modalFindFilter"),onEzChange:t=>this._filterArgument=t.detail}):void 0),this.getFilteredItems().length>0?e("div",{class:"ez-text ez-text--medium ez-text--primary ez-padding-bottom--small"},this.getActiveFiltersMsg()):void 0,e("div",null,this.getFilteredItems().map((t=>e("div",{class:"ez-padding--medium sc-snk-filter-bar snk-filter-bar__filter-modal-item ez-align--middle ez-margin-bottom--small"},e("ez-check",{class:"sc-snk-filter-bar snk-filter-bar__filter-modal-item__check",onEzChange:e=>this.updateValue(t.id,e.detail),enabled:t.enabled,value:t.active,mode:"switch"}),e("div",{class:"ez-text ez-title--primary ez-text--medium ez-margin-left--medium sc-snk-filter-bar snk-filter-bar__filter-modal-item__label"},t.label))))),e("div",{class:"ez-text ez-text--large ez-align--middle ez-text--secondary ez-text--center ez-padding-bottom--large"},this.infoText)))}},y=class{constructor(e){t(this,e),this.actionClick=r(this,"actionClick",7),this._titleKeyByElement={[k.UPDATE]:"snkTaskbar.titleUpdate",[k.PREVIOUS]:"snkTaskbar.titlePrevious",[k.NEXT]:"snkTaskbar.titleNext",[k.REFRESH]:"snkTaskbar.titleRefresh",[k.CLONE]:"snkTaskbar.titleClone",[k.REMOVE]:"snkTaskbar.titleRemove",[k.MORE_OPTIONS]:"snkTaskbar.titleMoreOptions",[k.INSERT]:"snkTaskbar.titleInsert",[k.CANCEL]:"snkTaskbar.titleCancel",[k.SAVE]:"snkTaskbar.titleSave",[k.GRID_MODE]:"snkTaskbar.titleGridMode",[k.CONFIG_GRID]:"snkTaskbar.titleConfigGrid",[k.FORM_MODE]:"snkTaskbar.titleFormMode"}}observeButtons(){this._definitions=void 0}elementsFromString(t){const e=[];return t&&t.split(",").forEach((t=>{t=t.trim(),(p[t]||this.isAllowed(t))&&e.push(t.trim())})),e}isAllowed(t){return!_[t]||!!this._permissions&&(this._permissions.isSup||this._permissions[t])}getTitle(t){let e;return e=this.isAllowed(t)?this._titleKeyByElement[t]:"snkTaskbar.forbidden",e?this._application.messagesBuilder.getMessage(e,{}):""}elementClick(t){if(this.dataUnit)switch(t){case k.PREVIOUS:this.dataUnit.previousRecord();break;case k.NEXT:this.dataUnit.nextRecord();break;case k.REFRESH:this.dataUnit.loadData();break;case k.CLONE:this.dataUnit.copySelected();break;case k.REMOVE:this.dataUnit.removeSelectedRecords();break;case k.INSERT:this.dataUnit.addRecord();break;case k.CANCEL:this.dataUnit.cancelEdition();break;case k.SAVE:this.dataUnit.saveData()}this.actionClick.emit(t)}isEnabled(t){return!(!this.isAllowed(t)||this.disabledButtons&&this.disabledButtons.includes(t))}getElement(t,e){let i=e===this.primaryButton?"ez-button--primary ":"";return t>1&&(i+="ez-padding-left--medium"),k[e.toString()]?v(e,i,(t=>this.getTitle(t)),(t=>this.elementClick(t)),(t=>this.isEnabled(t)),this.actionsList):g(e,i,(t=>this.elementClick(t)),(t=>this.isEnabled(t)))}componentWillLoad(){this._application=h.getContextValue("__SNK__APPLICATION__"),this._application?this._application.getAllAccess().then((t=>this._permissions=t)):this._permissions={}}componentWillRender(){null==this._definitions&&this._permissions&&(this._definitions=this.elementsFromString(this.buttons))}render(){if(void 0===this._definitions)return;let t=0;return e(i,null,this._definitions.map((i=>(i===k.DIVIDER?t=0:t++,k[i]?this.getElement(t,k[i]):this.customButtons.has(i)?this.getElement(t,this.customButtons.get(i)):e("slot",{name:i})))))}static get watchers(){return{buttons:["observeButtons"]}}};y.style=".sc-snk-taskbar-h{display:flex}";export{F as snk_filter_bar,x as snk_filter_item,z as snk_filter_list,T as snk_filter_modal,y as snk_taskbar}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,h as t,H as a}from"./p-fac2b6a9.js";import{UserInterface as s,ApplicationContext as i}from"@sankhyalabs/core";import{convertType as n}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{F as r}from"./p-9dd2b8cb.js";const l=class{constructor(t){e(this,t)}getValue(e,t){if(this.value&&t>=0&&t<this.value.length){const a=this.value[t];return e.type===s.SEARCH?a:n(e.dataType,a)}}setValue(e,t){this.value=null==this.value?Array(e).fill(null):[...this.value],this.value[e]=t,0==this.value.filter((e=>null!=e)).length&&(this.value=null)}doSearch(e,t,a){const s=i.getContextValue("__SNK__APPLICATION__");return new Promise(((i,n)=>{s.executePreparedSearch(e,t,a.searchContext).then((e=>{i(e)})).catch((e=>{n(e)}))}))}getParamsInterface(){var e,a,i;return(null===(i=null===(a=null===(e=this.config)||void 0===e?void 0:e.props)||void 0===a?void 0:a.personalizedFilter)||void 0===i?void 0:i.parameters).map(((e,a)=>{var i;switch(e.type){case s.SEARCH:return t("ez-search",{suppressEmptyOption:!0,value:this.getValue(e,a),onEzChange:e=>this.setValue(a,e.detail),label:e.label,optionLoader:({mode:t,argument:a})=>this.doSearch(t,a,e)});case s.SWITCH:case s.CHECKBOX:return t("ez-check",{class:"ez-padding-bottom--medium",mode:s.SWITCH===e.type?"switch":"regular",value:this.getValue(e,a),label:e.label,onEzChange:e=>this.setValue(a,e.detail)});case s.DECIMALNUMBER:case s.INTEGERNUMBER:return t("ez-number-input",{label:e.label,value:this.getValue(e,a),precision:null===(i=e.props)||void 0===i?void 0:i.precision,onEzChange:e=>this.setValue(a,e.detail)});case s.OPTIONSELECTOR:return t("ez-combo-box",{label:e.label,value:this.getValue(e,a),options:e.options,onEzChange:e=>{var t;return this.setValue(a,null===(t=e.detail)||void 0===t?void 0:t.value)}});case s.DATE:return t("ez-date-input",{label:e.label,value:this.getValue(e,a),onEzChange:e=>this.setValue(a,e.detail)});case s.DATETIME:return t("ez-date-time-input",{label:e.label,value:this.getValue(e,a),onEzChange:e=>this.setValue(a,e.detail)});default:return t("ez-text-input",{label:e.label,value:this.getValue(e,a),onEzChange:e=>this.setValue(a,e.detail)})}}))}render(){if(this.config&&this.config.type===r.PERSONALIZED)return t(a,null,this.getParamsInterface())}};export{l as snk_filter_personalized}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,c as i,h as s,g as a}from"./p-fac2b6a9.js";import{ApplicationContext as n}from"@sankhyalabs/core";const e=class{constructor(s){t(this,s),this.actionClick=i(this,"actionClick",7)}async goToView(t){this.executeAction(t)}async gridToForm(t=!1){this._backToGrid=!t&&0===await this._viewStack.getSelectedIndex(),this._viewStack.show(1)}async executeAction(t){"GRID_MODE"===t?this._viewStack.show(0):"FORM_MODE"!==t&&"UPDATE"!==t||this.gridToForm("UPDATE"!==t)}insertionModeHandler(){this.gridToForm()}cancelHandler(){this._backToGrid&&this._viewStack.show(0)}componentWillLoad(){let t=this._element.parentElement;for(;t;){if("SNK-DATA-UNIT"===t.tagName.toUpperCase()){this._snkDataUnit=t,this._snkDataUnit.addEventListener("insertionMode",(()=>this.insertionModeHandler())),this._snkDataUnit.addEventListener("cancelEdition",(()=>this.cancelHandler())),this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit||this._snkDataUnit.addEventListener("dataUnitReady",(t=>{this._dataUnit=t.detail})),this._snkDataUnit.addEventListener("dataStateChange",(t=>{this._dataState=t.detail}));break}t=t.parentElement}if(!this.configName){const t=n.getContextValue("__SNK__APPLICATION__");this.configName=t.configName}}render(){return s("ez-view-stack",{ref:t=>this._viewStack=t},s("stack-item",null,s("snk-grid",{configName:this.configName,onGridDoubleClick:()=>this.gridToForm(!0),taskbarManager:this.taskbarManager,onActionClick:t=>this.executeAction(t.detail),actionsList:this.actionsList,statusResolver:this.statusResolver},s("slot",{name:"SnkGridHeader"}),s("slot",{name:"SnkGridFooter"}),s("slot",{name:"SnkGridTaskBar"}))),s("stack-item",null,s("snk-form",{configName:this.configName,actionsList:this.actionsList,onExit:()=>this._viewStack.show(0),recordsValidator:this.recordsValidator,taskbarManager:this.taskbarManager,onActionClick:t=>this.executeAction(t.detail)},s("slot",{name:"SnkFormTaskBar"}))))}get _element(){return a(this)}};e.style=".sc-snk-crud-h{display:flex;flex-direction:column;height:100%;width:100%}";export{e as snk_crud}
|