dsql-admin/dsql-app/.local_dist/static/chunks/9967-c027b915261dae19.js

1 line
20 KiB
JavaScript
Raw Normal View History

2024-11-05 11:12:42 +00:00
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9967],{99967:function(e,t,l){l.d(t,{Z:function(){return m}});var a=l(47568),n=l(828),i=l(97582),s=l(85893),r=l(67294),d=l(24209),o=l(64838),u=l(96486),c=l.n(u);function m(e){var t,u,m,f=e.targetField,v=e.fieldIndex,x=e.tableFields,h=e.setTableFields,p=e.refreshFieldsListRef,g=e.setActiveEdit,N=e.database,j=e.currentTable,y=e.user,b=(null===f||void 0===f?void 0:f.dataType)?f.dataType.replace(/\d|\(|\)/g,""):null,T=(null===f||void 0===f?void 0:f.dataType)?f.dataType.replace(/[^\d]/g,""):"200",w=l(89594),_=r.useRef(c().cloneDeep(f)),F=r.useRef(),C=(0,n.Z)(r.useState(f),2),I=C[0],V=C[1],E=(0,n.Z)(r.useState(null===f||void 0===f?void 0:f.fieldName),2),S=E[0],D=(E[1],(0,n.Z)(r.useState(b),2)),k=D[0],Z=D[1],K=(0,n.Z)(r.useState(T),2),R=K[0],A=K[1],L=(0,n.Z)(r.useState("Varchar is simply letters and numbers within the range 0 - 255"),2),U=L[0],M=L[1],Y=(0,n.Z)(r.useState((null===f||void 0===f?void 0:f.richText)&&!(null===f||void 0===f?void 0:f.encrypted)?"Yes":"No"),2),q=(Y[0],Y[1],Boolean(null===k||void 0===k?void 0:k.match(/uuid/i)));return(0,s.jsx)("div",{className:"w-full -mt-3 bg-white dark:bg-slate-800 flex-wrap",ref:F,children:(0,s.jsxs)("form",{className:"flex flex-col xl:flex-row items-start gap-4 w-full justify-between border border-solid p-4 border-slate-200 dark:border-slate-600 rounded rounded-t-none focus:shadow-lg shadow-slate-700 dark:shadow-black relative flex-wrap",onSubmit:function(e){var t,l;e.preventDefault(),h((function(e){var t=e;return t[v]=I,t})),p.current((function(e){return e+1})),null===(l=null===(t=e.target.closest(".table-field-wrapper"))||void 0===t?void 0:t.querySelector(".edit-table-field-section"))||void 0===l||l.classList.toggle("hidden")},children:[(0,s.jsxs)("div",{className:"gap-4 flex-wrap w-full md:w-auto flex-col xl:flex-row items-stretch",children:[(0,s.jsxs)("div",{className:"flex flex-col items-start gap-0.5",children:[(0,s.jsx)("label",{htmlFor:"new_field_name",children:"Field Name"}),(0,s.jsx)("input",{type:"text",name:"new_field_name",id:"new_field_name",placeholder:"Eg. post_title",onInput:function(){var e=(0,a.Z)((function(e){var t;return(0,i.__generator)(this,(function(l){return(t=e.target).value=t.value.toLowerCase().replace(/ /g,"_"),V((function(e){var l=e;return l.fieldName=t.value,l.updatedField=!0,l.originName||(l.originName=S),l})),[2]}))}));return function(t){return e.apply(this,arguments)}}(),required:!0,defaultValue:S})]}),(0,s.jsxs)("div",{className:"flex flex-col items-start gap-4 xl:gap-0.5",children:[(0,s.jsxs)("div",{className:"flex-wrap xl:flex-nowrap w-full md:w-auto",children:[(0,s.jsx)("label",{htmlFor:"new_field_data_type",children:"Data Type"}),(0,s.jsxs)("div",{className:"dropdown-wrapper reversed text-sm items-start",children:[(0,s.jsx)("span",{className:"px-2 bg-slate-200 dark:bg-slate-700 rounded-full hover:bg-slate-100 dark:hover:bg-slate-600 hidden xl:flex",children:"Info"}),(0,s.jsx)("div",{className:"dropdown mt-0 xl:-mt-2",children:(0,s.jsx)("span",{children:U})})]})]}),(0,s.jsxs)("div",{className:"w-auto",children:[(0,s.jsx)("select",{name:"new_field_data_type",id:"new_field_data_type",className:"w-full xl-w-auto",onChange:function(e){var t=e.target;Z(t.value),t.childNodes.forEach((function(e){e.value===t.value&&e.dataset.desc&&M(e.dataset.desc),e.value===t.value&&e.dataset.literal?(I.defaultValueLiteral=e.dataset.literal,I.nullValue=!1):delete I.defaultValueLiteral})),f.dataType=t.value+(t.value.match(/VARCHAR/)?"(".concat(R||200,")"):"")},defaultValue:k||void 0,children:w.map((function(e,t){return e.name.match(/VARCHAR/)?(0,s.jsx)("option",{value:e.name,"data-desc":e.description,children:e.title+"("+(R||200)+")"},t+1):(0,s.jsx)("option",{value:e.name,"data-desc":e.description,"data-literal":e.valueLiteral||void 0,children:e.title},t+1)}))}),(null===k||void 0===k?void 0:k.match(/VARCHAR/))&&(0,s.jsx)("input",{type:"number",defaultValue:R||200,className:"px-2",style:{maxWidth:"60px"},max:255,min:5,onChange:function(e){A(e.target.value),f.dataType=k+"(".concat(e.target.value,")")}}