Liferay.Loader.define("@liferay/object-web@1.0.145/js/components/ObjectValidation/EditObjectValidation",["module","exports","require","@frontend-taglib-clay$clayui/tabs","@liferay/object-js-components-web","liferay!frontend-js-react-web$react","./BasicInfo","./Conditions","./useObjectValidationForm"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function EditObjectValidation({objectValidationRule:t,objectValidationRuleElements:a,readOnly:r}){var o;const[d,s]=(0,l.useState)(0),[u,f]=(0,l.useState)({}),{errors:b,handleChange:p,handleSubmit:m,setValues:g,values:y}=(0,c.useObjectValidationForm)({initialValues:t,onSubmit:async e=>{delete e.lineCount;try{await i.API.save("/o/object-admin/v1.0/object-validation-rules/".concat(e.id),e),(0,i.saveAndReload)(),(0,i.openToast)({message:Liferay.Language.get("the-object-validation-was-updated-successfully")})}catch(e){const{detail:t,message:a}=e,{fieldName:n,message:l}=JSON.parse(t);f({[n]:l}),(0,i.openToast)({message:a,type:"danger"})}}});return(0,l.useEffect)((()=>{"script_placeholder"===t.script&&(t.script="")}),[]),(0,l.useEffect)((()=>{Object.keys(b).length&&(0,i.openToast)({message:Liferay.Language.get("please-fill-out-all-required-fields"),type:"danger"})}),[b]),l.default.createElement(i.SidePanelForm,{onSubmit:m,title:null===(o=t.name)||void 0===o?void 0:o[Liferay.ThemeDisplay.getDefaultLanguageId()]},l.default.createElement(n.default,{className:"side-panel-iframe__tabs"},e.map((({label:e},t)=>l.default.createElement(n.default.Item,{active:d===t,key:t,onClick:()=>s(t)},e)))),l.default.createElement(n.default.Content,{activeIndex:d,fade:!0},e.map((({Component:e,label:t},i)=>d===i?l.default.createElement(n.default.TabPane,{key:i},l.default.createElement(e,{componentLabel:t,disabled:r,errors:0!==Object.keys(b).length?b:u,handleChange:p,objectValidationRuleElements:a,setValues:g,values:y})):l.default.createElement(l.default.Fragment,{key:i})))))};var n=function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}(a("@frontend-taglib-clay$clayui/tabs")),i=a("@liferay/object-js-components-web"),l=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var a={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var l=n?Object.getOwnPropertyDescriptor(e,i):null;l&&(l.get||l.set)?Object.defineProperty(a,i,l):a[i]=e[i]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react")),r=a("./BasicInfo"),o=a("./Conditions"),c=a("./useObjectValidationForm");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}const e=[{Component:r.BasicInfo,label:Liferay.Language.get("basic-info")},{Component:o.Conditions,label:Liferay.Language.get("conditions")}]}}));
//# sourceMappingURL=EditObjectValidation.js.map