Liferay.Loader.define("@liferay/object-web@1.0.181/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}},m]=(0,u.useViewContext)(),[p,j]=(0,i.useState)(b);(0,i.useEffect)((()=>{const e=b.filter((({defaultSort:e,objectFieldBusinessType:t})=>!e&&"Aggregation"!==t&&"Attachment"!==t&&"Encrypted"!==t&&"Formula"!==t&&"Relationship"!==t&&"RichText"!==t));j(e)}),[b]);const[_,S]=(0,i.useState)(),[v,C]=(0,i.useState)(e[0]),[E,L]=(0,i.useState)(""),O=(0,i.useMemo)((()=>(0,o.filterArrayByQuery)({array:p,query:E,str:"fieldLabel"})),[p,E]);return i.default.createElement(n.default,{observer:c},i.default.createElement(r.default,{onSubmit:e=>{e.preventDefault();let a=null==_?void 0:_.objectFieldName;!a&&O.length&&(a=O[0].objectFieldName),m(d?{payload:{editingObjectFieldName:t,selectedObjectSort:v.value},type:u.TYPES.EDIT_OBJECT_VIEW_SORT_COLUMN_SORT_ORDER}:{payload:{creationLanguageId:s,objectFieldName:a,objectFields:y,objectViewSortColumns:g,selectedObjetSort:v},type:u.TYPES.ADD_OBJECT_VIEW_SORT_COLUMN}),f()}},i.default.createElement(n.default.Header,null,a),i.default.createElement(n.default.Body,null,!d&&i.default.createElement(o.AutoComplete,{emptyStateMessage:Liferay.Language.get("there-are-no-columns-added-in-this-view-yet"),items:O,label:Liferay.Language.get("columns"),onActive:e=>e.objectFieldName===(null==_?void 0:_.objectFieldName),onChangeQuery:L,onSelectItem:e=>{S(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:v.label})),i.default.createElement(n.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")),r=_interopRequireDefault(a("@frontend-taglib-clay$clayui/form")),n=_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 r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var n=l?Object.getOwnPropertyDescriptor(e,r):null;n&&(n.get||n.set)?Object.defineProperty(a,r,n):a[r]=e[r]}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