dsql-admin/dsql-app/.local_dist/static/chunks/6156-9c7fc34b2aca4790.js

1 line
19 KiB
JavaScript
Raw Normal View History

2024-12-06 13:24:26 +00:00
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6156],{46156:(e,l,t)=>{t.d(l,{A:()=>F});var a=t(74848),i=t(96540),d=t(36517);function s(e){let{tableFields:l,setTableFields:t,setRefresh:a,setPageRefresh:i,refreshFieldsListRef:d}=e,s=l.findIndex(e=>"date_created"===e.fieldName);l.splice(s,0,{newTempField:!0}),t(l),(null==d?void 0:d.current)&&d.current(e=>e+1)}var n=t(66604),r=t(620),o=t(58825),c=t(2543),u=t.n(c);function m(e){let{tableFields:l,setTableFields:t,refreshFieldsListRef:a,order:i,field:d,e:s}=e,n=u().cloneDeep(l),r=n.findIndex(e=>e.fieldName===d.fieldName);if(r<0)return;let o=n[r];if("up"===i&&r&&r<=1){console.log("Min Reached =>",r);return}if("down"===i&&r&&r>=n.length-7){console.log("Max Reached =>",r);return}try{var c,m;let e;let l=s.target.closest(".table-field-wrapper"),t=l.previousElementSibling,a=l.nextElementSibling,d=window.DSQL.Flip,n=d.getState(l);"up"===i?(e=d.getState(t),null===(c=l.parentNode)||void 0===c||c.insertBefore(l,t)):(null==a?void 0:a.nextElementSibling)&&(e=d.getState(a),null===(m=l.parentNode)||void 0===m||m.insertBefore(l,a.nextElementSibling)),d.from(n,{duration:.3,ease:"power1.inOut"}),d.from(e,{duration:.3,ease:"power1.inOut"})}catch(e){console.log("Error =>",e.message)}if(!r){console.log("No target Field Index =>",r);return}n.splice(r,1),"up"===i?n.splice(r-1,0,o):n.splice(r+1,0,o),setTimeout(()=>{t([...n]),a.current&&a.current(e=>e+1)},500)}var p=t(35160),x=t(94996),h=t(23698);function v(e){var l,t,d,s,n,r,c,u,m,p,v;let{field:f,setTargetField:g,fieldIndex:w,tableFields:b,setTableFields:y,refreshFieldsListRef:j,database:N,currentTable:_,user:T,isDelegated:F,setLoading:A}=e,[C,k]=i.useState(f),[S,D]=i.useState(!1);return(0,a.jsxs)("div",{className:"flex-col w-full table-field-wrapper"+(S?" shadow-2xl shadow-slate-700/40 relative z-50":""),children:[(0,a.jsxs)("div",{className:"card no-hover items-center w-full py-4"+(S?" rounded-t":" rounded")+((null===(l=C.fieldName)||void 0===l?void 0:l.match(o.A))?" text-slate-400 pointer-events-none border-slate-200 border":" light-gray"),children:[(0,a.jsx)("span",{className:"font-bold"+((null===(t=C.fieldName)||void 0===t?void 0:t.match(o.A))?" dark:text-slate-500":" dark:text-white"),children:C.fieldName}),(0,a.jsx)("span",{className:"text-xs py-1 px-2 bg-slate-100 dark:bg-slate-700 dark:text-slate-200 rounded ",children:C.dataType}),(null==C?void 0:C.foreignKey)&&(0,a.jsxs)("div",{className:"text-xs bg-primary text-white px-2 py-0.5 rounded-full",children:[(0,a.jsx)("span",{children:"Foreign Key: "}),(0,a.jsxs)("span",{children:[C.foreignKey.destinationTableName," ("," ",(0,a.jsx)("b",{children:C.foreignKey.destinationTableColumnName})," ",")"]})]}),(null===(d=C.fieldName)||void 0===d?void 0:d.match(o.A))&&(0,a.jsx)("span",{className:"text-slate-300 text-sm font-semibold ml-0 md:ml-auto",children:"Default Field"}),!(!F&&!(null===(s=C.fieldName)||void 0===s?void 0:s.match(o.A))&&(null===(n=C.dataType)||void 0===n?void 0:n.match(/INT/)))||C.foreignKey||(null==N?void 0:null===(c=N.active_clone)||void 0===c?void 0:null===(r=c.toString())||void 0===r?void 0:r.match(/1/))?!(!F&&!(null===(u=C.fieldName)||void 0===u?void 0:u.match(o.A))&&(null===(m=C.dataType)||void 0===m?void 0:m.match(/INT/)))||(null==N?void 0:null===(v=N.active_clone)||void 0===v?void 0:null===(p=v.toString())||void 0===p?void 0:p.match(/1/))?(0,a.jsx)(i.Fragment,{}):(0,a.jsx)("div",{className:"ml-0 md:ml-auto flex-wrap",children:(0,a.jsx)("div",{className:"button py-1 text-xs light-gray",onClick:e=>{if(window.confirm("Delete this foreign Key?")){var l,t;delete f.foreignKey,A(!0),(0,h.A)("/api/updateClonedTableForeignKeys",{method:"post",body:{tableData:_,database:N.db_full_name,dbSlug:N.db_slug,delegated:null!==(t=window.location)&&void 0!==t&&null!==(l=t.search)&&void 0!==l&&!!l.match(/delegated=true/i)}},!0).then(e=>{e.success?window.location.reload():window.alert("Update Failed, Please Try again.")})}},style:{color:"var(--slate-500)"},children:"Delete Foreign Key"})}):(0,a.jsx)("div",{className:"ml-0 md:ml-auto flex-wrap",children:(0,a.jsx)("div",{class