@sankhyalabs/sankhyablocks 2.1.0 → 2.1.1

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.
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["teste-pesquisa.cjs",[[1,"teste-pesquisa"]]],["snk-data-unit.cjs",[[2,"snk-data-unit",{"dataState":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"beforeSave":[16],"afterSave":[16],"getDataUnit":[64]}]]],["snk-filter-binary-select.cjs",[[0,"snk-filter-binary-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-multi-select.cjs",[[0,"snk-filter-multi-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-number.cjs",[[0,"snk-filter-number",{"config":[16],"value":[2],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-period.cjs",[[0,"snk-filter-period",{"config":[16],"value":[8],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-personalized.cjs",[[0,"snk-filter-personalized",{"config":[16],"value":[1040],"fix":[16],"unfix":[16],"show":[64]}]]],["snk-filter-search.cjs",[[0,"snk-filter-search",{"config":[16],"value":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-text.cjs",[[0,"snk-filter-text",{"config":[16],"value":[1]},[[0,"ezChange","ezChangeListener"]]]]],["snk-pesquisa.cjs",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-config-options.cjs",[[2,"snk-config-options",{"fieldConfig":[16],"idConfig":[513,"id-config"],"dataUnit":[16],"_defaultType":[32]}]]],["snk-tab-config.cjs",[[6,"snk-tab-config",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1],"_processedTabs":[32],"_activeEditText":[32],"_activeEditTextIndex":[32],"_actionsHide":[32],"_actionsShow":[32]}]]],["snk-filter-detail.cjs",[[0,"snk-filter-detail",{"config":[1040],"getMessage":[16],"show":[64]}]]],["snk-field-config_2.cjs",[[6,"snk-grid",{"configName":[1,"config-name"],"actionsList":[16],"taskbarManager":[16],"statusResolver":[16],"_dataUnit":[32],"_dataState":[32],"_gridConfig":[32],"setShowGridConfig":[64],"setConfig":[64]}],[2,"snk-field-config",{"isConfigActive":[16],"fieldConfig":[16],"modeInsertion":[516,"mode-insertion"],"dataUnit":[16]}]]],["snk-form-config.cjs",[[2,"snk-form-config",{"dataUnit":[16],"formConfig":[16],"parentForm":[16],"_formConfigOptions":[32],"_fieldConfigSelected":[32],"_layoutFormConfig":[32],"_fieldsAvailable":[32],"_formConfig":[32],"_formConfigChanged":[32],"_optionFormConfigSelected":[32],"_optionFormConfigChanged":[32],"_tempGroups":[32]}]]],["snk-config-modal.cjs",[[2,"snk-config-modal",{"configName":[1,"config-name"],"gridMode":[4,"grid-mode"]}]]],["snk-configurator_6.cjs",[[2,"snk-filter-bar",{"dataUnit":[1040],"configName":[1,"config-name"],"filterConfig":[1040],"allowDefault":[32]},[[0,"filterChange","filterChangeListener"]]],[6,"snk-taskbar",{"configName":[1,"config-name"],"buttons":[1],"customButtons":[16],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"_permissions":[32]}],[0,"snk-filter-item",{"config":[1040],"getMessage":[16],"detailIsVisible":[32],"showUp":[64],"hideDetail":[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]],[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"]]],[0,"snk-filter-modal",{"getMessage":[16],"items":[1040],"modalTitle":[1,"modal-title"],"modalSubTitle":[1,"modal-sub-title"],"cancelButtonLabel":[1,"cancel-button-label"],"okButtonLabel":[1,"ok-button-label"],"infoText":[1,"info-text"],"useSearch":[4,"use-search"],"processModalAction":[16],"_filterArgument":[32]}],[2,"snk-configurator",{"configName":[1,"config-name"],"name":[1],"enabled":[4]}]]],["snk-form.cjs",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[16],"actionsList":[16],"taskbarManager":[16],"_dataUnit":[32],"_dataState":[32],"_editionFormConfig":[32],"_insertionFormConfig":[32],"_showFormConfig":[32],"setShowFormConfig":[64],"setConfig":[64]}]]],["snk-crud.cjs",[[6,"snk-crud",{"configName":[1025,"config-name"],"actionsList":[16],"taskbarManager":[16],"recordsValidator":[16],"statusResolver":[16],"_dataUnit":[32],"_dataState":[32],"goToView":[64]}]]],["snk-application.cjs",[[2,"snk-application",{"messagesBuilder":[1040],"configName":[1,"config-name"],"isUserSup":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"showModal":[64],"closeModal":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getDataUnit":[64],"getResourceID":[64],"getUserID":[64],"alert":[64],"error":[64],"success":[64],"message":[64],"confirm":[64],"info":[64],"loadFormConfig":[64],"loadGridConfig":[64],"fetchUserAvailableConfigs":[64],"fetchLegacyConfig":[64],"fetchDefaultConfig":[64],"loadTotals":[64],"saveGridConfig":[64],"getFilterBarConfig":[64],"saveFilterBarConfig":[64],"saveFormConfig":[64],"executeSearch":[64],"executePreparedSearch":[64],"isDebugMode":[64]}]]]], options);
17
+ return index.bootstrapLazy([["teste-pesquisa.cjs",[[1,"teste-pesquisa"]]],["snk-data-unit.cjs",[[2,"snk-data-unit",{"dataState":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"beforeSave":[16],"afterSave":[16],"getDataUnit":[64]}]]],["snk-filter-binary-select.cjs",[[0,"snk-filter-binary-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-multi-select.cjs",[[0,"snk-filter-multi-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-number.cjs",[[0,"snk-filter-number",{"config":[16],"value":[2],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-period.cjs",[[0,"snk-filter-period",{"config":[16],"value":[8],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-personalized.cjs",[[0,"snk-filter-personalized",{"config":[16],"value":[1040],"fix":[16],"unfix":[16],"show":[64]}]]],["snk-filter-search.cjs",[[0,"snk-filter-search",{"config":[16],"value":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-text.cjs",[[0,"snk-filter-text",{"config":[16],"value":[1]},[[0,"ezChange","ezChangeListener"]]]]],["snk-pesquisa.cjs",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-config-options.cjs",[[2,"snk-config-options",{"fieldConfig":[16],"idConfig":[513,"id-config"],"dataUnit":[16],"_defaultType":[32]}]]],["snk-tab-config.cjs",[[6,"snk-tab-config",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1],"_processedTabs":[32],"_activeEditText":[32],"_activeEditTextIndex":[32],"_actionsHide":[32],"_actionsShow":[32]}]]],["snk-filter-detail.cjs",[[0,"snk-filter-detail",{"config":[1040],"getMessage":[16],"show":[64]}]]],["snk-field-config_2.cjs",[[6,"snk-grid",{"configName":[1,"config-name"],"actionsList":[16],"taskbarManager":[16],"statusResolver":[16],"_dataUnit":[32],"_dataState":[32],"_gridConfig":[32],"setShowGridConfig":[64],"setConfig":[64]}],[2,"snk-field-config",{"isConfigActive":[16],"fieldConfig":[16],"modeInsertion":[516,"mode-insertion"],"dataUnit":[16]}]]],["snk-form-config.cjs",[[2,"snk-form-config",{"dataUnit":[16],"formConfig":[16],"parentForm":[16],"_formConfigOptions":[32],"_fieldConfigSelected":[32],"_layoutFormConfig":[32],"_fieldsAvailable":[32],"_formConfig":[32],"_formConfigChanged":[32],"_optionFormConfigSelected":[32],"_optionFormConfigChanged":[32],"_tempGroups":[32]}]]],["snk-config-modal.cjs",[[2,"snk-config-modal",{"configName":[1,"config-name"],"gridMode":[4,"grid-mode"]}]]],["snk-configurator_6.cjs",[[2,"snk-filter-bar",{"dataUnit":[1040],"configName":[1,"config-name"],"filterConfig":[1040],"allowDefault":[32]},[[0,"filterChange","filterChangeListener"]]],[6,"snk-taskbar",{"configName":[1,"config-name"],"buttons":[1],"customButtons":[16],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"_permissions":[32]}],[0,"snk-filter-item",{"config":[1040],"getMessage":[16],"detailIsVisible":[32],"showUp":[64],"hideDetail":[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]],[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"]]],[0,"snk-filter-modal",{"getMessage":[16],"items":[1040],"modalTitle":[1,"modal-title"],"modalSubTitle":[1,"modal-sub-title"],"cancelButtonLabel":[1,"cancel-button-label"],"okButtonLabel":[1,"ok-button-label"],"infoText":[1,"info-text"],"useSearch":[4,"use-search"],"processModalAction":[16],"_filterArgument":[32]}],[2,"snk-configurator",{"configName":[1,"config-name"],"name":[1],"enabled":[4]}]]],["snk-form.cjs",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[16],"actionsList":[16],"taskbarManager":[16],"_dataUnit":[32],"_dataState":[32],"_editionFormConfig":[32],"_insertionFormConfig":[32],"_showFormConfig":[32],"setShowFormConfig":[64],"setConfig":[64]}]]],["snk-crud.cjs",[[6,"snk-crud",{"configName":[1025,"config-name"],"actionsList":[16],"taskbarManager":[16],"recordsValidator":[16],"statusResolver":[16],"_dataUnit":[32],"_dataState":[32],"goToView":[64]}]]],["snk-application.cjs",[[2,"snk-application",{"messagesBuilder":[1040],"configName":[1,"config-name"],"isUserSup":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"showModal":[64],"closeModal":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getDataUnit":[64],"getResourceID":[64],"getUserID":[64],"alert":[64],"error":[64],"success":[64],"message":[64],"confirm":[64],"info":[64],"loadFormConfig":[64],"loadGridConfig":[64],"fetchUserAvailableConfigs":[64],"fetchLegacyConfig":[64],"fetchDefaultConfig":[64],"loadTotals":[64],"saveGridConfig":[64],"getFilterBarConfig":[64],"saveFilterBarConfig":[64],"saveFormConfig":[64],"getDefaultValues":[64],"getDefaultValue":[64],"executeSearch":[64],"executePreparedSearch":[64],"isDebugMode":[64]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["teste-pesquisa.cjs",[[1,"teste-pesquisa"]]],["snk-data-unit.cjs",[[2,"snk-data-unit",{"dataState":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"beforeSave":[16],"afterSave":[16],"getDataUnit":[64]}]]],["snk-filter-binary-select.cjs",[[0,"snk-filter-binary-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-multi-select.cjs",[[0,"snk-filter-multi-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-number.cjs",[[0,"snk-filter-number",{"config":[16],"value":[2],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-period.cjs",[[0,"snk-filter-period",{"config":[16],"value":[8],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-personalized.cjs",[[0,"snk-filter-personalized",{"config":[16],"value":[1040],"fix":[16],"unfix":[16],"show":[64]}]]],["snk-filter-search.cjs",[[0,"snk-filter-search",{"config":[16],"value":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-text.cjs",[[0,"snk-filter-text",{"config":[16],"value":[1]},[[0,"ezChange","ezChangeListener"]]]]],["snk-pesquisa.cjs",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-config-options.cjs",[[2,"snk-config-options",{"fieldConfig":[16],"idConfig":[513,"id-config"],"dataUnit":[16],"_defaultType":[32]}]]],["snk-tab-config.cjs",[[6,"snk-tab-config",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1],"_processedTabs":[32],"_activeEditText":[32],"_activeEditTextIndex":[32],"_actionsHide":[32],"_actionsShow":[32]}]]],["snk-filter-detail.cjs",[[0,"snk-filter-detail",{"config":[1040],"getMessage":[16],"show":[64]}]]],["snk-field-config_2.cjs",[[6,"snk-grid",{"configName":[1,"config-name"],"actionsList":[16],"taskbarManager":[16],"statusResolver":[16],"_dataUnit":[32],"_dataState":[32],"_gridConfig":[32],"setShowGridConfig":[64],"setConfig":[64]}],[2,"snk-field-config",{"isConfigActive":[16],"fieldConfig":[16],"modeInsertion":[516,"mode-insertion"],"dataUnit":[16]}]]],["snk-form-config.cjs",[[2,"snk-form-config",{"dataUnit":[16],"formConfig":[16],"parentForm":[16],"_formConfigOptions":[32],"_fieldConfigSelected":[32],"_layoutFormConfig":[32],"_fieldsAvailable":[32],"_formConfig":[32],"_formConfigChanged":[32],"_optionFormConfigSelected":[32],"_optionFormConfigChanged":[32],"_tempGroups":[32]}]]],["snk-config-modal.cjs",[[2,"snk-config-modal",{"configName":[1,"config-name"],"gridMode":[4,"grid-mode"]}]]],["snk-configurator_6.cjs",[[2,"snk-filter-bar",{"dataUnit":[1040],"configName":[1,"config-name"],"filterConfig":[1040],"allowDefault":[32]},[[0,"filterChange","filterChangeListener"]]],[6,"snk-taskbar",{"configName":[1,"config-name"],"buttons":[1],"customButtons":[16],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"_permissions":[32]}],[0,"snk-filter-item",{"config":[1040],"getMessage":[16],"detailIsVisible":[32],"showUp":[64],"hideDetail":[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]],[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"]]],[0,"snk-filter-modal",{"getMessage":[16],"items":[1040],"modalTitle":[1,"modal-title"],"modalSubTitle":[1,"modal-sub-title"],"cancelButtonLabel":[1,"cancel-button-label"],"okButtonLabel":[1,"ok-button-label"],"infoText":[1,"info-text"],"useSearch":[4,"use-search"],"processModalAction":[16],"_filterArgument":[32]}],[2,"snk-configurator",{"configName":[1,"config-name"],"name":[1],"enabled":[4]}]]],["snk-form.cjs",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[16],"actionsList":[16],"taskbarManager":[16],"_dataUnit":[32],"_dataState":[32],"_editionFormConfig":[32],"_insertionFormConfig":[32],"_showFormConfig":[32],"setShowFormConfig":[64],"setConfig":[64]}]]],["snk-crud.cjs",[[6,"snk-crud",{"configName":[1025,"config-name"],"actionsList":[16],"taskbarManager":[16],"recordsValidator":[16],"statusResolver":[16],"_dataUnit":[32],"_dataState":[32],"goToView":[64]}]]],["snk-application.cjs",[[2,"snk-application",{"messagesBuilder":[1040],"configName":[1,"config-name"],"isUserSup":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"showModal":[64],"closeModal":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getDataUnit":[64],"getResourceID":[64],"getUserID":[64],"alert":[64],"error":[64],"success":[64],"message":[64],"confirm":[64],"info":[64],"loadFormConfig":[64],"loadGridConfig":[64],"fetchUserAvailableConfigs":[64],"fetchLegacyConfig":[64],"fetchDefaultConfig":[64],"loadTotals":[64],"saveGridConfig":[64],"getFilterBarConfig":[64],"saveFilterBarConfig":[64],"saveFormConfig":[64],"executeSearch":[64],"executePreparedSearch":[64],"isDebugMode":[64]}]]]], options);
18
+ return index.bootstrapLazy([["teste-pesquisa.cjs",[[1,"teste-pesquisa"]]],["snk-data-unit.cjs",[[2,"snk-data-unit",{"dataState":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"beforeSave":[16],"afterSave":[16],"getDataUnit":[64]}]]],["snk-filter-binary-select.cjs",[[0,"snk-filter-binary-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-multi-select.cjs",[[0,"snk-filter-multi-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-number.cjs",[[0,"snk-filter-number",{"config":[16],"value":[2],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-period.cjs",[[0,"snk-filter-period",{"config":[16],"value":[8],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-personalized.cjs",[[0,"snk-filter-personalized",{"config":[16],"value":[1040],"fix":[16],"unfix":[16],"show":[64]}]]],["snk-filter-search.cjs",[[0,"snk-filter-search",{"config":[16],"value":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-text.cjs",[[0,"snk-filter-text",{"config":[16],"value":[1]},[[0,"ezChange","ezChangeListener"]]]]],["snk-pesquisa.cjs",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-config-options.cjs",[[2,"snk-config-options",{"fieldConfig":[16],"idConfig":[513,"id-config"],"dataUnit":[16],"_defaultType":[32]}]]],["snk-tab-config.cjs",[[6,"snk-tab-config",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1],"_processedTabs":[32],"_activeEditText":[32],"_activeEditTextIndex":[32],"_actionsHide":[32],"_actionsShow":[32]}]]],["snk-filter-detail.cjs",[[0,"snk-filter-detail",{"config":[1040],"getMessage":[16],"show":[64]}]]],["snk-field-config_2.cjs",[[6,"snk-grid",{"configName":[1,"config-name"],"actionsList":[16],"taskbarManager":[16],"statusResolver":[16],"_dataUnit":[32],"_dataState":[32],"_gridConfig":[32],"setShowGridConfig":[64],"setConfig":[64]}],[2,"snk-field-config",{"isConfigActive":[16],"fieldConfig":[16],"modeInsertion":[516,"mode-insertion"],"dataUnit":[16]}]]],["snk-form-config.cjs",[[2,"snk-form-config",{"dataUnit":[16],"formConfig":[16],"parentForm":[16],"_formConfigOptions":[32],"_fieldConfigSelected":[32],"_layoutFormConfig":[32],"_fieldsAvailable":[32],"_formConfig":[32],"_formConfigChanged":[32],"_optionFormConfigSelected":[32],"_optionFormConfigChanged":[32],"_tempGroups":[32]}]]],["snk-config-modal.cjs",[[2,"snk-config-modal",{"configName":[1,"config-name"],"gridMode":[4,"grid-mode"]}]]],["snk-configurator_6.cjs",[[2,"snk-filter-bar",{"dataUnit":[1040],"configName":[1,"config-name"],"filterConfig":[1040],"allowDefault":[32]},[[0,"filterChange","filterChangeListener"]]],[6,"snk-taskbar",{"configName":[1,"config-name"],"buttons":[1],"customButtons":[16],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"_permissions":[32]}],[0,"snk-filter-item",{"config":[1040],"getMessage":[16],"detailIsVisible":[32],"showUp":[64],"hideDetail":[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]],[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"]]],[0,"snk-filter-modal",{"getMessage":[16],"items":[1040],"modalTitle":[1,"modal-title"],"modalSubTitle":[1,"modal-sub-title"],"cancelButtonLabel":[1,"cancel-button-label"],"okButtonLabel":[1,"ok-button-label"],"infoText":[1,"info-text"],"useSearch":[4,"use-search"],"processModalAction":[16],"_filterArgument":[32]}],[2,"snk-configurator",{"configName":[1,"config-name"],"name":[1],"enabled":[4]}]]],["snk-form.cjs",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[16],"actionsList":[16],"taskbarManager":[16],"_dataUnit":[32],"_dataState":[32],"_editionFormConfig":[32],"_insertionFormConfig":[32],"_showFormConfig":[32],"setShowFormConfig":[64],"setConfig":[64]}]]],["snk-crud.cjs",[[6,"snk-crud",{"configName":[1025,"config-name"],"actionsList":[16],"taskbarManager":[16],"recordsValidator":[16],"statusResolver":[16],"_dataUnit":[32],"_dataState":[32],"goToView":[64]}]]],["snk-application.cjs",[[2,"snk-application",{"messagesBuilder":[1040],"configName":[1,"config-name"],"isUserSup":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"showModal":[64],"closeModal":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getDataUnit":[64],"getResourceID":[64],"getUserID":[64],"alert":[64],"error":[64],"success":[64],"message":[64],"confirm":[64],"info":[64],"loadFormConfig":[64],"loadGridConfig":[64],"fetchUserAvailableConfigs":[64],"fetchLegacyConfig":[64],"fetchDefaultConfig":[64],"loadTotals":[64],"saveGridConfig":[64],"getFilterBarConfig":[64],"saveFilterBarConfig":[64],"saveFormConfig":[64],"getDefaultValues":[64],"getDefaultValue":[64],"executeSearch":[64],"executePreparedSearch":[64],"isDebugMode":[64]}]]]], options);
19
19
  });
@@ -674,6 +674,23 @@ class FilterBarConfigFetcher extends formConfigFetcher.ResourceFetcher {
674
674
  }
675
675
  }
676
676
 
677
+ class DefaultValuesFetcher extends formConfigFetcher.ResourceFetcher {
678
+ getDefaultValues(resourceID) {
679
+ return new Promise((resolve, reject) => {
680
+ this.loadResource(`cfg://defaultValues/${resourceID}`)
681
+ .then(loadedResource => {
682
+ let value;
683
+ if (loadedResource) {
684
+ value = JSON.parse(loadedResource);
685
+ }
686
+ resolve(value);
687
+ }).catch((error) => {
688
+ reject(error);
689
+ });
690
+ });
691
+ }
692
+ }
693
+
677
694
  const snkApplicationCss = ".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";
678
695
 
679
696
  const SnkApplication = class {
@@ -1080,6 +1097,18 @@ const SnkApplication = class {
1080
1097
  async saveFormConfig(config, name) {
1081
1098
  return this.formConfigFetcher.saveConfig(config, name, this.resourceID);
1082
1099
  }
1100
+ /**
1101
+ * Busca um objeto com um conjunto de valores padrão.
1102
+ */
1103
+ async getDefaultValues() {
1104
+ return this.defaultValuesFetcher.getDefaultValues(this.resourceID);
1105
+ }
1106
+ /**
1107
+ * Retorna um valor padrão específico de uma expressão.
1108
+ */
1109
+ async getDefaultValue(expression) {
1110
+ return this._defaultValues && this._defaultValues[expression];
1111
+ }
1083
1112
  async getAuthList(_auth) {
1084
1113
  return await (new MGEAuthorization()).parseFromJSON(_auth);
1085
1114
  }
@@ -1131,6 +1160,12 @@ const SnkApplication = class {
1131
1160
  }
1132
1161
  return this._filterBarConfigFetcher;
1133
1162
  }
1163
+ get defaultValuesFetcher() {
1164
+ if (!this._defaultValuesFetcher) {
1165
+ this._defaultValuesFetcher = new DefaultValuesFetcher();
1166
+ }
1167
+ return this._defaultValuesFetcher;
1168
+ }
1134
1169
  async executeSearch(searchArgument, fieldName, dataUnit) {
1135
1170
  const descriptor = dataUnit === null || dataUnit === void 0 ? void 0 : dataUnit.getField(fieldName);
1136
1171
  if (!descriptor) ;
@@ -1225,6 +1260,9 @@ const SnkApplication = class {
1225
1260
  });
1226
1261
  }
1227
1262
  core.ErrorTracking.init();
1263
+ this.getDefaultValues().then((defaultValues) => {
1264
+ this._defaultValues = defaultValues;
1265
+ });
1228
1266
  }
1229
1267
  connectedCallback() {
1230
1268
  core.ApplicationContext.setContextValue("__SNK__APPLICATION__", this);
@@ -35,38 +35,55 @@ const SnkForm = class {
35
35
  */
36
36
  async setConfig(config) {
37
37
  this._editionFormConfig = {};
38
- setTimeout(() => {
39
- this._editionFormConfig = config != undefined ? config : {};
38
+ if (!this.loadConfig(config)) {
40
39
  this.loadInsertionConfig();
41
- }, this._renderTimer);
42
- }
43
- getFormConfig() {
44
- return (this._dataState && this._dataState.insertionMode ? this._insertionFormConfig : this._editionFormConfig);
45
- }
46
- exitForm() {
47
- if (this._dataUnit.isDirty()) {
48
- this._dataUnit.cancelEdition({ after: () => this.exit.emit() });
49
- }
50
- else {
51
- this.exit.emit();
52
40
  }
53
41
  }
54
- getDisabledButtons() {
55
- const disabled = [];
56
- if (!this._dataState.hasPrevious) {
57
- disabled.push("PREVIOUS");
42
+ loadConfig(config) {
43
+ if ((config === null || config === void 0 ? void 0 : config.fields) == undefined) {
44
+ return false;
58
45
  }
59
- if (!this._dataState.hasNext) {
60
- disabled.push("NEXT");
46
+ setTimeout(async () => {
47
+ for (const field of config.fields) {
48
+ if (field.defaultValue && "value" in field.defaultValue) {
49
+ const value = field.defaultValue.value;
50
+ await this.getFormattedValue(value)
51
+ .then((formattedValue) => {
52
+ field.defaultValue.formattedValue = formattedValue;
53
+ });
54
+ }
55
+ }
56
+ this._editionFormConfig = config;
57
+ this.loadInsertionConfig();
58
+ }, this._renderTimer);
59
+ return true;
60
+ }
61
+ async getFormattedValue(value) {
62
+ switch (value) {
63
+ case "${data}":
64
+ return () => core.DateUtils.getToday();
65
+ case "${datahora}":
66
+ return () => core.DateUtils.getToday(true);
67
+ case "${usuario}":
68
+ case "${usuario.empresa}":
69
+ case "${usuario.vendedor}":
70
+ case "${usuario.centroresultado}":
71
+ let fieldValue;
72
+ await this._application.getDefaultValue(value)
73
+ .then((defaultValue) => {
74
+ fieldValue = defaultValue;
75
+ });
76
+ return fieldValue;
77
+ default:
78
+ return value;
61
79
  }
62
- return disabled;
63
80
  }
64
81
  loadInsertionConfig() {
65
82
  var _a;
66
83
  if (this._dataUnit) {
67
84
  const copyFormConfig = core.ObjectUtils.copy(this._editionFormConfig || {});
68
- copyFormConfig.fields = (_a = copyFormConfig.fields) === null || _a === void 0 ? void 0 : _a.filter(fieldCfg => {
69
- const def = this._dataUnit.getField(fieldCfg.name);
85
+ copyFormConfig.fields = (_a = copyFormConfig.fields) === null || _a === void 0 ? void 0 : _a.filter(field => {
86
+ const def = this._dataUnit.getField(field.name);
70
87
  if (def === null || def === void 0 ? void 0 : def.readOnly) {
71
88
  return false;
72
89
  }
@@ -75,6 +92,17 @@ const SnkForm = class {
75
92
  this._insertionFormConfig = copyFormConfig;
76
93
  }
77
94
  }
95
+ getFormConfig() {
96
+ return (this._dataState && this._dataState.insertionMode ? this._insertionFormConfig : this._editionFormConfig);
97
+ }
98
+ exitForm() {
99
+ if (this._dataUnit.isDirty()) {
100
+ this._dataUnit.cancelEdition({ after: () => this.exit.emit() });
101
+ }
102
+ else {
103
+ this.exit.emit();
104
+ }
105
+ }
78
106
  /**
79
107
  * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
80
108
  * através de um pequeno modulo na estrutura da aplicação:
@@ -91,6 +119,16 @@ const SnkForm = class {
91
119
  changeConfig(config) {
92
120
  this.configChanged.emit(config);
93
121
  }
122
+ getDisabledButtons() {
123
+ const disabled = [];
124
+ if (!this._dataState.hasPrevious) {
125
+ disabled.push("PREVIOUS");
126
+ }
127
+ if (!this._dataState.hasNext) {
128
+ disabled.push("NEXT");
129
+ }
130
+ return disabled;
131
+ }
94
132
  componentDidRender() {
95
133
  configurableElementsStorage.ConfigurableElementsStorage.setForm(this.configName, this._element);
96
134
  }
@@ -16,6 +16,7 @@ import MGEAuthorization from '../../lib/auth/mgeauthorization.module';
16
16
  import GridConfigFetcher from "../../lib/http/data-fetcher/fetchers/grid-config-fetcher";
17
17
  import AuthFetcher, { AutorizationType } from "../../lib/http/data-fetcher/fetchers/auth-fetcher";
18
18
  import FilterBarConfigFetcher from "../../lib/http/data-fetcher/fetchers/filter-bar-config-fetcher";
19
+ import { DefaultValuesFetcher } from "../../lib/http/data-fetcher/fetchers/default-values-fetcher";
19
20
  /**
20
21
  * É possível customizar as mensagens dos blocos de construção através de um pequeno modulo na estrutura da aplicação:
21
22
  * - Criar um arquivo no seguinte caminho: /messages/appmessages.msg.js.
@@ -422,6 +423,18 @@ export class SnkApplication {
422
423
  async saveFormConfig(config, name) {
423
424
  return this.formConfigFetcher.saveConfig(config, name, this.resourceID);
424
425
  }
426
+ /**
427
+ * Busca um objeto com um conjunto de valores padrão.
428
+ */
429
+ async getDefaultValues() {
430
+ return this.defaultValuesFetcher.getDefaultValues(this.resourceID);
431
+ }
432
+ /**
433
+ * Retorna um valor padrão específico de uma expressão.
434
+ */
435
+ async getDefaultValue(expression) {
436
+ return this._defaultValues && this._defaultValues[expression];
437
+ }
425
438
  async getAuthList(_auth) {
426
439
  return await (new MGEAuthorization()).parseFromJSON(_auth);
427
440
  }
@@ -473,6 +486,12 @@ export class SnkApplication {
473
486
  }
474
487
  return this._filterBarConfigFetcher;
475
488
  }
489
+ get defaultValuesFetcher() {
490
+ if (!this._defaultValuesFetcher) {
491
+ this._defaultValuesFetcher = new DefaultValuesFetcher();
492
+ }
493
+ return this._defaultValuesFetcher;
494
+ }
476
495
  async executeSearch(searchArgument, fieldName, dataUnit) {
477
496
  const descriptor = dataUnit === null || dataUnit === void 0 ? void 0 : dataUnit.getField(fieldName);
478
497
  if (!descriptor) {
@@ -569,6 +588,9 @@ export class SnkApplication {
569
588
  });
570
589
  }
571
590
  ErrorTracking.init();
591
+ this.getDefaultValues().then((defaultValues) => {
592
+ this._defaultValues = defaultValues;
593
+ });
572
594
  }
573
595
  connectedCallback() {
574
596
  ApplicationContext.setContextValue("__SNK__APPLICATION__", this);
@@ -1547,6 +1569,41 @@ export class SnkApplication {
1547
1569
  "tags": []
1548
1570
  }
1549
1571
  },
1572
+ "getDefaultValues": {
1573
+ "complexType": {
1574
+ "signature": "() => Promise<string>",
1575
+ "parameters": [],
1576
+ "references": {
1577
+ "Promise": {
1578
+ "location": "global"
1579
+ }
1580
+ },
1581
+ "return": "Promise<string>"
1582
+ },
1583
+ "docs": {
1584
+ "text": "Busca um objeto com um conjunto de valores padr\u00E3o.",
1585
+ "tags": []
1586
+ }
1587
+ },
1588
+ "getDefaultValue": {
1589
+ "complexType": {
1590
+ "signature": "(expression: string) => Promise<any>",
1591
+ "parameters": [{
1592
+ "tags": [],
1593
+ "text": ""
1594
+ }],
1595
+ "references": {
1596
+ "Promise": {
1597
+ "location": "global"
1598
+ }
1599
+ },
1600
+ "return": "Promise<any>"
1601
+ },
1602
+ "docs": {
1603
+ "text": "Retorna um valor padr\u00E3o espec\u00EDfico de uma express\u00E3o.",
1604
+ "tags": []
1605
+ }
1606
+ },
1550
1607
  "executeSearch": {
1551
1608
  "complexType": {
1552
1609
  "signature": "(searchArgument: ISearchArgument, fieldName: string, dataUnit: DataUnit) => Promise<Array<IOption> | IOption>",
@@ -1,4 +1,4 @@
1
- import { ApplicationContext, ObjectUtils } from '@sankhyalabs/core';
1
+ import { ApplicationContext, DateUtils, ObjectUtils } from '@sankhyalabs/core';
2
2
  import { h } from '@stencil/core';
3
3
  import ConfigurableElementsStorage from '../snk-configurator/subcomponents/configModalProvider/configurableElementsStorage';
4
4
  import TaskbarProcessor from '../snk-taskbar/processor/taskbar-processor';
@@ -24,38 +24,55 @@ export class SnkForm {
24
24
  */
25
25
  async setConfig(config) {
26
26
  this._editionFormConfig = {};
27
- setTimeout(() => {
28
- this._editionFormConfig = config != undefined ? config : {};
27
+ if (!this.loadConfig(config)) {
29
28
  this.loadInsertionConfig();
30
- }, this._renderTimer);
31
- }
32
- getFormConfig() {
33
- return (this._dataState && this._dataState.insertionMode ? this._insertionFormConfig : this._editionFormConfig);
34
- }
35
- exitForm() {
36
- if (this._dataUnit.isDirty()) {
37
- this._dataUnit.cancelEdition({ after: () => this.exit.emit() });
38
- }
39
- else {
40
- this.exit.emit();
41
29
  }
42
30
  }
43
- getDisabledButtons() {
44
- const disabled = [];
45
- if (!this._dataState.hasPrevious) {
46
- disabled.push("PREVIOUS");
31
+ loadConfig(config) {
32
+ if ((config === null || config === void 0 ? void 0 : config.fields) == undefined) {
33
+ return false;
47
34
  }
48
- if (!this._dataState.hasNext) {
49
- disabled.push("NEXT");
35
+ setTimeout(async () => {
36
+ for (const field of config.fields) {
37
+ if (field.defaultValue && "value" in field.defaultValue) {
38
+ const value = field.defaultValue.value;
39
+ await this.getFormattedValue(value)
40
+ .then((formattedValue) => {
41
+ field.defaultValue.formattedValue = formattedValue;
42
+ });
43
+ }
44
+ }
45
+ this._editionFormConfig = config;
46
+ this.loadInsertionConfig();
47
+ }, this._renderTimer);
48
+ return true;
49
+ }
50
+ async getFormattedValue(value) {
51
+ switch (value) {
52
+ case "${data}":
53
+ return () => DateUtils.getToday();
54
+ case "${datahora}":
55
+ return () => DateUtils.getToday(true);
56
+ case "${usuario}":
57
+ case "${usuario.empresa}":
58
+ case "${usuario.vendedor}":
59
+ case "${usuario.centroresultado}":
60
+ let fieldValue;
61
+ await this._application.getDefaultValue(value)
62
+ .then((defaultValue) => {
63
+ fieldValue = defaultValue;
64
+ });
65
+ return fieldValue;
66
+ default:
67
+ return value;
50
68
  }
51
- return disabled;
52
69
  }
53
70
  loadInsertionConfig() {
54
71
  var _a;
55
72
  if (this._dataUnit) {
56
73
  const copyFormConfig = ObjectUtils.copy(this._editionFormConfig || {});
57
- copyFormConfig.fields = (_a = copyFormConfig.fields) === null || _a === void 0 ? void 0 : _a.filter(fieldCfg => {
58
- const def = this._dataUnit.getField(fieldCfg.name);
74
+ copyFormConfig.fields = (_a = copyFormConfig.fields) === null || _a === void 0 ? void 0 : _a.filter(field => {
75
+ const def = this._dataUnit.getField(field.name);
59
76
  if (def === null || def === void 0 ? void 0 : def.readOnly) {
60
77
  return false;
61
78
  }
@@ -64,6 +81,17 @@ export class SnkForm {
64
81
  this._insertionFormConfig = copyFormConfig;
65
82
  }
66
83
  }
84
+ getFormConfig() {
85
+ return (this._dataState && this._dataState.insertionMode ? this._insertionFormConfig : this._editionFormConfig);
86
+ }
87
+ exitForm() {
88
+ if (this._dataUnit.isDirty()) {
89
+ this._dataUnit.cancelEdition({ after: () => this.exit.emit() });
90
+ }
91
+ else {
92
+ this.exit.emit();
93
+ }
94
+ }
67
95
  /**
68
96
  * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
69
97
  * através de um pequeno modulo na estrutura da aplicação:
@@ -80,6 +108,16 @@ export class SnkForm {
80
108
  changeConfig(config) {
81
109
  this.configChanged.emit(config);
82
110
  }
111
+ getDisabledButtons() {
112
+ const disabled = [];
113
+ if (!this._dataState.hasPrevious) {
114
+ disabled.push("PREVIOUS");
115
+ }
116
+ if (!this._dataState.hasNext) {
117
+ disabled.push("NEXT");
118
+ }
119
+ return disabled;
120
+ }
83
121
  componentDidRender() {
84
122
  ConfigurableElementsStorage.setForm(this.configName, this._element);
85
123
  }
@@ -0,0 +1,17 @@
1
+ import { ResourceFetcher } from "./resource-fetcher";
2
+ export class DefaultValuesFetcher extends ResourceFetcher {
3
+ getDefaultValues(resourceID) {
4
+ return new Promise((resolve, reject) => {
5
+ this.loadResource(`cfg://defaultValues/${resourceID}`)
6
+ .then(loadedResource => {
7
+ let value;
8
+ if (loadedResource) {
9
+ value = JSON.parse(loadedResource);
10
+ }
11
+ resolve(value);
12
+ }).catch((error) => {
13
+ reject(error);
14
+ });
15
+ });
16
+ }
17
+ }
@@ -670,6 +670,23 @@ class FilterBarConfigFetcher extends ResourceFetcher {
670
670
  }
671
671
  }
672
672
 
673
+ class DefaultValuesFetcher extends ResourceFetcher {
674
+ getDefaultValues(resourceID) {
675
+ return new Promise((resolve, reject) => {
676
+ this.loadResource(`cfg://defaultValues/${resourceID}`)
677
+ .then(loadedResource => {
678
+ let value;
679
+ if (loadedResource) {
680
+ value = JSON.parse(loadedResource);
681
+ }
682
+ resolve(value);
683
+ }).catch((error) => {
684
+ reject(error);
685
+ });
686
+ });
687
+ }
688
+ }
689
+
673
690
  const snkApplicationCss = ".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";
674
691
 
675
692
  const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
@@ -1077,6 +1094,18 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
1077
1094
  async saveFormConfig(config, name) {
1078
1095
  return this.formConfigFetcher.saveConfig(config, name, this.resourceID);
1079
1096
  }
1097
+ /**
1098
+ * Busca um objeto com um conjunto de valores padrão.
1099
+ */
1100
+ async getDefaultValues() {
1101
+ return this.defaultValuesFetcher.getDefaultValues(this.resourceID);
1102
+ }
1103
+ /**
1104
+ * Retorna um valor padrão específico de uma expressão.
1105
+ */
1106
+ async getDefaultValue(expression) {
1107
+ return this._defaultValues && this._defaultValues[expression];
1108
+ }
1080
1109
  async getAuthList(_auth) {
1081
1110
  return await (new MGEAuthorization()).parseFromJSON(_auth);
1082
1111
  }
@@ -1128,6 +1157,12 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
1128
1157
  }
1129
1158
  return this._filterBarConfigFetcher;
1130
1159
  }
1160
+ get defaultValuesFetcher() {
1161
+ if (!this._defaultValuesFetcher) {
1162
+ this._defaultValuesFetcher = new DefaultValuesFetcher();
1163
+ }
1164
+ return this._defaultValuesFetcher;
1165
+ }
1131
1166
  async executeSearch(searchArgument, fieldName, dataUnit) {
1132
1167
  const descriptor = dataUnit === null || dataUnit === void 0 ? void 0 : dataUnit.getField(fieldName);
1133
1168
  if (!descriptor) ;
@@ -1222,6 +1257,9 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
1222
1257
  });
1223
1258
  }
1224
1259
  ErrorTracking.init();
1260
+ this.getDefaultValues().then((defaultValues) => {
1261
+ this._defaultValues = defaultValues;
1262
+ });
1225
1263
  }
1226
1264
  connectedCallback() {
1227
1265
  ApplicationContext.setContextValue("__SNK__APPLICATION__", this);
@@ -1280,6 +1318,8 @@ const SnkApplication = /*@__PURE__*/ proxyCustomElement(class extends HTMLElemen
1280
1318
  "getFilterBarConfig": [64],
1281
1319
  "saveFilterBarConfig": [64],
1282
1320
  "saveFormConfig": [64],
1321
+ "getDefaultValues": [64],
1322
+ "getDefaultValue": [64],
1283
1323
  "executeSearch": [64],
1284
1324
  "executePreparedSearch": [64],
1285
1325
  "isDebugMode": [64]
@@ -1,5 +1,5 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
- import { ObjectUtils, ApplicationContext } from '@sankhyalabs/core';
2
+ import { DateUtils, ObjectUtils, ApplicationContext } from '@sankhyalabs/core';
3
3
  import { C as ConfigurableElementsStorage, d as defineCustomElement$7 } from './snk-config-modal2.js';
4
4
  import { T as TaskbarProcessor } from './taskbar-processor.js';
5
5
  import { d as defineCustomElement$6 } from './snk-config-options2.js';
@@ -38,38 +38,55 @@ const SnkForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
38
38
  */
39
39
  async setConfig(config) {
40
40
  this._editionFormConfig = {};
41
- setTimeout(() => {
42
- this._editionFormConfig = config != undefined ? config : {};
41
+ if (!this.loadConfig(config)) {
43
42
  this.loadInsertionConfig();
44
- }, this._renderTimer);
45
- }
46
- getFormConfig() {
47
- return (this._dataState && this._dataState.insertionMode ? this._insertionFormConfig : this._editionFormConfig);
48
- }
49
- exitForm() {
50
- if (this._dataUnit.isDirty()) {
51
- this._dataUnit.cancelEdition({ after: () => this.exit.emit() });
52
- }
53
- else {
54
- this.exit.emit();
55
43
  }
56
44
  }
57
- getDisabledButtons() {
58
- const disabled = [];
59
- if (!this._dataState.hasPrevious) {
60
- disabled.push("PREVIOUS");
45
+ loadConfig(config) {
46
+ if ((config === null || config === void 0 ? void 0 : config.fields) == undefined) {
47
+ return false;
61
48
  }
62
- if (!this._dataState.hasNext) {
63
- disabled.push("NEXT");
49
+ setTimeout(async () => {
50
+ for (const field of config.fields) {
51
+ if (field.defaultValue && "value" in field.defaultValue) {
52
+ const value = field.defaultValue.value;
53
+ await this.getFormattedValue(value)
54
+ .then((formattedValue) => {
55
+ field.defaultValue.formattedValue = formattedValue;
56
+ });
57
+ }
58
+ }
59
+ this._editionFormConfig = config;
60
+ this.loadInsertionConfig();
61
+ }, this._renderTimer);
62
+ return true;
63
+ }
64
+ async getFormattedValue(value) {
65
+ switch (value) {
66
+ case "${data}":
67
+ return () => DateUtils.getToday();
68
+ case "${datahora}":
69
+ return () => DateUtils.getToday(true);
70
+ case "${usuario}":
71
+ case "${usuario.empresa}":
72
+ case "${usuario.vendedor}":
73
+ case "${usuario.centroresultado}":
74
+ let fieldValue;
75
+ await this._application.getDefaultValue(value)
76
+ .then((defaultValue) => {
77
+ fieldValue = defaultValue;
78
+ });
79
+ return fieldValue;
80
+ default:
81
+ return value;
64
82
  }
65
- return disabled;
66
83
  }
67
84
  loadInsertionConfig() {
68
85
  var _a;
69
86
  if (this._dataUnit) {
70
87
  const copyFormConfig = ObjectUtils.copy(this._editionFormConfig || {});
71
- copyFormConfig.fields = (_a = copyFormConfig.fields) === null || _a === void 0 ? void 0 : _a.filter(fieldCfg => {
72
- const def = this._dataUnit.getField(fieldCfg.name);
88
+ copyFormConfig.fields = (_a = copyFormConfig.fields) === null || _a === void 0 ? void 0 : _a.filter(field => {
89
+ const def = this._dataUnit.getField(field.name);
73
90
  if (def === null || def === void 0 ? void 0 : def.readOnly) {
74
91
  return false;
75
92
  }
@@ -78,6 +95,17 @@ const SnkForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
78
95
  this._insertionFormConfig = copyFormConfig;
79
96
  }
80
97
  }
98
+ getFormConfig() {
99
+ return (this._dataState && this._dataState.insertionMode ? this._insertionFormConfig : this._editionFormConfig);
100
+ }
101
+ exitForm() {
102
+ if (this._dataUnit.isDirty()) {
103
+ this._dataUnit.cancelEdition({ after: () => this.exit.emit() });
104
+ }
105
+ else {
106
+ this.exit.emit();
107
+ }
108
+ }
81
109
  /**
82
110
  * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
83
111
  * através de um pequeno modulo na estrutura da aplicação:
@@ -94,6 +122,16 @@ const SnkForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
94
122
  changeConfig(config) {
95
123
  this.configChanged.emit(config);
96
124
  }
125
+ getDisabledButtons() {
126
+ const disabled = [];
127
+ if (!this._dataState.hasPrevious) {
128
+ disabled.push("PREVIOUS");
129
+ }
130
+ if (!this._dataState.hasNext) {
131
+ disabled.push("NEXT");
132
+ }
133
+ return disabled;
134
+ }
97
135
  componentDidRender() {
98
136
  ConfigurableElementsStorage.setForm(this.configName, this._element);
99
137
  }
@@ -10,7 +10,7 @@ const patchEsm = () => {
10
10
  const defineCustomElements = (win, options) => {
11
11
  if (typeof window === 'undefined') return Promise.resolve();
12
12
  return patchEsm().then(() => {
13
- return bootstrapLazy([["teste-pesquisa",[[1,"teste-pesquisa"]]],["snk-data-unit",[[2,"snk-data-unit",{"dataState":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"beforeSave":[16],"afterSave":[16],"getDataUnit":[64]}]]],["snk-filter-binary-select",[[0,"snk-filter-binary-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-multi-select",[[0,"snk-filter-multi-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-number",[[0,"snk-filter-number",{"config":[16],"value":[2],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-period",[[0,"snk-filter-period",{"config":[16],"value":[8],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-personalized",[[0,"snk-filter-personalized",{"config":[16],"value":[1040],"fix":[16],"unfix":[16],"show":[64]}]]],["snk-filter-search",[[0,"snk-filter-search",{"config":[16],"value":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-text",[[0,"snk-filter-text",{"config":[16],"value":[1]},[[0,"ezChange","ezChangeListener"]]]]],["snk-pesquisa",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-config-options",[[2,"snk-config-options",{"fieldConfig":[16],"idConfig":[513,"id-config"],"dataUnit":[16],"_defaultType":[32]}]]],["snk-tab-config",[[6,"snk-tab-config",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1],"_processedTabs":[32],"_activeEditText":[32],"_activeEditTextIndex":[32],"_actionsHide":[32],"_actionsShow":[32]}]]],["snk-filter-detail",[[0,"snk-filter-detail",{"config":[1040],"getMessage":[16],"show":[64]}]]],["snk-field-config_2",[[6,"snk-grid",{"configName":[1,"config-name"],"actionsList":[16],"taskbarManager":[16],"statusResolver":[16],"_dataUnit":[32],"_dataState":[32],"_gridConfig":[32],"setShowGridConfig":[64],"setConfig":[64]}],[2,"snk-field-config",{"isConfigActive":[16],"fieldConfig":[16],"modeInsertion":[516,"mode-insertion"],"dataUnit":[16]}]]],["snk-form-config",[[2,"snk-form-config",{"dataUnit":[16],"formConfig":[16],"parentForm":[16],"_formConfigOptions":[32],"_fieldConfigSelected":[32],"_layoutFormConfig":[32],"_fieldsAvailable":[32],"_formConfig":[32],"_formConfigChanged":[32],"_optionFormConfigSelected":[32],"_optionFormConfigChanged":[32],"_tempGroups":[32]}]]],["snk-config-modal",[[2,"snk-config-modal",{"configName":[1,"config-name"],"gridMode":[4,"grid-mode"]}]]],["snk-configurator_6",[[2,"snk-filter-bar",{"dataUnit":[1040],"configName":[1,"config-name"],"filterConfig":[1040],"allowDefault":[32]},[[0,"filterChange","filterChangeListener"]]],[6,"snk-taskbar",{"configName":[1,"config-name"],"buttons":[1],"customButtons":[16],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"_permissions":[32]}],[0,"snk-filter-item",{"config":[1040],"getMessage":[16],"detailIsVisible":[32],"showUp":[64],"hideDetail":[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]],[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"]]],[0,"snk-filter-modal",{"getMessage":[16],"items":[1040],"modalTitle":[1,"modal-title"],"modalSubTitle":[1,"modal-sub-title"],"cancelButtonLabel":[1,"cancel-button-label"],"okButtonLabel":[1,"ok-button-label"],"infoText":[1,"info-text"],"useSearch":[4,"use-search"],"processModalAction":[16],"_filterArgument":[32]}],[2,"snk-configurator",{"configName":[1,"config-name"],"name":[1],"enabled":[4]}]]],["snk-form",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[16],"actionsList":[16],"taskbarManager":[16],"_dataUnit":[32],"_dataState":[32],"_editionFormConfig":[32],"_insertionFormConfig":[32],"_showFormConfig":[32],"setShowFormConfig":[64],"setConfig":[64]}]]],["snk-crud",[[6,"snk-crud",{"configName":[1025,"config-name"],"actionsList":[16],"taskbarManager":[16],"recordsValidator":[16],"statusResolver":[16],"_dataUnit":[32],"_dataState":[32],"goToView":[64]}]]],["snk-application",[[2,"snk-application",{"messagesBuilder":[1040],"configName":[1,"config-name"],"isUserSup":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"showModal":[64],"closeModal":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getDataUnit":[64],"getResourceID":[64],"getUserID":[64],"alert":[64],"error":[64],"success":[64],"message":[64],"confirm":[64],"info":[64],"loadFormConfig":[64],"loadGridConfig":[64],"fetchUserAvailableConfigs":[64],"fetchLegacyConfig":[64],"fetchDefaultConfig":[64],"loadTotals":[64],"saveGridConfig":[64],"getFilterBarConfig":[64],"saveFilterBarConfig":[64],"saveFormConfig":[64],"executeSearch":[64],"executePreparedSearch":[64],"isDebugMode":[64]}]]]], options);
13
+ return bootstrapLazy([["teste-pesquisa",[[1,"teste-pesquisa"]]],["snk-data-unit",[[2,"snk-data-unit",{"dataState":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"beforeSave":[16],"afterSave":[16],"getDataUnit":[64]}]]],["snk-filter-binary-select",[[0,"snk-filter-binary-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-multi-select",[[0,"snk-filter-multi-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-number",[[0,"snk-filter-number",{"config":[16],"value":[2],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-period",[[0,"snk-filter-period",{"config":[16],"value":[8],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-personalized",[[0,"snk-filter-personalized",{"config":[16],"value":[1040],"fix":[16],"unfix":[16],"show":[64]}]]],["snk-filter-search",[[0,"snk-filter-search",{"config":[16],"value":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-text",[[0,"snk-filter-text",{"config":[16],"value":[1]},[[0,"ezChange","ezChangeListener"]]]]],["snk-pesquisa",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-config-options",[[2,"snk-config-options",{"fieldConfig":[16],"idConfig":[513,"id-config"],"dataUnit":[16],"_defaultType":[32]}]]],["snk-tab-config",[[6,"snk-tab-config",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1],"_processedTabs":[32],"_activeEditText":[32],"_activeEditTextIndex":[32],"_actionsHide":[32],"_actionsShow":[32]}]]],["snk-filter-detail",[[0,"snk-filter-detail",{"config":[1040],"getMessage":[16],"show":[64]}]]],["snk-field-config_2",[[6,"snk-grid",{"configName":[1,"config-name"],"actionsList":[16],"taskbarManager":[16],"statusResolver":[16],"_dataUnit":[32],"_dataState":[32],"_gridConfig":[32],"setShowGridConfig":[64],"setConfig":[64]}],[2,"snk-field-config",{"isConfigActive":[16],"fieldConfig":[16],"modeInsertion":[516,"mode-insertion"],"dataUnit":[16]}]]],["snk-form-config",[[2,"snk-form-config",{"dataUnit":[16],"formConfig":[16],"parentForm":[16],"_formConfigOptions":[32],"_fieldConfigSelected":[32],"_layoutFormConfig":[32],"_fieldsAvailable":[32],"_formConfig":[32],"_formConfigChanged":[32],"_optionFormConfigSelected":[32],"_optionFormConfigChanged":[32],"_tempGroups":[32]}]]],["snk-config-modal",[[2,"snk-config-modal",{"configName":[1,"config-name"],"gridMode":[4,"grid-mode"]}]]],["snk-configurator_6",[[2,"snk-filter-bar",{"dataUnit":[1040],"configName":[1,"config-name"],"filterConfig":[1040],"allowDefault":[32]},[[0,"filterChange","filterChangeListener"]]],[6,"snk-taskbar",{"configName":[1,"config-name"],"buttons":[1],"customButtons":[16],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"_permissions":[32]}],[0,"snk-filter-item",{"config":[1040],"getMessage":[16],"detailIsVisible":[32],"showUp":[64],"hideDetail":[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]],[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"]]],[0,"snk-filter-modal",{"getMessage":[16],"items":[1040],"modalTitle":[1,"modal-title"],"modalSubTitle":[1,"modal-sub-title"],"cancelButtonLabel":[1,"cancel-button-label"],"okButtonLabel":[1,"ok-button-label"],"infoText":[1,"info-text"],"useSearch":[4,"use-search"],"processModalAction":[16],"_filterArgument":[32]}],[2,"snk-configurator",{"configName":[1,"config-name"],"name":[1],"enabled":[4]}]]],["snk-form",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[16],"actionsList":[16],"taskbarManager":[16],"_dataUnit":[32],"_dataState":[32],"_editionFormConfig":[32],"_insertionFormConfig":[32],"_showFormConfig":[32],"setShowFormConfig":[64],"setConfig":[64]}]]],["snk-crud",[[6,"snk-crud",{"configName":[1025,"config-name"],"actionsList":[16],"taskbarManager":[16],"recordsValidator":[16],"statusResolver":[16],"_dataUnit":[32],"_dataState":[32],"goToView":[64]}]]],["snk-application",[[2,"snk-application",{"messagesBuilder":[1040],"configName":[1,"config-name"],"isUserSup":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"showModal":[64],"closeModal":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getDataUnit":[64],"getResourceID":[64],"getUserID":[64],"alert":[64],"error":[64],"success":[64],"message":[64],"confirm":[64],"info":[64],"loadFormConfig":[64],"loadGridConfig":[64],"fetchUserAvailableConfigs":[64],"fetchLegacyConfig":[64],"fetchDefaultConfig":[64],"loadTotals":[64],"saveGridConfig":[64],"getFilterBarConfig":[64],"saveFilterBarConfig":[64],"saveFormConfig":[64],"getDefaultValues":[64],"getDefaultValue":[64],"executeSearch":[64],"executePreparedSearch":[64],"isDebugMode":[64]}]]]], options);
14
14
  });
15
15
  };
16
16
 
@@ -13,5 +13,5 @@ const patchBrowser = () => {
13
13
  };
14
14
 
15
15
  patchBrowser().then(options => {
16
- return bootstrapLazy([["teste-pesquisa",[[1,"teste-pesquisa"]]],["snk-data-unit",[[2,"snk-data-unit",{"dataState":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"beforeSave":[16],"afterSave":[16],"getDataUnit":[64]}]]],["snk-filter-binary-select",[[0,"snk-filter-binary-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-multi-select",[[0,"snk-filter-multi-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-number",[[0,"snk-filter-number",{"config":[16],"value":[2],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-period",[[0,"snk-filter-period",{"config":[16],"value":[8],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-personalized",[[0,"snk-filter-personalized",{"config":[16],"value":[1040],"fix":[16],"unfix":[16],"show":[64]}]]],["snk-filter-search",[[0,"snk-filter-search",{"config":[16],"value":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-text",[[0,"snk-filter-text",{"config":[16],"value":[1]},[[0,"ezChange","ezChangeListener"]]]]],["snk-pesquisa",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-config-options",[[2,"snk-config-options",{"fieldConfig":[16],"idConfig":[513,"id-config"],"dataUnit":[16],"_defaultType":[32]}]]],["snk-tab-config",[[6,"snk-tab-config",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1],"_processedTabs":[32],"_activeEditText":[32],"_activeEditTextIndex":[32],"_actionsHide":[32],"_actionsShow":[32]}]]],["snk-filter-detail",[[0,"snk-filter-detail",{"config":[1040],"getMessage":[16],"show":[64]}]]],["snk-field-config_2",[[6,"snk-grid",{"configName":[1,"config-name"],"actionsList":[16],"taskbarManager":[16],"statusResolver":[16],"_dataUnit":[32],"_dataState":[32],"_gridConfig":[32],"setShowGridConfig":[64],"setConfig":[64]}],[2,"snk-field-config",{"isConfigActive":[16],"fieldConfig":[16],"modeInsertion":[516,"mode-insertion"],"dataUnit":[16]}]]],["snk-form-config",[[2,"snk-form-config",{"dataUnit":[16],"formConfig":[16],"parentForm":[16],"_formConfigOptions":[32],"_fieldConfigSelected":[32],"_layoutFormConfig":[32],"_fieldsAvailable":[32],"_formConfig":[32],"_formConfigChanged":[32],"_optionFormConfigSelected":[32],"_optionFormConfigChanged":[32],"_tempGroups":[32]}]]],["snk-config-modal",[[2,"snk-config-modal",{"configName":[1,"config-name"],"gridMode":[4,"grid-mode"]}]]],["snk-configurator_6",[[2,"snk-filter-bar",{"dataUnit":[1040],"configName":[1,"config-name"],"filterConfig":[1040],"allowDefault":[32]},[[0,"filterChange","filterChangeListener"]]],[6,"snk-taskbar",{"configName":[1,"config-name"],"buttons":[1],"customButtons":[16],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"_permissions":[32]}],[0,"snk-filter-item",{"config":[1040],"getMessage":[16],"detailIsVisible":[32],"showUp":[64],"hideDetail":[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]],[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"]]],[0,"snk-filter-modal",{"getMessage":[16],"items":[1040],"modalTitle":[1,"modal-title"],"modalSubTitle":[1,"modal-sub-title"],"cancelButtonLabel":[1,"cancel-button-label"],"okButtonLabel":[1,"ok-button-label"],"infoText":[1,"info-text"],"useSearch":[4,"use-search"],"processModalAction":[16],"_filterArgument":[32]}],[2,"snk-configurator",{"configName":[1,"config-name"],"name":[1],"enabled":[4]}]]],["snk-form",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[16],"actionsList":[16],"taskbarManager":[16],"_dataUnit":[32],"_dataState":[32],"_editionFormConfig":[32],"_insertionFormConfig":[32],"_showFormConfig":[32],"setShowFormConfig":[64],"setConfig":[64]}]]],["snk-crud",[[6,"snk-crud",{"configName":[1025,"config-name"],"actionsList":[16],"taskbarManager":[16],"recordsValidator":[16],"statusResolver":[16],"_dataUnit":[32],"_dataState":[32],"goToView":[64]}]]],["snk-application",[[2,"snk-application",{"messagesBuilder":[1040],"configName":[1,"config-name"],"isUserSup":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"showModal":[64],"closeModal":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getDataUnit":[64],"getResourceID":[64],"getUserID":[64],"alert":[64],"error":[64],"success":[64],"message":[64],"confirm":[64],"info":[64],"loadFormConfig":[64],"loadGridConfig":[64],"fetchUserAvailableConfigs":[64],"fetchLegacyConfig":[64],"fetchDefaultConfig":[64],"loadTotals":[64],"saveGridConfig":[64],"getFilterBarConfig":[64],"saveFilterBarConfig":[64],"saveFormConfig":[64],"executeSearch":[64],"executePreparedSearch":[64],"isDebugMode":[64]}]]]], options);
16
+ return bootstrapLazy([["teste-pesquisa",[[1,"teste-pesquisa"]]],["snk-data-unit",[[2,"snk-data-unit",{"dataState":[1040],"dataUnitName":[1,"data-unit-name"],"entityName":[1,"entity-name"],"pageSize":[2,"page-size"],"dataUnit":[1040],"beforeSave":[16],"afterSave":[16],"getDataUnit":[64]}]]],["snk-filter-binary-select",[[0,"snk-filter-binary-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-multi-select",[[0,"snk-filter-multi-select",{"value":[1544],"config":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-number",[[0,"snk-filter-number",{"config":[16],"value":[2],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-period",[[0,"snk-filter-period",{"config":[16],"value":[8],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-personalized",[[0,"snk-filter-personalized",{"config":[16],"value":[1040],"fix":[16],"unfix":[16],"show":[64]}]]],["snk-filter-search",[[0,"snk-filter-search",{"config":[16],"value":[16],"show":[64]},[[0,"ezChange","ezChangeListener"]]]]],["snk-filter-text",[[0,"snk-filter-text",{"config":[16],"value":[1]},[[0,"ezChange","ezChangeListener"]]]]],["snk-pesquisa",[[2,"snk-pesquisa",{"searchLoader":[16],"selectItem":[16],"argument":[1025],"_itemList":[32],"_startLoading":[32]}]]],["snk-config-options",[[2,"snk-config-options",{"fieldConfig":[16],"idConfig":[513,"id-config"],"dataUnit":[16],"_defaultType":[32]}]]],["snk-tab-config",[[6,"snk-tab-config",{"selectedIndex":[1538,"selected-index"],"selectedTab":[1537,"selected-tab"],"tabs":[1],"_processedTabs":[32],"_activeEditText":[32],"_activeEditTextIndex":[32],"_actionsHide":[32],"_actionsShow":[32]}]]],["snk-filter-detail",[[0,"snk-filter-detail",{"config":[1040],"getMessage":[16],"show":[64]}]]],["snk-field-config_2",[[6,"snk-grid",{"configName":[1,"config-name"],"actionsList":[16],"taskbarManager":[16],"statusResolver":[16],"_dataUnit":[32],"_dataState":[32],"_gridConfig":[32],"setShowGridConfig":[64],"setConfig":[64]}],[2,"snk-field-config",{"isConfigActive":[16],"fieldConfig":[16],"modeInsertion":[516,"mode-insertion"],"dataUnit":[16]}]]],["snk-form-config",[[2,"snk-form-config",{"dataUnit":[16],"formConfig":[16],"parentForm":[16],"_formConfigOptions":[32],"_fieldConfigSelected":[32],"_layoutFormConfig":[32],"_fieldsAvailable":[32],"_formConfig":[32],"_formConfigChanged":[32],"_optionFormConfigSelected":[32],"_optionFormConfigChanged":[32],"_tempGroups":[32]}]]],["snk-config-modal",[[2,"snk-config-modal",{"configName":[1,"config-name"],"gridMode":[4,"grid-mode"]}]]],["snk-configurator_6",[[2,"snk-filter-bar",{"dataUnit":[1040],"configName":[1,"config-name"],"filterConfig":[1040],"allowDefault":[32]},[[0,"filterChange","filterChangeListener"]]],[6,"snk-taskbar",{"configName":[1,"config-name"],"buttons":[1],"customButtons":[16],"actionsList":[16],"primaryButton":[1,"primary-button"],"disabledButtons":[16],"dataUnit":[16],"_permissions":[32]}],[0,"snk-filter-item",{"config":[1040],"getMessage":[16],"detailIsVisible":[32],"showUp":[64],"hideDetail":[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]],[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"]]],[0,"snk-filter-modal",{"getMessage":[16],"items":[1040],"modalTitle":[1,"modal-title"],"modalSubTitle":[1,"modal-sub-title"],"cancelButtonLabel":[1,"cancel-button-label"],"okButtonLabel":[1,"ok-button-label"],"infoText":[1,"info-text"],"useSearch":[4,"use-search"],"processModalAction":[16],"_filterArgument":[32]}],[2,"snk-configurator",{"configName":[1,"config-name"],"name":[1],"enabled":[4]}]]],["snk-form",[[2,"snk-form",{"configName":[1,"config-name"],"recordsValidator":[16],"actionsList":[16],"taskbarManager":[16],"_dataUnit":[32],"_dataState":[32],"_editionFormConfig":[32],"_insertionFormConfig":[32],"_showFormConfig":[32],"setShowFormConfig":[64],"setConfig":[64]}]]],["snk-crud",[[6,"snk-crud",{"configName":[1025,"config-name"],"actionsList":[16],"taskbarManager":[16],"recordsValidator":[16],"statusResolver":[16],"_dataUnit":[32],"_dataState":[32],"goToView":[64]}]]],["snk-application",[[2,"snk-application",{"messagesBuilder":[1040],"configName":[1,"config-name"],"isUserSup":[64],"hasAccess":[64],"getAllAccess":[64],"getStringParam":[64],"getIntParam":[64],"getFloatParam":[64],"getBooleanParam":[64],"getDateParam":[64],"showPopUp":[64],"showModal":[64],"closeModal":[64],"closePopUp":[64],"temOpcional":[64],"getConfig":[64],"saveConfig":[64],"getAttributeFromHTMLWrapper":[64],"openApp":[64],"createDataunit":[64],"getDataUnit":[64],"getResourceID":[64],"getUserID":[64],"alert":[64],"error":[64],"success":[64],"message":[64],"confirm":[64],"info":[64],"loadFormConfig":[64],"loadGridConfig":[64],"fetchUserAvailableConfigs":[64],"fetchLegacyConfig":[64],"fetchDefaultConfig":[64],"loadTotals":[64],"saveGridConfig":[64],"getFilterBarConfig":[64],"saveFilterBarConfig":[64],"saveFormConfig":[64],"getDefaultValues":[64],"getDefaultValue":[64],"executeSearch":[64],"executePreparedSearch":[64],"isDebugMode":[64]}]]]], options);
17
17
  });
@@ -670,6 +670,23 @@ class FilterBarConfigFetcher extends ResourceFetcher {
670
670
  }
671
671
  }
672
672
 
673
+ class DefaultValuesFetcher extends ResourceFetcher {
674
+ getDefaultValues(resourceID) {
675
+ return new Promise((resolve, reject) => {
676
+ this.loadResource(`cfg://defaultValues/${resourceID}`)
677
+ .then(loadedResource => {
678
+ let value;
679
+ if (loadedResource) {
680
+ value = JSON.parse(loadedResource);
681
+ }
682
+ resolve(value);
683
+ }).catch((error) => {
684
+ reject(error);
685
+ });
686
+ });
687
+ }
688
+ }
689
+
673
690
  const snkApplicationCss = ".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";
674
691
 
675
692
  const SnkApplication = class {
@@ -1076,6 +1093,18 @@ const SnkApplication = class {
1076
1093
  async saveFormConfig(config, name) {
1077
1094
  return this.formConfigFetcher.saveConfig(config, name, this.resourceID);
1078
1095
  }
1096
+ /**
1097
+ * Busca um objeto com um conjunto de valores padrão.
1098
+ */
1099
+ async getDefaultValues() {
1100
+ return this.defaultValuesFetcher.getDefaultValues(this.resourceID);
1101
+ }
1102
+ /**
1103
+ * Retorna um valor padrão específico de uma expressão.
1104
+ */
1105
+ async getDefaultValue(expression) {
1106
+ return this._defaultValues && this._defaultValues[expression];
1107
+ }
1079
1108
  async getAuthList(_auth) {
1080
1109
  return await (new MGEAuthorization()).parseFromJSON(_auth);
1081
1110
  }
@@ -1127,6 +1156,12 @@ const SnkApplication = class {
1127
1156
  }
1128
1157
  return this._filterBarConfigFetcher;
1129
1158
  }
1159
+ get defaultValuesFetcher() {
1160
+ if (!this._defaultValuesFetcher) {
1161
+ this._defaultValuesFetcher = new DefaultValuesFetcher();
1162
+ }
1163
+ return this._defaultValuesFetcher;
1164
+ }
1130
1165
  async executeSearch(searchArgument, fieldName, dataUnit) {
1131
1166
  const descriptor = dataUnit === null || dataUnit === void 0 ? void 0 : dataUnit.getField(fieldName);
1132
1167
  if (!descriptor) ;
@@ -1221,6 +1256,9 @@ const SnkApplication = class {
1221
1256
  });
1222
1257
  }
1223
1258
  ErrorTracking.init();
1259
+ this.getDefaultValues().then((defaultValues) => {
1260
+ this._defaultValues = defaultValues;
1261
+ });
1224
1262
  }
1225
1263
  connectedCallback() {
1226
1264
  ApplicationContext.setContextValue("__SNK__APPLICATION__", this);
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, c as createEvent, h, g as getElement } from './index-e4121713.js';
2
- import { ObjectUtils, ApplicationContext } from '@sankhyalabs/core';
2
+ import { DateUtils, ObjectUtils, ApplicationContext } from '@sankhyalabs/core';
3
3
  import { C as ConfigurableElementsStorage } from './configurableElementsStorage-cdc144b5.js';
4
4
  import { T as TaskbarProcessor } from './taskbar-processor-aa6772c9.js';
5
5
 
@@ -31,38 +31,55 @@ const SnkForm = class {
31
31
  */
32
32
  async setConfig(config) {
33
33
  this._editionFormConfig = {};
34
- setTimeout(() => {
35
- this._editionFormConfig = config != undefined ? config : {};
34
+ if (!this.loadConfig(config)) {
36
35
  this.loadInsertionConfig();
37
- }, this._renderTimer);
38
- }
39
- getFormConfig() {
40
- return (this._dataState && this._dataState.insertionMode ? this._insertionFormConfig : this._editionFormConfig);
41
- }
42
- exitForm() {
43
- if (this._dataUnit.isDirty()) {
44
- this._dataUnit.cancelEdition({ after: () => this.exit.emit() });
45
- }
46
- else {
47
- this.exit.emit();
48
36
  }
49
37
  }
50
- getDisabledButtons() {
51
- const disabled = [];
52
- if (!this._dataState.hasPrevious) {
53
- disabled.push("PREVIOUS");
38
+ loadConfig(config) {
39
+ if ((config === null || config === void 0 ? void 0 : config.fields) == undefined) {
40
+ return false;
54
41
  }
55
- if (!this._dataState.hasNext) {
56
- disabled.push("NEXT");
42
+ setTimeout(async () => {
43
+ for (const field of config.fields) {
44
+ if (field.defaultValue && "value" in field.defaultValue) {
45
+ const value = field.defaultValue.value;
46
+ await this.getFormattedValue(value)
47
+ .then((formattedValue) => {
48
+ field.defaultValue.formattedValue = formattedValue;
49
+ });
50
+ }
51
+ }
52
+ this._editionFormConfig = config;
53
+ this.loadInsertionConfig();
54
+ }, this._renderTimer);
55
+ return true;
56
+ }
57
+ async getFormattedValue(value) {
58
+ switch (value) {
59
+ case "${data}":
60
+ return () => DateUtils.getToday();
61
+ case "${datahora}":
62
+ return () => DateUtils.getToday(true);
63
+ case "${usuario}":
64
+ case "${usuario.empresa}":
65
+ case "${usuario.vendedor}":
66
+ case "${usuario.centroresultado}":
67
+ let fieldValue;
68
+ await this._application.getDefaultValue(value)
69
+ .then((defaultValue) => {
70
+ fieldValue = defaultValue;
71
+ });
72
+ return fieldValue;
73
+ default:
74
+ return value;
57
75
  }
58
- return disabled;
59
76
  }
60
77
  loadInsertionConfig() {
61
78
  var _a;
62
79
  if (this._dataUnit) {
63
80
  const copyFormConfig = ObjectUtils.copy(this._editionFormConfig || {});
64
- copyFormConfig.fields = (_a = copyFormConfig.fields) === null || _a === void 0 ? void 0 : _a.filter(fieldCfg => {
65
- const def = this._dataUnit.getField(fieldCfg.name);
81
+ copyFormConfig.fields = (_a = copyFormConfig.fields) === null || _a === void 0 ? void 0 : _a.filter(field => {
82
+ const def = this._dataUnit.getField(field.name);
66
83
  if (def === null || def === void 0 ? void 0 : def.readOnly) {
67
84
  return false;
68
85
  }
@@ -71,6 +88,17 @@ const SnkForm = class {
71
88
  this._insertionFormConfig = copyFormConfig;
72
89
  }
73
90
  }
91
+ getFormConfig() {
92
+ return (this._dataState && this._dataState.insertionMode ? this._insertionFormConfig : this._editionFormConfig);
93
+ }
94
+ exitForm() {
95
+ if (this._dataUnit.isDirty()) {
96
+ this._dataUnit.cancelEdition({ after: () => this.exit.emit() });
97
+ }
98
+ else {
99
+ this.exit.emit();
100
+ }
101
+ }
74
102
  /**
75
103
  * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
76
104
  * através de um pequeno modulo na estrutura da aplicação:
@@ -87,6 +115,16 @@ const SnkForm = class {
87
115
  changeConfig(config) {
88
116
  this.configChanged.emit(config);
89
117
  }
118
+ getDisabledButtons() {
119
+ const disabled = [];
120
+ if (!this._dataState.hasPrevious) {
121
+ disabled.push("PREVIOUS");
122
+ }
123
+ if (!this._dataState.hasNext) {
124
+ disabled.push("NEXT");
125
+ }
126
+ return disabled;
127
+ }
90
128
  componentDidRender() {
91
129
  ConfigurableElementsStorage.setForm(this.configName, this._element);
92
130
  }
@@ -72,4 +72,4 @@ import{r as t,c as e,h as s}from"./p-9ba3df4c.js";import{WaitingChangeException
72
72
  name
73
73
  resource
74
74
  }
75
- }`)}async getParam(t){const e=`param://application?params=${t}`;return y.get().callGraphQL({values:{name:e},query:this.templateByQuery.get("fetchParam")})}async asString(t){const e=await this.getParam(t);return this.getValue(e)}async asInteger(t){const e=await this.getParam(t);return parseInt(this.getValue(e))}async asFloat(t){const e=await this.getParam(t);return parseFloat(this.getValue(e))}async asBoolean(t){const e=await this.getParam(t);return this.getValue(e).includes('"S"')}async asDate(t){const e=await this.getParam(t);return l.strToDate(this.getValue(e))}async getBatchParams(t){const e=await this.getParam(t.join(",")),s={};return e.forEach((t=>s[t.name]=t.resource)),s}getValue(t={}){return Array.isArray(t)&&t.length>0&&(t=t[0]),h.isEmpty(t.resource)?"":t.resource}}const U=O;function O(t,e){const s=F();return(O=function(t){return s[t-=378]})(t,e)}function F(){const t=["true","863GKWjmo","parse","56355fjjjAm","isSup","putAccess","4324480sjuCdS","hasOwnProperty","239748okvJLB","name","6055770tXeRaU","actions","forEach","7RPRvzn","1042CHxkUw","2988126NIwRMm","20MTNzmH","authorizationSf","item","string","hasAccess","isArray","Objeto não pode ser indefinido.","3071943fWslZp","parseFromJSON"];return(F=function(){return t})()}!function(){const t=O,e=F();for(;;)try{if(281287==parseInt(t(399))/1*(-parseInt(t(387))/2)+-parseInt(t(401))/3+parseInt(t(381))/4*(-parseInt(t(389))/5)+parseInt(t(388))/6*(-parseInt(t(386))/7)+parseInt(t(379))/8+parseInt(t(396))/9+parseInt(t(383))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class R{[U(397)](t){const e=U;if(typeof(t=utxt(t[e(390)]))==e(392)&&(t=JSON[e(400)](t)),null==t)throw Error(e(395));const s=new L("S"===t[e(402)]||!0===t[e(402)]);return Array[e(394)](t[e(391)])&&t[e(391)][e(385)]((t=>s.putAccess(t[e(382)],String(t.status)==e(398)))),s}}class L{constructor(t){const e=U;this.isSup=t,this[e(384)]={}}[U(378)](t,e){this[U(384)][t]=e}[U(393)](t){const e=U;if(this[e(402)])return!0;let s=!0;return this[e(384)][e(380)](t)&&(s=this.actions[t]),s}isUserSup(){return this.isSup}}class j extends g{constructor(){super(...arguments),this.GRID_CONFIG_VERSION="V3:"}getConfig(t,e){const s=`cfg://grid/${this.GRID_CONFIG_VERSION}${e}`;return new Promise(((t,e)=>{this.loadResource(s).then((e=>{let s;e&&(s=JSON.parse(e)),t(s)})).catch((t=>{e(t)}))}))}saveConfig(t,e){const s=`cfg://grid/${this.GRID_CONFIG_VERSION}${e}`;return new Promise(((e,i)=>{this.saveResource(t,s).then((t=>{e(t)})).catch((t=>{i(t)}))}))}}class k extends g{getData(t){const e=`cfg://auth/${t}`;return new Promise(((t,s)=>{this.loadResource(e).then((e=>{let s=a.stringToObject(e);s&&"object"==typeof s&&t(s)})).catch((t=>{s(t)}))}))}}var M;function x(t){if(null==t)return t;if(t instanceof Date)return t.toISOString();if("object"==typeof t){if(t instanceof Array)return t.map((t=>x(t)));{const e=Object.assign({},t);return Object.keys(t).forEach((s=>{t[s]?e[s]=x(t[s]):delete e[s]})),e}}return t}!function(t){t.INSERT="I",t.UPDATE="A",t.REMOVE="E",t.SHOW="C",t.CONFIG="F",t.CONFIG_NUMBER="N",t.CLONE="D",t.CONFIG_GRID="G"}(M||(M={}));class B extends g{saveConfig(t,e,s){const i=t.map((t=>{const{id:e,value:s,fixed:i,visible:r}=t,n={id:e};return s&&(n.value=x(s)),i&&(n.fixed=i),r&&(n.visible=!0),n}));return this.saveResource(i,`cfg://filter/FilterBarState:${e}/${s}`)}getConfig(t,e){return new Promise(((s,i)=>{this.loadResource(`cfg://filter/FilterBarState:${t}/${e}`).then((t=>{let e;t&&(e=JSON.parse(t).items),s(e||[])})).catch((t=>{i(t)}))}))}}const z=class{constructor(s){t(this,s),this.applicationLoaded=e(this,"applicationLoaded",7),this.applicationLoading=e(this,"applicationLoading",7),this._authPromises=[],this._duCache=new Map,this._duPromises=new Map,this._requestListener=new J}get parameters(){return this._parameters||(this._parameters=new b),this._parameters}get resourceID(){return this._resourceID||(this._resourceID=this.urlParams.get("workspaceResourceID")||this.urlParams.get("resourceID")||q.resourceID||"unknown.resource.id"),this._resourceID}get auth(){return this._auth?Promise.resolve(this._auth):new Promise(((t,e)=>{const s=this._authPromises.length>0;this._authPromises.push(new G(t,e)),s||this.authFetcher.getData(this.resourceID).then((t=>{for(this._auth=t;this._authPromises.length>0;)this._authPromises.pop().resolve(this._auth)})).catch((t=>{for(;this._authPromises.length>0;)this._authPromises.pop().reject(t)}))}))}async isUserSup(){return new Promise(((t,e)=>{this.auth.then((s=>{this.getAuthList(s).then((e=>{t(e.isSup)})).catch((t=>e(t)))}))}))}async hasAccess(t){return new Promise(((e,s)=>{this.auth.then((i=>{this.getAuthList(i).then((s=>{e(s.isSup||s.actions[t])})).catch((t=>s(t)))}))}))}async getAllAccess(){return new Promise(((t,e)=>{this.auth.then((s=>{this.getAuthList(s).then((e=>{const s={};s.isSup=e.isSup,Object.entries(M).forEach((t=>{s[t[0]]=e.actions[t[1]]||!1})),t(s)})).catch((t=>e(t)))}))}))}async getStringParam(t){return this.parameters.asString(t)}async getIntParam(t){return this.parameters.asInteger(t)}async getFloatParam(t){return this.parameters.asFloat(t)}async getBooleanParam(t){return this.parameters.asBoolean(t)}async getDateParam(t){return this.parameters.asDate(t)}async showPopUp(t,e="full"){this.clearContent(this._popUp),"EZ-MODAL-CONTAINER"===t.tagName&&(this._popUp.useHeader=!1),this._popUp.appendChild(t),this._popUp.opened=!0,this._popUp.heightMode=e}async showModal(t){this.clearContent(this._rightModal),this._rightModal.appendChild(t),this._rightModal.opened=!0}async closeModal(){this.clearContent(this._rightModal),this._rightModal.opened=!1}async closePopUp(){this.clearContent(this._popUp),this._popUp.opened=!1,this._popUp.useHeader=!0,this._popUp.heightMode="full"}async temOpcional(t){const e=t.split(",");return new Promise(((t,s)=>{this.getAttributeFromHTMLWrapper("opc0009").then((i=>{"1"===i?t(!0):Promise.all(e.map((t=>this.getAttributeFromHTMLWrapper("opc"+t)))).then((e=>{t(e.includes("1"))})).catch((t=>{s(t)}))})).catch((t=>{s(t)}))}))}async getConfig(t){let e={serviceName:"SystemUtilsSP.getConf",requestBody:{config:{chave:t,tipo:"T"}}};return new Promise(((t,s)=>{y.get().callServiceBroker("SystemUtilsSP.getConf",JSON.stringify(e)).then((e=>{var s;return t(null===(s=e.config)||void 0===s?void 0:s.data)})).catch((t=>s(t)))}))}async saveConfig(t,e){let s={serviceName:"SystemUtilsSP.saveConf",requestBody:{config:{chave:t,tipo:"T",data:e}}};return new Promise(((t,e)=>{y.get().callServiceBroker("SystemUtilsSP.saveConf",JSON.stringify(s)).then((e=>t(e))).catch((t=>e(t)))}))}async getAttributeFromHTMLWrapper(t){return Promise.resolve(window[t])}async openApp(t,e){q.openAppActivity(t,e)}getDuPromissesStack(t){let e;return t&&(e=this._duPromises.get(t),e||(e=[],this._duPromises.set(t,e))),e||[]}async createDataunit(t,e){return new Promise(((s,i)=>{const r=this.getDuPromissesStack(e),n=r.length>0;if(r.push(new G(s,i)),!n){const s=this.dataUnitFetcher.getDataUnit(t,this.resourceID);s.loadMetadata().then((()=>{for(e&&this._duCache.set(e,s);r.length>0;)r.pop().resolve(s)})).catch((t=>{for(;r.length>0;)r.pop().reject(t)}))}}))}async getDataUnit(t,e){return new Promise(((s,i)=>{const r=this._duCache.get(e);r?s(r):this.createDataunit(t,e).then((t=>{s(t)})).catch((t=>i(t)))}))}async getResourceID(){return Promise.resolve(this.resourceID)}async getUserID(){return Promise.resolve(window.UID)}async alert(t,e,s,i){return I.alert(t,e,s,i)}async error(t,e,s,i){return I.error(t,e,s,i)}async success(t,e,s,i){return I.success(t,e,s,i)}async message(t,e,s,i){return I.message(t,e,s,i)}async confirm(t,e,s,i,r){return I.confirm(t,e,s,i,r)}async info(t,e){return I.info(t,e)}async loadFormConfig(t){return this.formConfigFetcher.loadFormConfig(t,this.resourceID)}async loadGridConfig(t){return this.gridConfigFetcher.getConfig(t,this.resourceID)}async fetchUserAvailableConfigs(t){return this.formConfigFetcher.fetchUserAvailableConfigs(t,this.resourceID)}async fetchLegacyConfig(t){return this.formConfigFetcher.fetchLegacyConfig(t,this.resourceID)}async fetchDefaultConfig(t){return this.formConfigFetcher.fetchDefaultConfig(t,this.resourceID)}async loadTotals(t,e,s){return this.totalsFetcher.fetchTotals(t,e,s)}async saveGridConfig(t){return this.gridConfigFetcher.saveConfig(t,this.resourceID)}async getFilterBarConfig(t){return new Promise(((e,s)=>{this.configName===t&&this._filterBarConfig?e(this._filterBarConfig):this.configName===t&&null!=this._filterConfigPromise?Promise.all([this._filterConfigPromise]).then((t=>e(t[0]))).catch((t=>s(t[0]))):this.filterBarConfigFetcher.getConfig(this.resourceID,t).then((t=>e(t))).catch((t=>s(t)))}))}async saveFilterBarConfig(t,e){return this.filterBarConfigFetcher.saveConfig(t,this.resourceID,e)}async saveFormConfig(t,e){return this.formConfigFetcher.saveConfig(t,e,this.resourceID)}async getAuthList(t){return await(new R).parseFromJSON(t)}get urlParams(){return this._urlParams||(this._urlParams=v.getQueryParams(location.search)),this._urlParams}get dataUnitFetcher(){return this._dataUnitFetcher||(this._dataUnitFetcher=new N),this._dataUnitFetcher}get formConfigFetcher(){return this._formConfigFetcher||(this._formConfigFetcher=new w),this._formConfigFetcher}get gridConfigFetcher(){return this._gridConfigFetcher||(this._gridConfigFetcher=new j),this._gridConfigFetcher}get totalsFetcher(){return this._totalsFetcher||(this._totalsFetcher=new T),this._totalsFetcher}get pesquisaFetcher(){return this._pesquisaFetcher||(this._pesquisaFetcher=new _),this._pesquisaFetcher}get authFetcher(){return this._authFetcher||(this._authFetcher=new k),this._authFetcher}get filterBarConfigFetcher(){return this._filterBarConfigFetcher||(this._filterBarConfigFetcher=new B),this._filterBarConfigFetcher}async executeSearch(t,e,s){const i=null==s?void 0:s.getField(e);if(i){const{mode:e,argument:r}=t,{ENTITYNAME:n,CODEFIELD:a,DESCRIPTIONFIELD:c,ROOTENTITY:h,DESCRIPTIONENTITY:u}=i.properties,l=i.dependencies;let p;const m={rootEntity:h,descriptionFieldName:c,codeFieldName:a,showInactives:!1};return null==l||l.filter((t=>{var e;return null===(e=t.masterFields)||void 0===e?void 0:e.every((t=>{var e;return null===(e=s.getField(t))||void 0===e?void 0:e.visible}))})).forEach((t=>{var e;t.type===d.SEARCHING&&(null===(e=t.masterFields)||void 0===e?void 0:e.length)>0&&(p={expression:t.expression,params:t.masterFields.map((t=>{const e=s.getField(t),i=(null==e?void 0:e.dataType)||o.TEXT,r=s.getFieldValue(t);if(null==r)throw this.alert("Erro ao pesquisar",`É necessario informar o campo ${e.label} para executar a pesquisa.`),new Error(`É necessario informar o campo ${e.label} para executar a pesquisa.`);return{name:t,value:r,dataType:i}}))})})),this.executePreparedSearch(e,r,{entity:n,entityDescription:u,criteria:p,searchOptions:m})}}async executePreparedSearch(t,e,s){const{entity:i,entityDescription:r,criteria:n,searchOptions:a}=s;return"ADVANCED"===t?new Promise((t=>{const s=document.createElement("snk-pesquisa");s.argument=e,s.searchLoader=t=>this.pesquisaFetcher.loadAdvancedSearch(i,t,n,a),s.selectItem=e=>{t(e),this.clearPopUpTitle(),this.closePopUp()},this.setPopUpTitle(r),this.showPopUp(s)})):this.pesquisaFetcher.loadSearchOptions(i,e,n,a)}async isDebugMode(){return new Promise((t=>{t(window.isDebugMode)}))}clearContent(t){t&&Array.from(t.children).forEach((e=>{t.removeChild(e)}))}clearPopUpTitle(){this._popUp.ezTitle=""}setPopUpTitle(t){this._popUp.ezTitle=t}componentWillLoad(){this._errorHandler=new $(this),this.messagesBuilder=new P,p.setContextValue("__EZUI__UPLOAD__ADD__URL__",`${v.getUrlBase()}/mge/upload/file`),p.setContextValue("__EZUI__SEARCH__OPTION__LOADER__",((t,e,s)=>this.executeSearch(t,e,s))),p.setContextValue("__EZUI__GRID_LICENSE__",A),this.configName&&(this._filterConfigPromise=new Promise(((t,e)=>{this.filterBarConfigFetcher.getConfig(this.resourceID,this.configName).then((e=>{this._filterBarConfig=e,t(e)})).catch((t=>e(t)))}))),m.init()}connectedCallback(){p.setContextValue("__SNK__APPLICATION__",this),y.addRequestListener(this._requestListener)}disconnectedCallback(){y.removeRequestListener(this._requestListener)}componentDidLoad(){this.applicationLoading.emit(!0),window.requestAnimationFrame((()=>{this.applicationLoaded.emit(!0)}))}render(){return s("div",null,s("ez-loading-bar",{ref:t=>this._requestListener.loadingBar=t}),s("ez-popup",{opened:!1,ref:t=>this._popUp=t,onEzClosePopup:()=>this.closePopUp()}),s("ez-modal",{opened:!1,ref:t=>this._rightModal=t,"modal-size":"col col--sd-3",closeOutsideClick:!0,closeEsc:!0}))}};class J{constructor(){this._debounceTime=1e3,this._ignoredNameTypes=["totals"],this._countRequest=0}onRequestStart(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest++,this.loadingBar.show(),this._timerLoading&&clearTimeout(this._timerLoading))}onRequestEnd(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest--,this._timerLoading=setTimeout((()=>{this._countRequest<=0&&this.loadingBar.hide()}),this._debounceTime))}isIgnoreLoadingOnRequest(t){var e;if(1==(null===(e=null==t?void 0:t.requestBody)||void 0===e?void 0:e.length)){const{name:e}=t.requestBody[0].variables;if(e){const t=e.split(":");return this._ignoredNameTypes.indexOf(t[0])>=0}}return!1}}class G{constructor(t,e){this.resolve=t,this.reject=e}}z.style=".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";export{z as snk_application}
75
+ }`)}async getParam(t){const e=`param://application?params=${t}`;return y.get().callGraphQL({values:{name:e},query:this.templateByQuery.get("fetchParam")})}async asString(t){const e=await this.getParam(t);return this.getValue(e)}async asInteger(t){const e=await this.getParam(t);return parseInt(this.getValue(e))}async asFloat(t){const e=await this.getParam(t);return parseFloat(this.getValue(e))}async asBoolean(t){const e=await this.getParam(t);return this.getValue(e).includes('"S"')}async asDate(t){const e=await this.getParam(t);return l.strToDate(this.getValue(e))}async getBatchParams(t){const e=await this.getParam(t.join(",")),s={};return e.forEach((t=>s[t.name]=t.resource)),s}getValue(t={}){return Array.isArray(t)&&t.length>0&&(t=t[0]),h.isEmpty(t.resource)?"":t.resource}}const O=U;function U(t,e){const s=F();return(U=function(t){return s[t-=378]})(t,e)}function F(){const t=["true","863GKWjmo","parse","56355fjjjAm","isSup","putAccess","4324480sjuCdS","hasOwnProperty","239748okvJLB","name","6055770tXeRaU","actions","forEach","7RPRvzn","1042CHxkUw","2988126NIwRMm","20MTNzmH","authorizationSf","item","string","hasAccess","isArray","Objeto não pode ser indefinido.","3071943fWslZp","parseFromJSON"];return(F=function(){return t})()}!function(){const t=U,e=F();for(;;)try{if(281287==parseInt(t(399))/1*(-parseInt(t(387))/2)+-parseInt(t(401))/3+parseInt(t(381))/4*(-parseInt(t(389))/5)+parseInt(t(388))/6*(-parseInt(t(386))/7)+parseInt(t(379))/8+parseInt(t(396))/9+parseInt(t(383))/10)break;e.push(e.shift())}catch(t){e.push(e.shift())}}();class R{[O(397)](t){const e=O;if(typeof(t=utxt(t[e(390)]))==e(392)&&(t=JSON[e(400)](t)),null==t)throw Error(e(395));const s=new L("S"===t[e(402)]||!0===t[e(402)]);return Array[e(394)](t[e(391)])&&t[e(391)][e(385)]((t=>s.putAccess(t[e(382)],String(t.status)==e(398)))),s}}class L{constructor(t){const e=O;this.isSup=t,this[e(384)]={}}[O(378)](t,e){this[O(384)][t]=e}[O(393)](t){const e=O;if(this[e(402)])return!0;let s=!0;return this[e(384)][e(380)](t)&&(s=this.actions[t]),s}isUserSup(){return this.isSup}}class j extends g{constructor(){super(...arguments),this.GRID_CONFIG_VERSION="V3:"}getConfig(t,e){const s=`cfg://grid/${this.GRID_CONFIG_VERSION}${e}`;return new Promise(((t,e)=>{this.loadResource(s).then((e=>{let s;e&&(s=JSON.parse(e)),t(s)})).catch((t=>{e(t)}))}))}saveConfig(t,e){const s=`cfg://grid/${this.GRID_CONFIG_VERSION}${e}`;return new Promise(((e,i)=>{this.saveResource(t,s).then((t=>{e(t)})).catch((t=>{i(t)}))}))}}class k extends g{getData(t){const e=`cfg://auth/${t}`;return new Promise(((t,s)=>{this.loadResource(e).then((e=>{let s=a.stringToObject(e);s&&"object"==typeof s&&t(s)})).catch((t=>{s(t)}))}))}}var M;function x(t){if(null==t)return t;if(t instanceof Date)return t.toISOString();if("object"==typeof t){if(t instanceof Array)return t.map((t=>x(t)));{const e=Object.assign({},t);return Object.keys(t).forEach((s=>{t[s]?e[s]=x(t[s]):delete e[s]})),e}}return t}!function(t){t.INSERT="I",t.UPDATE="A",t.REMOVE="E",t.SHOW="C",t.CONFIG="F",t.CONFIG_NUMBER="N",t.CLONE="D",t.CONFIG_GRID="G"}(M||(M={}));class B extends g{saveConfig(t,e,s){const i=t.map((t=>{const{id:e,value:s,fixed:i,visible:r}=t,n={id:e};return s&&(n.value=x(s)),i&&(n.fixed=i),r&&(n.visible=!0),n}));return this.saveResource(i,`cfg://filter/FilterBarState:${e}/${s}`)}getConfig(t,e){return new Promise(((s,i)=>{this.loadResource(`cfg://filter/FilterBarState:${t}/${e}`).then((t=>{let e;t&&(e=JSON.parse(t).items),s(e||[])})).catch((t=>{i(t)}))}))}}class z extends g{getDefaultValues(t){return new Promise(((e,s)=>{this.loadResource(`cfg://defaultValues/${t}`).then((t=>{let s;t&&(s=JSON.parse(t)),e(s)})).catch((t=>{s(t)}))}))}}const J=class{constructor(s){t(this,s),this.applicationLoaded=e(this,"applicationLoaded",7),this.applicationLoading=e(this,"applicationLoading",7),this._authPromises=[],this._duCache=new Map,this._duPromises=new Map,this._requestListener=new V}get parameters(){return this._parameters||(this._parameters=new b),this._parameters}get resourceID(){return this._resourceID||(this._resourceID=this.urlParams.get("workspaceResourceID")||this.urlParams.get("resourceID")||q.resourceID||"unknown.resource.id"),this._resourceID}get auth(){return this._auth?Promise.resolve(this._auth):new Promise(((t,e)=>{const s=this._authPromises.length>0;this._authPromises.push(new G(t,e)),s||this.authFetcher.getData(this.resourceID).then((t=>{for(this._auth=t;this._authPromises.length>0;)this._authPromises.pop().resolve(this._auth)})).catch((t=>{for(;this._authPromises.length>0;)this._authPromises.pop().reject(t)}))}))}async isUserSup(){return new Promise(((t,e)=>{this.auth.then((s=>{this.getAuthList(s).then((e=>{t(e.isSup)})).catch((t=>e(t)))}))}))}async hasAccess(t){return new Promise(((e,s)=>{this.auth.then((i=>{this.getAuthList(i).then((s=>{e(s.isSup||s.actions[t])})).catch((t=>s(t)))}))}))}async getAllAccess(){return new Promise(((t,e)=>{this.auth.then((s=>{this.getAuthList(s).then((e=>{const s={};s.isSup=e.isSup,Object.entries(M).forEach((t=>{s[t[0]]=e.actions[t[1]]||!1})),t(s)})).catch((t=>e(t)))}))}))}async getStringParam(t){return this.parameters.asString(t)}async getIntParam(t){return this.parameters.asInteger(t)}async getFloatParam(t){return this.parameters.asFloat(t)}async getBooleanParam(t){return this.parameters.asBoolean(t)}async getDateParam(t){return this.parameters.asDate(t)}async showPopUp(t,e="full"){this.clearContent(this._popUp),"EZ-MODAL-CONTAINER"===t.tagName&&(this._popUp.useHeader=!1),this._popUp.appendChild(t),this._popUp.opened=!0,this._popUp.heightMode=e}async showModal(t){this.clearContent(this._rightModal),this._rightModal.appendChild(t),this._rightModal.opened=!0}async closeModal(){this.clearContent(this._rightModal),this._rightModal.opened=!1}async closePopUp(){this.clearContent(this._popUp),this._popUp.opened=!1,this._popUp.useHeader=!0,this._popUp.heightMode="full"}async temOpcional(t){const e=t.split(",");return new Promise(((t,s)=>{this.getAttributeFromHTMLWrapper("opc0009").then((i=>{"1"===i?t(!0):Promise.all(e.map((t=>this.getAttributeFromHTMLWrapper("opc"+t)))).then((e=>{t(e.includes("1"))})).catch((t=>{s(t)}))})).catch((t=>{s(t)}))}))}async getConfig(t){let e={serviceName:"SystemUtilsSP.getConf",requestBody:{config:{chave:t,tipo:"T"}}};return new Promise(((t,s)=>{y.get().callServiceBroker("SystemUtilsSP.getConf",JSON.stringify(e)).then((e=>{var s;return t(null===(s=e.config)||void 0===s?void 0:s.data)})).catch((t=>s(t)))}))}async saveConfig(t,e){let s={serviceName:"SystemUtilsSP.saveConf",requestBody:{config:{chave:t,tipo:"T",data:e}}};return new Promise(((t,e)=>{y.get().callServiceBroker("SystemUtilsSP.saveConf",JSON.stringify(s)).then((e=>t(e))).catch((t=>e(t)))}))}async getAttributeFromHTMLWrapper(t){return Promise.resolve(window[t])}async openApp(t,e){q.openAppActivity(t,e)}getDuPromissesStack(t){let e;return t&&(e=this._duPromises.get(t),e||(e=[],this._duPromises.set(t,e))),e||[]}async createDataunit(t,e){return new Promise(((s,i)=>{const r=this.getDuPromissesStack(e),n=r.length>0;if(r.push(new G(s,i)),!n){const s=this.dataUnitFetcher.getDataUnit(t,this.resourceID);s.loadMetadata().then((()=>{for(e&&this._duCache.set(e,s);r.length>0;)r.pop().resolve(s)})).catch((t=>{for(;r.length>0;)r.pop().reject(t)}))}}))}async getDataUnit(t,e){return new Promise(((s,i)=>{const r=this._duCache.get(e);r?s(r):this.createDataunit(t,e).then((t=>{s(t)})).catch((t=>i(t)))}))}async getResourceID(){return Promise.resolve(this.resourceID)}async getUserID(){return Promise.resolve(window.UID)}async alert(t,e,s,i){return I.alert(t,e,s,i)}async error(t,e,s,i){return I.error(t,e,s,i)}async success(t,e,s,i){return I.success(t,e,s,i)}async message(t,e,s,i){return I.message(t,e,s,i)}async confirm(t,e,s,i,r){return I.confirm(t,e,s,i,r)}async info(t,e){return I.info(t,e)}async loadFormConfig(t){return this.formConfigFetcher.loadFormConfig(t,this.resourceID)}async loadGridConfig(t){return this.gridConfigFetcher.getConfig(t,this.resourceID)}async fetchUserAvailableConfigs(t){return this.formConfigFetcher.fetchUserAvailableConfigs(t,this.resourceID)}async fetchLegacyConfig(t){return this.formConfigFetcher.fetchLegacyConfig(t,this.resourceID)}async fetchDefaultConfig(t){return this.formConfigFetcher.fetchDefaultConfig(t,this.resourceID)}async loadTotals(t,e,s){return this.totalsFetcher.fetchTotals(t,e,s)}async saveGridConfig(t){return this.gridConfigFetcher.saveConfig(t,this.resourceID)}async getFilterBarConfig(t){return new Promise(((e,s)=>{this.configName===t&&this._filterBarConfig?e(this._filterBarConfig):this.configName===t&&null!=this._filterConfigPromise?Promise.all([this._filterConfigPromise]).then((t=>e(t[0]))).catch((t=>s(t[0]))):this.filterBarConfigFetcher.getConfig(this.resourceID,t).then((t=>e(t))).catch((t=>s(t)))}))}async saveFilterBarConfig(t,e){return this.filterBarConfigFetcher.saveConfig(t,this.resourceID,e)}async saveFormConfig(t,e){return this.formConfigFetcher.saveConfig(t,e,this.resourceID)}async getDefaultValues(){return this.defaultValuesFetcher.getDefaultValues(this.resourceID)}async getDefaultValue(t){return this._defaultValues&&this._defaultValues[t]}async getAuthList(t){return await(new R).parseFromJSON(t)}get urlParams(){return this._urlParams||(this._urlParams=v.getQueryParams(location.search)),this._urlParams}get dataUnitFetcher(){return this._dataUnitFetcher||(this._dataUnitFetcher=new N),this._dataUnitFetcher}get formConfigFetcher(){return this._formConfigFetcher||(this._formConfigFetcher=new w),this._formConfigFetcher}get gridConfigFetcher(){return this._gridConfigFetcher||(this._gridConfigFetcher=new j),this._gridConfigFetcher}get totalsFetcher(){return this._totalsFetcher||(this._totalsFetcher=new T),this._totalsFetcher}get pesquisaFetcher(){return this._pesquisaFetcher||(this._pesquisaFetcher=new _),this._pesquisaFetcher}get authFetcher(){return this._authFetcher||(this._authFetcher=new k),this._authFetcher}get filterBarConfigFetcher(){return this._filterBarConfigFetcher||(this._filterBarConfigFetcher=new B),this._filterBarConfigFetcher}get defaultValuesFetcher(){return this._defaultValuesFetcher||(this._defaultValuesFetcher=new z),this._defaultValuesFetcher}async executeSearch(t,e,s){const i=null==s?void 0:s.getField(e);if(i){const{mode:e,argument:r}=t,{ENTITYNAME:n,CODEFIELD:a,DESCRIPTIONFIELD:c,ROOTENTITY:h,DESCRIPTIONENTITY:u}=i.properties,l=i.dependencies;let p;const m={rootEntity:h,descriptionFieldName:c,codeFieldName:a,showInactives:!1};return null==l||l.filter((t=>{var e;return null===(e=t.masterFields)||void 0===e?void 0:e.every((t=>{var e;return null===(e=s.getField(t))||void 0===e?void 0:e.visible}))})).forEach((t=>{var e;t.type===d.SEARCHING&&(null===(e=t.masterFields)||void 0===e?void 0:e.length)>0&&(p={expression:t.expression,params:t.masterFields.map((t=>{const e=s.getField(t),i=(null==e?void 0:e.dataType)||o.TEXT,r=s.getFieldValue(t);if(null==r)throw this.alert("Erro ao pesquisar",`É necessario informar o campo ${e.label} para executar a pesquisa.`),new Error(`É necessario informar o campo ${e.label} para executar a pesquisa.`);return{name:t,value:r,dataType:i}}))})})),this.executePreparedSearch(e,r,{entity:n,entityDescription:u,criteria:p,searchOptions:m})}}async executePreparedSearch(t,e,s){const{entity:i,entityDescription:r,criteria:n,searchOptions:a}=s;return"ADVANCED"===t?new Promise((t=>{const s=document.createElement("snk-pesquisa");s.argument=e,s.searchLoader=t=>this.pesquisaFetcher.loadAdvancedSearch(i,t,n,a),s.selectItem=e=>{t(e),this.clearPopUpTitle(),this.closePopUp()},this.setPopUpTitle(r),this.showPopUp(s)})):this.pesquisaFetcher.loadSearchOptions(i,e,n,a)}async isDebugMode(){return new Promise((t=>{t(window.isDebugMode)}))}clearContent(t){t&&Array.from(t.children).forEach((e=>{t.removeChild(e)}))}clearPopUpTitle(){this._popUp.ezTitle=""}setPopUpTitle(t){this._popUp.ezTitle=t}componentWillLoad(){this._errorHandler=new $(this),this.messagesBuilder=new P,p.setContextValue("__EZUI__UPLOAD__ADD__URL__",`${v.getUrlBase()}/mge/upload/file`),p.setContextValue("__EZUI__SEARCH__OPTION__LOADER__",((t,e,s)=>this.executeSearch(t,e,s))),p.setContextValue("__EZUI__GRID_LICENSE__",A),this.configName&&(this._filterConfigPromise=new Promise(((t,e)=>{this.filterBarConfigFetcher.getConfig(this.resourceID,this.configName).then((e=>{this._filterBarConfig=e,t(e)})).catch((t=>e(t)))}))),m.init(),this.getDefaultValues().then((t=>{this._defaultValues=t}))}connectedCallback(){p.setContextValue("__SNK__APPLICATION__",this),y.addRequestListener(this._requestListener)}disconnectedCallback(){y.removeRequestListener(this._requestListener)}componentDidLoad(){this.applicationLoading.emit(!0),window.requestAnimationFrame((()=>{this.applicationLoaded.emit(!0)}))}render(){return s("div",null,s("ez-loading-bar",{ref:t=>this._requestListener.loadingBar=t}),s("ez-popup",{opened:!1,ref:t=>this._popUp=t,onEzClosePopup:()=>this.closePopUp()}),s("ez-modal",{opened:!1,ref:t=>this._rightModal=t,"modal-size":"col col--sd-3",closeOutsideClick:!0,closeEsc:!0}))}};class V{constructor(){this._debounceTime=1e3,this._ignoredNameTypes=["totals"],this._countRequest=0}onRequestStart(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest++,this.loadingBar.show(),this._timerLoading&&clearTimeout(this._timerLoading))}onRequestEnd(t){this.isIgnoreLoadingOnRequest(t)||(this._countRequest--,this._timerLoading=setTimeout((()=>{this._countRequest<=0&&this.loadingBar.hide()}),this._debounceTime))}isIgnoreLoadingOnRequest(t){var e;if(1==(null===(e=null==t?void 0:t.requestBody)||void 0===e?void 0:e.length)){const{name:e}=t.requestBody[0].variables;if(e){const t=e.split(":");return this._ignoredNameTypes.indexOf(t[0])>=0}}return!1}}class G{constructor(t,e){this.resolve=t,this.reject=e}}J.style=".sc-snk-application-h{display:flex;flex-direction:column;height:100%}";export{J as snk_application}
@@ -0,0 +1 @@
1
+ import{r as s,c as i,h as t,g as e}from"./p-9ba3df4c.js";import{DateUtils as a,ObjectUtils as o,ApplicationContext as r}from"@sankhyalabs/core";import{C as n}from"./p-d50651a3.js";import{T as h}from"./p-03f9c407.js";const d=class{constructor(t){s(this,t),this.exit=i(this,"exit",7),this.actionClick=i(this,"actionClick",7),this.configChanged=i(this,"configChanged",7),this._renderTimer=500,this._taskbarProcessor=new h({"snkForm.regular":["PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","GRID_MODE","CONFIGURATOR","INSERT"],"snkForm.finish_edition":["CANCEL","SAVE"]}),this._editionFormConfig={},this._insertionFormConfig={},this._showFormConfig=!1}async setShowFormConfig(s){this._showFormConfig=s}async setConfig(s){this._editionFormConfig={},this.loadConfig(s)||this.loadInsertionConfig()}loadConfig(s){return null!=(null==s?void 0:s.fields)&&(setTimeout((async()=>{for(const i of s.fields)if(i.defaultValue&&"value"in i.defaultValue){const s=i.defaultValue.value;await this.getFormattedValue(s).then((s=>{i.defaultValue.formattedValue=s}))}this._editionFormConfig=s,this.loadInsertionConfig()}),this._renderTimer),!0)}async getFormattedValue(s){switch(s){case"${data}":return()=>a.getToday();case"${datahora}":return()=>a.getToday(!0);case"${usuario}":case"${usuario.empresa}":case"${usuario.vendedor}":case"${usuario.centroresultado}":let i;return await this._application.getDefaultValue(s).then((s=>{i=s})),i;default:return s}}loadInsertionConfig(){var s;if(this._dataUnit){const i=o.copy(this._editionFormConfig||{});i.fields=null===(s=i.fields)||void 0===s?void 0:s.filter((s=>{const i=this._dataUnit.getField(s.name);return!(null==i?void 0:i.readOnly)})),this._insertionFormConfig=i}}getFormConfig(){return this._dataState&&this._dataState.insertionMode?this._insertionFormConfig:this._editionFormConfig}exitForm(){this._dataUnit.isDirty()?this._dataUnit.cancelEdition({after:()=>this.exit.emit()}):this.exit.emit()}getMessage(s){return this._application.messagesBuilder.getMessage(s,this.getMessageParams())}getMessageParams(){var s;return(null===(s=this._dataState)||void 0===s?void 0:s.selectedRecords)?this._dataState.selectedRecords[0]:void 0}changeConfig(s){this.configChanged.emit(s)}getDisabledButtons(){const s=[];return this._dataState.hasPrevious||s.push("PREVIOUS"),this._dataState.hasNext||s.push("NEXT"),s}componentDidRender(){n.setForm(this.configName,this._element)}componentWillLoad(){this._application=r.getContextValue("__SNK__APPLICATION__");let s=this._element.parentElement;for(;s;){if("SNK-DATA-UNIT"===s.tagName.toUpperCase()){this._snkDataUnit=s,this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.loadInsertionConfig():this._snkDataUnit.addEventListener("dataUnitReady",(s=>{this._dataUnit=s.detail,this.loadInsertionConfig()})),this._snkDataUnit.addEventListener("dataStateChange",(s=>{this._dataState=s.detail}));break}s=s.parentElement}}componentWillRender(){var s;const i=(null===(s=this._dataState)||void 0===s?void 0:s.isDirty)?"snkForm.finish_edition":"snkForm.regular",t=[];this._dataState&&this._dataState.hasPrevious||t.push("PREVIOUS"),this._dataState&&this._dataState.hasNext||t.push("NEXT"),this._taskbarProcessor.process(i,this.taskbarManager,this._dataState,t)}render(){var s;if(this._dataUnit&&this._dataState)return t("section",{class:"snk-form"},t("div",{class:"snk-form__header snk-form__header--fixed ez-row"},t("div",{class:"ez-col ez-col--sd-6 ez-col--tb-6",key:"formHeader"},t("ez-button",{title:this.getMessage("snkForm.goBackTitle"),mode:"icon",iconName:"arrow_back",class:"ez-padding-right--medium",size:"small",onClick:()=>this.exitForm()}),t("h1",{class:"ez-title ez-title--primary ez-title--xlarge ez-align--middle"},this.getMessage("snkForm.title"))),t("div",{class:"ez-col ez-col--sd-6 ez-col--tb-6 ez-align--right"},t("snk-taskbar",{key:"formTaskbar",configName:this.configName,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,actionsList:this.actionsList,primaryButton:(null===(s=this._dataState)||void 0===s?void 0:s.isDirty)?"SAVE":"INSERT",dataUnit:this._dataUnit}))),t("section",null,t("div",{class:"ez-row"},t("div",{class:"ez-col ez-col--sd-12"},t("ez-form",{key:"ezForm"+this._snkDataUnit.entityName,dataUnit:this._dataUnit,config:this.getFormConfig(),recordsValidator:this.recordsValidator,class:this._showFormConfig?"snk-form__form--hidden":""}),this._showFormConfig&&t("snk-form-config",{dataUnit:this._dataUnit,formConfig:this.getFormConfig(),parentForm:this._element,onConfigChange:s=>{this.changeConfig(s.detail)}})))))}get _element(){return e(this)}};d.style=".sc-snk-form-h{display:block}.snk-form.sc-snk-form{position:relative;padding:var(--space--large);padding-top:var(--space--medium)}.snk-form__header.sc-snk-form{position:relative;padding-top:var(--space--medium);padding-bottom:var(--space--medium);margin-bottom:var(--space--medium)}.snk-form__header--fixed.sc-snk-form{position:sticky;top:0;background:var(--background--body);z-index:var(--more-visible, 2);padding-left:var(--space--large);padding-right:var(--space--large);margin-left:calc(var(--space--large) * -1);margin-right:calc(var(--space--large) * -1);width:calc(100% + (var(--space--large) * 2))}.snk-form__form--hidden.sc-snk-form{display:none}";export{d as snk_form}
@@ -1 +1 @@
1
- import{p as e,b as t}from"./p-9ba3df4c.js";(()=>{const t=import.meta.url,a={};return""!==t&&(a.resourcesUrl=new URL(".",t).href),e(a)})().then((e=>t([["p-44ce5b90",[[1,"teste-pesquisa"]]],["p-92782503",[[2,"snk-data-unit",{dataState:[1040],dataUnitName:[1,"data-unit-name"],entityName:[1,"entity-name"],pageSize:[2,"page-size"],dataUnit:[1040],beforeSave:[16],afterSave:[16],getDataUnit:[64]}]]],["p-9dc4426d",[[0,"snk-filter-binary-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-3a276f3d",[[0,"snk-filter-multi-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-cc4bef9f",[[0,"snk-filter-number",{config:[16],value:[2],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-029ae4e4",[[0,"snk-filter-period",{config:[16],value:[8],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-12ad2a19",[[0,"snk-filter-personalized",{config:[16],value:[1040],fix:[16],unfix:[16],show:[64]}]]],["p-2dc76d79",[[0,"snk-filter-search",{config:[16],value:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-e9beab79",[[0,"snk-filter-text",{config:[16],value:[1]},[[0,"ezChange","ezChangeListener"]]]]],["p-ac71ef38",[[2,"snk-pesquisa",{searchLoader:[16],selectItem:[16],argument:[1025],_itemList:[32],_startLoading:[32]}]]],["p-8706fe65",[[2,"snk-config-options",{fieldConfig:[16],idConfig:[513,"id-config"],dataUnit:[16],_defaultType:[32]}]]],["p-f37cdeb5",[[6,"snk-tab-config",{selectedIndex:[1538,"selected-index"],selectedTab:[1537,"selected-tab"],tabs:[1],_processedTabs:[32],_activeEditText:[32],_activeEditTextIndex:[32],_actionsHide:[32],_actionsShow:[32]}]]],["p-deb1f523",[[0,"snk-filter-detail",{config:[1040],getMessage:[16],show:[64]}]]],["p-eb23420d",[[6,"snk-grid",{configName:[1,"config-name"],actionsList:[16],taskbarManager:[16],statusResolver:[16],_dataUnit:[32],_dataState:[32],_gridConfig:[32],setShowGridConfig:[64],setConfig:[64]}],[2,"snk-field-config",{isConfigActive:[16],fieldConfig:[16],modeInsertion:[516,"mode-insertion"],dataUnit:[16]}]]],["p-626cf022",[[2,"snk-form-config",{dataUnit:[16],formConfig:[16],parentForm:[16],_formConfigOptions:[32],_fieldConfigSelected:[32],_layoutFormConfig:[32],_fieldsAvailable:[32],_formConfig:[32],_formConfigChanged:[32],_optionFormConfigSelected:[32],_optionFormConfigChanged:[32],_tempGroups:[32]}]]],["p-60eef7cd",[[2,"snk-config-modal",{configName:[1,"config-name"],gridMode:[4,"grid-mode"]}]]],["p-e8591491",[[2,"snk-filter-bar",{dataUnit:[1040],configName:[1,"config-name"],filterConfig:[1040],allowDefault:[32]},[[0,"filterChange","filterChangeListener"]]],[6,"snk-taskbar",{configName:[1,"config-name"],buttons:[1],customButtons:[16],actionsList:[16],primaryButton:[1,"primary-button"],disabledButtons:[16],dataUnit:[16],_permissions:[32]}],[0,"snk-filter-item",{config:[1040],getMessage:[16],detailIsVisible:[32],showUp:[64],hideDetail:[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]],[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"]]],[0,"snk-filter-modal",{getMessage:[16],items:[1040],modalTitle:[1,"modal-title"],modalSubTitle:[1,"modal-sub-title"],cancelButtonLabel:[1,"cancel-button-label"],okButtonLabel:[1,"ok-button-label"],infoText:[1,"info-text"],useSearch:[4,"use-search"],processModalAction:[16],_filterArgument:[32]}],[2,"snk-configurator",{configName:[1,"config-name"],name:[1],enabled:[4]}]]],["p-2b891c4a",[[2,"snk-form",{configName:[1,"config-name"],recordsValidator:[16],actionsList:[16],taskbarManager:[16],_dataUnit:[32],_dataState:[32],_editionFormConfig:[32],_insertionFormConfig:[32],_showFormConfig:[32],setShowFormConfig:[64],setConfig:[64]}]]],["p-e128f747",[[6,"snk-crud",{configName:[1025,"config-name"],actionsList:[16],taskbarManager:[16],recordsValidator:[16],statusResolver:[16],_dataUnit:[32],_dataState:[32],goToView:[64]}]]],["p-4c887c1f",[[2,"snk-application",{messagesBuilder:[1040],configName:[1,"config-name"],isUserSup:[64],hasAccess:[64],getAllAccess:[64],getStringParam:[64],getIntParam:[64],getFloatParam:[64],getBooleanParam:[64],getDateParam:[64],showPopUp:[64],showModal:[64],closeModal:[64],closePopUp:[64],temOpcional:[64],getConfig:[64],saveConfig:[64],getAttributeFromHTMLWrapper:[64],openApp:[64],createDataunit:[64],getDataUnit:[64],getResourceID:[64],getUserID:[64],alert:[64],error:[64],success:[64],message:[64],confirm:[64],info:[64],loadFormConfig:[64],loadGridConfig:[64],fetchUserAvailableConfigs:[64],fetchLegacyConfig:[64],fetchDefaultConfig:[64],loadTotals:[64],saveGridConfig:[64],getFilterBarConfig:[64],saveFilterBarConfig:[64],saveFormConfig:[64],executeSearch:[64],executePreparedSearch:[64],isDebugMode:[64]}]]]],e)));
1
+ import{p as e,b as t}from"./p-9ba3df4c.js";(()=>{const t=import.meta.url,a={};return""!==t&&(a.resourcesUrl=new URL(".",t).href),e(a)})().then((e=>t([["p-44ce5b90",[[1,"teste-pesquisa"]]],["p-92782503",[[2,"snk-data-unit",{dataState:[1040],dataUnitName:[1,"data-unit-name"],entityName:[1,"entity-name"],pageSize:[2,"page-size"],dataUnit:[1040],beforeSave:[16],afterSave:[16],getDataUnit:[64]}]]],["p-9dc4426d",[[0,"snk-filter-binary-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-3a276f3d",[[0,"snk-filter-multi-select",{value:[1544],config:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-cc4bef9f",[[0,"snk-filter-number",{config:[16],value:[2],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-029ae4e4",[[0,"snk-filter-period",{config:[16],value:[8],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-12ad2a19",[[0,"snk-filter-personalized",{config:[16],value:[1040],fix:[16],unfix:[16],show:[64]}]]],["p-2dc76d79",[[0,"snk-filter-search",{config:[16],value:[16],show:[64]},[[0,"ezChange","ezChangeListener"]]]]],["p-e9beab79",[[0,"snk-filter-text",{config:[16],value:[1]},[[0,"ezChange","ezChangeListener"]]]]],["p-ac71ef38",[[2,"snk-pesquisa",{searchLoader:[16],selectItem:[16],argument:[1025],_itemList:[32],_startLoading:[32]}]]],["p-8706fe65",[[2,"snk-config-options",{fieldConfig:[16],idConfig:[513,"id-config"],dataUnit:[16],_defaultType:[32]}]]],["p-f37cdeb5",[[6,"snk-tab-config",{selectedIndex:[1538,"selected-index"],selectedTab:[1537,"selected-tab"],tabs:[1],_processedTabs:[32],_activeEditText:[32],_activeEditTextIndex:[32],_actionsHide:[32],_actionsShow:[32]}]]],["p-deb1f523",[[0,"snk-filter-detail",{config:[1040],getMessage:[16],show:[64]}]]],["p-eb23420d",[[6,"snk-grid",{configName:[1,"config-name"],actionsList:[16],taskbarManager:[16],statusResolver:[16],_dataUnit:[32],_dataState:[32],_gridConfig:[32],setShowGridConfig:[64],setConfig:[64]}],[2,"snk-field-config",{isConfigActive:[16],fieldConfig:[16],modeInsertion:[516,"mode-insertion"],dataUnit:[16]}]]],["p-626cf022",[[2,"snk-form-config",{dataUnit:[16],formConfig:[16],parentForm:[16],_formConfigOptions:[32],_fieldConfigSelected:[32],_layoutFormConfig:[32],_fieldsAvailable:[32],_formConfig:[32],_formConfigChanged:[32],_optionFormConfigSelected:[32],_optionFormConfigChanged:[32],_tempGroups:[32]}]]],["p-60eef7cd",[[2,"snk-config-modal",{configName:[1,"config-name"],gridMode:[4,"grid-mode"]}]]],["p-e8591491",[[2,"snk-filter-bar",{dataUnit:[1040],configName:[1,"config-name"],filterConfig:[1040],allowDefault:[32]},[[0,"filterChange","filterChangeListener"]]],[6,"snk-taskbar",{configName:[1,"config-name"],buttons:[1],customButtons:[16],actionsList:[16],primaryButton:[1,"primary-button"],disabledButtons:[16],dataUnit:[16],_permissions:[32]}],[0,"snk-filter-item",{config:[1040],getMessage:[16],detailIsVisible:[32],showUp:[64],hideDetail:[64]},[[2,"click","clickListener"],[2,"mousedown","mouseDownListener"],[0,"filterChange","filterChangeListener"]]],[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"]]],[0,"snk-filter-modal",{getMessage:[16],items:[1040],modalTitle:[1,"modal-title"],modalSubTitle:[1,"modal-sub-title"],cancelButtonLabel:[1,"cancel-button-label"],okButtonLabel:[1,"ok-button-label"],infoText:[1,"info-text"],useSearch:[4,"use-search"],processModalAction:[16],_filterArgument:[32]}],[2,"snk-configurator",{configName:[1,"config-name"],name:[1],enabled:[4]}]]],["p-ce7c38a1",[[2,"snk-form",{configName:[1,"config-name"],recordsValidator:[16],actionsList:[16],taskbarManager:[16],_dataUnit:[32],_dataState:[32],_editionFormConfig:[32],_insertionFormConfig:[32],_showFormConfig:[32],setShowFormConfig:[64],setConfig:[64]}]]],["p-e128f747",[[6,"snk-crud",{configName:[1025,"config-name"],actionsList:[16],taskbarManager:[16],recordsValidator:[16],statusResolver:[16],_dataUnit:[32],_dataState:[32],goToView:[64]}]]],["p-599846fb",[[2,"snk-application",{messagesBuilder:[1040],configName:[1,"config-name"],isUserSup:[64],hasAccess:[64],getAllAccess:[64],getStringParam:[64],getIntParam:[64],getFloatParam:[64],getBooleanParam:[64],getDateParam:[64],showPopUp:[64],showModal:[64],closeModal:[64],closePopUp:[64],temOpcional:[64],getConfig:[64],saveConfig:[64],getAttributeFromHTMLWrapper:[64],openApp:[64],createDataunit:[64],getDataUnit:[64],getResourceID:[64],getUserID:[64],alert:[64],error:[64],success:[64],message:[64],confirm:[64],info:[64],loadFormConfig:[64],loadGridConfig:[64],fetchUserAvailableConfigs:[64],fetchLegacyConfig:[64],fetchDefaultConfig:[64],loadTotals:[64],saveGridConfig:[64],getFilterBarConfig:[64],saveFilterBarConfig:[64],saveFormConfig:[64],getDefaultValues:[64],getDefaultValue:[64],executeSearch:[64],executePreparedSearch:[64],isDebugMode:[64]}]]]],e)));
@@ -16,6 +16,7 @@ import ParametersFetcher from "../../lib/http/data-fetcher/fetchers/parameters-f
16
16
  import GridConfigFetcher from "../../lib/http/data-fetcher/fetchers/grid-config-fetcher";
17
17
  import AuthFetcher, { AutorizationType } from "../../lib/http/data-fetcher/fetchers/auth-fetcher";
18
18
  import FilterBarConfigFetcher from "../../lib/http/data-fetcher/fetchers/filter-bar-config-fetcher";
19
+ import { DefaultValuesFetcher } from "../../lib/http/data-fetcher/fetchers/default-values-fetcher";
19
20
  export declare class SnkApplication {
20
21
  _parameters: ParametersFetcher;
21
22
  _urlParams: Map<string, any>;
@@ -26,7 +27,9 @@ export declare class SnkApplication {
26
27
  _pesquisaFetcher: PesquisaFetcher;
27
28
  _authFetcher: AuthFetcher;
28
29
  _filterBarConfigFetcher: FilterBarConfigFetcher;
30
+ _defaultValuesFetcher: DefaultValuesFetcher;
29
31
  _resourceID: string;
32
+ _defaultValues: any;
30
33
  _popUp: HTMLEzPopupElement;
31
34
  _rightModal: HTMLEzModalElement;
32
35
  _errorHandler: SnkErrorHandler;
@@ -194,6 +197,14 @@ export declare class SnkApplication {
194
197
  * Salva a configuração de formulário.
195
198
  */
196
199
  saveFormConfig(config: IFormConfig, name: string): Promise<boolean>;
200
+ /**
201
+ * Busca um objeto com um conjunto de valores padrão.
202
+ */
203
+ getDefaultValues(): Promise<string>;
204
+ /**
205
+ * Retorna um valor padrão específico de uma expressão.
206
+ */
207
+ getDefaultValue(expression: string): Promise<any>;
197
208
  /**
198
209
  * Evento disparado quando a aplicação for carregada.
199
210
  */
@@ -211,6 +222,7 @@ export declare class SnkApplication {
211
222
  private get pesquisaFetcher();
212
223
  private get authFetcher();
213
224
  private get filterBarConfigFetcher();
225
+ private get defaultValuesFetcher();
214
226
  executeSearch(searchArgument: ISearchArgument, fieldName: string, dataUnit: DataUnit): Promise<Array<IOption> | IOption>;
215
227
  executePreparedSearch(mode: string, argument: string, options: any): Promise<Array<IOption> | IOption>;
216
228
  isDebugMode(): Promise<boolean>;
@@ -51,10 +51,11 @@ export declare class SnkForm {
51
51
  * Método responsável por setar as configurações do form.
52
52
  */
53
53
  setConfig(config: IFormConfig): Promise<void>;
54
- getFormConfig(): IFormConfig;
55
- exitForm(): void;
56
- getDisabledButtons(): Array<string>;
57
- loadInsertionConfig(): void;
54
+ private loadConfig;
55
+ private getFormattedValue;
56
+ private loadInsertionConfig;
57
+ private getFormConfig;
58
+ private exitForm;
58
59
  /**
59
60
  * Conforme mecanismo de mensagens, é possível customizar as mensagens dos blocos de construção
60
61
  * através de um pequeno modulo na estrutura da aplicação:
@@ -64,6 +65,7 @@ export declare class SnkForm {
64
65
  private getMessage;
65
66
  private getMessageParams;
66
67
  private changeConfig;
68
+ getDisabledButtons(): Array<string>;
67
69
  componentDidRender(): void;
68
70
  componentWillLoad(): void;
69
71
  componentWillRender(): void;
@@ -89,6 +89,14 @@ export namespace Components {
89
89
  * Retorna o valor de um parâmetro do tipo data.
90
90
  */
91
91
  "getDateParam": (name: string) => Promise<Date>;
92
+ /**
93
+ * Retorna um valor padrão específico de uma expressão.
94
+ */
95
+ "getDefaultValue": (expression: string) => Promise<any>;
96
+ /**
97
+ * Busca um objeto com um conjunto de valores padrão.
98
+ */
99
+ "getDefaultValues": () => Promise<string>;
92
100
  /**
93
101
  * Obtém as configurações da barra de filtros
94
102
  */
@@ -0,0 +1,4 @@
1
+ import { ResourceFetcher } from "./resource-fetcher";
2
+ export declare class DefaultValuesFetcher extends ResourceFetcher {
3
+ getDefaultValues(resourceID: string): Promise<string>;
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sankhyalabs/sankhyablocks",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Stencil Component Starter",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.js",
@@ -1 +0,0 @@
1
- import{r as i,c as s,h as t,g as e}from"./p-9ba3df4c.js";import{ObjectUtils as o,ApplicationContext as a}from"@sankhyalabs/core";import{C as r}from"./p-d50651a3.js";import{T as n}from"./p-03f9c407.js";const h=class{constructor(t){i(this,t),this.exit=s(this,"exit",7),this.actionClick=s(this,"actionClick",7),this.configChanged=s(this,"configChanged",7),this._renderTimer=500,this._taskbarProcessor=new n({"snkForm.regular":["PREVIOUS","NEXT","DIVIDER","CLONE","REMOVE","MORE_OPTIONS","DIVIDER","GRID_MODE","CONFIGURATOR","INSERT"],"snkForm.finish_edition":["CANCEL","SAVE"]}),this._editionFormConfig={},this._insertionFormConfig={},this._showFormConfig=!1}async setShowFormConfig(i){this._showFormConfig=i}async setConfig(i){this._editionFormConfig={},setTimeout((()=>{this._editionFormConfig=null!=i?i:{},this.loadInsertionConfig()}),this._renderTimer)}getFormConfig(){return this._dataState&&this._dataState.insertionMode?this._insertionFormConfig:this._editionFormConfig}exitForm(){this._dataUnit.isDirty()?this._dataUnit.cancelEdition({after:()=>this.exit.emit()}):this.exit.emit()}getDisabledButtons(){const i=[];return this._dataState.hasPrevious||i.push("PREVIOUS"),this._dataState.hasNext||i.push("NEXT"),i}loadInsertionConfig(){var i;if(this._dataUnit){const s=o.copy(this._editionFormConfig||{});s.fields=null===(i=s.fields)||void 0===i?void 0:i.filter((i=>{const s=this._dataUnit.getField(i.name);return!(null==s?void 0:s.readOnly)})),this._insertionFormConfig=s}}getMessage(i){return this._application.messagesBuilder.getMessage(i,this.getMessageParams())}getMessageParams(){var i;return(null===(i=this._dataState)||void 0===i?void 0:i.selectedRecords)?this._dataState.selectedRecords[0]:void 0}changeConfig(i){this.configChanged.emit(i)}componentDidRender(){r.setForm(this.configName,this._element)}componentWillLoad(){this._application=a.getContextValue("__SNK__APPLICATION__");let i=this._element.parentElement;for(;i;){if("SNK-DATA-UNIT"===i.tagName.toUpperCase()){this._snkDataUnit=i,this._dataUnit=this._snkDataUnit.dataUnit,this._dataState=this._snkDataUnit.dataState,this._dataUnit?this.loadInsertionConfig():this._snkDataUnit.addEventListener("dataUnitReady",(i=>{this._dataUnit=i.detail,this.loadInsertionConfig()})),this._snkDataUnit.addEventListener("dataStateChange",(i=>{this._dataState=i.detail}));break}i=i.parentElement}}componentWillRender(){var i;const s=(null===(i=this._dataState)||void 0===i?void 0:i.isDirty)?"snkForm.finish_edition":"snkForm.regular",t=[];this._dataState&&this._dataState.hasPrevious||t.push("PREVIOUS"),this._dataState&&this._dataState.hasNext||t.push("NEXT"),this._taskbarProcessor.process(s,this.taskbarManager,this._dataState,t)}render(){var i;if(this._dataUnit&&this._dataState)return t("section",{class:"snk-form"},t("div",{class:"snk-form__header snk-form__header--fixed ez-row"},t("div",{class:"ez-col ez-col--sd-6 ez-col--tb-6",key:"formHeader"},t("ez-button",{title:this.getMessage("snkForm.goBackTitle"),mode:"icon",iconName:"arrow_back",class:"ez-padding-right--medium",size:"small",onClick:()=>this.exitForm()}),t("h1",{class:"ez-title ez-title--primary ez-title--xlarge ez-align--middle"},this.getMessage("snkForm.title"))),t("div",{class:"ez-col ez-col--sd-6 ez-col--tb-6 ez-align--right"},t("snk-taskbar",{key:"formTaskbar",configName:this.configName,buttons:this._taskbarProcessor.buttons,disabledButtons:this._taskbarProcessor.disabledButtons,customButtons:this._taskbarProcessor.customButtons,actionsList:this.actionsList,primaryButton:(null===(i=this._dataState)||void 0===i?void 0:i.isDirty)?"SAVE":"INSERT",dataUnit:this._dataUnit}))),t("section",null,t("div",{class:"ez-row"},t("div",{class:"ez-col ez-col--sd-12"},t("ez-form",{key:"ezForm"+this._snkDataUnit.entityName,dataUnit:this._dataUnit,config:this.getFormConfig(),recordsValidator:this.recordsValidator,class:this._showFormConfig?"snk-form__form--hidden":""}),this._showFormConfig&&t("snk-form-config",{dataUnit:this._dataUnit,formConfig:this.getFormConfig(),parentForm:this._element,onConfigChange:i=>{this.changeConfig(i.detail)}})))))}get _element(){return e(this)}};h.style=".sc-snk-form-h{display:block}.snk-form.sc-snk-form{position:relative;padding:var(--space--large);padding-top:var(--space--medium)}.snk-form__header.sc-snk-form{position:relative;padding-top:var(--space--medium);padding-bottom:var(--space--medium);margin-bottom:var(--space--medium)}.snk-form__header--fixed.sc-snk-form{position:sticky;top:0;background:var(--background--body);z-index:var(--more-visible, 2);padding-left:var(--space--large);padding-right:var(--space--large);margin-left:calc(var(--space--large) * -1);margin-right:calc(var(--space--large) * -1);width:calc(100% + (var(--space--large) * 2))}.snk-form__form--hidden.sc-snk-form{display:none}";export{h as snk_form}