dsql-admin/dsql-app/.local_dist/server/chunks/4417.js

1 line
16 KiB
JavaScript
Raw Normal View History

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