dsql-admin/dsql-app/.local_dist/static/chunks/8311-87e8d6ec01c2e05f.js

1 line
39 KiB
JavaScript
Raw Normal View History

2025-01-14 06:42:13 +00:00
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8311],{8034:(e,l,a)=>{a.d(l,{A:()=>o});var t=a(4848),i=a(6540),n=a(809),s=a(1765),d=a(2543),r=a.n(d);function o(e){var l,d,o;let{targetField:c,fieldIndex:u,tableFields:m,setTableFields:x,refreshFieldsListRef:p,setActiveEdit:h,database:f,currentTable:v,user:g}=e,y=(null==c?void 0:c.dataType)?c.dataType.replace(/\d|\(|\)/g,""):null,j=(null==c?void 0:c.dataType)?c.dataType.replace(/[^\d]/g,""):"200",N=a(4327),b=i.useRef(r().cloneDeep(c)),w=i.useRef(),[T,_]=i.useState(c),[F,C]=i.useState(null==c?void 0:c.fieldName),[A,S]=i.useState(y),[k,D]=i.useState(j),[V,I]=i.useState("Varchar is simply letters and numbers within the range 0 - 255"),[E,K]=i.useState((null==c?void 0:c.richText)&&!(null==c?void 0:c.encrypted)?"Yes":"No"),R=!!(null==A?void 0:A.match(/uuid/i));return(0,t.jsx)("div",{className:"w-full -mt-3 bg-white dark:bg-slate-800 flex-wrap",ref:w,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[u]=T,e)),p.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:V})})]})]}),(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;S(l.value),l.childNodes.forEach(e=>{e.value===l.value&&e.dataset.desc&&I(e.dataset.desc),e.value===l.value&&e.dataset.literal?(T.defaultValueLiteral=e.dataset.literal,T.nullValue=!1):delete T.defaultValueLiteral}),c.dataType=l.value+(l.value.match(/VARCHAR/)?"(".concat(k||200,")"):"")},defaultValue:A||void 0,children:N.map((e,l)=>e.name.match(/VARCHAR/)?(0,t.jsx)("option",{value:e.name,"data-desc":e.description,children:e.title+"("+(k||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==A?void 0:A.match(/VARCHAR/))&&(0,t.jsx)("input",{type:"number",defaultValue:k||200,className:"px-2",style:{maxWidth:"60px"},max:255,min:5,onChange:e=>{D(e.target.value),c.dataType=A+"(".concat(e.target.value,")")}})]})]}),(null==A?void 0:A.match(/text/i))&&(0,t.jsx)(i.Fragment,{children:(0,t.jsx)(s.A,{targetField:c})}),!(null===(l=c.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==c?void 0:c.notNullValue)?"Yes":"No",onChange:e=>{console.log(c),"Yes"===e.target.value?c.notNullValue=!0:(c.