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