Liferay.Loader.define("@liferay/object-web@1.0.108/js/components/ObjectView/index",["module","exports","require","@frontend-taglib-clay$clayui/tabs","@liferay/object-js-components-web","liferay!frontend-js-react-web$react","./BasicInfoScreen/BasicInfoScreen","./DefaultSortScreen/DefaultSortScreen","./FilterScreen/FilterScreen","./ViewBuilderScreen/ViewBuilderScreen","./objectViewContext"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=b(r("@frontend-taglib-clay$clayui/tabs")),a=r("@liferay/object-js-components-web"),o=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=s();if(t&&t.has(e))return t.get(e);var r={},n=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var o=n?Object.getOwnPropertyDescriptor(e,a):null;o&&(o.get||o.set)?Object.defineProperty(r,a,o):r[a]=e[a]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")),i=b(r("./BasicInfoScreen/BasicInfoScreen")),l=r("./DefaultSortScreen/DefaultSortScreen"),c=r("./FilterScreen/FilterScreen"),u=b(r("./ViewBuilderScreen/ViewBuilderScreen")),f=r("./objectViewContext");function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}function b(e){return e&&e.__esModule?e:{default:e}}function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function y(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?d(Object(r),!0).forEach((function(t){j(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):d(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function j(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const e=[{Component:i.default,label:Liferay.Language.get("basic-info")},{Component:u.default,label:Liferay.Language.get("view-builder")},{Component:l.DefaultSortScreen,label:Liferay.Language.get("default-sort")},{Component:c.FilterScreen,label:Liferay.Language.get("filters")}],m=()=>{const[{isViewOnly:t,objectView:r,objectViewId:i},l]=(0,f.useViewContext)(),[c,u]=(0,o.useState)(0),[s,b]=(0,o.useState)(!0);(0,o.useEffect)((()=>{(async()=>{const{defaultObjectView:e,name:t,objectDefinitionId:r,objectViewColumns:n,objectViewFilterColumns:o,objectViewSortColumns:c}=await a.API.fetchJSON("/o/object-admin/v1.0/object-views/".concat(i)),u=await a.API.getObjectFields(r),s={defaultObjectView:e,name:t,objectDefinitionId:r,objectViewColumns:n,objectViewFilterColumns:o,objectViewSortColumns:c};l({payload:{objectView:s},type:f.TYPES.ADD_OBJECT_VIEW}),l({payload:{objectFields:u,objectView:s},type:f.TYPES.ADD_OBJECT_FIELDS}),b(!1)})()}),[i,l]);return o.default.createElement(a.SidePanelContent,{onSave:async()=>{const e=(e=>{const{objectViewColumns:t,objectViewFilterColumns:r,objectViewSortColumns:n}=e,a=t.map((e=>({label:e.label,objectFieldName:e.objectFieldName,priority:e.priority}))),o=r.map((e=>({filterType:e.filterType,json:JSON.stringify(e.definition),objectFieldName:e.objectFieldName}))),i=n.map((e=>({objectFieldName:e.objectFieldName,priority:e.priority,sortOrder:e.sortOrder})));return y(y({},e),{},{objectViewColumns:a,objectViewFilterColumns:o,objectViewSortColumns:i})})(r),{objectViewColumns:t}=e;if((0,a.invalidateRequired)(r.name[Liferay.ThemeDisplay.getDefaultLanguageId()]))(0,a.openToast)({message:Liferay.Language.get("a-name-is-required"),type:"danger"});else if(r.defaultObjectView&&0===t.length)(0,a.openToast)({message:Liferay.Language.get("default-view-must-have-at-least-one-column"),type:"danger"});else try{await a.API.save("/o/object-admin/v1.0/object-views/".concat(i),e),(0,a.saveAndReload)(),(0,a.openToast)({message:Liferay.Language.get("modifications-saved-successfully")})}catch(e){(0,a.openToast)({message:e.message,type:"danger"})}},readOnly:t||s,title:Liferay.Language.get("custom-view")},o.default.createElement(n.default,{className:"side-panel-iframe__tabs"},e.map((({label:e},t)=>o.default.createElement(n.default.Item,{active:c===t,key:t,onClick:()=>u(t)},e)))),o.default.createElement(n.default.Content,{activeIndex:c,fade:!0},e.map((({Component:e},t)=>o.default.createElement(n.default.TabPane,{key:t},!s&&o.default.createElement(e,null))))))};var p=({filterOperators:e,isViewOnly:t,objectViewId:r,workflowStatusJSONArray:n})=>o.default.createElement(f.ViewContextProvider,{value:{filterOperators:e,isViewOnly:t,objectViewId:r,workflowStatusJSONArray:n}},o.default.createElement(m,null));t.default=p}}));
//# sourceMappingURL=index.js.map