1 line
20 KiB
JavaScript
1 line
20 KiB
JavaScript
|
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5160],{5160:(e,l,a)=>{a.d(l,{A:()=>o});var t=a(4848),n=a(6540),s=a(6051),i=a(9007),d=a(2543),r=a.n(d);function o(e){var l,d,o;let{targetField:u,fieldIndex:c,tableFields:m,setTableFields:x,refreshFieldsListRef:p,setActiveEdit:h,database:f,currentTable:v,user:g}=e,N=(null==u?void 0:u.dataType)?u.dataType.replace(/\d|\(|\)/g,""):null,y=(null==u?void 0:u.dataType)?u.dataType.replace(/[^\d]/g,""):"200",j=a(4327),b=n.useRef(r().cloneDeep(u)),w=n.useRef(),[T,_]=n.useState(u),[C,F]=n.useState(null==u?void 0:u.fieldName),[V,I]=n.useState(N),[k,S]=n.useState(y),[A,E]=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"),U=!!(null==V?void 0:V.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[c]=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=C),e))},required:!0,defaultValue:C})]}),(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:A})})]})]}),(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&&E(e.dataset.desc),e.value===l.value&&e.dataset.literal?(T.defaultValueLiteral=e.dataset.literal,T.nullValue=!1):delete T.defaultValueLiteral}),u.dataType=l.value+(l.value.match(/VARCHAR/)?"(".concat(k||200,")"):"")},defaultValue:V||void 0,children:j.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==V?void 0:V.match(/VARCHAR/))&&(0,t.jsx)("input",{type:"number",defaultValue:k||200,className:"px-2",style:{maxWidth:"60px"},max:255,min:5,onChange:e=>{S(e.target.value),u.dataType=V+"(".concat(e.target.value,")")}})]})]}),(null==V?void 0:V.match(/text/i))&&(0,t.jsx)(n.Fragment,{children:(0,t.jsx)(i.A,{targetField:u})}),!(null===(l=u.dataType)||void 0===l?void 0:l.match(/text/i))&&!U&&(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=!0:(u
|