Liferay.Loader.define("@liferay/object-web@1.0.181/js/components/ModalDeleteObjectField",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/modal","@liferay/object-js-components-web","frontend-js-web","liferay!frontend-js-react-web$react","../utils/constants","./WarningModal"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function ModalWithProvider({baseResourceURL:e}){const[t,a]=(0,i.useState)(null),{observer:n,onClose:c,open:u}=(0,r.useModal)({onClose:()=>a(null)});return(0,i.useEffect)((()=>(Liferay.on("deleteObjectField",(async({itemData:t})=>{const n=(0,o.createResourceURL)(e,{objectFieldId:t.id,p_p_resource_id:"/object_definitions/get_object_field_delete_info"}).href,{showDeletionModal:r,showDeletionNotAllowedModal:i}=await l.API.fetchJSON(n);a(_objectSpread(_objectSpread({},t),{},{showDeletionModal:r,showDeletionNotAllowedModal:i}))})),()=>Liferay.detach("deleteObjectField"))),[e]),i.default.createElement(r.ClayModalProvider,null,t&&i.default.createElement(ModalDeleteObjectField,{objectField:t,observer:n,onClose:c,onDelete:async e=>{try{await l.API.deleteObjectField(Number(e)),Liferay.Util.openToast({message:(0,o.sub)(Liferay.Language.get("x-was-deleted-successfully"),"<strong>".concat(null==t?void 0:t.label[d.defaultLanguageId],"</strong>"))}),u?c():a(null),setTimeout((()=>window.location.reload()),1500)}catch(e){Liferay.Util.openToast({message:e.message,type:"danger"})}}}))};var n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/button")),r=_interopRequireWildcard(a("@frontend-taglib-clay$clayui/modal")),l=a("@liferay/object-js-components-web"),o=a("frontend-js-web"),i=_interopRequireWildcard(a("liferay!frontend-js-react-web$react")),d=a("../utils/constants"),c=_interopRequireDefault(a("./WarningModal"));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}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 r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var l=n?Object.getOwnPropertyDescriptor(e,r):null;l&&(l.get||l.set)?Object.defineProperty(a,r,l):a[r]=e[r]}return a.default=e,t&&t.set(e,a),a}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ownKeys(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(a),!0).forEach((function(t){_defineProperty(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):ownKeys(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function _defineProperty(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function ModalDeleteObjectField({objectField:e,observer:t,onClose:a,onDelete:l}){const{id:u,label:f,showDeletionModal:s,showDeletionNotAllowedModal:b}=e;return s?b?i.default.createElement(c.default,{observer:t,onClose:a,title:Liferay.Language.get("deletion-not-allowed")},i.default.createElement("div",null,(0,o.sub)(Liferay.Language.get("x-is-the-only-field-of-the-published-object-definition-and-cannot-be-deleted"),"".concat(f[d.defaultLanguageId])))):i.default.createElement(r.default,{observer:t,status:"danger"},i.default.createElement(r.default.Header,null,Liferay.Language.get("delete-object-field")),i.default.createElement(r.default.Body,null,i.default.createElement("p",null,Liferay.Language.get("this-action-cannot-be-undone-and-will-permanently-delete-this-field's-data")),i.default.createElement("p",null,Liferay.Language.get("it-may-affect-many-records")),i.default.createElement("p",null,Liferay.Language.get("do-you-want-to-proceed"))),i.default.createElement(r.default.Footer,{last:i.default.createElement(n.default.Group,{spaced:!0},i.default.createElement(n.default,{displayType:"secondary",onClick:a},Liferay.Language.get("cancel")),i.default.createElement(n.default,{displayType:"danger",onClick:()=>l(u)},Liferay.Language.get("delete")))})):(l(u),null)}}}));
//# sourceMappingURL=ModalDeleteObjectField.js.map