Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
assets.7190.9bf1d89926b9972b5b0a.js Maven / Gradle / Ivy
"use strict";(self.webpackChunkopen_metadata=self.webpackChunkopen_metadata||[]).push([[7190],{97190:function(e,t,n){n.r(t),n.d(t,{default:function(){return L}});var a,l=n(70655),r=n(49409),i=n(71230),o=n(15746),u=n(71577),s=n(23031),c=n(96486),d=n(67294),m=n(15137),p=n(39819),f=n(96162),y=n(16139),v=n(85071);!function(e){e.Entity="entity",e.Field="field"}(a||(a={}));var b=n(17309),C=n(226),h=n(78770),g=n(58804),E=n(96840),T=n(46321),S=n(89011),k=n(1261),R=n(36169),L=function(){var e=(0,l.CR)(r.Z.useForm(),1)[0],t=(0,m.UO)().entityType,n=(0,m.k6)(),L=(0,l.CR)((0,d.useState)(),2),Z=L[0],w=L[1],U=(0,l.CR)((0,d.useState)([]),2),q=U[0],P=U[1],F=(0,l.CR)((0,d.useState)(""),2),N=F[0],O=F[1],G=(0,l.CR)((0,d.useState)(!1),2),I=G[0],M=G[1],x=r.Z.useWatch("propertyType",e),B=(0,d.useMemo)((function(){return[{name:(0,s.t)("label.setting-plural"),url:(0,E.si)()},{name:(0,s.t)("label.custom-attribute-plural"),url:(0,E.si)(f.CZ.CUSTOM_PROPERTIES,(0,g.cE)(t))},{name:(0,s.t)("label.add-entity",{entity:(0,s.t)("label.custom-property")}),url:""}]}),[t]),W=(0,d.useMemo)((function(){return(0,c.map)(q,(function(e){var t;return{key:e.name,label:(0,c.startCase)((null!==(t=e.displayName)&&void 0!==t?t:e.name).replace(/-cp/g,"")),value:e.id}}))}),[q]),z=(0,d.useMemo)((function(){var e,t=W.find((function(e){return e.value===x})),n=null!==(e=null==t?void 0:t.key)&&void 0!==e?e:"";return{hasEnumConfig:"enum"===n,hasFormatConfig:p.rn.includes(n),hasEntityReferenceConfig:p.FM.includes(n),watchedOption:t}}),[x,W]),H=z.hasEnumConfig,J=z.hasFormatConfig,_=z.hasEntityReferenceConfig,j=z.watchedOption,Q=(0,d.useCallback)((function(){return n.goBack()}),[n]),X=(0,d.useCallback)((function(e){var t=e.target.classList.contains("ProseMirror");O(t?"root/description":e.target.id)}),[]);(0,d.useEffect)((function(){var e;e=t,(0,l.mG)(void 0,void 0,void 0,(function(){var t,n;return(0,l.Jh)(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,(0,C.ov)(e)];case 1:return t=a.sent(),w(t),[3,3];case 2:return n=a.sent(),(0,T.Eo)(n),[3,3];case 3:return[2]}}))}))}),[t]),(0,d.useEffect)((function(){(0,l.mG)(void 0,void 0,void 0,(function(){var e,t;return(0,l.Jh)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,(0,C.Qe)(a.Field)];case 1:return e=n.sent(),P(e.data),[3,3];case 2:return t=n.sent(),(0,T.Eo)(t),[3,3];case 3:return[2]}}))}))}),[]);var A=[{name:"name",required:!0,label:(0,s.t)("label.name"),id:"root/name",type:b.Uv.TEXT,props:{"data-testid":"name",autoComplete:"off"},placeholder:(0,s.t)("label.name"),rules:[{pattern:y.YZ,message:(0,s.t)("message.custom-property-name-validation")}]},{name:"propertyType",required:!0,label:(0,s.t)("label.type"),id:"root/propertyType",type:b.Uv.SELECT,props:{"data-testid":"propertyType",options:W,placeholder:""+(0,s.t)("label.select-field",{field:(0,s.t)("label.type")}),showSearch:!0,filterOption:function(e,t){var n;return(null!==(n=null==t?void 0:t.label)&&void 0!==n?n:"").toLowerCase().includes(e.toLowerCase())}}}],D={name:"description",required:!0,label:(0,s.t)("label.description"),id:"root/description",type:b.Uv.DESCRIPTION,props:{"data-testid":"description",initialValue:""}},V={name:"enumConfig",required:!1,label:(0,s.t)("label.enum-value-plural"),id:"root/enumConfig",type:b.Uv.SELECT,props:{"data-testid":"enumConfig",mode:"tags",placeholder:(0,s.t)("label.enum-value-plural")},rules:[{required:!0,message:(0,s.t)("label.field-required",{field:(0,s.t)("label.enum-value-plural")})}]},Y={name:"multiSelect",label:(0,s.t)("label.multi-select"),type:b.Uv.SWITCH,required:!1,props:{"data-testid":"multiSelect"},id:"root/multiSelect",formItemLayout:b.EP.HORIZONTAL},K={name:"formatConfig",required:!1,label:(0,s.t)("label.format"),id:"root/formatConfig",type:b.Uv.TEXT,props:{"data-testid":"formatConfig",autoComplete:"off"},placeholder:(0,s.t)("label.format"),rules:[{validator:function(e,t){var n,a=null!==(n=null==j?void 0:j.key)&&void 0!==n?n:"";return p.H2[a].includes(t)?Promise.resolve():Promise.reject((0,s.t)("label.field-invalid",{field:(0,s.t)("label.format")}))}}]},$={name:"entityReferenceConfig",required:!0,label:(0,s.t)("label.entity-reference-types"),id:"root/entityReferenceConfig",type:b.Uv.SELECT,props:{mode:"multiple",options:p.Qx,"data-testid":"entityReferenceConfig",placeholder:""+(0,s.t)("label.select-field",{field:(0,s.t)("label.type")})}},ee=d.createElement("div",{className:"max-width-md w-9/10 service-form-container"},d.createElement(R.Z,{titleLinks:B}),d.createElement(r.Z,{className:"m-t-md","data-testid":"custom-property-form",form:e,layout:"vertical",onFinish:function(e){return(0,l.mG)(void 0,void 0,void 0,(function(){var t,a,r,i;return(0,l.Jh)(this,(function(o){switch(o.label){case 0:if((0,c.isUndefined)(Z))return[2];o.label=1;case 1:return o.trys.push([1,3,4,5]),M(!0),t=void 0,H&&(t={config:{multiSelect:Boolean(null==e?void 0:e.multiSelect),values:e.enumConfig}}),J&&(t={config:e.formatConfig}),_&&(t={config:e.entityReferenceConfig}),a=(0,c.omitBy)((0,l.pi)((0,l.pi)({},(0,c.omit)(e,["multiSelect","formatConfig","entityReferenceConfig","enumConfig"])),{propertyType:{id:e.propertyType,type:"type"},customPropertyConfig:t}),c.isUndefined),[4,(0,C.q8)(null!==(i=null==Z?void 0:Z.id)&&void 0!==i?i:"",a)];case 2:return o.sent(),n.goBack(),[3,5];case 3:return r=o.sent(),(0,T.Eo)(r),[3,5];case 4:return M(!1),[7];case 5:return[2]}}))}))},onFocus:X},(0,h.GL)(A),H&&(0,h.GL)([V,Y]),J&&(0,h.GL)([K]),_&&(0,h.GL)([$]),(0,h.GL)([D]),d.createElement(i.Z,{justify:"end"},d.createElement(o.Z,null,d.createElement(u.Z,{"data-testid":"back-button",type:"link",onClick:Q},(0,s.t)("label.back"))),d.createElement(o.Z,null,d.createElement(u.Z,{"data-testid":"create-button",htmlType:"submit",loading:I,type:"primary"},(0,s.t)("label.create")))))),te=d.createElement(k.Z,{activeField:N,serviceName:v.uR,serviceType:v.rn});return d.createElement(S.Z,{className:"content-height-with-resizable-panel",firstPanel:{className:"content-resizable-panel-container",children:ee,minWidth:700,flex:.7},pageTitle:(0,s.t)("label.add-entity",{entity:(0,s.t)("label.custom-property")}),secondPanel:{children:te,className:"service-doc-panel content-resizable-panel-container",minWidth:400,flex:.3}})}}}]);