dsql-admin/dsql-app/.local_dist/static/chunks/4893-e30c16360c86c67d.js

1 line
21 KiB
JavaScript
Raw Normal View History

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