Liferay.Loader.define("@liferay/object-web@1.0.153/js/components/ObjectView/ModalAddDefaultSortColumn/ModalAddDefaultSortColumn",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/form","@frontend-taglib-clay$clayui/modal","@liferay/object-js-components-web","liferay!frontend-js-react-web$react","../objectViewContext"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.ModalAddDefaultSortColumn=function ModalAddDefaultSortColumn({editingObjectFieldName:t,header:a,isEditingSort:d,observer:c,onClose:f}){const[{creationLanguageId:s,objectFields:y,objectView:{objectViewColumns:b,objectViewSortColumns:g}},p]=(0,u.useViewContext)(),[m,j]=(0,i.useState)(b);(0,i.useEffect)((()=>{const e=b.filter((e=>!e.defaultSort&&"Aggregation"!==e.objectFieldBusinessType&&"Attachment"!==e.objectFieldBusinessType&&"Formula"!==e.objectFieldBusinessType&&"Relationship"!==e.objectFieldBusinessType&&"RichText"!==e.objectFieldBusinessType));j(e)}),[b]);const[_,L]=(0,i.useState)(),[S,C]=(0,i.useState)(e[0]),[E,O]=(0,i.useState)(""),v=(0,i.useMemo)((()=>(0,o.filterArrayByQuery)({array:m,query:E,str:"fieldLabel"})),[m,E]);return i.default.createElement(r.default,{observer:c},i.default.createElement(n.default,{onSubmit:e=>{e.preventDefault();let a=null==_?void 0:_.objectFieldName;!a&&v.length&&(a=v[0].objectFieldName),p(d?{payload:{editingObjectFieldName:t,selectedObjectSort:S.value},type:u.TYPES.EDIT_OBJECT_VIEW_SORT_COLUMN_SORT_ORDER}:{payload:{creationLanguageId:s,objectFieldName:a,objectFields:y,objectViewSortColumns:g,selectedObjetSort:S},type:u.TYPES.ADD_OBJECT_VIEW_SORT_COLUMN}),f()}},i.default.createElement(r.default.Header,null,a),i.default.createElement(r.default.Body,null,!d&&i.default.createElement(o.AutoComplete,{creationLanguageId:s,emptyStateMessage:Liferay.Language.get("there-are-no-columns-added-in-this-view-yet"),items:v,label:Liferay.Language.get("columns"),onChangeQuery:O,onSelectItem:e=>{L(e)},query:E,required:!0,value:null==_?void 0:_.fieldLabel},(({fieldLabel:e})=>i.default.createElement("div",{className:"d-flex justify-content-between"},i.default.createElement("div",null,e)))),i.default.createElement(o.SingleSelect,{label:Liferay.Language.get("sorting"),onChange:e=>{C(e)},options:e,value:S.label})),i.default.createElement(r.default.Footer,{last:i.default.createElement(l.default.Group,{key:1,spaced:!0},i.default.createElement(l.default,{displayType:"secondary",onClick:()=>f()},Liferay.Language.get("cancel")),i.default.createElement(l.default,{disabled:!d&&!_,displayType:"primary",type:"submit"},Liferay.Language.get("save")))})))};var l=_interopRequireDefault(a("@frontend-taglib-clay$clayui/button")),n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/form")),r=_interopRequireDefault(a("@frontend-taglib-clay$clayui/modal")),o=a("@liferay/object-js-components-web"),i=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={},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var r=l?Object.getOwnPropertyDescriptor(e,n):null;r&&(r.get||r.set)?Object.defineProperty(a,n,r):a[n]=e[n]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react")),u=a("../objectViewContext");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const e=[{label:Liferay.Language.get("ascending"),value:"asc"},{label:Liferay.Language.get("descending"),value:"desc"}]}}));
//# sourceMappingURL=ModalAddDefaultSortColumn.js.map