dsql-admin/dsql-app/.local_dist/static/chunks/5160-e9f06aec35447872.js

1 line
19 KiB
JavaScript
Raw Normal View History

2024-12-05 07:03:33 +00:00
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5160],{35160:(e,l,a)=>{a.d(l,{A:()=>o});var t=a(74848),n=a(96540),i=a(66051),s=a(39007),d=a(2543),r=a.n(d);function o(e){var l,d,o;let{targetField:u,fieldIndex:c,tableFields:m,setTableFields:x,refreshFieldsListRef:h,setActiveEdit:p,database:f,currentTable:v,user:g}=e,N=(null==u?void 0:u.dataType)?u.dataType.replace(/\d|\(|\)/g,""):null,j=(null==u?void 0:u.dataType)?u.dataType.replace(/[^\d]/g,""):"200",y=a(43431),b=n.useRef(r().cloneDeep(u)),T=n.useRef(),[w,_]=n.useState(u),[F,V]=n.useState(null==u?void 0:u.fieldName),[C,I]=n.useState(N),[S,A]=n.useState(j),[E,k]=n.useState("Varchar is simply letters and numbers within the range 0 - 255"),[D,K]=n.useState((null==u?void 0:u.richText)&&!(null==u?void 0:u.encrypted)?"Yes":"No"),R=!!(null==C?void 0:C.match(/uuid/i));return(0,t.jsx)("div",{className:"w-full -mt-3 bg-white dark:bg-slate-800 flex-wrap",ref:T,children:(0,t.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:e=>{var l,a;e.preventDefault(),x(e=>(e[c]=w,e)),h.current(e=>e+1),null===(a=e.target.closest(".table-field-wrapper"))||void 0===a||null===(l=a.querySelector(".edit-table-field-section"))||void 0===l||l.classList.toggle("hidden")},children:[(0,t.jsxs)("div",{className:"gap-4 flex-wrap w-full md:w-auto flex-col xl:flex-row items-stretch",children:[(0,t.jsxs)("div",{className:"flex flex-col items-start gap-0.5",children:[(0,t.jsx)("label",{htmlFor:"new_field_name",children:"Field Name"}),(0,t.jsx)("input",{type:"text",name:"new_field_name",id:"new_field_name",placeholder:"Eg. post_title",onInput:async e=>{let l=e.target;l.value=l.value.toLowerCase().replace(/ /g,"_"),_(e=>(e.fieldName=l.value,e.updatedField=!0,e.originName||(e.originName=F),e))},required:!0,defaultValue:F})]}),(0,t.jsxs)("div",{className:"flex flex-col items-start gap-4 xl:gap-0.5",children:[(0,t.jsxs)("div",{className:"flex-wrap xl:flex-nowrap w-full md:w-auto",children:[(0,t.jsx)("label",{htmlFor:"new_field_data_type",children:"Data Type"}),(0,t.jsxs)("div",{className:"dropdown-wrapper reversed text-sm items-start",children:[(0,t.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,t.jsx)("div",{className:"dropdown mt-0 xl:-mt-2",children:(0,t.jsx)("span",{children:E})})]})]}),(0,t.jsxs)("div",{className:"w-auto",children:[(0,t.jsx)("select",{name:"new_field_data_type",id:"new_field_data_type",className:"w-full xl-w-auto",onChange:e=>{let l=e.target;I(l.value),l.childNodes.forEach(e=>{e.value===l.value&&e.dataset.desc&&k(e.dataset.desc),e.value===l.value&&e.dataset.literal?(w.defaultValueLiteral=e.dataset.literal,w.nullValue=!1):delete w.defaultValueLiteral}),u.dataType=l.value+(l.value.match(/VARCHAR/)?"(".concat(S||200,")"):"")},defaultValue:C||void 0,children:y.map((e,l)=>e.name.match(/VARCHAR/)?(0,t.jsx)("option",{value:e.name,"data-desc":e.description,children:e.title+"("+(S||200)+")"},l+1):(0,t.jsx)("option",{value:e.name,"data-desc":e.description,"data-literal":e.valueLiteral||void 0,children:e.title},l+1))}),(null==C?void 0:C.match(/VARCHAR/))&&(0,t.jsx)("input",{type:"number",defaultValue:S||200,className:"px-2",style:{maxWidth:"60px"},max:255,min:5,onChange:e=>{A(e.target.value),u.dataType=C+"(".concat(e.target.value,")")}})]})]}),(null==C?void 0:C.match(/text/i))&&(0,t.jsx)(n.Fragment,{children:(0,t.jsx)(s.A,{targetField:u})}),!(null===(l=u.dataType)||void 0===l?void 0:l.match(/text/i))&&!R&&(0,t.jsxs)("div",{className:"flex flex-col items-start gap-0.5",style:{minWidth:"70px"},children:[(0,t.jsx)("label",{htmlFor:"new_field_required",children:"Required?"}),(0,t.jsxs)("select",{name:"new_field_required",id:"new_field_required",className:"px-2",defaultValue:(null==u?void 0:u.notNullValue)?"Yes":"No",onChange:e=>{console.log(u),"Yes"===e.target.value?u.notNullValue