@sankhyalabs/sankhyablocks 8.16.0-dev.105 → 8.16.0-dev.107
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/{ClientSideExporterProvider-8c219037.js → ClientSideExporterProvider-a2753c93.js} +3 -3
- package/dist/cjs/{dataunit-fetcher-4a5d491a.js → dataunit-fetcher-a723f0dc.js} +5 -2
- package/dist/cjs/pesquisa-grid_2.cjs.entry.js +1 -1
- package/dist/cjs/snk-actions-button_7.cjs.entry.js +1 -1
- package/dist/cjs/snk-application.cjs.entry.js +1 -1
- package/dist/cjs/snk-attach.cjs.entry.js +1 -1
- package/dist/cjs/snk-crud.cjs.entry.js +1 -1
- package/dist/cjs/snk-data-exporter.cjs.entry.js +2 -2
- package/dist/cjs/{snk-data-unit-9a463a4f.js → snk-data-unit-ebfdb9ba.js} +1 -1
- package/dist/cjs/snk-data-unit.cjs.entry.js +2 -2
- package/dist/cjs/snk-detail-view.cjs.entry.js +2 -2
- package/dist/cjs/snk-grid.cjs.entry.js +2 -2
- package/dist/cjs/{snk-guides-viewer-c9e1e97b.js → snk-guides-viewer-fd39f437.js} +1 -1
- package/dist/cjs/snk-guides-viewer.cjs.entry.js +2 -2
- package/dist/cjs/snk-pesquisa.cjs.entry.js +1 -1
- package/dist/cjs/snk-simple-crud.cjs.entry.js +3 -3
- package/dist/collection/components/snk-grid/filtercolumn/SnkMultiSelectionListDataSource.js +2 -2
- package/dist/collection/components/snk-simple-crud/snk-simple-crud.js +1 -1
- package/dist/collection/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.js +5 -2
- package/dist/components/ContinuousInsertUtils.js +2 -2
- package/dist/components/dataunit-fetcher.js +5 -2
- package/dist/components/snk-simple-crud2.js +1 -1
- package/dist/esm/{ClientSideExporterProvider-a37f890b.js → ClientSideExporterProvider-b3871edb.js} +3 -3
- package/dist/esm/{dataunit-fetcher-1d02ecfc.js → dataunit-fetcher-0e025732.js} +5 -2
- package/dist/esm/pesquisa-grid_2.entry.js +1 -1
- package/dist/esm/snk-actions-button_7.entry.js +1 -1
- package/dist/esm/snk-application.entry.js +1 -1
- package/dist/esm/snk-attach.entry.js +1 -1
- package/dist/esm/snk-crud.entry.js +1 -1
- package/dist/esm/snk-data-exporter.entry.js +2 -2
- package/dist/esm/{snk-data-unit-affee080.js → snk-data-unit-03654813.js} +1 -1
- package/dist/esm/snk-data-unit.entry.js +2 -2
- package/dist/esm/snk-detail-view.entry.js +2 -2
- package/dist/esm/snk-grid.entry.js +2 -2
- package/dist/esm/{snk-guides-viewer-3befd409.js → snk-guides-viewer-75e06feb.js} +1 -1
- package/dist/esm/snk-guides-viewer.entry.js +2 -2
- package/dist/esm/snk-pesquisa.entry.js +1 -1
- package/dist/esm/snk-simple-crud.entry.js +3 -3
- package/dist/sankhyablocks/{p-2101be8b.entry.js → p-1a51dfde.entry.js} +1 -1
- package/dist/sankhyablocks/{p-21a5acc4.entry.js → p-1c29409b.entry.js} +1 -1
- package/dist/sankhyablocks/{p-cbb4c043.entry.js → p-271c86d3.entry.js} +1 -1
- package/dist/sankhyablocks/{p-3f624cbe.js → p-41da5310.js} +1 -1
- package/dist/sankhyablocks/{p-624390bb.entry.js → p-4a93daef.entry.js} +1 -1
- package/dist/sankhyablocks/{p-cf685cef.entry.js → p-65be98c5.entry.js} +1 -1
- package/dist/sankhyablocks/{p-6541bb6d.entry.js → p-6a0c8ce0.entry.js} +1 -1
- package/dist/sankhyablocks/p-7993b2e3.js +60 -0
- package/dist/sankhyablocks/{p-a5e5574c.entry.js → p-7cd5c315.entry.js} +1 -1
- package/dist/sankhyablocks/p-885802c3.js +1 -0
- package/dist/sankhyablocks/{p-ea55f2ab.entry.js → p-ad07f0c5.entry.js} +1 -1
- package/dist/sankhyablocks/{p-dcfc8b35.entry.js → p-cc8c3bca.entry.js} +1 -1
- package/dist/sankhyablocks/{p-53e1de0a.entry.js → p-cf1f25ed.entry.js} +1 -1
- package/dist/sankhyablocks/{p-3b190fb1.entry.js → p-d31a701e.entry.js} +1 -1
- package/dist/sankhyablocks/{p-00796b12.entry.js → p-dc6ad9a6.entry.js} +1 -1
- package/dist/sankhyablocks/{p-82177c24.js → p-f4d5bb7f.js} +1 -1
- package/dist/sankhyablocks/sankhyablocks.esm.js +1 -1
- package/dist/types/components/snk-grid/filtercolumn/SnkMultiSelectionListDataSource.d.ts +2 -1
- package/dist/types/lib/http/data-fetcher/fetchers/data-unit/cache/PreloadManager.d.ts +1 -1
- package/package.json +1 -1
- package/dist/sankhyablocks/p-8fa828b5.js +0 -1
- package/dist/sankhyablocks/p-a8be1d67.js +0 -60
@@ -1 +1 @@
|
|
1
|
-
import{r as t,c as i,h as s,g as e,H as n}from"./p-d2d301a6.js";import{Action as a,ObjectUtils as o,DataUnitAction as r,StringUtils as h,ApplicationContext as d}from"@sankhyalabs/core";import{ApplicationUtils as l,DialogType as c}from"@sankhyalabs/ezui/dist/collection/utils";import{O as u,S as v}from"./p-80f8c22c.js";import{g as m,a as f}from"./p-a8be1d67.js";import{convertType as p}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{g as b}from"./p-7dd49d15.js";const g="__NO_TAB_NAME__";const w=class{constructor(s){t(this,s),this.dataStateChange=i(this,"dataStateChange",3),this.dataUnitReady=i(this,"dataUnitReady",3),this.messagesBuilderUpdated=i(this,"messagesBuilderUpdated",3),this.dataUnitFieldsHidded=i(this,"dataUnitFieldsHidded",7),this.insertionMode=i(this,"insertionMode",3),this.cancelEdition=i(this,"cancelEdition",3),this._onDataUnitResolve=[],this._openedAlert=!1,this._fieldsWithRmp=[],this._fieldsWithRmPrecision=[],this._metadataByRow=new Map,this._rowMetadataCache=new Map,this._formFieldsConfig=[],this.REGEX_DATAUNIT_NAME=/dd:\/\/(.+?)\//,this._dataUnitObserver=async t=>{const i=await this.buildDataState(t.type);switch(this.dataState=i,this.messagesBuilder.currentOperation=this.getMessageOperation(),t.type){case a.DATA_SAVED:await this.handleDataSaved(t);break;case a.RECORDS_ADDED:case a.RECORDS_COPIED:this.insertionMode.emit();break;case a.EDITION_CANCELED:this.cancelEdition.emit();break;case a.RECORDS_REMOVED:this.handleRecordsRemoved(t);break;case a.METADATA_LOADED:this.fillFieldsWithRmp(this.dataUnit.metadata),this.fillFieldsWithRmPrecision(this.dataUnit.metadata)}},this.fieldsToLink=[],this.dataState=void 0,this.messagesBuilder=void 0,this.dataUnitName=void 0,this.entityName=void 0,this.pageSize=150,this.dataUnit=void 0,this.beforeSave=void 0,this.afterSave=void 0,this.useCancelConfirm=!0,this.ignoreSaveMessage=void 0,this.configName=void 0,this.resourceID=void 0,this.domainMessagesBuilder=void 0}observePageSize(){this.dataUnit&&(this.dataUnit.pageSize=this.pageSize)}observeDataUnitName(t,i){i!=t&&(this.dataUnit?this._application.updateDataunitCache(i,this.dataUnitName,this.dataUnit):this.loadDataUnit())}observeEntityName(t,i){i!=t&&(this.dataUnit=void 0,this.entityName=t,this.loadDataUnit())}observeDataState(t,i){o.objectToString(i)!=o.objectToString(t)&&this.dataStateChange.emit(t)}observeDataUnit(){this.handlerLinkFields(),this.dataUnitReady.emit(this.dataUnit)}observeMessagesBuilder(t){t&&this.messagesBuilderUpdated.emit(t)}onMasterFormConfigChange({detail:t}){var i;this._formFieldsConfig=null!==(i=null==t?void 0:t.fields)&&void 0!==i?i:[]}async getDataUnit(){return new Promise((t=>{this.dataUnit?t(this.dataUnit):this._onDataUnitResolve.push(t)}))}async getSelectedRecordsIDsInfo(){return b(this.dataUnit)}async getFieldsWithRmp(){return this._fieldsWithRmp}async getFieldsWithRmPrecision(){return this._fieldsWithRmPrecision}async getRowMetadata(t){return this.doGetRowMetadata(t)}async doGetRowMetadata(t){const i=this.dataUnit.getSelectedRecord();if(!t&&!i)return;const s=t||i,e="string"==typeof s?s:s.__record__id__;let n=this._metadataByRow.get(e);return this.dataUnit.isNewRecord(e)&&!n&&(n=await this.handleLoadRowMetadata(i)),n?(n.getProp=this.buildGetPropRowMetadata(n),Object.assign({},n)):void 0}buildGetPropRowMetadata(t){return(i,s)=>("rm_precision"===i&&(i=this.resolvePrecisionFromMetadata(s)),o.getProp(t,i))}resolvePrecisionFromMetadata(t){var i,s;if(!t)return void l.error(this.getMessage("snkDataUnit.fieldNameRequired"));const e=null===(s=null===(i=this.dataUnit.getField(t))||void 0===i?void 0:i.properties)||void 0===s?void 0:s.rm_precision;return e?e.split(".").filter(((t,i)=>1!==i)).join("."):""}getCleanOnCopyFields(){var t;return null===(t=this.dataUnit.metadata)||void 0===t?void 0:t.fields.filter((t=>{var i;return null===(i=t.properties)||void 0===i?void 0:i.cleanOnCopy})).map((t=>t.name))}fillFieldsWithRmp(t){t.fields.forEach((t=>{var i;(null===(i=t.properties)||void 0===i?void 0:i.rmp)&&!this._fieldsWithRmp.includes(t.name)&&this._fieldsWithRmp.push(t.name)}))}fillFieldsWithRmPrecision(t){t.fields.forEach((t=>{var i;(null===(i=t.properties)||void 0===i?void 0:i.rm_precision)&&!this._fieldsWithRmPrecision.includes(t.name)&&this._fieldsWithRmPrecision.push(t.name)}))}getCacheName(t,i,s){return[t,i,s].join("_")}updateDataStateRmp(t){const i=Object.assign({},t);this.dataState.rowMetadata=i}saveCacheRmd(t){const i=t.__record__metadata__,s=Object.keys(i);s.shift(),s.forEach((s=>{const e=m(t,s),n=this.getCacheName(s,i.provider,e);this._rowMetadataCache.set(n,Object.assign({},i))}))}getMetadataByRow(t){var i;if(!(null===(i=t.records)||void 0===i?void 0:i.length))return t;if(!this._fieldsWithRmp.length){const i=t.records.map((t=>(delete t.__record__metadata__,t)));return Object.assign(Object.assign({},t),{records:i})}const s=t.records.map((t=>{if(!t.__record__metadata__)return t;this.saveCacheRmd(t);const i=Object.assign({},t.__record__metadata__);return i.getProp=this.buildGetPropRowMetadata(i),this._metadataByRow.set(t.__record__id__,i),delete t.__record__metadata__,t}));return Object.assign(Object.assign({},t),{records:s})}interceptRecordsAdded(t){if(this.isAllowed("INSERT"))return new r(a.RECORDS_ADDED,this.handleLinksWithParent(t.payload));l.info(this.getMessage("snkDataUnit.forbiddenInsert"))}interceptRecordsCopied(t){if(this.isAllowed("CLONE"))return new r(a.RECORDS_COPIED,this.handleRecordsCopied(t.payload));l.info(this.getMessage("snkDataUnit.forbiddenClone"))}async interceptDataChange(t){var i;const s=null===(i=this.dataUnit.getSelectedRecord())||void 0===i?void 0:i.__record__id__;if(this.isAllowed("UPDATE")||this.dataUnit.isNewRecord(s))return t;this._openedAlert?await this.dataUnit.cancelEdition():(this._openedAlert=!0,await this.dataUnit.cancelEdition(),await l.alert(this.getMessage("snkDataUnit.forbidden"),this.getMessage("snkDataUnit.forbiddenUpdate")),this._openedAlert=!1)}async interceptSavingData(t){if(this.dataUnit.isMultipleEdition&&!await this.confirmMultipleSavingData())return;if(!this.beforeSave)return t;const i=this.beforeSave(this.dataUnit);return i instanceof Promise?await i?t:void 0:i?t:void 0}async confirmMultipleSavingData(){const t=this.dataUnit.getSelectionInfo().records,i=this.getMessage("snkDataUnit.multipleUpdateConfirmationTitle"),s=this.getMessage("snkDataUnit.multipleUpdateConfirmationMessage",{size:t.length}),e=this.getMessage("snkDataUnit.confirm.cancel"),n=this.getMessage("snkDataUnit.confirm.updateMultipleConfirm");return await async function({title:t,labelBtnConfirm:i,labelBtnCancel:s,message:e,changingFields:n}){return new Promise((a=>{const o=function(t,i){const s=document.createElement("ez-popup");return s.opened=!0,s.size="small",s.ezTitle=t,s.heightMode="auto",s.addEventListener("ezClosePopup",(()=>{document.body.removeChild(s),i(!1)}),{once:!0}),s.addEventListener("ezPopupAction",(()=>{document.body.removeChild(s),i(!1)}),{once:!0}),s}(t,a),r=function(){const t=document.createElement("div");return t.style.display="flex",t.style.flexDirection="column",t.style.fontFamily="var(--font-pattern, Roboto)",t.style.fontSize="var(--text--medium, 14px)",t}();r.appendChild(function(t){const i=document.createElement("p");return i.textContent=t,i.style.fontSize="var(--text--medium, 14px)",i}(e)),r.appendChild(function(t){const i=document.createElement("div");i.style.flexDirection="column",i.style.display="flex",i.style.overflow="auto",i.style.maxHeight="300px";const s=function(t){const i=new Map;return t.forEach((t=>{var s;const e=null!==(s=t.tabName)&&void 0!==s?s:g;i.has(e)||i.set(e,[]),i.get(e).push(t)})),i}(t);return s.forEach(((t,s)=>{i.appendChild(function(t,i){const s=document.createElement("span");s.innerText=function(t){switch(t){case g:return"";case"__main":return"Principal";default:return t}}(t),s.style.display="block",s.style.fontWeight="var(--text-weight--large, 500)",s.style.fontSize="var(--text--medium, 14px)",s.style.marginBottom="var(--space--small, 6px)";const e=document.createElement("div");return e.style.padding="var(--space--medium, 12px) 0",e.style.borderTop="1px solid var(--color--disable-secondary, #f2f5f8)",e.appendChild(s),i.forEach((t=>{const i=document.createElement("span");i.innerHTML=`${t.label}: <span style="color: var(--text--primary, #626e82)">${t.value}</span>`,i.style.display="block",i.style.marginBottom="var(--space--extra-small, 3px)",e.appendChild(i)})),e}(s,t))})),i}(n));const h=function(){const t=document.createElement("div");return t.style.display="flex",t.style.flexDirection="row",t.style.justifyContent="flex-end",t.style.gap="5px",t}();h.appendChild(function(t,i,s){const e=document.createElement("ez-button");return e.label=i,e.size="medium",e.onclick=()=>{document.body.removeChild(t),s(!1)},e}(o,s,a)),h.appendChild(function(t,i,s){const e=document.createElement("ez-button");return e.label=i,e.size="medium",e.classList.add("ez-button--primary"),e.onclick=()=>{document.body.removeChild(t),s(!0)},e}(o,i,a)),r.appendChild(h),o.appendChild(r),document.body.appendChild(o)}))}({title:i,message:s,labelBtnConfirm:n,labelBtnCancel:e,changingFields:this.getChangingFields()})}getChangingFields(){const t=this.dataUnit.buildChangesToSave();if(!(null==t?void 0:t.length))return[];const i=t[0];return Object.keys(i.updatingFields).map((t=>this.buildChangingField(t,i[t])))}buildChangingField(t,i){return{label:this.dataUnit.getField(t).label,value:this.dataUnit.getFormattedValue(t,i),tabName:this.getFieldTabName(t)}}getFieldTabName(t){var i;const s=null===(i=this._formFieldsConfig.find((i=>i.name===t)))||void 0===i?void 0:i.tab;if(s)return"string"==typeof s?s:s.label}interceptDataSaved(t){if(!this.afterSave)return t;this.afterSave(this.dataUnit)}async interceptEditionCanceled(t){var i,s;if(!this.useCancelConfirm||!this.dataState.hasDirtyRecords||(null===(i=t.payload)||void 0===i?void 0:i.fromParent)||(null===(s=t.payload)||void 0===s?void 0:s.silent))return t;const e=this.getMessage("snkDataUnit.cancelConfirmation");if(null==e)return this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo")),t;const n=this.getMessage("snkDataUnit.cancelConfirmationTitle"),a=await l.confirm(n,e);if(a){let t;if(this.dataUnit.isMultipleEdition){const i=this.dataUnit.getSelectionInfo().records;t=this.buildMultipleUpdateMessage(i,!0)}else t=this.getMessage("snkDataUnit.cancelInfo");this.showSuccessMessage(t)}return a?t:void 0}async interceptRemovingRecords(t){var i,s,e;if(!this.isAllowed("REMOVE"))return void l.info(this.getMessage("snkDataUnit.forbiddenRemove"));let n=!1,a=!(null===(i=t.payload)||void 0===i?void 0:i.silent)&&this.getMessage("snkDataUnit.removeConfirmation");const o=null===(s=this.dataUnit)||void 0===s?void 0:s.getSelectionInfo();if(!(null===(e=t.payload)||void 0===e?void 0:e.silent)&&(null==o?void 0:o.length)>1&&(a=this.getMessage("snkDataUnit.removeAllConfirmation",{size:o.length}),n=!0),!a)return t;const r={canClose:!1,labelCancel:this.getMessage("snkDataUnit.confirm."+(n?"no":"cancel")),labelConfirm:this.getMessage("snkDataUnit.confirm."+(n?"yes":"delete")),btnConfirmDanger:!1},h=this.getMessage("snkDataUnit.removeConfirmationTitle");return await l.confirm(h,a,null,c.WARN,r)?t:void 0}interceptDataLoaded(t){const i=this.getMetadataByRow(t.payload);return new r(a.DATA_LOADED,i)}interceptMetadataLoaded(t){return this.fillFieldsWithRmp(t.payload),this.fillFieldsWithRmPrecision(t.payload),new r(a.METADATA_LOADED,this.handleDULinksOnMetadataLoaded(t.payload))}async interceptAction(t){switch(t.type){case a.RECORDS_ADDED:return this.interceptRecordsAdded(t);case a.RECORDS_COPIED:return this.interceptRecordsCopied(t);case a.DATA_CHANGED:return await this.handleLoadRowMetadata(t.payload),await this.interceptDataChange(t);case a.CHANGING_DATA:return await this.interceptDataChange(t);case a.SAVING_DATA:return await this.interceptSavingData(t);case a.DATA_SAVED:return this.interceptDataSaved(t);case a.EDITION_CANCELED:return await this.interceptEditionCanceled(t);case a.REMOVING_RECORDS:return await this.interceptRemovingRecords(t);case a.DATA_LOADED:return this.interceptDataLoaded(t);case a.METADATA_LOADED:return this.interceptMetadataLoaded(t);default:return t}}async handleLoadRowMetadata(t){if(!t)return;const i=Object.keys(t).find((t=>this._fieldsWithRmp.includes(t)));if(i){const s=this.dataUnit.getField(i).properties.rmp,e=m(t,i);return await this.updateRowMetadata({fieldName:i,fieldValue:e,metadataName:s,updatedFields:t})}}async updateRowMetadata({fieldName:t,fieldValue:i,metadataName:s,updatedFields:e}){const n=this.getCacheName(t,s,i),a=this._rowMetadataCache.get(n);if(a)return this.updateDataStateRmp(a),a;{const i=new f,a=await i.loadRowMetadata(this,t,s,e);return this.updateDataStateRmp(a._rmd),this._rowMetadataCache.set(n,Object.assign({},a._rmd)),Object.assign({},a._rmd)}}handleDULinksOnMetadataLoaded(t){const i=Object.assign({},t);return this.processLinks(i),i}handleRecordsCopied(t){let i=[...t];return i=this.handleCleanOnCopy(i),this.handleLinksWithParent(i)}handleLinksWithParent(t){var i,s;const e=null!==(i=this._parentDataUnit)&&void 0!==i?i:null===(s=this.dataUnit)||void 0===s?void 0:s.getParentDataUnit();if(!e)return t;const n=e.getSelectedRecord(),a=null==e?void 0:e.getChildInfo(this.getCleanDataUnitName()),{links:o}=a;return o&&0!==o.length?t.map((t=>this.buildRecordWithLinkedFields(t,o,n))):t}buildRecordWithLinkedFields(t,i,s){const e=Object.assign({},t);return i.forEach((t=>{const i=p(this.dataUnit.getField(t.target).dataType,s[t.source]);e[t.target]=i})),e}handleCleanOnCopy(t){const i=this.getCleanOnCopyFields();return i.length>0&&(t=t.map((t=>this.buildCopyWithCleanedFields(t,i)))),t}buildCopyWithCleanedFields(t,i){const s=Object.assign({},t);return i.forEach((t=>delete s[t])),s}showSuccessMessage(t){l.info(t,{iconName:"check"})}isAllowed(t){return!!this._permissions&&(this._permissions.isSup||this._permissions[t])}async buildDataState(t){var i;const s=this.dataUnit.getSelectionInfo(),e=(this.dataUnit.hasDirtyRecords()||this.dataUnit.hasWaitingChanges())&&(null==s?void 0:s.isEmpty()),n=this.dataUnit.getSelectedRecord();let o=null===(i=this.dataState)||void 0===i?void 0:i.rowMetadata;return!n||o&&![a.SELECTION_CHANGED,a.EDITION_CANCELED,a.NEXT_SELECTED,a.PREVIOUS_SELECTED].includes(t)?o&&(o.getProp=this.buildGetPropRowMetadata(o)):o=await this.doGetRowMetadata(n),new D({insertionMode:this.dataUnit.hasNewRecord(),isStartingInsertionMode:e,hasNext:this.dataUnit.hasNext(),hasPrevious:this.dataUnit.hasPrevious(),copyMode:this.dataUnit.hasCopiedRecord(),isDirty:this.dataUnit.isDirty(),hasDirtyRecords:this.dataUnit.hasDirtyRecords(),selectedRecords:void 0,selectionInfo:s,selectedRecord:n,recordsIsEmpty:0===this.dataUnit.records.length,metadataByRow:this._metadataByRow,rowMetadata:o})}async handleDataSaved(t){var i,s,e;const n=null===(i=null==t?void 0:t.payload)||void 0===i?void 0:i.changes,a=null===(s=null==t?void 0:t.payload)||void 0===s?void 0:s.records,o=await this.handleLoadRowMetadata(null===(e=null==n?void 0:n[0])||void 0===e?void 0:e.record);o&&(o.getProp=this.buildGetPropRowMetadata(o)),this._metadataByRow.set(a[0].__record__id__,o),this.dataState=await this.buildDataState();let r=n[0]._operation.toLowerCase();if("copy"==r&&(r=u.CLONE),this.canIgnoreOperationMessage(r))return;let h=this.buildOperationMessage(r,a);null!=h&&this.showSuccessMessage(h)}canIgnoreOperationMessage(t){return this.ignoreSaveMessage&&!this.isCloneOrInsertOperation(t)}isCloneOrInsertOperation(t){return[u.CLONE,u.INSERT].includes(t)}buildOperationMessage(t,i){return this.isMultiplesUpdate(t,i)?this.buildMultipleUpdateMessage(i):this.getMessage("snkDataUnit.saveInfo",i[0],t)}buildMultipleUpdateMessage(t,i){return this.getMessage("snkDataUnit."+(i?"cancelInfo":"saveInfo"),{records:t},u.UPDATE_MULTIPLES)}isMultiplesUpdate(t,i){return t===u.UPDATE&&i.length>1}handleRecordsRemoved(t){var i,s;let e=this.buildRemoveFinishMessage(t);null!=e&&this.showSuccessMessage(e);const n=null!==(s=null===(i=this.dataUnit.records)||void 0===i?void 0:i.length)&&void 0!==s?s:0,a=this.dataUnit.getPaginationInfo();a&&this.dataUnit.gotoPage(n>0||a.hasMore?a.currentPage:0)}buildRemoveFinishMessage(t){const i=t.payload.records;if(i&&i.length)return(null==i?void 0:i.length)>1?this.getMessage("snkDataUnit.removeAllInfo",{size:i.length}):this.getMessage("snkDataUnit.removeInfo",i)}getMessage(t,i,s){return i||(i=this.getMessageParams()),s&&(this.messagesBuilder.currentOperation=s),this.messagesBuilder.getMessage(t,i)}getMessageParams(){return this.dataState.selectedRecord}getMessageOperation(){return this.dataState.copyMode?u.CLONE:this.dataState.insertionMode||this.dataState.isStartingInsertionMode?u.INSERT:this.dataState.isDirty?u.UPDATE:u.CLEAN}async getDataUnitParentOrChild(){var t;const i=this.dataUnitName?this.dataUnitName:this.entityName;return this._parentSnkDataUnit?(this._parentDataUnit=await(null===(t=this._parentSnkDataUnit)||void 0===t?void 0:t.getDataUnit()),await this._application.getDataUnit(this.entityName,i,this._parentDataUnit,this.configName,this.resourceID)):await this._application.getDataUnit(this.entityName,i,null,this.configName,this.resourceID)}updateMetadataWithRMP(){this.fillFieldsWithRmp(this.dataUnit.metadata),this.fillFieldsWithRmPrecision(this.dataUnit.metadata);const t=this.handleDULinksOnMetadataLoaded(this.dataUnit.metadata);this.dataUnit.metadata=t}async loadDataUnit(){var t,i;if(null==this.dataUnit&&this._application&&this.entityName&&(this.dataUnit=await this.getDataUnitParentOrChild()),this.dataUnit){if(this.dataUnit.pageSize=this.pageSize,this.dataUnit.unsubscribe(this._dataUnitObserver),this.dataUnit.subscribe(this._dataUnitObserver),(null===(t=this.dataUnit)||void 0===t?void 0:t.metadata)&&this.updateMetadataWithRMP(),this.dataUnit.addInterceptor(this),null===(i=this.dataUnit.records)||void 0===i?void 0:i.length){const{records:t}=this.getMetadataByRow(this.dataUnit);this.dataUnit.records=t}let s;for(this.dataState=await this.buildDataState();s=this._onDataUnitResolve.pop();)s(this.dataUnit)}}getParentSnkDataUnit(){let t=this.element;for(;t.parentNode;){if("SNK-DATA-UNIT"===t.parentNode.nodeName)return t.parentNode;t=t.parentNode}}handlerLinkFields(){var t,i,s,e;const n=null!==(t=this._parentDataUnit)&&void 0!==t?t:null===(i=this.dataUnit)||void 0===i?void 0:i.getParentDataUnit();if(!n)return;const a=null!==(s=this.entityName)&&void 0!==s?s:this.getCleanDataUnitName(),o=n.getChildInfo(a);if(!o)return;const r=null===(e=null==o?void 0:o.links)||void 0===e?void 0:e.map((t=>t.target));this.handleDUWithLinks(r)}handleDUWithLinks(t){this.fieldsToLink=t;const i=Object.assign({},this.dataUnit.metadata);this.processLinks(i),this.dataUnit.metadata=i,this.dataUnitFieldsHidded.emit()}processLinks(t){var i;null===(i=null==t?void 0:t.fields)||void 0===i||i.forEach((t=>{var i;(null===(i=this.fieldsToLink)||void 0===i?void 0:i.includes(t.name))&&(t.visible=!1)}))}getCleanDataUnitName(){var t;const i=this.dataUnit.name;if(h.isEmpty(i))return i;const s=this.REGEX_DATAUNIT_NAME.exec(i);return null!==(t=null==s?void 0:s[1])&&void 0!==t?t:i}static getNearestInstance(t){let i=t.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase())return i;i=i.parentElement}}instanceMessagesBuilder(){var t;this.messagesBuilder||(this.messagesBuilder=new v(null!==(t=this.domainMessagesBuilder)&&void 0!==t?t:this.entityName))}componentWillLoad(){this._application=d.getContextValue("__SNK__APPLICATION__"),this._application.getAllAccess(this.resourceID).then((t=>this._permissions=t)),this._parentSnkDataUnit=this.getParentSnkDataUnit(),this.instanceMessagesBuilder()}disconnectedCallback(){this.dataUnit&&this.dataUnit.releaseCallbacks()}async componentDidLoad(){await this.loadDataUnit(),this.handlerLinkFields()}render(){return s(n,null)}get element(){return e(this)}static get watchers(){return{pageSize:["observePageSize"],dataUnitName:["observeDataUnitName"],entityName:["observeEntityName"],dataState:["observeDataState"],dataUnit:["observeDataUnit"],messagesBuilder:["observeMessagesBuilder"]}}};class D{constructor(t){this.copyMode=t.copyMode,this.insertionMode=t.insertionMode,this.isStartingInsertionMode=t.isStartingInsertionMode,this.isDirty=t.isDirty,this.hasDirtyRecords=t.hasDirtyRecords,this.hasNext=t.hasNext,this.hasPrevious=t.hasPrevious,this.selectionInfo=t.selectionInfo,this.selectedRecord=t.selectedRecord,this.recordsIsEmpty=t.recordsIsEmpty,this.metadataByRow=t.metadataByRow,this.rowMetadata=t.rowMetadata}get selectedRecords(){var t;if(console.warn("SnkDataUnit: O método `selectedRecords` foi descontinuado. Use o método `selectionInfo`."),null===(t=this.selectionInfo)||void 0===t?void 0:t.isAllRecords())throw new Error("Erro interno: Impossível obter os registros selecionados. A seleção atual é virtual. Use o atributo `selectionInfo`.");return this.selectionInfo.records}}export{w as S}
|
1
|
+
import{r as t,c as i,h as s,g as e,H as n}from"./p-d2d301a6.js";import{Action as a,ObjectUtils as o,DataUnitAction as r,StringUtils as h,ApplicationContext as d}from"@sankhyalabs/core";import{ApplicationUtils as l,DialogType as c}from"@sankhyalabs/ezui/dist/collection/utils";import{O as u,S as v}from"./p-80f8c22c.js";import{g as m,a as f}from"./p-7993b2e3.js";import{convertType as p}from"@sankhyalabs/core/dist/dataunit/metadata/DataType";import{g as b}from"./p-7dd49d15.js";const g="__NO_TAB_NAME__";const w=class{constructor(s){t(this,s),this.dataStateChange=i(this,"dataStateChange",3),this.dataUnitReady=i(this,"dataUnitReady",3),this.messagesBuilderUpdated=i(this,"messagesBuilderUpdated",3),this.dataUnitFieldsHidded=i(this,"dataUnitFieldsHidded",7),this.insertionMode=i(this,"insertionMode",3),this.cancelEdition=i(this,"cancelEdition",3),this._onDataUnitResolve=[],this._openedAlert=!1,this._fieldsWithRmp=[],this._fieldsWithRmPrecision=[],this._metadataByRow=new Map,this._rowMetadataCache=new Map,this._formFieldsConfig=[],this.REGEX_DATAUNIT_NAME=/dd:\/\/(.+?)\//,this._dataUnitObserver=async t=>{const i=await this.buildDataState(t.type);switch(this.dataState=i,this.messagesBuilder.currentOperation=this.getMessageOperation(),t.type){case a.DATA_SAVED:await this.handleDataSaved(t);break;case a.RECORDS_ADDED:case a.RECORDS_COPIED:this.insertionMode.emit();break;case a.EDITION_CANCELED:this.cancelEdition.emit();break;case a.RECORDS_REMOVED:this.handleRecordsRemoved(t);break;case a.METADATA_LOADED:this.fillFieldsWithRmp(this.dataUnit.metadata),this.fillFieldsWithRmPrecision(this.dataUnit.metadata)}},this.fieldsToLink=[],this.dataState=void 0,this.messagesBuilder=void 0,this.dataUnitName=void 0,this.entityName=void 0,this.pageSize=150,this.dataUnit=void 0,this.beforeSave=void 0,this.afterSave=void 0,this.useCancelConfirm=!0,this.ignoreSaveMessage=void 0,this.configName=void 0,this.resourceID=void 0,this.domainMessagesBuilder=void 0}observePageSize(){this.dataUnit&&(this.dataUnit.pageSize=this.pageSize)}observeDataUnitName(t,i){i!=t&&(this.dataUnit?this._application.updateDataunitCache(i,this.dataUnitName,this.dataUnit):this.loadDataUnit())}observeEntityName(t,i){i!=t&&(this.dataUnit=void 0,this.entityName=t,this.loadDataUnit())}observeDataState(t,i){o.objectToString(i)!=o.objectToString(t)&&this.dataStateChange.emit(t)}observeDataUnit(){this.handlerLinkFields(),this.dataUnitReady.emit(this.dataUnit)}observeMessagesBuilder(t){t&&this.messagesBuilderUpdated.emit(t)}onMasterFormConfigChange({detail:t}){var i;this._formFieldsConfig=null!==(i=null==t?void 0:t.fields)&&void 0!==i?i:[]}async getDataUnit(){return new Promise((t=>{this.dataUnit?t(this.dataUnit):this._onDataUnitResolve.push(t)}))}async getSelectedRecordsIDsInfo(){return b(this.dataUnit)}async getFieldsWithRmp(){return this._fieldsWithRmp}async getFieldsWithRmPrecision(){return this._fieldsWithRmPrecision}async getRowMetadata(t){return this.doGetRowMetadata(t)}async doGetRowMetadata(t){const i=this.dataUnit.getSelectedRecord();if(!t&&!i)return;const s=t||i,e="string"==typeof s?s:s.__record__id__;let n=this._metadataByRow.get(e);return this.dataUnit.isNewRecord(e)&&!n&&(n=await this.handleLoadRowMetadata(i)),n?(n.getProp=this.buildGetPropRowMetadata(n),Object.assign({},n)):void 0}buildGetPropRowMetadata(t){return(i,s)=>("rm_precision"===i&&(i=this.resolvePrecisionFromMetadata(s)),o.getProp(t,i))}resolvePrecisionFromMetadata(t){var i,s;if(!t)return void l.error(this.getMessage("snkDataUnit.fieldNameRequired"));const e=null===(s=null===(i=this.dataUnit.getField(t))||void 0===i?void 0:i.properties)||void 0===s?void 0:s.rm_precision;return e?e.split(".").filter(((t,i)=>1!==i)).join("."):""}getCleanOnCopyFields(){var t;return null===(t=this.dataUnit.metadata)||void 0===t?void 0:t.fields.filter((t=>{var i;return null===(i=t.properties)||void 0===i?void 0:i.cleanOnCopy})).map((t=>t.name))}fillFieldsWithRmp(t){t.fields.forEach((t=>{var i;(null===(i=t.properties)||void 0===i?void 0:i.rmp)&&!this._fieldsWithRmp.includes(t.name)&&this._fieldsWithRmp.push(t.name)}))}fillFieldsWithRmPrecision(t){t.fields.forEach((t=>{var i;(null===(i=t.properties)||void 0===i?void 0:i.rm_precision)&&!this._fieldsWithRmPrecision.includes(t.name)&&this._fieldsWithRmPrecision.push(t.name)}))}getCacheName(t,i,s){return[t,i,s].join("_")}updateDataStateRmp(t){const i=Object.assign({},t);this.dataState.rowMetadata=i}saveCacheRmd(t){const i=t.__record__metadata__,s=Object.keys(i);s.shift(),s.forEach((s=>{const e=m(t,s),n=this.getCacheName(s,i.provider,e);this._rowMetadataCache.set(n,Object.assign({},i))}))}getMetadataByRow(t){var i;if(!(null===(i=t.records)||void 0===i?void 0:i.length))return t;if(!this._fieldsWithRmp.length){const i=t.records.map((t=>(delete t.__record__metadata__,t)));return Object.assign(Object.assign({},t),{records:i})}const s=t.records.map((t=>{if(!t.__record__metadata__)return t;this.saveCacheRmd(t);const i=Object.assign({},t.__record__metadata__);return i.getProp=this.buildGetPropRowMetadata(i),this._metadataByRow.set(t.__record__id__,i),delete t.__record__metadata__,t}));return Object.assign(Object.assign({},t),{records:s})}interceptRecordsAdded(t){if(this.isAllowed("INSERT"))return new r(a.RECORDS_ADDED,this.handleLinksWithParent(t.payload));l.info(this.getMessage("snkDataUnit.forbiddenInsert"))}interceptRecordsCopied(t){if(this.isAllowed("CLONE"))return new r(a.RECORDS_COPIED,this.handleRecordsCopied(t.payload));l.info(this.getMessage("snkDataUnit.forbiddenClone"))}async interceptDataChange(t){var i;const s=null===(i=this.dataUnit.getSelectedRecord())||void 0===i?void 0:i.__record__id__;if(this.isAllowed("UPDATE")||this.dataUnit.isNewRecord(s))return t;this._openedAlert?await this.dataUnit.cancelEdition():(this._openedAlert=!0,await this.dataUnit.cancelEdition(),await l.alert(this.getMessage("snkDataUnit.forbidden"),this.getMessage("snkDataUnit.forbiddenUpdate")),this._openedAlert=!1)}async interceptSavingData(t){if(this.dataUnit.isMultipleEdition&&!await this.confirmMultipleSavingData())return;if(!this.beforeSave)return t;const i=this.beforeSave(this.dataUnit);return i instanceof Promise?await i?t:void 0:i?t:void 0}async confirmMultipleSavingData(){const t=this.dataUnit.getSelectionInfo().records,i=this.getMessage("snkDataUnit.multipleUpdateConfirmationTitle"),s=this.getMessage("snkDataUnit.multipleUpdateConfirmationMessage",{size:t.length}),e=this.getMessage("snkDataUnit.confirm.cancel"),n=this.getMessage("snkDataUnit.confirm.updateMultipleConfirm");return await async function({title:t,labelBtnConfirm:i,labelBtnCancel:s,message:e,changingFields:n}){return new Promise((a=>{const o=function(t,i){const s=document.createElement("ez-popup");return s.opened=!0,s.size="small",s.ezTitle=t,s.heightMode="auto",s.addEventListener("ezClosePopup",(()=>{document.body.removeChild(s),i(!1)}),{once:!0}),s.addEventListener("ezPopupAction",(()=>{document.body.removeChild(s),i(!1)}),{once:!0}),s}(t,a),r=function(){const t=document.createElement("div");return t.style.display="flex",t.style.flexDirection="column",t.style.fontFamily="var(--font-pattern, Roboto)",t.style.fontSize="var(--text--medium, 14px)",t}();r.appendChild(function(t){const i=document.createElement("p");return i.textContent=t,i.style.fontSize="var(--text--medium, 14px)",i}(e)),r.appendChild(function(t){const i=document.createElement("div");i.style.flexDirection="column",i.style.display="flex",i.style.overflow="auto",i.style.maxHeight="300px";const s=function(t){const i=new Map;return t.forEach((t=>{var s;const e=null!==(s=t.tabName)&&void 0!==s?s:g;i.has(e)||i.set(e,[]),i.get(e).push(t)})),i}(t);return s.forEach(((t,s)=>{i.appendChild(function(t,i){const s=document.createElement("span");s.innerText=function(t){switch(t){case g:return"";case"__main":return"Principal";default:return t}}(t),s.style.display="block",s.style.fontWeight="var(--text-weight--large, 500)",s.style.fontSize="var(--text--medium, 14px)",s.style.marginBottom="var(--space--small, 6px)";const e=document.createElement("div");return e.style.padding="var(--space--medium, 12px) 0",e.style.borderTop="1px solid var(--color--disable-secondary, #f2f5f8)",e.appendChild(s),i.forEach((t=>{const i=document.createElement("span");i.innerHTML=`${t.label}: <span style="color: var(--text--primary, #626e82)">${t.value}</span>`,i.style.display="block",i.style.marginBottom="var(--space--extra-small, 3px)",e.appendChild(i)})),e}(s,t))})),i}(n));const h=function(){const t=document.createElement("div");return t.style.display="flex",t.style.flexDirection="row",t.style.justifyContent="flex-end",t.style.gap="5px",t}();h.appendChild(function(t,i,s){const e=document.createElement("ez-button");return e.label=i,e.size="medium",e.onclick=()=>{document.body.removeChild(t),s(!1)},e}(o,s,a)),h.appendChild(function(t,i,s){const e=document.createElement("ez-button");return e.label=i,e.size="medium",e.classList.add("ez-button--primary"),e.onclick=()=>{document.body.removeChild(t),s(!0)},e}(o,i,a)),r.appendChild(h),o.appendChild(r),document.body.appendChild(o)}))}({title:i,message:s,labelBtnConfirm:n,labelBtnCancel:e,changingFields:this.getChangingFields()})}getChangingFields(){const t=this.dataUnit.buildChangesToSave();if(!(null==t?void 0:t.length))return[];const i=t[0];return Object.keys(i.updatingFields).map((t=>this.buildChangingField(t,i[t])))}buildChangingField(t,i){return{label:this.dataUnit.getField(t).label,value:this.dataUnit.getFormattedValue(t,i),tabName:this.getFieldTabName(t)}}getFieldTabName(t){var i;const s=null===(i=this._formFieldsConfig.find((i=>i.name===t)))||void 0===i?void 0:i.tab;if(s)return"string"==typeof s?s:s.label}interceptDataSaved(t){if(!this.afterSave)return t;this.afterSave(this.dataUnit)}async interceptEditionCanceled(t){var i,s;if(!this.useCancelConfirm||!this.dataState.hasDirtyRecords||(null===(i=t.payload)||void 0===i?void 0:i.fromParent)||(null===(s=t.payload)||void 0===s?void 0:s.silent))return t;const e=this.getMessage("snkDataUnit.cancelConfirmation");if(null==e)return this.showSuccessMessage(this.getMessage("snkDataUnit.cancelInfo")),t;const n=this.getMessage("snkDataUnit.cancelConfirmationTitle"),a=await l.confirm(n,e);if(a){let t;if(this.dataUnit.isMultipleEdition){const i=this.dataUnit.getSelectionInfo().records;t=this.buildMultipleUpdateMessage(i,!0)}else t=this.getMessage("snkDataUnit.cancelInfo");this.showSuccessMessage(t)}return a?t:void 0}async interceptRemovingRecords(t){var i,s,e;if(!this.isAllowed("REMOVE"))return void l.info(this.getMessage("snkDataUnit.forbiddenRemove"));let n=!1,a=!(null===(i=t.payload)||void 0===i?void 0:i.silent)&&this.getMessage("snkDataUnit.removeConfirmation");const o=null===(s=this.dataUnit)||void 0===s?void 0:s.getSelectionInfo();if(!(null===(e=t.payload)||void 0===e?void 0:e.silent)&&(null==o?void 0:o.length)>1&&(a=this.getMessage("snkDataUnit.removeAllConfirmation",{size:o.length}),n=!0),!a)return t;const r={canClose:!1,labelCancel:this.getMessage("snkDataUnit.confirm."+(n?"no":"cancel")),labelConfirm:this.getMessage("snkDataUnit.confirm."+(n?"yes":"delete")),btnConfirmDanger:!1},h=this.getMessage("snkDataUnit.removeConfirmationTitle");return await l.confirm(h,a,null,c.WARN,r)?t:void 0}interceptDataLoaded(t){const i=this.getMetadataByRow(t.payload);return new r(a.DATA_LOADED,i)}interceptMetadataLoaded(t){return this.fillFieldsWithRmp(t.payload),this.fillFieldsWithRmPrecision(t.payload),new r(a.METADATA_LOADED,this.handleDULinksOnMetadataLoaded(t.payload))}async interceptAction(t){switch(t.type){case a.RECORDS_ADDED:return this.interceptRecordsAdded(t);case a.RECORDS_COPIED:return this.interceptRecordsCopied(t);case a.DATA_CHANGED:return await this.handleLoadRowMetadata(t.payload),await this.interceptDataChange(t);case a.CHANGING_DATA:return await this.interceptDataChange(t);case a.SAVING_DATA:return await this.interceptSavingData(t);case a.DATA_SAVED:return this.interceptDataSaved(t);case a.EDITION_CANCELED:return await this.interceptEditionCanceled(t);case a.REMOVING_RECORDS:return await this.interceptRemovingRecords(t);case a.DATA_LOADED:return this.interceptDataLoaded(t);case a.METADATA_LOADED:return this.interceptMetadataLoaded(t);default:return t}}async handleLoadRowMetadata(t){if(!t)return;const i=Object.keys(t).find((t=>this._fieldsWithRmp.includes(t)));if(i){const s=this.dataUnit.getField(i).properties.rmp,e=m(t,i);return await this.updateRowMetadata({fieldName:i,fieldValue:e,metadataName:s,updatedFields:t})}}async updateRowMetadata({fieldName:t,fieldValue:i,metadataName:s,updatedFields:e}){const n=this.getCacheName(t,s,i),a=this._rowMetadataCache.get(n);if(a)return this.updateDataStateRmp(a),a;{const i=new f,a=await i.loadRowMetadata(this,t,s,e);return this.updateDataStateRmp(a._rmd),this._rowMetadataCache.set(n,Object.assign({},a._rmd)),Object.assign({},a._rmd)}}handleDULinksOnMetadataLoaded(t){const i=Object.assign({},t);return this.processLinks(i),i}handleRecordsCopied(t){let i=[...t];return i=this.handleCleanOnCopy(i),this.handleLinksWithParent(i)}handleLinksWithParent(t){var i,s;const e=null!==(i=this._parentDataUnit)&&void 0!==i?i:null===(s=this.dataUnit)||void 0===s?void 0:s.getParentDataUnit();if(!e)return t;const n=e.getSelectedRecord(),a=null==e?void 0:e.getChildInfo(this.getCleanDataUnitName()),{links:o}=a;return o&&0!==o.length?t.map((t=>this.buildRecordWithLinkedFields(t,o,n))):t}buildRecordWithLinkedFields(t,i,s){const e=Object.assign({},t);return i.forEach((t=>{const i=p(this.dataUnit.getField(t.target).dataType,s[t.source]);e[t.target]=i})),e}handleCleanOnCopy(t){const i=this.getCleanOnCopyFields();return i.length>0&&(t=t.map((t=>this.buildCopyWithCleanedFields(t,i)))),t}buildCopyWithCleanedFields(t,i){const s=Object.assign({},t);return i.forEach((t=>delete s[t])),s}showSuccessMessage(t){l.info(t,{iconName:"check"})}isAllowed(t){return!!this._permissions&&(this._permissions.isSup||this._permissions[t])}async buildDataState(t){var i;const s=this.dataUnit.getSelectionInfo(),e=(this.dataUnit.hasDirtyRecords()||this.dataUnit.hasWaitingChanges())&&(null==s?void 0:s.isEmpty()),n=this.dataUnit.getSelectedRecord();let o=null===(i=this.dataState)||void 0===i?void 0:i.rowMetadata;return!n||o&&![a.SELECTION_CHANGED,a.EDITION_CANCELED,a.NEXT_SELECTED,a.PREVIOUS_SELECTED].includes(t)?o&&(o.getProp=this.buildGetPropRowMetadata(o)):o=await this.doGetRowMetadata(n),new D({insertionMode:this.dataUnit.hasNewRecord(),isStartingInsertionMode:e,hasNext:this.dataUnit.hasNext(),hasPrevious:this.dataUnit.hasPrevious(),copyMode:this.dataUnit.hasCopiedRecord(),isDirty:this.dataUnit.isDirty(),hasDirtyRecords:this.dataUnit.hasDirtyRecords(),selectedRecords:void 0,selectionInfo:s,selectedRecord:n,recordsIsEmpty:0===this.dataUnit.records.length,metadataByRow:this._metadataByRow,rowMetadata:o})}async handleDataSaved(t){var i,s,e;const n=null===(i=null==t?void 0:t.payload)||void 0===i?void 0:i.changes,a=null===(s=null==t?void 0:t.payload)||void 0===s?void 0:s.records,o=await this.handleLoadRowMetadata(null===(e=null==n?void 0:n[0])||void 0===e?void 0:e.record);o&&(o.getProp=this.buildGetPropRowMetadata(o)),this._metadataByRow.set(a[0].__record__id__,o),this.dataState=await this.buildDataState();let r=n[0]._operation.toLowerCase();if("copy"==r&&(r=u.CLONE),this.canIgnoreOperationMessage(r))return;let h=this.buildOperationMessage(r,a);null!=h&&this.showSuccessMessage(h)}canIgnoreOperationMessage(t){return this.ignoreSaveMessage&&!this.isCloneOrInsertOperation(t)}isCloneOrInsertOperation(t){return[u.CLONE,u.INSERT].includes(t)}buildOperationMessage(t,i){return this.isMultiplesUpdate(t,i)?this.buildMultipleUpdateMessage(i):this.getMessage("snkDataUnit.saveInfo",i[0],t)}buildMultipleUpdateMessage(t,i){return this.getMessage("snkDataUnit."+(i?"cancelInfo":"saveInfo"),{records:t},u.UPDATE_MULTIPLES)}isMultiplesUpdate(t,i){return t===u.UPDATE&&i.length>1}handleRecordsRemoved(t){var i,s;let e=this.buildRemoveFinishMessage(t);null!=e&&this.showSuccessMessage(e);const n=null!==(s=null===(i=this.dataUnit.records)||void 0===i?void 0:i.length)&&void 0!==s?s:0,a=this.dataUnit.getPaginationInfo();a&&this.dataUnit.gotoPage(n>0||a.hasMore?a.currentPage:0)}buildRemoveFinishMessage(t){const i=t.payload.records;if(i&&i.length)return(null==i?void 0:i.length)>1?this.getMessage("snkDataUnit.removeAllInfo",{size:i.length}):this.getMessage("snkDataUnit.removeInfo",i)}getMessage(t,i,s){return i||(i=this.getMessageParams()),s&&(this.messagesBuilder.currentOperation=s),this.messagesBuilder.getMessage(t,i)}getMessageParams(){return this.dataState.selectedRecord}getMessageOperation(){return this.dataState.copyMode?u.CLONE:this.dataState.insertionMode||this.dataState.isStartingInsertionMode?u.INSERT:this.dataState.isDirty?u.UPDATE:u.CLEAN}async getDataUnitParentOrChild(){var t;const i=this.dataUnitName?this.dataUnitName:this.entityName;return this._parentSnkDataUnit?(this._parentDataUnit=await(null===(t=this._parentSnkDataUnit)||void 0===t?void 0:t.getDataUnit()),await this._application.getDataUnit(this.entityName,i,this._parentDataUnit,this.configName,this.resourceID)):await this._application.getDataUnit(this.entityName,i,null,this.configName,this.resourceID)}updateMetadataWithRMP(){this.fillFieldsWithRmp(this.dataUnit.metadata),this.fillFieldsWithRmPrecision(this.dataUnit.metadata);const t=this.handleDULinksOnMetadataLoaded(this.dataUnit.metadata);this.dataUnit.metadata=t}async loadDataUnit(){var t,i;if(null==this.dataUnit&&this._application&&this.entityName&&(this.dataUnit=await this.getDataUnitParentOrChild()),this.dataUnit){if(this.dataUnit.pageSize=this.pageSize,this.dataUnit.unsubscribe(this._dataUnitObserver),this.dataUnit.subscribe(this._dataUnitObserver),(null===(t=this.dataUnit)||void 0===t?void 0:t.metadata)&&this.updateMetadataWithRMP(),this.dataUnit.addInterceptor(this),null===(i=this.dataUnit.records)||void 0===i?void 0:i.length){const{records:t}=this.getMetadataByRow(this.dataUnit);this.dataUnit.records=t}let s;for(this.dataState=await this.buildDataState();s=this._onDataUnitResolve.pop();)s(this.dataUnit)}}getParentSnkDataUnit(){let t=this.element;for(;t.parentNode;){if("SNK-DATA-UNIT"===t.parentNode.nodeName)return t.parentNode;t=t.parentNode}}handlerLinkFields(){var t,i,s,e;const n=null!==(t=this._parentDataUnit)&&void 0!==t?t:null===(i=this.dataUnit)||void 0===i?void 0:i.getParentDataUnit();if(!n)return;const a=null!==(s=this.entityName)&&void 0!==s?s:this.getCleanDataUnitName(),o=n.getChildInfo(a);if(!o)return;const r=null===(e=null==o?void 0:o.links)||void 0===e?void 0:e.map((t=>t.target));this.handleDUWithLinks(r)}handleDUWithLinks(t){this.fieldsToLink=t;const i=Object.assign({},this.dataUnit.metadata);this.processLinks(i),this.dataUnit.metadata=i,this.dataUnitFieldsHidded.emit()}processLinks(t){var i;null===(i=null==t?void 0:t.fields)||void 0===i||i.forEach((t=>{var i;(null===(i=this.fieldsToLink)||void 0===i?void 0:i.includes(t.name))&&(t.visible=!1)}))}getCleanDataUnitName(){var t;const i=this.dataUnit.name;if(h.isEmpty(i))return i;const s=this.REGEX_DATAUNIT_NAME.exec(i);return null!==(t=null==s?void 0:s[1])&&void 0!==t?t:i}static getNearestInstance(t){let i=t.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase())return i;i=i.parentElement}}instanceMessagesBuilder(){var t;this.messagesBuilder||(this.messagesBuilder=new v(null!==(t=this.domainMessagesBuilder)&&void 0!==t?t:this.entityName))}componentWillLoad(){this._application=d.getContextValue("__SNK__APPLICATION__"),this._application.getAllAccess(this.resourceID).then((t=>this._permissions=t)),this._parentSnkDataUnit=this.getParentSnkDataUnit(),this.instanceMessagesBuilder()}disconnectedCallback(){this.dataUnit&&this.dataUnit.releaseCallbacks()}async componentDidLoad(){await this.loadDataUnit(),this.handlerLinkFields()}render(){return s(n,null)}get element(){return e(this)}static get watchers(){return{pageSize:["observePageSize"],dataUnitName:["observeDataUnitName"],entityName:["observeEntityName"],dataState:["observeDataState"],dataUnit:["observeDataUnit"],messagesBuilder:["observeMessagesBuilder"]}}};class D{constructor(t){this.copyMode=t.copyMode,this.insertionMode=t.insertionMode,this.isStartingInsertionMode=t.isStartingInsertionMode,this.isDirty=t.isDirty,this.hasDirtyRecords=t.hasDirtyRecords,this.hasNext=t.hasNext,this.hasPrevious=t.hasPrevious,this.selectionInfo=t.selectionInfo,this.selectedRecord=t.selectedRecord,this.recordsIsEmpty=t.recordsIsEmpty,this.metadataByRow=t.metadataByRow,this.rowMetadata=t.rowMetadata}get selectedRecords(){var t;if(console.warn("SnkDataUnit: O método `selectedRecords` foi descontinuado. Use o método `selectionInfo`."),null===(t=this.selectionInfo)||void 0===t?void 0:t.isAllRecords())throw new Error("Erro interno: Impossível obter os registros selecionados. A seleção atual é virtual. Use o atributo `selectionInfo`.");return this.selectionInfo.records}}export{w as S}
|
@@ -1 +1 @@
|
|
1
|
-
import{p as e,b as t}from"./p-d2d301a6.js";export{s as setNonce}from"./p-d2d301a6.js";(()=>{const t=import.meta.url,a={};return""!==t&&(a.resourcesUrl=new URL(".",t).href),e(a)})().then((e=>t(JSON.parse('[["p-118e769b",[[1,"teste-pesquisa"]]],["p-ac8d1cd6",[[2,"snk-actions-form",{"action":[16],"applyParameters":[16],"dataUnit":[32],"openPopup":[64]}]]],["p-9531fd46",[[2,"snk-client-confirm",{"titleMessage":[1,"title-message"],"message":[1],"accept":[16],"cancel":[16],"openPopup":[64]}]]],["p-21a81901",[[6,"snk-custom-slot-elements",{"slotName":[1,"slot-name"]}]]],["p-33718dfc",[[2,"snk-entity-list",{"config":[1040],"rightListSlotBuilder":[1040],"maxHeightList":[1,"max-height-list"],"_searchValue":[32],"_ezListSource":[32],"reloadList":[64]}]]],["p-8c235d4c",[[0,"snk-filter-binary-select",{"value":[1544],"config":[16],"presentationMode":[2,"presentation-mode"],"resetValues":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-5f157b09",[[0,"snk-filter-checkbox-list",{"config":[1040],"optionsList":[32]}]]],["p-bf2acf72",[[0,"snk-filter-multi-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-79f823f3",[[0,"snk-filter-number",{"config":[16],"getMessage":[16],"value":[2],"presentationMode":[2,"presentation-mode"],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-7e2ded86",[[0,"snk-filter-period",{"config":[16],"getMessage":[16],"value":[8],"presentationMode":[2,"presentation-mode"],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-b6200d32",[[0,"snk-filter-search",{"config":[16],"value":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-89c92727",[[0,"snk-filter-text",{"config":[16],"value":[1]},[[0,"ezChange","ezChangeListener"]]]]],["p-47178038",[[2,"snk-personalized-filter-editor",{"messagesBuilder":[1040],"presentationMode":[2,"presentation-mode"],"config":[16],"value":[1040],"items":[32],"show":[64]}]]],["p-434817f0",[[2,"snk-print-selector",{"_printServerActive":[32],"_selectedPrinter":[32],"_remotePrintersDataSource":[32],"_localPrintersDataSource":[32],"_printJobData":[32],"openPrintSelector":[64]}]]],["p-00796b12",[[2,"snk-pesquisa",{"searchLoader":[16],"treeLoader":[16],"selectItem":[16],"entityName":[1,"entity-name"],"argument":[1025],"isHierarchyEntity":[4,"is-hierarchy-entity"],"allowsNonAnalytic":[4,"allows-non-analytic"],"_itemList":[32],"_startLoading":[32],"_presentationMode":[32],"_currentView":[32]}]]],["p-a5e5574c",[[2,"snk-application",{"enableLockManagerLoadingApp":[4,"enable-lock-manager-loading-app"],"messagesBuilder":[1040],"configName":[1,"config-name"],"gridLegacyConfigName":[1,"grid-legacy-config-name"],"formLegacyConfigName":[1,"form-legacy-config-name"],"loadByPK":[16],"_applicationReady":[32],"_templateSkeleton":[32],"_activeScrimWindow":[32],"getKeyboardManager":[64],"getLayoutFormConfig":[64],"isUserSup":[64],"addPendingAction":[64],"callServiceBroker":[64],"initOnboarding":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"showModal":[64],"showAlerts":[64],"closeModal":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"webConnection":[64],"createDataunit":[64],"updateDataunitCache":[64],"getDataUnit":[64],"addClientEvent":[64],"removeClientEvent":[64],"hasClientEvent":[64],"getResourceID":[64],"getUserID":[64],"alert":[64],"error":[64],"success":[64],"message":[64],"confirm":[64],"info":[64],"loadTotals":[64],"isLoadedByPk":[64],"preloadMangerRemoveRecord":[64],"executeSearch":[64],"executePreparedSearchPlus":[64],"executePreparedSearch":[64],"isDebugMode":[64],"getAppLabel":[64],"addSearchListener":[64],"importScript":[64],"getApplicationPath":[64],"executeSelectDistinct":[64],"getDataFetcher":[64],"whenApplicationReady":[64],"setSearchFilterContext":[64],"clearPopUpTitle":[64],"setPopUpTitle":[64],"showScrimApp":[64],"markToReload":[64],"addLoadingLock":[64]}]]],["p-165cde3b",[[0,"snk-filter-modal-item",{"filterItem":[1040],"configName":[1025,"config-name"],"resourceID":[1,"resource-i-d"]}]]],["p-54a5d52a",[[0,"snk-filter-detail",{"config":[1040],"getMessage":[16],"showHardFixed":[4,"show-hard-fixed"],"show":[64]}]]],["p-c2e468c9",[[6,"snk-simple-bar",{"label":[1],"breadcrumbItens":[16],"messagesBuilder":[1040]}]]],["p-8002dcd0",[[2,"snk-filter-field-search",{"searchable":[4],"fieldsDataSource":[16],"breadcrumbItems":[32],"linkItems":[32],"fieldItems":[32],"searchEmpty":[32],"groupEmpty":[32],"show":[64],"applyFilter":[64]}],[0,"snk-filter-param-config",{"messagesBuilder":[1040],"_opened":[32],"_configType":[32],"_expressionItem":[32],"_informedInstance":[32],"_canSave":[32],"open":[64],"close":[64]}]]],["p-9d3a025a",[[2,"snk-expression-group",{"parentTop":[1026,"parent-top"],"group":[1040],"messagesBuilder":[1040],"filterId":[1025,"filter-id"],"entityURI":[1025,"entity-u-r-i"],"_conditionOperator":[32],"_group":[32],"_selfTop":[32],"canAddExpression":[32],"_showDashes":[32],"getExpressionGroup":[64]},[[8,"ezExpressionLayoutChanged","todoCompletedHandler"]]],[2,"snk-expression-item",{"expression":[16],"canRemove":[516,"can-remove"],"messagesBuilder":[1040],"entityURI":[1025,"entity-u-r-i"],"_showValueVariable":[32],"_fieldSelected":[32],"_optionNotNull":[32]}]]],["p-3ab6df3d",[[2,"snk-filter-assistent-mode",{"filterAssistent":[1040],"messagesBuilder":[1040],"filterId":[1025,"filter-id"],"entityUri":[1025,"entity-uri"],"application":[1040]}],[2,"snk-filter-advanced-mode",{"filterAssistent":[1040],"application":[1040]}]]],["p-490b75b5",[[2,"snk-personalized-filter",{"messagesBuilder":[1040],"entityUri":[1025,"entity-uri"],"filterId":[1025,"filter-id"],"configName":[1025,"config-name"],"resourceID":[1,"resource-i-d"],"_filterAssistentMode":[32],"_filterAssistent":[32],"createPersonalizedFilter":[64]}]]],["p-6541bb6d",[[0,"snk-simple-form-config",{"dataUnit":[16],"configName":[1,"config-name"],"avaliableFields":[32],"selectedFields":[32],"show":[64]}],[2,"snk-grid-config",{"selectedIndex":[1026,"selected-index"],"columns":[1040],"config":[1040],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"]}],[2,"snk-layout-form-config",{"layoutType":[32],"save":[64]}],[2,"snk-actions-button",{"_items":[32],"_showDropdown":[32]}],[1,"snk-select-box",{"selectedOption":[1,"selected-option"]}],[2,"snk-view-representation",{"mode":[8]}],[2,"taskbar-actions-button",{"title":[1],"enabled":[4],"actions":[16],"_showDropdown":[32],"showActions":[64],"hideActions":[64],"isOpened":[64]},[[8,"keydown","handleKeyDown"],[8,"ezOpenModal","handleClose"]]]]],["p-cf685cef",[[6,"snk-grid",{"columnFilterDataSource":[1040],"enableLockManagerLoadingComp":[4,"enable-lock-manager-loading-comp"],"enableLockManagerTaskbarClick":[4,"enable-lock-manager-taskbar-click"],"configName":[1,"config-name"],"filterBarTitle":[1,"filter-bar-title"],"resourceID":[1,"resource-i-d"],"selectionToastConfig":[16],"actionsList":[16],"isDetail":[4,"is-detail"],"taskbarManager":[16],"statusResolver":[16],"multipleSelection":[4,"multiple-selection"],"presentationMode":[1,"presentation-mode"],"messagesBuilder":[1040],"useEnterLikeTab":[4,"use-enter-like-tab"],"recordsValidator":[16],"canEdit":[4,"can-edit"],"taskbarCustomContainerId":[1,"taskbar-custom-container-id"],"gridHeaderCustomSlotId":[1,"grid-header-custom-slot-id"],"topTaskbarCustomSlotId":[1,"top-taskbar-custom-slot-id"],"disablePersonalizedFilter":[4,"disable-personalized-filter"],"gridLegacyConfigName":[1,"grid-legacy-config-name"],"filterBarLegacyConfigName":[1,"filter-bar-legacy-config-name"],"autoLoad":[4,"auto-load"],"autoFocus":[4,"auto-focus"],"enableGridInsert":[4,"enable-grid-insert"],"outlineMode":[4,"outline-mode"],"strategyExporter":[1025,"strategy-exporter"],"multipleEditionEnabled":[4,"multiple-edition-enabled"],"_dataUnit":[32],"_dataState":[32],"_gridConfig":[32],"_popUpGridConfig":[32],"_showSnkFilterBar":[32],"_enableContinuousInsert":[32],"reloadConfig":[64],"showConfig":[64],"hideConfig":[64],"setConfig":[64],"reloadFilterBar":[64],"getFilterBar":[64],"findColumn":[64],"addCustomEditor":[64],"addGridCustomRender":[64],"addCustomValueFormatter":[64],"removeCustomValueFormatter":[64],"setFocus":[64]},[[2,"click","handleClick"]]]]],["p-26b0ce3e",[[2,"snk-form-summary",{"fixed":[1540],"contracted":[1540],"summary":[16]}]]],["p-1db45d26",[[6,"snk-form-view",{"levelPath":[1,"level-path"],"label":[1],"name":[1],"fields":[16],"formMetadata":[8,"form-metadata"],"dataUnit":[16],"contracted":[4],"fixed":[1540],"summaryFields":[16],"canExpand":[4,"can-expand"],"canFix":[4,"can-fix"],"recordsValidator":[16],"fieldToFocus":[1,"field-to-focus"],"customEditors":[16],"fieldsProps":[16],"showUp":[64],"addCustomEditor":[64],"setFieldProp":[64]}]]],["p-3749dffb",[[2,"snk-field-config",{"isConfigActive":[16],"fieldConfig":[16],"modeInsertion":[516,"mode-insertion"],"dataUnit":[16],"messagesBuilder":[1040]}]]],["p-c0eb761b",[[6,"snk-tab-config",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1],"tabItems":[16],"messagesBuilder":[1040],"_processedTabs":[32],"_activeEditText":[32],"_activeEditTextIndex":[32],"_actionsHide":[32],"_actionsShow":[32]}]]],["p-90684a75",[[2,"snk-configurator",{"showActionButtons":[4,"show-action-buttons"],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"viewMode":[2,"view-mode"],"customContainerId":[1,"custom-container-id"],"layoutFormConfig":[4,"layout-form-config"],"messagesBuilder":[1040],"_opened":[32],"_permissions":[32],"open":[64],"close":[64]}]]],["p-624390bb",[[2,"snk-data-unit",{"dataState":[1040],"messagesBuilder":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"beforeSave":[16],"afterSave":[16],"useCancelConfirm":[4,"use-cancel-confirm"],"ignoreSaveMessage":[4,"ignore-save-message"],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"domainMessagesBuilder":[1,"domain-messages-builder"],"fieldsToLink":[32],"getDataUnit":[64],"getSelectedRecordsIDsInfo":[64],"getFieldsWithRmp":[64],"getFieldsWithRmPrecision":[64],"getRowMetadata":[64]},[[0,"snkMasterFormConfigChange","onMasterFormConfigChange"]]]]],["p-3b190fb1",[[2,"pesquisa-grid",{"metadata":[16],"dataSource":[16],"pkField":[1,"pk-field"],"descriptionField":[1,"description-field"],"entityName":[1,"entity-name"],"shouldLoadConfig":[4,"should-load-config"],"_gridConfig":[32],"_inMemoryLoader":[32],"_dataunit":[32]}],[2,"pesquisa-tree",{"treeLoader":[16],"argument":[1025],"allowsNonAnalytic":[4,"allows-non-analytic"],"shouldLoadTree":[4,"should-load-tree"],"items":[32],"applyFilter":[64]}]]],["p-16a1dd18",[[0,"snk-exporter-email-sender",{"getMessage":[16],"_config":[32],"_opened":[32],"_currentStep":[32],"open":[64],"close":[64]}]]],["p-ea55f2ab",[[2,"snk-data-exporter",{"provider":[16],"messagesBuilder":[1040],"_items":[32],"_showDropdown":[32]}]]],["p-2d6df7e7",[[6,"snk-taskbar",{"alignRigth":[4,"align-rigth"],"customSlotId":[1,"custom-slot-id"],"customContainerId":[1,"custom-container-id"],"overflowStrategy":[1,"overflow-strategy"],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"buttons":[1],"customButtons":[16],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"presentationMode":[1537,"presentation-mode"],"messagesBuilder":[1040],"_permissions":[32],"_overFlowedElements":[32],"_customElements":[32],"_customElementsId":[32],"_slotContainer":[32],"_hiddenActionsList":[32],"_lastWidth":[32],"_hasToUpdateOverFlow":[32],"_isWaitingForSave":[32]},[[8,"snkCustomSlotElementsLoaded","handleCustomSlotElementsLoaded"],[8,"taskbarSaveLocker","handleTaskbarSaveLocker"],[8,"taskbarSaveUnlocker","handleTaskbarSaveUnlocker"]]]]],["p-53e1de0a",[[6,"snk-simple-crud",{"enableLockManagerLoadingComp":[4,"enable-lock-manager-loading-comp"],"enableLockManagerTaskbarClick":[4,"enable-lock-manager-taskbar-click"],"dataState":[16],"dataUnit":[16],"entityName":[1,"entity-name"],"mode":[2],"gridConfig":[1040],"formConfig":[1040],"enableContinuousInsert":[1028,"enable-continuous-insert"],"multipleSelection":[4,"multiple-selection"],"useCancelConfirm":[4,"use-cancel-confirm"],"pageSize":[2,"page-size"],"resourceID":[1,"resource-i-d"],"enableGridInsert":[4,"enable-grid-insert"],"taskbarManager":[16],"messagesBuilder":[1040],"useEnterLikeTab":[4,"use-enter-like-tab"],"actionsList":[16],"configName":[1025,"config-name"],"showConfiguratorButtons":[4,"show-configurator-buttons"],"gridLegacyConfigName":[1,"grid-legacy-config-name"],"formLegacyConfigName":[1,"form-legacy-config-name"],"ignoreReadOnlyFormFields":[4,"ignore-read-only-form-fields"],"autoFocus":[4,"auto-focus"],"domainMessagesBuilder":[1,"domain-messages-builder"],"multipleEditionEnabled":[4,"multiple-edition-enabled"],"layoutFormConfig":[4,"layout-form-config"],"autoLoad":[4,"auto-load"],"outlineMode":[4,"outline-mode"],"_showPopUpGridConfig":[32],"_currentViewMode":[32],"_config":[32],"_fieldToGetFocus":[32],"_customContainerId":[32],"_formFields":[32],"_fieldsProps":[32],"addCustomEditor":[64],"addGridCustomRender":[64],"addCustomValueFormatter":[64],"removeCustomValueFormatter":[64],"setFieldProp":[64],"goToView":[64],"setMetadata":[64],"setRecords":[64],"getRecords":[64],"openConfigurator":[64],"closeConfigurator":[64],"updateConfig":[64]},[[0,"actionClick","actionClickListener"]]]]],["p-21a5acc4",[[2,"snk-attach",{"fetcherType":[1,"fetcher-type"],"fetcher":[16],"dataUnit":[16],"dataUnitBuilder":[16],"registerKey":[1,"register-key"],"entityName":[1,"entity-name"],"messagesBuilder":[1040],"_currentFetcher":[32],"_currentDataUnit":[32],"crudConfig":[32]}]]],["p-60137b7a",[[0,"snk-filter-modal",{"getMessage":[16],"configName":[1025,"config-name"],"filters":[1040],"applyFilters":[16],"closeModal":[16],"addPersonalizedFilter":[16],"editPersonalizedFilter":[16],"deletePersonalizedFilter":[16],"filtersToDelete":[16],"disablePersonalizedFilter":[4,"disable-personalized-filter"]},[[0,"deleteFilter","deletePersonalizedFilterListener"]]],[4,"snk-filter-list",{"label":[1],"iconName":[1,"icon-name"],"items":[16],"getMessage":[16],"emptyText":[1,"empty-text"],"findFilterText":[1,"find-filter-text"],"buttonClass":[1,"button-class"],"_filterArgument":[32],"_showAll":[32],"hideDetail":[64]},[[2,"keydown","keyDownHandler"]]],[2,"snk-filter-bar",{"enableLockManagerLoadingComp":[4,"enable-lock-manager-loading-comp"],"customFilterBarConfig":[16],"dataUnit":[1040],"title":[1],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"mode":[1],"filterConfig":[1040],"messagesBuilder":[1040],"disablePersonalizedFilter":[4,"disable-personalized-filter"],"filterBarLegacyConfigName":[1,"filter-bar-legacy-config-name"],"autoLoad":[4,"auto-load"],"afterApplyConfig":[16],"allowDefault":[32],"scrollerLocked":[32],"showPersonalizedFilter":[32],"personalizedFilterId":[32],"reload":[64],"getFilterItem":[64],"updateFilterItem":[64],"addFilterItem":[64],"removeFilterItem":[64],"showFilterModal":[64]},[[0,"filterChange","filterChangeListener"]]],[0,"snk-filter-item",{"config":[1040],"getMessage":[16],"showChips":[4,"show-chips"],"detailIsVisible":[32],"showUp":[64],"hideDetail":[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]]]],["p-2101be8b",[[6,"snk-detail-view",{"formConfigManager":[1040],"dataUnitName":[1,"data-unit-name"],"resourceID":[1,"resource-i-d"],"guideItemPath":[16],"entityName":[1,"entity-name"],"label":[1],"dataUnit":[1040],"selectedForm":[1025,"selected-form"],"dataState":[1040],"messagesBuilder":[1040],"branchGuide":[1040],"canEdit":[4,"can-edit"],"taskbarCustomContainerId":[1,"taskbar-custom-container-id"],"customEditors":[16],"customRenders":[16],"presentationMode":[1,"presentation-mode"],"_disabledButtons":[32],"_currentView":[32],"attachmentRegisterKey":[32],"changeViewMode":[64],"configGrid":[64],"showUp":[64],"addCustomEditor":[64],"addGridCustomRender":[64]},[[0,"snkContentCardChanged","onContentCardChanged"]]]]],["p-5ffa0493",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[16],"messagesBuilder":[1040],"formLegacyConfigName":[1,"form-legacy-config-name"],"resourceID":[1,"resource-i-d"],"_dataUnit":[32],"_dataState":[32],"_showFormConfig":[32],"_configManager":[32],"showConfig":[64],"hideConfig":[64],"addCustomEditor":[64],"setFieldProp":[64]}],[2,"snk-form-config",{"dataUnit":[16],"configManager":[16],"messagesBuilder":[1040],"ignoreReadOnlyFormFields":[4,"ignore-read-only-form-fields"],"_formConfigOptions":[32],"_fieldConfigSelected":[32],"_layoutFormConfig":[32],"_fieldsAvailable":[32],"_formConfig":[32],"_formConfigChanged":[32],"_optionFormConfigSelected":[32],"_optionFormConfigChanged":[32],"_tempGroups":[32]}],[2,"snk-config-options",{"fieldConfig":[16],"idConfig":[513,"id-config"],"dataUnit":[16],"messagesBuilder":[1040],"_defaultType":[32]}]]],["p-cbb4c043",[[6,"snk-guides-viewer",{"dataUnit":[16],"dataState":[16],"configName":[1,"config-name"],"entityPath":[1,"entity-path"],"actionsList":[16],"recordsValidator":[16],"masterFormConfig":[1040],"selectedGuide":[16],"taskbarManager":[16],"messagesBuilder":[1040],"canEdit":[4,"can-edit"],"presentationMode":[1,"presentation-mode"],"resourceID":[1,"resource-i-d"],"detailTaskbarCustomContainerId":[1,"detail-taskbar-custom-container-id"],"formLegacyConfigName":[1,"form-legacy-config-name"],"enableGridInsert":[4,"enable-grid-insert"],"ignoreReadOnlyFormFields":[4,"ignore-read-only-form-fields"],"getCustomTitle":[16],"_hasToCreateFieldSearch":[32],"_breadcrumbItems":[32],"_guides":[32],"_formEditorConfigManager":[32],"_formEditorDataUnit":[32],"_fieldToGetFocus":[32],"_customEditors":[32],"_customRenders":[32],"_fieldsProps":[32],"showFormConfig":[64],"findField":[64],"addCustomEditor":[64],"addGridCustomRender":[64],"setFieldProp":[64],"setFocus":[64]},[[2,"actionClick","onActionClick"],[0,"snkContentCardChanged","onContentCardChanged"]]]]],["p-dcfc8b35",[[6,"snk-crud",{"enableLockManagerLoadingComp":[4,"enable-lock-manager-loading-comp"],"enableLockManagerTaskbarClick":[4,"enable-lock-manager-taskbar-click"],"configName":[1025,"config-name"],"filterBarTitle":[1,"filter-bar-title"],"selectionToastConfig":[16],"showActionButtons":[4,"show-action-buttons"],"actionsList":[16],"taskbarManager":[16],"recordsValidator":[16],"statusResolver":[16],"multipleSelection":[4,"multiple-selection"],"presentationMode":[1,"presentation-mode"],"messagesBuilder":[1040],"useEnterLikeTab":[4,"use-enter-like-tab"],"gridLegacyConfigName":[1,"grid-legacy-config-name"],"filterBarLegacyConfigName":[1,"filter-bar-legacy-config-name"],"formLegacyConfigName":[1,"form-legacy-config-name"],"disablePersonalizedFilter":[4,"disable-personalized-filter"],"autoLoad":[4,"auto-load"],"autoFocus":[4,"auto-focus"],"enableGridInsert":[4,"enable-grid-insert"],"domainMessagesBuilder":[1,"domain-messages-builder"],"ignoreReadOnlyFormFields":[4,"ignore-read-only-form-fields"],"setCustomFormTitle":[16],"strategyExporter":[1025,"strategy-exporter"],"layoutFormConfig":[4,"layout-form-config"],"multipleEditionEnabled":[4,"multiple-edition-enabled"],"_dataUnit":[32],"_dataState":[32],"attachmentRegisterKey":[32],"_currentViewMode":[32],"_canEdit":[32],"_resourceID":[32],"customContainerId":[32],"goToView":[64],"openConfigurator":[64],"closeConfigurator":[64],"reloadFilterBar":[64],"getFilterBar":[64],"addCustomEditor":[64],"addGridCustomRender":[64],"addCustomValueFormatter":[64],"removeCustomValueFormatter":[64],"setFieldProp":[64]}]]]]'),e)));
|
1
|
+
import{p as e,b as t}from"./p-d2d301a6.js";export{s as setNonce}from"./p-d2d301a6.js";(()=>{const t=import.meta.url,a={};return""!==t&&(a.resourcesUrl=new URL(".",t).href),e(a)})().then((e=>t(JSON.parse('[["p-118e769b",[[1,"teste-pesquisa"]]],["p-ac8d1cd6",[[2,"snk-actions-form",{"action":[16],"applyParameters":[16],"dataUnit":[32],"openPopup":[64]}]]],["p-9531fd46",[[2,"snk-client-confirm",{"titleMessage":[1,"title-message"],"message":[1],"accept":[16],"cancel":[16],"openPopup":[64]}]]],["p-21a81901",[[6,"snk-custom-slot-elements",{"slotName":[1,"slot-name"]}]]],["p-33718dfc",[[2,"snk-entity-list",{"config":[1040],"rightListSlotBuilder":[1040],"maxHeightList":[1,"max-height-list"],"_searchValue":[32],"_ezListSource":[32],"reloadList":[64]}]]],["p-8c235d4c",[[0,"snk-filter-binary-select",{"value":[1544],"config":[16],"presentationMode":[2,"presentation-mode"],"resetValues":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-5f157b09",[[0,"snk-filter-checkbox-list",{"config":[1040],"optionsList":[32]}]]],["p-bf2acf72",[[0,"snk-filter-multi-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-79f823f3",[[0,"snk-filter-number",{"config":[16],"getMessage":[16],"value":[2],"presentationMode":[2,"presentation-mode"],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-7e2ded86",[[0,"snk-filter-period",{"config":[16],"getMessage":[16],"value":[8],"presentationMode":[2,"presentation-mode"],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-b6200d32",[[0,"snk-filter-search",{"config":[16],"value":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-89c92727",[[0,"snk-filter-text",{"config":[16],"value":[1]},[[0,"ezChange","ezChangeListener"]]]]],["p-47178038",[[2,"snk-personalized-filter-editor",{"messagesBuilder":[1040],"presentationMode":[2,"presentation-mode"],"config":[16],"value":[1040],"items":[32],"show":[64]}]]],["p-434817f0",[[2,"snk-print-selector",{"_printServerActive":[32],"_selectedPrinter":[32],"_remotePrintersDataSource":[32],"_localPrintersDataSource":[32],"_printJobData":[32],"openPrintSelector":[64]}]]],["p-dc6ad9a6",[[2,"snk-pesquisa",{"searchLoader":[16],"treeLoader":[16],"selectItem":[16],"entityName":[1,"entity-name"],"argument":[1025],"isHierarchyEntity":[4,"is-hierarchy-entity"],"allowsNonAnalytic":[4,"allows-non-analytic"],"_itemList":[32],"_startLoading":[32],"_presentationMode":[32],"_currentView":[32]}]]],["p-7cd5c315",[[2,"snk-application",{"enableLockManagerLoadingApp":[4,"enable-lock-manager-loading-app"],"messagesBuilder":[1040],"configName":[1,"config-name"],"gridLegacyConfigName":[1,"grid-legacy-config-name"],"formLegacyConfigName":[1,"form-legacy-config-name"],"loadByPK":[16],"_applicationReady":[32],"_templateSkeleton":[32],"_activeScrimWindow":[32],"getKeyboardManager":[64],"getLayoutFormConfig":[64],"isUserSup":[64],"addPendingAction":[64],"callServiceBroker":[64],"initOnboarding":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"showModal":[64],"showAlerts":[64],"closeModal":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"webConnection":[64],"createDataunit":[64],"updateDataunitCache":[64],"getDataUnit":[64],"addClientEvent":[64],"removeClientEvent":[64],"hasClientEvent":[64],"getResourceID":[64],"getUserID":[64],"alert":[64],"error":[64],"success":[64],"message":[64],"confirm":[64],"info":[64],"loadTotals":[64],"isLoadedByPk":[64],"preloadMangerRemoveRecord":[64],"executeSearch":[64],"executePreparedSearchPlus":[64],"executePreparedSearch":[64],"isDebugMode":[64],"getAppLabel":[64],"addSearchListener":[64],"importScript":[64],"getApplicationPath":[64],"executeSelectDistinct":[64],"getDataFetcher":[64],"whenApplicationReady":[64],"setSearchFilterContext":[64],"clearPopUpTitle":[64],"setPopUpTitle":[64],"showScrimApp":[64],"markToReload":[64],"addLoadingLock":[64]}]]],["p-165cde3b",[[0,"snk-filter-modal-item",{"filterItem":[1040],"configName":[1025,"config-name"],"resourceID":[1,"resource-i-d"]}]]],["p-54a5d52a",[[0,"snk-filter-detail",{"config":[1040],"getMessage":[16],"showHardFixed":[4,"show-hard-fixed"],"show":[64]}]]],["p-c2e468c9",[[6,"snk-simple-bar",{"label":[1],"breadcrumbItens":[16],"messagesBuilder":[1040]}]]],["p-8002dcd0",[[2,"snk-filter-field-search",{"searchable":[4],"fieldsDataSource":[16],"breadcrumbItems":[32],"linkItems":[32],"fieldItems":[32],"searchEmpty":[32],"groupEmpty":[32],"show":[64],"applyFilter":[64]}],[0,"snk-filter-param-config",{"messagesBuilder":[1040],"_opened":[32],"_configType":[32],"_expressionItem":[32],"_informedInstance":[32],"_canSave":[32],"open":[64],"close":[64]}]]],["p-9d3a025a",[[2,"snk-expression-group",{"parentTop":[1026,"parent-top"],"group":[1040],"messagesBuilder":[1040],"filterId":[1025,"filter-id"],"entityURI":[1025,"entity-u-r-i"],"_conditionOperator":[32],"_group":[32],"_selfTop":[32],"canAddExpression":[32],"_showDashes":[32],"getExpressionGroup":[64]},[[8,"ezExpressionLayoutChanged","todoCompletedHandler"]]],[2,"snk-expression-item",{"expression":[16],"canRemove":[516,"can-remove"],"messagesBuilder":[1040],"entityURI":[1025,"entity-u-r-i"],"_showValueVariable":[32],"_fieldSelected":[32],"_optionNotNull":[32]}]]],["p-3ab6df3d",[[2,"snk-filter-assistent-mode",{"filterAssistent":[1040],"messagesBuilder":[1040],"filterId":[1025,"filter-id"],"entityUri":[1025,"entity-uri"],"application":[1040]}],[2,"snk-filter-advanced-mode",{"filterAssistent":[1040],"application":[1040]}]]],["p-490b75b5",[[2,"snk-personalized-filter",{"messagesBuilder":[1040],"entityUri":[1025,"entity-uri"],"filterId":[1025,"filter-id"],"configName":[1025,"config-name"],"resourceID":[1,"resource-i-d"],"_filterAssistentMode":[32],"_filterAssistent":[32],"createPersonalizedFilter":[64]}]]],["p-6a0c8ce0",[[0,"snk-simple-form-config",{"dataUnit":[16],"configName":[1,"config-name"],"avaliableFields":[32],"selectedFields":[32],"show":[64]}],[2,"snk-grid-config",{"selectedIndex":[1026,"selected-index"],"columns":[1040],"config":[1040],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"]}],[2,"snk-layout-form-config",{"layoutType":[32],"save":[64]}],[2,"snk-actions-button",{"_items":[32],"_showDropdown":[32]}],[1,"snk-select-box",{"selectedOption":[1,"selected-option"]}],[2,"snk-view-representation",{"mode":[8]}],[2,"taskbar-actions-button",{"title":[1],"enabled":[4],"actions":[16],"_showDropdown":[32],"showActions":[64],"hideActions":[64],"isOpened":[64]},[[8,"keydown","handleKeyDown"],[8,"ezOpenModal","handleClose"]]]]],["p-65be98c5",[[6,"snk-grid",{"columnFilterDataSource":[1040],"enableLockManagerLoadingComp":[4,"enable-lock-manager-loading-comp"],"enableLockManagerTaskbarClick":[4,"enable-lock-manager-taskbar-click"],"configName":[1,"config-name"],"filterBarTitle":[1,"filter-bar-title"],"resourceID":[1,"resource-i-d"],"selectionToastConfig":[16],"actionsList":[16],"isDetail":[4,"is-detail"],"taskbarManager":[16],"statusResolver":[16],"multipleSelection":[4,"multiple-selection"],"presentationMode":[1,"presentation-mode"],"messagesBuilder":[1040],"useEnterLikeTab":[4,"use-enter-like-tab"],"recordsValidator":[16],"canEdit":[4,"can-edit"],"taskbarCustomContainerId":[1,"taskbar-custom-container-id"],"gridHeaderCustomSlotId":[1,"grid-header-custom-slot-id"],"topTaskbarCustomSlotId":[1,"top-taskbar-custom-slot-id"],"disablePersonalizedFilter":[4,"disable-personalized-filter"],"gridLegacyConfigName":[1,"grid-legacy-config-name"],"filterBarLegacyConfigName":[1,"filter-bar-legacy-config-name"],"autoLoad":[4,"auto-load"],"autoFocus":[4,"auto-focus"],"enableGridInsert":[4,"enable-grid-insert"],"outlineMode":[4,"outline-mode"],"strategyExporter":[1025,"strategy-exporter"],"multipleEditionEnabled":[4,"multiple-edition-enabled"],"_dataUnit":[32],"_dataState":[32],"_gridConfig":[32],"_popUpGridConfig":[32],"_showSnkFilterBar":[32],"_enableContinuousInsert":[32],"reloadConfig":[64],"showConfig":[64],"hideConfig":[64],"setConfig":[64],"reloadFilterBar":[64],"getFilterBar":[64],"findColumn":[64],"addCustomEditor":[64],"addGridCustomRender":[64],"addCustomValueFormatter":[64],"removeCustomValueFormatter":[64],"setFocus":[64]},[[2,"click","handleClick"]]]]],["p-26b0ce3e",[[2,"snk-form-summary",{"fixed":[1540],"contracted":[1540],"summary":[16]}]]],["p-1db45d26",[[6,"snk-form-view",{"levelPath":[1,"level-path"],"label":[1],"name":[1],"fields":[16],"formMetadata":[8,"form-metadata"],"dataUnit":[16],"contracted":[4],"fixed":[1540],"summaryFields":[16],"canExpand":[4,"can-expand"],"canFix":[4,"can-fix"],"recordsValidator":[16],"fieldToFocus":[1,"field-to-focus"],"customEditors":[16],"fieldsProps":[16],"showUp":[64],"addCustomEditor":[64],"setFieldProp":[64]}]]],["p-3749dffb",[[2,"snk-field-config",{"isConfigActive":[16],"fieldConfig":[16],"modeInsertion":[516,"mode-insertion"],"dataUnit":[16],"messagesBuilder":[1040]}]]],["p-c0eb761b",[[6,"snk-tab-config",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1],"tabItems":[16],"messagesBuilder":[1040],"_processedTabs":[32],"_activeEditText":[32],"_activeEditTextIndex":[32],"_actionsHide":[32],"_actionsShow":[32]}]]],["p-90684a75",[[2,"snk-configurator",{"showActionButtons":[4,"show-action-buttons"],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"viewMode":[2,"view-mode"],"customContainerId":[1,"custom-container-id"],"layoutFormConfig":[4,"layout-form-config"],"messagesBuilder":[1040],"_opened":[32],"_permissions":[32],"open":[64],"close":[64]}]]],["p-4a93daef",[[2,"snk-data-unit",{"dataState":[1040],"messagesBuilder":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"beforeSave":[16],"afterSave":[16],"useCancelConfirm":[4,"use-cancel-confirm"],"ignoreSaveMessage":[4,"ignore-save-message"],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"domainMessagesBuilder":[1,"domain-messages-builder"],"fieldsToLink":[32],"getDataUnit":[64],"getSelectedRecordsIDsInfo":[64],"getFieldsWithRmp":[64],"getFieldsWithRmPrecision":[64],"getRowMetadata":[64]},[[0,"snkMasterFormConfigChange","onMasterFormConfigChange"]]]]],["p-d31a701e",[[2,"pesquisa-grid",{"metadata":[16],"dataSource":[16],"pkField":[1,"pk-field"],"descriptionField":[1,"description-field"],"entityName":[1,"entity-name"],"shouldLoadConfig":[4,"should-load-config"],"_gridConfig":[32],"_inMemoryLoader":[32],"_dataunit":[32]}],[2,"pesquisa-tree",{"treeLoader":[16],"argument":[1025],"allowsNonAnalytic":[4,"allows-non-analytic"],"shouldLoadTree":[4,"should-load-tree"],"items":[32],"applyFilter":[64]}]]],["p-16a1dd18",[[0,"snk-exporter-email-sender",{"getMessage":[16],"_config":[32],"_opened":[32],"_currentStep":[32],"open":[64],"close":[64]}]]],["p-ad07f0c5",[[2,"snk-data-exporter",{"provider":[16],"messagesBuilder":[1040],"_items":[32],"_showDropdown":[32]}]]],["p-2d6df7e7",[[6,"snk-taskbar",{"alignRigth":[4,"align-rigth"],"customSlotId":[1,"custom-slot-id"],"customContainerId":[1,"custom-container-id"],"overflowStrategy":[1,"overflow-strategy"],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"buttons":[1],"customButtons":[16],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"presentationMode":[1537,"presentation-mode"],"messagesBuilder":[1040],"_permissions":[32],"_overFlowedElements":[32],"_customElements":[32],"_customElementsId":[32],"_slotContainer":[32],"_hiddenActionsList":[32],"_lastWidth":[32],"_hasToUpdateOverFlow":[32],"_isWaitingForSave":[32]},[[8,"snkCustomSlotElementsLoaded","handleCustomSlotElementsLoaded"],[8,"taskbarSaveLocker","handleTaskbarSaveLocker"],[8,"taskbarSaveUnlocker","handleTaskbarSaveUnlocker"]]]]],["p-cf1f25ed",[[6,"snk-simple-crud",{"enableLockManagerLoadingComp":[4,"enable-lock-manager-loading-comp"],"enableLockManagerTaskbarClick":[4,"enable-lock-manager-taskbar-click"],"dataState":[16],"dataUnit":[16],"entityName":[1,"entity-name"],"mode":[2],"gridConfig":[1040],"formConfig":[1040],"enableContinuousInsert":[1028,"enable-continuous-insert"],"multipleSelection":[4,"multiple-selection"],"useCancelConfirm":[4,"use-cancel-confirm"],"pageSize":[2,"page-size"],"resourceID":[1,"resource-i-d"],"enableGridInsert":[4,"enable-grid-insert"],"taskbarManager":[16],"messagesBuilder":[1040],"useEnterLikeTab":[4,"use-enter-like-tab"],"actionsList":[16],"configName":[1025,"config-name"],"showConfiguratorButtons":[4,"show-configurator-buttons"],"gridLegacyConfigName":[1,"grid-legacy-config-name"],"formLegacyConfigName":[1,"form-legacy-config-name"],"ignoreReadOnlyFormFields":[4,"ignore-read-only-form-fields"],"autoFocus":[4,"auto-focus"],"domainMessagesBuilder":[1,"domain-messages-builder"],"multipleEditionEnabled":[4,"multiple-edition-enabled"],"layoutFormConfig":[4,"layout-form-config"],"autoLoad":[4,"auto-load"],"outlineMode":[4,"outline-mode"],"_showPopUpGridConfig":[32],"_currentViewMode":[32],"_config":[32],"_fieldToGetFocus":[32],"_customContainerId":[32],"_formFields":[32],"_fieldsProps":[32],"addCustomEditor":[64],"addGridCustomRender":[64],"addCustomValueFormatter":[64],"removeCustomValueFormatter":[64],"setFieldProp":[64],"goToView":[64],"setMetadata":[64],"setRecords":[64],"getRecords":[64],"openConfigurator":[64],"closeConfigurator":[64],"updateConfig":[64]},[[0,"actionClick","actionClickListener"]]]]],["p-1c29409b",[[2,"snk-attach",{"fetcherType":[1,"fetcher-type"],"fetcher":[16],"dataUnit":[16],"dataUnitBuilder":[16],"registerKey":[1,"register-key"],"entityName":[1,"entity-name"],"messagesBuilder":[1040],"_currentFetcher":[32],"_currentDataUnit":[32],"crudConfig":[32]}]]],["p-60137b7a",[[0,"snk-filter-modal",{"getMessage":[16],"configName":[1025,"config-name"],"filters":[1040],"applyFilters":[16],"closeModal":[16],"addPersonalizedFilter":[16],"editPersonalizedFilter":[16],"deletePersonalizedFilter":[16],"filtersToDelete":[16],"disablePersonalizedFilter":[4,"disable-personalized-filter"]},[[0,"deleteFilter","deletePersonalizedFilterListener"]]],[4,"snk-filter-list",{"label":[1],"iconName":[1,"icon-name"],"items":[16],"getMessage":[16],"emptyText":[1,"empty-text"],"findFilterText":[1,"find-filter-text"],"buttonClass":[1,"button-class"],"_filterArgument":[32],"_showAll":[32],"hideDetail":[64]},[[2,"keydown","keyDownHandler"]]],[2,"snk-filter-bar",{"enableLockManagerLoadingComp":[4,"enable-lock-manager-loading-comp"],"customFilterBarConfig":[16],"dataUnit":[1040],"title":[1],"configName":[1,"config-name"],"resourceID":[1,"resource-i-d"],"mode":[1],"filterConfig":[1040],"messagesBuilder":[1040],"disablePersonalizedFilter":[4,"disable-personalized-filter"],"filterBarLegacyConfigName":[1,"filter-bar-legacy-config-name"],"autoLoad":[4,"auto-load"],"afterApplyConfig":[16],"allowDefault":[32],"scrollerLocked":[32],"showPersonalizedFilter":[32],"personalizedFilterId":[32],"reload":[64],"getFilterItem":[64],"updateFilterItem":[64],"addFilterItem":[64],"removeFilterItem":[64],"showFilterModal":[64]},[[0,"filterChange","filterChangeListener"]]],[0,"snk-filter-item",{"config":[1040],"getMessage":[16],"showChips":[4,"show-chips"],"detailIsVisible":[32],"showUp":[64],"hideDetail":[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]]]],["p-1a51dfde",[[6,"snk-detail-view",{"formConfigManager":[1040],"dataUnitName":[1,"data-unit-name"],"resourceID":[1,"resource-i-d"],"guideItemPath":[16],"entityName":[1,"entity-name"],"label":[1],"dataUnit":[1040],"selectedForm":[1025,"selected-form"],"dataState":[1040],"messagesBuilder":[1040],"branchGuide":[1040],"canEdit":[4,"can-edit"],"taskbarCustomContainerId":[1,"taskbar-custom-container-id"],"customEditors":[16],"customRenders":[16],"presentationMode":[1,"presentation-mode"],"_disabledButtons":[32],"_currentView":[32],"attachmentRegisterKey":[32],"changeViewMode":[64],"configGrid":[64],"showUp":[64],"addCustomEditor":[64],"addGridCustomRender":[64]},[[0,"snkContentCardChanged","onContentCardChanged"]]]]],["p-5ffa0493",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[16],"messagesBuilder":[1040],"formLegacyConfigName":[1,"form-legacy-config-name"],"resourceID":[1,"resource-i-d"],"_dataUnit":[32],"_dataState":[32],"_showFormConfig":[32],"_configManager":[32],"showConfig":[64],"hideConfig":[64],"addCustomEditor":[64],"setFieldProp":[64]}],[2,"snk-form-config",{"dataUnit":[16],"configManager":[16],"messagesBuilder":[1040],"ignoreReadOnlyFormFields":[4,"ignore-read-only-form-fields"],"_formConfigOptions":[32],"_fieldConfigSelected":[32],"_layoutFormConfig":[32],"_fieldsAvailable":[32],"_formConfig":[32],"_formConfigChanged":[32],"_optionFormConfigSelected":[32],"_optionFormConfigChanged":[32],"_tempGroups":[32]}],[2,"snk-config-options",{"fieldConfig":[16],"idConfig":[513,"id-config"],"dataUnit":[16],"messagesBuilder":[1040],"_defaultType":[32]}]]],["p-271c86d3",[[6,"snk-guides-viewer",{"dataUnit":[16],"dataState":[16],"configName":[1,"config-name"],"entityPath":[1,"entity-path"],"actionsList":[16],"recordsValidator":[16],"masterFormConfig":[1040],"selectedGuide":[16],"taskbarManager":[16],"messagesBuilder":[1040],"canEdit":[4,"can-edit"],"presentationMode":[1,"presentation-mode"],"resourceID":[1,"resource-i-d"],"detailTaskbarCustomContainerId":[1,"detail-taskbar-custom-container-id"],"formLegacyConfigName":[1,"form-legacy-config-name"],"enableGridInsert":[4,"enable-grid-insert"],"ignoreReadOnlyFormFields":[4,"ignore-read-only-form-fields"],"getCustomTitle":[16],"_hasToCreateFieldSearch":[32],"_breadcrumbItems":[32],"_guides":[32],"_formEditorConfigManager":[32],"_formEditorDataUnit":[32],"_fieldToGetFocus":[32],"_customEditors":[32],"_customRenders":[32],"_fieldsProps":[32],"showFormConfig":[64],"findField":[64],"addCustomEditor":[64],"addGridCustomRender":[64],"setFieldProp":[64],"setFocus":[64]},[[2,"actionClick","onActionClick"],[0,"snkContentCardChanged","onContentCardChanged"]]]]],["p-cc8c3bca",[[6,"snk-crud",{"enableLockManagerLoadingComp":[4,"enable-lock-manager-loading-comp"],"enableLockManagerTaskbarClick":[4,"enable-lock-manager-taskbar-click"],"configName":[1025,"config-name"],"filterBarTitle":[1,"filter-bar-title"],"selectionToastConfig":[16],"showActionButtons":[4,"show-action-buttons"],"actionsList":[16],"taskbarManager":[16],"recordsValidator":[16],"statusResolver":[16],"multipleSelection":[4,"multiple-selection"],"presentationMode":[1,"presentation-mode"],"messagesBuilder":[1040],"useEnterLikeTab":[4,"use-enter-like-tab"],"gridLegacyConfigName":[1,"grid-legacy-config-name"],"filterBarLegacyConfigName":[1,"filter-bar-legacy-config-name"],"formLegacyConfigName":[1,"form-legacy-config-name"],"disablePersonalizedFilter":[4,"disable-personalized-filter"],"autoLoad":[4,"auto-load"],"autoFocus":[4,"auto-focus"],"enableGridInsert":[4,"enable-grid-insert"],"domainMessagesBuilder":[1,"domain-messages-builder"],"ignoreReadOnlyFormFields":[4,"ignore-read-only-form-fields"],"setCustomFormTitle":[16],"strategyExporter":[1025,"strategy-exporter"],"layoutFormConfig":[4,"layout-form-config"],"multipleEditionEnabled":[4,"multiple-edition-enabled"],"_dataUnit":[32],"_dataState":[32],"attachmentRegisterKey":[32],"_currentViewMode":[32],"_canEdit":[32],"_resourceID":[32],"customContainerId":[32],"goToView":[64],"openConfigurator":[64],"closeConfigurator":[64],"reloadFilterBar":[64],"getFilterBar":[64],"addCustomEditor":[64],"addGridCustomRender":[64],"addCustomValueFormatter":[64],"removeCustomValueFormatter":[64],"setFieldProp":[64]}]]]]'),e)));
|
@@ -2,13 +2,14 @@ import { DataUnit } from '@sankhyalabs/core';
|
|
2
2
|
import { IMultiSelectionListDataSource } from '@sankhyalabs/ezui/dist/types/components/ez-multi-selection-list/interfaces/IMultiSelectionListDataSource';
|
3
3
|
import { IMultiSelectionOption } from '@sankhyalabs/ezui/dist/types/components/ez-multi-selection-list/interfaces/IMultiSelectionOption';
|
4
4
|
import { SnkApplication } from '../../snk-application/snk-application';
|
5
|
+
import { IStaticOptionsFetchConfig } from '@sankhyalabs/ezui/dist/types/components/ez-multi-selection-list/interfaces/IStaticOptionsFetchConfig';
|
5
6
|
export default class SnkMultiSelectionListDataSource implements IMultiSelectionListDataSource {
|
6
7
|
private _dataUnit;
|
7
8
|
private _application;
|
8
9
|
setDataUnit(dataUnit: DataUnit): void;
|
9
10
|
setApplication(application: SnkApplication): void;
|
10
11
|
private formatLabel;
|
11
|
-
getStaticOptions(fieldName: string): Promise<IMultiSelectionOption[] | undefined>;
|
12
|
+
getStaticOptions(fieldName: string, options: IStaticOptionsFetchConfig): Promise<IMultiSelectionOption[] | undefined>;
|
12
13
|
fetchData(filterTerm: string, fieldName: string): Promise<Array<IMultiSelectionOption>>;
|
13
14
|
sortItems(fieldName: string, items: IMultiSelectionOption[]): IMultiSelectionOption[];
|
14
15
|
}
|
@@ -8,7 +8,7 @@ export default class PreloadManager {
|
|
8
8
|
static isCacheEnabled(_dataUnit: DataUnit): boolean;
|
9
9
|
static cacheRecords(dataUnit: DataUnit, records: Array<Record>, resetDatabase: boolean, loadingInProgress: boolean): void;
|
10
10
|
static getSortingFunction(dataUnit: DataUnit, sorting?: Array<Sort>): (recordA: Record, recordB: Record) => number;
|
11
|
-
static getDistinct(dataUnit: DataUnit, fieldName: string): Promise<Array<IMultiSelectionOption>>;
|
11
|
+
static getDistinct(dataUnit: DataUnit, fieldName: string, onlyLabel?: boolean): Promise<Array<IMultiSelectionOption>>;
|
12
12
|
static loadData(dataUnit: DataUnit, request: LoadDataRequest, loadFromServer: DataLoader): Promise<LoadDataResponse>;
|
13
13
|
static insertRecords(dataUnit: DataUnit, reference: Record, records: Array<Record>): void;
|
14
14
|
static updateRecords(dataUnit: DataUnit, records: Array<Record>): void;
|
package/package.json
CHANGED
@@ -1 +0,0 @@
|
|
1
|
-
import{D as t}from"./p-fbba7e3d.js";import"./p-6dd38d7b.js";import{SortMode as i,ApplicationContext as s,UserInterface as e,DateUtils as r,ObjectUtils as n,StringUtils as o,NumberUtils as a,DataType as l}from"@sankhyalabs/core";import{D as d}from"./p-0f3698af.js";import"@sankhyalabs/ezui/dist/collection/utils/constants";import{UserInterface as u}from"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{P as c}from"./p-a8be1d67.js";import"./p-ff1990ad.js";import"./p-601b252b.js";import"./p-9261d8a0.js";import h from"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils/InMemoryFilterColumnDataSource";import{h as v}from"./p-d2d301a6.js";import{g as f}from"./p-7dd49d15.js";import{I as m}from"./p-8f3f2306.js";class p{static assertDefaultSorting(t,s){t&&s&&(s.defaultSorting=t.columns.filter((t=>null!=t.ascending)).sort(((t,i)=>t.orderIndex-i.orderIndex)).map((({name:t,ascending:e})=>{const{dataType:r}=s.getField(t);return{field:t,dataType:r,mode:e?i.ASC:i.DESC}})))}static parseCrudResults(t,i){Array.isArray(t)||(t=[t]);const s=[];for(const e of t){let t={fields:new Map};for(let s in e){let r=e[s];if(r.hasOwnProperty("$")&&t.fields.set(s,r.$),i)break}s.push(t)}return s.length>1?s:s[0]}static find(i,e,r,n=!0,o,a){let l=[],d=[],u={},c=s.getContextValue("__SNK__APPLICATION__");if(e){if(!Array.isArray(e))throw new Error(c.messagesBuilder.getMessage("crudUtils.errorArray",null));e.forEach((t=>{l.push({name:t})}))}if(r)for(const t in r)r.hasOwnProperty(t)&&d.push({nome:t,valor:r[t]});o&&(u={expression:{$:o}});let h={requestBody:{entity:{name:i,criterio:d,fields:{field:l},literalCriteria:u,orderby:a}}};return new Promise((i=>{t.get().callServiceBroker("mge@crud.find",JSON.stringify(h)).then((t=>{var s;let e=null===(s=t.entidades)||void 0===s?void 0:s.entidade;e||i(null);const r=this.parseCrudResults(e,n);i(r)}))}))}}class b{setDataUnit(t){this._dataUnit=t}setApplication(t){this._application=t}formatLabel(t,i){const{userInterface:s}=this._dataUnit.getField(t);return s===e.DATETIME?r.formatDate(this._dataUnit.valueFromString(t,i)):String(this._dataUnit.getFormattedValue(t,i))}async getStaticOptions(t){return Promise.resolve(null==t?void 0:await c.getDistinct(this._dataUnit,t))}fetchData(t,i){return new Promise((s=>{this._application.executeSelectDistinct(this._dataUnit,i,t).then((t=>{s(t.map((t=>this._dataUnit.getField(i).userInterface===e.SEARCH?Object.assign(Object.assign({},JSON.parse(t)),{check:!0}):{value:t,label:this.formatLabel(i,t),check:!0})))}))}))}sortItems(t,i){return h.defaultSorterMultSelectionOption(this._dataUnit,t,i)}}class y{setGrid(t){this._grid||(this._grid=t,this.refreshSelectedRows())}setDataState(t){this._dataState&&n.equals(null==t?void 0:t.metadataByRow,this._dataState.metadataByRow)||(this._dataState=t,this.refreshSelectedRows())}format(t,i,s){var e;if(o.isEmpty(t))return t;const r=null===(e=this._dataState)||void 0===e?void 0:e.metadataByRow.get(s),n=null==r?void 0:r.getProp("rm_precision",i.name);if(n||0===n)return a.format(t,n,n);if(null==i?void 0:i.props){const s=null==i?void 0:i.props.get("precision"),e=null==i?void 0:i.props.get("prettyPrecision");if(void 0!==s&&void 0!==e)return a.format(t,s,e)}return t}refreshSelectedRows(){var t;null===(t=this._grid)||void 0===t||t.refreshSelectedRows()}}class g{constructor(t,i){this.MAX_WIDTH_COD=60,this.MIN_WIDTH_COD=10,this.DEFAULT_FONT_SIZE=13,this.dataUnit=t,this.grid=i}async getColumnsMetadata(){var t;return this.columnsState=await(null===(t=this.grid)||void 0===t?void 0:t.getColumnsState())||[],await this.buildColumnsMetadata(this.columnsState)}getColumnsState(){return this.columnsState}async buildColumnsMetadata(t){var i,s,e;const r=[];for(const n of t){if(n.hidden&&"RECDESP"!==n.name)continue;const t=null===(i=this.dataUnit)||void 0===i?void 0:i.getField(n.name),o=await this.grid.getCustomValueFormatter(n.name),a=(null==t?void 0:t.userInterface)===u.SEARCH,d=a?"Cód. ":n.label;let c,h={id:n.name,label:d,width:a?d.length*this.DEFAULT_FONT_SIZE:n.width,type:null==t?void 0:t.dataType,userInterface:null==t?void 0:t.userInterface,customFormatter:o};if(a&&null!=(null===(s=null==t?void 0:t.properties)||void 0===s?void 0:s.DESCRIPTIONFIELD)){const i=null===(e=null==t?void 0:t.properties)||void 0===e?void 0:e.DESCRIPTIONENTITY,s=t.properties.mergedFrom;c={id:`${s?s+".":""}${t.properties.ENTITYNAME}.${t.properties.DESCRIPTIONFIELD}`,label:i,width:a&&i?i.length*this.DEFAULT_FONT_SIZE-60:n.width,type:l.TEXT,userInterface:u.LONGTEXT,descriptionFrom:t.name};const r=this.getWidthByMetaData(null==n?void 0:n.width,null==h?void 0:h.width,null==c?void 0:c.width);h=Object.assign(Object.assign({},h),{width:null==r?void 0:r.codWidth}),c=Object.assign(Object.assign({},c),{width:null==r?void 0:r.descWidth,label:(null==c?void 0:c.label)||(null==n?void 0:n.label)})}r.push(h),c&&r.push(c)}return r||[]}getWidthByMetaData(t,i,s){const e=i+s,r=s/e;let n=Math.round(t*(i/e)),o=Math.round(t*r);return n>this.MAX_WIDTH_COD?(n=this.MAX_WIDTH_COD,o=t-this.MAX_WIDTH_COD):n<this.MIN_WIDTH_COD&&(n=this.MIN_WIDTH_COD,o=t-this.MIN_WIDTH_COD),{codWidth:n,descWidth:o}}}class w{constructor(t,i,s){this.snkApplication=t,this.keyConfigEnableContinuousInsert=`${i}enableContinuousInsert${s||""}`}handleSaveConfig(t){return this.snkApplication.saveConfig(this.keyConfigEnableContinuousInsert,t)}getConfig(){return this.snkApplication.getConfig(this.keyConfigEnableContinuousInsert).then((t=>!!t&&"true"==t)).catch((()=>!1))}actionContinuousInsert(t,i){return{value:o.generateUUID(),label:t?"Desativar inclusão contínua":"Ativar inclusão contínua",enabled:!0,itemBuilder:()=>v("div",{class:"ez-dropdown__item-wrapper",onClick:i},v("span",{class:"ez-dropdown__item-label"},t?"Desativar inclusão contínua":"Ativar inclusão contínua"))}}}class j extends g{getSelectedNumber(){return this.dataUnit.getSelectionInfo().length}getTotalRecords(){var t,i,s;const{total:e}=(null===(t=this.dataUnit)||void 0===t?void 0:t.getPaginationInfo())||{};return null!=e?e:null===(s=null===(i=this.dataUnit)||void 0===i?void 0:i.records)||void 0===s?void 0:s.length}getSelectedIDs(){return f(this.dataUnit)}getRecordID(){var t,i,s;return null===(s=null===(i=null===(t=this.dataUnit)||void 0===t?void 0:t.records)||void 0===i?void 0:i[0])||void 0===s?void 0:s.__record__id__}async getRecords(t){if(0===this.dataUnit.records.length)return[];switch(t){case m.ALL:return this.dataUnit.getSelectionInfo().getAllRecords();case m.SELECTION:return this.resolveRecordsFromSelection();case m.PAGE:return this.dataUnit.records;default:return this.resolveRecordsFromSelection()}}resolveRecordsFromSelection(){const t=this.dataUnit.getSelectionInfo(),i=t.isEmpty()||t.isAllRecords()?t.getAllRecords():t.records;return i.length?i:this.dataUnit.records}getHiddenOptions(){return[d.EXPORT_BY_EMAIL,d.EXPORT_PDF_TO_EMAIL,d.EXPORT_XLS_TO_EMAIL,d.EXPORT_PAGE_TO_PDF,d.EXPORT_PAGE_TO_XLS]}formatValue(t,i){const{id:s,descriptionFrom:r}=i,n=t[r||s];if(null==n)return"";if(null!=r)return n.label;if(this.dataUnit.getField(s).userInterface===e.SEARCH)return n.value;if(i.customFormatter){const s=this.getColumnsState().find((t=>i.id===t.name));return i.customFormatter.format(n,s,t.__record__id__)}return this.dataUnit.getFormattedValue(s,n)}}export{g as C,y as R,b as S,p as a,w as b,j as c}
|
@@ -1,60 +0,0 @@
|
|
1
|
-
import{ObjectUtils as t,DataUnit as e,DataUnitInMemoryLoader as n,ApplicationContext as r,StringUtils as a,UserInterface as s,DataUnitStorage as o,DataType as i,ChangeOperation as c}from"@sankhyalabs/core";import{D as l,d as u}from"./p-fbba7e3d.js";import{DISTINCT_FILTER_NAME_PREFIX as d}from"@sankhyalabs/ezui/dist/collection/utils/constants";import{DataUnitTransient as m}from"@sankhyalabs/core/dist/dataunit/metadata/UnitMetadata";import{ColumnFilterManager as h}from"@sankhyalabs/ezui/dist/collection/components/ez-grid/utils";import f from"@sankhyalabs/core/dist/utils/SortingUtils";import{R as p}from"./p-688dcb4c.js";class g{constructor(t){this._list=[],this._listCopy=[],this._listLastUpdate=0,this._listCopyLastUpdate=0,this._equalsFunction=t}async load(t,e,n,r){let a=[].concat(this._list);null!=t&&(a=this._list.filter((e=>t(e)))),null!=e&&(a=a.sort(e));const s=a.length;if(null!=r){const t=n||0;a=a.slice(t,r?t+r:a.length)}return Promise.resolve({result:a,count:s})}async distict(t){const e=[];let n=!1;for(const r of this._list){const a=t(r);null!=a&&(null!=a.value?e.push(a):n=!0)}return n&&e.push({key:"",value:null}),Promise.resolve(new Map(e.map((t=>[t.key,t.value]))))}async push(t){this.updateList([...this._list,...t])}async clear(){this.updateList([])}async delete(t){const e=this._list.filter((e=>{for(const n of t)if(this._equalsFunction(e,n))return!1;return!0}));this.updateList(e)}async update(t){const e=this._list.map((e=>{const n=t.find((t=>this._equalsFunction(e,t)));return null==n?e:n}));this.updateList(e)}async insert(t,e){const n=this._list.indexOf(t);if(-1==n)return void this.push(e);const r=this._list.slice(0,n).concat(e).concat(this._list.slice(n));this.updateList(r)}isOperating(){return!0}async isEmpty(){return Promise.resolve(0===this._list.length)}async count(){return Promise.resolve(this._list.length)}getFromCache(){return this._listLastUpdate>this._listCopyLastUpdate&&(this._listCopyLastUpdate=this._listLastUpdate,this._listCopy=t.copy(this._list)),this._listCopy}updateList(t){this._list=t,this._listLastUpdate=Date.now()}}class _{static setLoadingStatus(t,e){this._loadingStatus.set(t.name,e)}static isCacheEnabled(t){return!0}static cacheRecords(t,e,n,r){_.setLoadingStatus(t,r),_.isCacheEnabled(t)?this.getRepository(t).push(e):n&&this._repositories.delete(t.name)}static getSortingFunction(t,e){return f.getSortingFunction(t,e)}static async getDistinct(t,e){if(!_.isCacheEnabled(t))return Promise.resolve(h.compileDistinct(e,t));let n;const r=t.getLastLoadRequest();if(null!=r){const a=h.getColumnFilters(r.filters,e);n=h.getFilterFunction(t,Array.from(a.values()))}return new Promise(((r,a)=>{_.getRepository(t).distict((r=>{if(null!=n&&!n(r))return;const a=r[e];if(null==a)return{key:null,value:null};const s=null!=a.value?a.value:a;return{key:t.getFormattedValue(e,a),value:s}})).then((t=>{r(null!=t?Array.from(t.entries()).map((([t,e])=>({label:t,value:e,check:!0}))):void 0)})).catch((t=>a(t)))}))}static async loadData(t,n,r){try{if(_.isCacheEnabled(t)){if(["EZ_GRID_LOADING_SOURCE",e.CHANGING_PAGE_LOADING_SOURCE,e.ALL_RECORDS_SELECTION_SOURCE].includes(n.source)&&!await _.getRepository(t).isEmpty())return _.loadFromCache(t,n);_.getRepository(t).clear().catch((()=>{}))}return r(t,n)}catch(t){return console.error(t),Promise.reject(t)}}static insertRecords(t,e,n){_.isCacheEnabled(t)&&_.getRepository(t).insert(e,n)}static updateRecords(t,e){_.isCacheEnabled(t)&&_.getRepository(t).update(e)}static removeRecords(t,e){_.isCacheEnabled(t)&&_.getRepository(t).delete(e)}static async countRecords(t){return _.isCacheEnabled(t)?_.getRepository(t).count():Promise.resolve(0)}static getRepository(t){const e=t.name;return _._repositories.has(e)||_._repositories.set(e,new g(((t,e)=>t.__record__id__===e.__record__id__))),_._repositories.get(e)}static async loadFromCache(t,e){return new Promise(((n,r)=>{const a=h.getColumnFilters(e.filters,""),{limit:s,offset:o,sort:i}=e;_.getRepository(t).load(h.getFilterFunction(t,Array.from(a.values())),_.getSortingFunction(t,i),o,s).then((e=>{const r=_._loadingStatus.get(t.name),{count:a,result:i}=e,c=0==a?0:o+1,l=o+Math.min(i.length,s);n({records:i,paginationInfo:{count:a,currentPage:o/s,firstRecord:c,lastRecord:l,hasMore:r||l<a,total:r?void 0:a}})})).catch((t=>r(t)))}))}static getCachedRecords(t){return _.getRepository(t).getFromCache()}}_._repositories=new Map,_._loadingStatus=new Map;class b{constructor(t,e,r){this._dataUnitInMemoryLoader=new n(t,e,r)}get dataUnit(){return this._dataUnitInMemoryLoader.dataUnit}get records(){return this._dataUnitInMemoryLoader.records}set records(t){this._dataUnitInMemoryLoader.records=t}get metadata(){return this._dataUnitInMemoryLoader.metadata}set metadata(t){this._dataUnitInMemoryLoader.metadata=t}removeLoader(t,e){return this._dataUnitInMemoryLoader.removeLoader(t,e)}static getConvertedValue(t,e,r){return n.getConvertedValue(t,e,r)}}function v(t,e){var n,r;return void 0!==(null===(n=t[e])||void 0===n?void 0:n.value)?null===(r=t[e])||void 0===r?void 0:r.value:t[e]}b.IN_MEMORY_DATA_UNIT_NAME=n.IN_MEMORY_DATA_UNIT_NAME;class y{canSlice(){return!1}processSortingSide(t,e,n){var r;const a=[],o=[];if(null!=t.sort){if(0===n.length)return{localSorting:t.sort,serverSorting:[]};for(const n of t.sort){const t=e.getField(n.field);"true"===(null===(r=null==t?void 0:t.properties)||void 0===r?void 0:r.calculated)||(null==t?void 0:t.userInterface)===s.LONGTEXT?a.push(n):o.push(n)}}return{localSorting:a,serverSorting:o}}async load(t,e,n){var r,a;if(null==t.metadata)return Promise.resolve({records:[],loadingInfo:n});try{const s=null!==(a=null===(r=e.filters)||void 0===r?void 0:r.filter((t=>!t.name.startsWith("FILTRO_COLUNA_"))))&&void 0!==a?a:[],{localSorting:o,serverSorting:i}=this.processSortingSide(e,t,s),c=this.getFieldsList(t),u="DatasetSP.loadRecords",d=this.buildRequestBody(u,c,t,e,n,i,s),m=n.quiet?{urlParams:{quietMode:"true"}}:void 0,{result:h,pagerID:f,askRowsLimit:p}=await l.get().callServiceBroker(u,d,m),g=this.processRecords(t,c,h),_=null!=f,b=n.count+g.length,v=t.hasNewRecord(),y=o.length>0,P=!_&&y;return P&&v&&t.setWaitingToReload(!0),Promise.resolve({records:g,loadingInfo:Object.assign(Object.assign({},n),{pagerId:f,loadingInProgress:_,total:_?void 0:b,count:b,needReload:P&&!v,askRowsLimit:p,hasLocalSorting:y})})}catch(t){return console.error(t),Promise.reject(t)}}async loadRowMetadata(t,e,n,r={}){try{const a="DatasetSP.loadRowMetadata",s=await this.buildRequestBodyLoadRowMetadata({snkDataUnit:t,fieldName:e,metadataName:n,serviceName:a,updatedFields:r});return await l.get().callServiceBroker(a,s)}catch(t){return console.error(t),Promise.reject(t)}}async buildRequestBodyLoadRowMetadata({snkDataUnit:t,serviceName:e,fieldName:n,metadataName:r,updatedFields:a}){const s=t.dataUnit,o=N.parseDataUnitName(s.name).entityName,i=(await t.getSelectedRecordsIDsInfo()).reduce(((t,e)=>(t[e.name]=e.value,t)),{}),c=s.getSelectedRecord(),l=s.metadata.fields.filter((({standAlone:t,name:e})=>!t&&!e.includes("."))).map((({name:t})=>t)),u=l.reduce(((t,e,n)=>{const r=v(c,e),s=v(a,e);return t[n]=void 0!==s?s:r,t}),{});return JSON.stringify({serviceName:e,requestBody:{dataSetID:s.dataUnitId,entityName:o,standAlone:!1,metadataName:r,fieldName:n,fields:l,record:{pk:i,oldPk:i,values:u}}})}getFieldsList(t){let e=["__record__id__","__record__label__"];return t.metadata.fields.forEach((t=>{t.standAlone||(e=e.concat(this.getFieldNames(t)))})),e}getStandAloneFieldsList(t){let e={};return t.metadata.fields.forEach((t=>{t.standAlone&&(e=Object.assign(Object.assign({},e),{[t.name]:{fieldType:t.dataType,userType:t.userInterface}}))})),e}getFieldNames(t){const e=this.getSearchDescriptionField(t);return null==e?t.name:[t.name,e]}buildRequestBody(t,e,n,r,a,s,o){const i=n.dataUnitId,c=N.parseDataUnitName(n.name).entityName,l=!(!r.limit&&!r.offset),u={serviceName:t,requestBody:{dataSetID:i,fields:e,entityName:c,pageNumber:a.pageNumber,totalRecordsCount:a.count,pagerID:a.pagerId,standAlone:!1,standAloneFieldsMD:Object.assign({__record__id__:{fieldType:"S",userType:"P"},__record__label__:{fieldType:"S",userType:"P"}},this.getStandAloneFieldsList(n)),tryJoinedFields:!0,parallelLoader:l,crudListener:`br.com.sankhya.bff.${this.getModuleName()}.BFFDataUnitDatasetAdapter`,txProperties:this.getTxProperties(n,r,s,o),useDefaultRowsLimit:!1}};return JSON.stringify(u)}getModuleName(){return r.getContextValue("__SNK__APPLICATION__").getModuleName().replace("-bff","")}getTxProperties(t,e,n,r){const a={"__DATA_UNIT_ADAPTER__[dataUnitName]":t.name};0!==r.length&&(a["__DATA_UNIT_ADAPTER__[criteria]"]=JSON.stringify(r)),null!=n&&0!==n.length&&(a["__DATA_UNIT_ADAPTER__[sorting]"]=JSON.stringify(n)),null!=e.parentRecordId&&(a["__DATA_UNIT_ADAPTER__[parentRecordId]"]=e.parentRecordId);const s=t.getGlobalLoaderProps();return null==s||0===s.size||Array.from(s.entries()).forEach((([t,e])=>{a[t]=e})),a}processRecords(t,e,n){return n.map((n=>{const r={__record__id__:n[0],__record__label__:n[1],__record__metadata__:n[n.length-1]._rmd};return t.metadata.fields.forEach((t=>{r[t.name]=this.buildFieldValue(t,e,n)})),r}))}buildFieldValue(t,e,n){const r=e.indexOf(t.name);if(r<0)return null;const o=n[r];if(a.isEmpty(o))return null;const i=this.getSearchDescriptionField(t);if(null!=i){const t=e.indexOf(i);if(t>=0)return{value:o,label:n[t]}}return t.userInterface===s.SEARCH?isNaN(Number(o))?o:Number(o):b.getConvertedValue(t,o)}getSearchDescriptionField(t){if(![s.SEARCH,s.SEARCHPLUS].includes(t.userInterface))return;const{ENTITYNAME:e,mergedFrom:n,DESCRIPTIONFIELD:r}=t.properties;return a.isEmpty(r)?void 0:null!=n?`${n}.${e}.${r}`:`${e}.${r}`}}var P;!function(t){t.CANCEL="CANCEL",t.CONTINUE="CONTINUE",t.LOAD_ALL="LOAD_ALL"}(P||(P={}));class D{constructor(){}static async debounce(t,e){const n=t.name;D._debouncingTimeouts[n]&&(clearTimeout(D._debouncingTimeouts[n]),delete D._debouncingTimeouts[n]),D._debouncingTimeouts[n]=setTimeout((()=>{delete D._debouncingTimeouts[n],e()}),100)}static async loadData(t,e){return new Promise(((n,r)=>{D.debounce(t,(()=>{_.loadData(t,e,this.loadFromServer).then((t=>n(t))).catch((t=>r(t)))}))}))}static getCachedRecords(t){return _.getCachedRecords(t)}static async loadFromServer(t,e,n){try{n=D.registryLoading(t,n);const r=await D.callLoader(t,e,n);if(null==r)return;const a=r.records,s=D.buildPaginationInfo(a.length,e,r.loadingInfo),o=null==s?a:a.slice(0,s.lastRecord);return Promise.resolve({records:o,paginationInfo:s})}catch(t){return console.error(t),Promise.reject(t)}}static async callLoader(t,e,n,r){null==r&&(r=new y);const a=await r.load(t,e,n),s=a.loadingInfo;if(D.isOldRequest(t,s))return Promise.resolve(void 0);if(this.handleCache(r,s,t,a.records),t.cancelPagination)return this.handlePaginationCanceled(t,a);if(this.canFinishPagination(t,s))return Promise.resolve(a);const o=Object.assign(Object.assign({},e),{offset:s.count});let i=this.buildNewLoadingInfo(s);if(this.canProceedPagination(s))return this.recallLoader(t,o,i,r,a);const c=await async function(){return new Promise((t=>{const{checkboxContainer:e,checkbox:n}=function(){const t=document.createElement("div");t.style.marginBottom="14px",t.style.display="flex",t.style.alignItems="center";const{checkbox:e,checkboxLabel:n}=function(){const t=document.createElement("input");t.type="checkbox",t.id="loadAll";const e=document.createElement("label");return e.htmlFor="loadAll",e.textContent="Carregar tudo",e.style.marginLeft="5px",{checkbox:t,checkboxLabel:e}}();return t.appendChild(e),t.appendChild(n),{checkboxContainer:t,checkbox:e}}(),r=function(t,e){const n=document.createElement("ez-popup");return n.opened=!0,n.size="x-small",n.ezTitle="Aviso",n.heightMode="auto",n.addEventListener("ezClosePopup",(()=>{document.body.removeChild(n),t(e.checked?P.LOAD_ALL:P.CONTINUE)}),{once:!0}),n.addEventListener("ezPopupAction",(()=>{document.body.removeChild(n),t(P.CANCEL)}),{once:!0}),n}(t,n),a=function(){const t=document.createElement("div");return t.style.display="flex",t.style.flexDirection="column",t.style.fontFamily="var(--font-pattern, Roboto)",t.style.fontSize="var(--text--medium)",t}();a.appendChild(function(){const t=document.createElement("div"),e=document.createElement("p"),n=document.createElement("p"),r=document.createElement("p");return r.style.fontWeight="var(--text-weight--large, 600)",e.textContent="Uma quantidade de registros muito grande está sendo carregada.",n.textContent="Recomendamos que a paginação seja cancelada e que seja criado um filtro para os registros.",r.textContent="Deseja cancelar o carregamento?",t.appendChild(e),t.appendChild(n),t.appendChild(r),t}()),a.appendChild(e);const s=function(){const t=document.createElement("div");return t.style.display="flex",t.style.flexDirection="row",t.style.justifyContent="end",t.style.gap="5px",t}();s.appendChild(function(t,e,n){const r=document.createElement("ez-button");return r.label="Continuar",r.size="medium",r.onclick=()=>{document.body.removeChild(t),n(e.checked?P.LOAD_ALL:P.CONTINUE)},r}(r,n,t)),s.appendChild(function(t,e){const n=document.createElement("ez-button");return n.label="Cancelar paginação",n.size="medium",n.classList.add("ez-button--primary"),n.onclick=()=>{document.body.removeChild(t),e(P.CANCEL)},n}(r,t)),a.appendChild(s),r.appendChild(a),document.body.appendChild(r)}))}();return c===P.CANCEL?this.handlePaginationCanceled(t,a):(c===P.LOAD_ALL&&(i=Object.assign(Object.assign({},i),{loadAllRecords:!0})),i=Object.assign(Object.assign({},i),{lastRowLimitAsked:i.count}),this.recallLoader(t,o,i,r,a))}static buildNewLoadingInfo(t){return Object.assign(Object.assign({},t),{pageNumber:(t.pageNumber||0)+1,quiet:!0})}static handleCache(t,e,n,r){const a=!t.canSlice()||0===e.count;_.cacheRecords(n,r,a,e.loadingInProgress)}static recallLoader(t,e,n,r,a){return this.callLoader(t,e,n,r).then((e=>D.afterLoadingPage(t,e.loadingInfo))).catch((t=>console.error(t))),Promise.resolve(a)}static canFinishPagination(t,e){return!_.isCacheEnabled(t)||!e.loadingInProgress}static canProceedPagination(t){const{count:e,askRowsLimit:n,loadAllRecords:r,lastRowLimitAsked:a}=t;if(r)return!0;if(!e||!n)return!0;const s=Number(n);return e<s||e<s+(a||0)}static handlePaginationCanceled(t,e){t.cancelPagination=!1;let n=e.loadingInfo;return n=Object.assign(Object.assign({},n),{total:n.count,loadingInProgress:!1,pagerId:void 0,needReload:n.hasLocalSorting}),Promise.resolve({records:e.records,loadingInfo:n})}static afterLoadingPage(t,e){_.setLoadingStatus(t,e.loadingInProgress);const n=t.getPaginationInfo();if(null==n)return;const r=e.count;e.loadingInProgress?t.updatePagination(Object.assign(Object.assign({},n),{count:r,loadingInProgress:!0})):e.needReload?t.gotoPage(0):t.updatePagination(Object.assign(Object.assign({},n),{total:r,count:r,loadingInProgress:!1}))}static registryLoading(t,e){return null==e&&(e={requestTime:(new Date).getTime(),count:0}),D._requestTimeByDataUnit.set(t.name,e.requestTime),e}static isOldRequest(t,e){return D._requestTimeByDataUnit.get(t.name)>e.requestTime}static buildPaginationInfo(t,e,n){let{limit:r,offset:a}=e;if(!r)return;1===n.pageNumber&&(a=0);const{total:s,count:o,loadingInProgress:i,askRowsLimit:c}=n,l=0===o||0===t?0:a+1,u=a+Math.min(t,r);return{total:s,count:o,lastRecord:u,firstRecord:l,currentPage:a/r,hasMore:u<o||i,askRowsLimit:c}}}D._requestTimeByDataUnit=new Map,D._debouncingTimeouts={};const R=/dd:\/\/([^/]+)\/([^/?]+)/;class N{constructor(){this.templateByQuery=new Map,this.buldTemplates()}buldTemplates(){this.templateByQuery.set("fetchDataUnit",u.gql`query($name: String!) {
|
2
|
-
$queryAlias$: fetchDataUnit(name: $name){
|
3
|
-
name
|
4
|
-
fields{
|
5
|
-
name
|
6
|
-
defaultValue
|
7
|
-
label
|
8
|
-
visible
|
9
|
-
standAlone
|
10
|
-
readOnly
|
11
|
-
required
|
12
|
-
dataType
|
13
|
-
userInterface
|
14
|
-
calculated
|
15
|
-
group
|
16
|
-
order
|
17
|
-
properties{
|
18
|
-
name
|
19
|
-
value
|
20
|
-
}
|
21
|
-
dependencies{
|
22
|
-
masterFields
|
23
|
-
type
|
24
|
-
expression
|
25
|
-
}
|
26
|
-
}
|
27
|
-
children{
|
28
|
-
name
|
29
|
-
label
|
30
|
-
links{
|
31
|
-
source
|
32
|
-
target
|
33
|
-
}
|
34
|
-
}
|
35
|
-
}
|
36
|
-
}`),this.templateByQuery.set("saveData",u.gql`mutation($changes: [InputBatchChange!]!) {
|
37
|
-
$queryAlias$: batchOperationDataUnit(changes: $changes){
|
38
|
-
oldId
|
39
|
-
id
|
40
|
-
label
|
41
|
-
ownerDataUnitName
|
42
|
-
fields {
|
43
|
-
name
|
44
|
-
value
|
45
|
-
}
|
46
|
-
}
|
47
|
-
}`),this.templateByQuery.set("fetchDataRecord",u.gql`query($dataunit: String! $recordID: [String!]) {
|
48
|
-
$queryAlias$: fetchDataUnit(name: $dataunit){
|
49
|
-
record(id: $recordID){
|
50
|
-
id
|
51
|
-
label
|
52
|
-
fields {
|
53
|
-
name
|
54
|
-
value
|
55
|
-
}
|
56
|
-
}
|
57
|
-
}
|
58
|
-
}`),this.templateByQuery.set("fetchDistinctColumn",u.gql`query($dataUnit: String!, $fieldName: String!, $argument: String, $filters: [InputFilter], $parentRecordId: String) {
|
59
|
-
$queryAlias$: selectDistinct(dataUnit: $dataUnit, fieldName: $fieldName, argument: $argument, filters: $filters, parentRecordId: $parentRecordId)
|
60
|
-
}`)}static parseDataUnitName(t){if(null==t)return;const e=R.exec(t);return e?{entityName:e[1],resourceID:e[2]}:void 0}getDataUnit(t,n,r,a){null==_.applicationResourceID&&p.getResourceID().then((t=>_.applicationResourceID=t));const s=`dd://${t}/${n}${a?"/"+a:""}`,o=null!=r?r.getChildDataunit(s):new e(s);return o.metadataLoader=t=>this.loadMetadata(t),o.dataLoader=(t,e)=>D.loadData(t,e),o.saveLoader=(t,e)=>this.saveData(o,e),o.removeLoader=(t,e)=>this.removeRecords(t,e),o.recordLoader=(t,e)=>this.loadRecord(t,e),o.allRecordsLoader=t=>D.getCachedRecords(t),o}loadMetadata(t){return new Promise(((e,n)=>{l.get().callGraphQL({values:{name:t.name},query:this.templateByQuery.get("fetchDataUnit")}).then((t=>{var n;const r={name:t.name,label:t.name,children:[...t.children],fields:[]};null===(n=t.fields)||void 0===n||n.forEach((t=>{let e;Array.isArray(t.properties)&&(e={},t.calculated&&(e.gridHeaderTooltip="Campos calculados não podem ser ordenados"),t.properties.forEach((t=>e[t.name]=t.value))),r.fields.push(Object.assign(Object.assign({},t),{properties:e}))})),r.fields.sort(((t,e)=>t.order-e.order)),e(r)})).catch((t=>{n(t)}))}))}loadSelectDistinct(t,e,n){const{parentRecordId:r,filters:a}=t.getLastLoadRequest()||{},s=a.filter((t=>t.name!==`${d}${e}`)),o={dataUnit:t.name,argument:n,fieldName:e,parentRecordId:r,filters:s};return new Promise(((t,e)=>{l.get().callGraphQL({values:o,query:this.templateByQuery.get("fetchDistinctColumn")}).then((e=>{t(e)})).catch((t=>{e(t)}))}))}addTransientProperties(t,e){const n=t.getGlobalLoaderProps();return null==n||0===n.size||(null==e&&(e={}),Array.from(n.entries()).forEach((([t,n])=>{e[`transient.${t}`]=n}))),e}getUpdatingFields(t,e){if(null==e)return;const n=Object.assign({},e);return Object.keys(n).forEach((e=>{const r=t.getField(e);null!=r&&r.standAlone&&delete n[e]})),this.addTransientProperties(t,n)}saveData(t,e){const n=[],r=[],a=e.map((e=>{const{dataUnit:a,record:s,operation:l}=e,u=o.get(a),d=this.getUpdatingFields(u,e.updatingFields);let m;null!=d&&(m=Object.entries(d).map((([t,e])=>{const n=u.getField(t);return{fieldName:t,dataType:n?n.dataType:i.TEXT,value:u.valueToString(t,e)}}))),a===t.name&&(l===c.INSERT||l===c.COPY?r.push(s.__record__id__):n.push(s.__record__id__));const h={dataUnit:a,fields:m,operation:l,recordId:s.__record__id__};return e.sourceId&&(h.sourceId=e.sourceId),s.__parent__record__id__&&(h.parentRecordId=s.__parent__record__id__),h}));return new Promise(((e,s)=>{const i=a.map((t=>function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(r=Object.getOwnPropertySymbols(t);a<r.length;a++)e.indexOf(r[a])<0&&Object.prototype.propertyIsEnumerable.call(t,r[a])&&(n[r[a]]=t[r[a]])}return n}(t,[])));l.get().callGraphQL({values:{changes:i},query:this.templateByQuery.get("saveData")}).then((a=>{const s=[];null==a||a.forEach((e=>{const n={__record__id__:e.id,__record__label__:e.label,__owner__dataunit__name__:e.ownerDataUnitName},r=o.get(n.__owner__dataunit__name__)||t;e.oldId&&(n.__old__id__=e.oldId),e.fields.forEach((({name:t,value:e})=>{var a;const s=null===(a=null==r?void 0:r.valueFromString)||void 0===a?void 0:a.call(r,t,e);n[t]=void 0!==s?s:e})),s.push(n)})),this.updateCache(t,s,n,r),e(s)})).catch((t=>{s(t)}))}))}updateCache(t,e,n,r){const a=new Map(e.map((t=>[t.__old__id__||t.__record__id__,t]))),s=r.map((t=>{const e=Object.assign({},a.get(t));return delete e.__old__id__,e}));s.length>0&&_.insertRecords(t,t.records[0],s);const o=n.map((t=>Object.assign({},a.get(t))));_.updateRecords(t,o)}getTransientInfo(t,e){const{records:n}=t.getSelectionInfo();return Object.entries(n.filter((t=>t.__record__id__==e))[0]).filter((([t])=>t.startsWith(m.DATA_UNIT_TRANSIENT_PREFIX_NAME))).map((([t,e])=>({fieldName:t,value:e,dataType:i.TEXT})))}removeRecords(t,e){const n=e.map((e=>({dataUnit:t.name,operation:c.DELETE,recordId:e,fields:this.getTransientInfo(t,e)})));return new Promise(((r,a)=>{l.get().callGraphQL({values:{changes:n},query:this.templateByQuery.get("saveData")}).then((()=>{_.removeRecords(t,t.records.filter((t=>e.includes(t.__record__id__)))),r(e)})).catch((t=>{a(t)}))}))}loadRecord(t,e){return new Promise(((n,r)=>{l.get().callGraphQL({values:{recordID:e,dataunit:t.name},query:this.templateByQuery.get("fetchDataRecord")}).then((e=>{const r=[];e.record.forEach((e=>{const n={__record__id__:e.id,__record__label__:e.label};e.fields.forEach((({name:e,value:r})=>{n[e]=t.valueFromString(e,r)})),r.push(n)})),n(r)})).catch((t=>{r(t)}))}))}}export{N as D,b as I,_ as P,y as a,v as g}
|