1 line
9.2 KiB
JavaScript
1 line
9.2 KiB
JavaScript
"use strict";exports.id=4627,exports.ids=[4627],exports.modules={23180:(e,t,a)=>{a.d(t,{A:()=>b});var l=a(8732),i=a(82015),s=a.n(i),d=a(42960),n=a(46169),r=a(72390),c=a(51339),o=a(16757),p=a(6748),u=a(27825),m=a.n(u),f=a(60424),h=a(95939),x=a(41836);function y({user:e,table:t,entry:a,url:i,query:d}){let[n,r]=s().useState(!1),c=s().useRef(null);return(0,l.jsx)("div",{className:"relative z-[1000]",children:(0,l.jsx)(x.Popover,{isOpen:n,onClickOutside:()=>r(!1),containerClassName:"z-[1000]",positions:["bottom"],align:"end",content:(0,l.jsx)("div",{className:"bg-white dark:bg-slate-900 rounded shadow-md cancel-link",children:(0,l.jsxs)("div",{className:"flex-col min-w-[200px] items-stretch gap-0",children:[(0,l.jsx)("button",{className:"plain-text justify-start py-3",onClick:()=>{navigator.clipboard.writeText(JSON.stringify(a)).then(()=>{window.alert("Post Copied"),r(!1)})},children:"Copy Object"}),(0,l.jsx)("hr",{className:"m-0"}),(0,l.jsx)("button",{className:"plain-text justify-start py-3",onClick:()=>{let a=(0,f.A)({paradigm:"JavaScript",table:t,query:d,user:e});navigator.clipboard.writeText(a||"").then(()=>{window.alert("JavaScript Type Definition Copied"),r(!1)})},children:"Copy JS Type Definition"}),(0,l.jsx)("hr",{className:"m-0"}),(0,l.jsx)("button",{className:"plain-text justify-start py-3",onClick:()=>{let a=(0,f.A)({paradigm:"TypeScript",table:t,query:d,user:e});navigator.clipboard.writeText(a||"").then(()=>{window.alert("TypeScript Type Definition Copied"),r(!1)})},children:"Copy TS Type Definition"}),(0,l.jsx)("hr",{className:"m-0"}),(0,l.jsx)("a",{href:i,className:"button plain-text justify-start py-3",children:(0,l.jsx)("span",{children:"View Entry"})})]})}),children:(0,l.jsx)("button",{onClick:()=>{r(!n)},ref:c,className:"ghost p-2",children:(0,l.jsx)(h.A,{})})})})}function b({user:e,database:t,table:a,dbSchemaData:i,richTextEditors:u,jsonTextEditors:f,dataTypes:h,entry:x,entryPage:b,confirmedDelegetedUser:N,query:g}){let w=a.fields.filter(e=>e.fieldName&&!e.fieldName.match(d.A)),j=a.fields.find(e=>"uuid"===e.fieldName),v=N?.delegated;N?.priviledges?.match(/Edit Tables/i),N?.priviledges?.match(/Delete Tables/i),N?.priviledges?.match(/Create Tables/i),N?.priviledges?.match(/Edit Entries/i);let T=N?.priviledges?.match(/Delete Entries/i);j&&w.unshift({dataType:"UUID",fieldName:"uuid",defaultField:!0}),w.unshift({dataType:"BIGINT",fieldName:"id",defaultField:!0}),w.push({dataType:"VARCHAR(250)",fieldName:"date_created",defaultField:!0}),w.push({dataType:"BIGINT",fieldName:"date_created_code",defaultField:!0}),w.push({dataType:"TIMESTAMP",fieldName:"date_created_timestamp",defaultField:!0}),w.push({dataType:"VARCHAR(250)",fieldName:"date_updated",defaultField:!0}),w.push({dataType:"BIGINT",fieldName:"date_updated_code",defaultField:!0}),w.push({dataType:"TIMESTAMP",fieldName:"date_updated_timestamp",defaultField:!0});let[_,E]=s().useState(!1),[S,C]=s().useState(!0),[k,A]=s().useState(x),[F,I]=s().useState(!1);s().useRef(null);let D=s().useRef([]),[$,R]=s().useState(`/admin/${e?.id}/databases/${t.db_slug}/tables/${a.tableName}/entries/${k.id}`),L=`${t.db_slug}-${a.tableName}-${k.id}-submit-button`;return(0,l.jsxs)("div",{className:"card col w-full overflow-hidden",children:[(0,l.jsx)("a",{href:$,onClick:e=>{let t=e.target;(t.closest(".cancel-link")||t.closest(".MuiPopover-root"))&&e.preventDefault()},className:"w-full",children:(0,l.jsxs)("div",{className:"w-full bg-slate-700 text-white py-2 px-4 rounded justify-between flex-wrap hover:bg-slate-800 cursor-pointer relative z-[1000] ",onClick:e=>{let t=e.target;t.closest(".cancel-link")||t.closest(".MuiPopover-root")||(e.ctrlKey?window.open($,"__blank"):window.location.href=$)},children:[(0,l.jsxs)("span",{children:["Entry #",k.id]}),(0,l.jsxs)("div",{className:"flex-wrap cancel-link",children:[(!v||v&&T)&&(0,l.jsx)("span",{className:"text-slate-300 hover:text-fuchsia-200 cursor-pointer"+(_?" pointer-events-none opacity-40":""),onClick:e=>{window.confirm(`Delete Entry #${k.id}?`)&&(E(!0),(0,n.A)("/api/deleteTableEntry"+window.location.search,{method:"post",body:{dbFullName:t.db_full_name,tableName:a.tableName,entryId:k.id,dbSlug:t.db_slug,dbId:t.id,delegated:g?.delegated,confirmedDelegetedUser:N}},!0).then(e=>{e.success?(0,r.A)().then(()=>{window.location.reload()}):(window.alert(e.msg),setTimeout(()=>{E(!1)},500))}))},children:"Delete Entry"}),!b&&(0,l.jsxs)(s().Fragment,{children:[(0,l.jsx)("span",{className:"opacity-20",children:"|"}),(0,l.jsx)("span",{className:"text-slate-300 hover:text-fuchsia-200 cursor-pointer",onClick:e=>{S?C(!1):C(!0)},children:S?(0,l.jsx)("span",{children:"Expand"}):(0,l.jsx)("span",{children:"Collapse"})})]}),(0,l.jsx)("span",{className:"opacity-20",children:"|"}),(0,l.jsx)("div",{className:"button ghost px-0",onClick:l=>{let i=m().cloneDeep(x);delete i.date_created,delete i.date_created_code,delete i.date_created_timestamp,delete i.date_updated,delete i.date_updated_code,delete i.date_updated_timestamp,delete i.id,delete i.uuid,localStorage.setItem("duplicate_entry",JSON.stringify(i)),window.location.href=`/admin/${e?.id}/databases/${t.db_slug}/tables/${a.tableName}/entries/add-entry?duplicate=true&id=${x.id}`},children:(0,l.jsx)("span",{className:"text-slate-300",children:"Duplicate"})}),(0,l.jsx)("span",{className:"opacity-20",children:"|"}),(0,l.jsx)(y,{table:a,user:e,entry:x,query:g,url:$})]})]})}),(0,l.jsxs)("form",{className:"w-full flex flex-col items-stretch gap-8 minimal-scrollbars relative",style:b?{}:{maxHeight:S?"300px":"none",paddingTop:"10px",paddingBottom:"10px",overflow:"hidden"},onSubmit:e=>{e.preventDefault(),E(!0);let l={},i=e.target;w.forEach(e=>{if(!e.fieldName||!i[e.fieldName])return;let t="string"!=typeof i[e.fieldName].value,a="number"!=typeof i[e.fieldName].value;(t||a||i[e.fieldName].value)&&(i[e.fieldName]?.dataset.default||(l[e.fieldName]=i[e.fieldName].value))}),D.current[0]&&D.current.forEach(e=>{e?.fieldName&&e?.ref?.current&&(l[e.fieldName]=e.ref.current.getContent())}),f.current[0]&&f.current.forEach(e=>{e?.fieldName&&e?.ref?.current&&(l[e.fieldName]=e.ref.current.getValue())}),(0,n.A)("/api/updateTableEntry",{method:"post",body:{dbFullName:t.db_full_name,dbSlug:t.db_slug,dbId:t.id,tableName:a.tableName,entryId:k.id,payload:l,tableSchema:a,delegated:g?.delegated,confirmedDelegetedUser:N}},!0).then(e=>{e.success?(0,n.A)("/api/refreshEntry",{method:"POST",body:{table:a.tableName,db:t.db_full_name,id:k.id,schema:JSON.stringify(a)}}).then(e=>{e.success&&(A(e.entry),setTimeout(()=>{E(!1)},500))}):(window.alert(e.msg+"\n"+(e.err||"")),setTimeout(()=>{E(!1)},500))})},onKeyUp:e=>{e.ctrlKey&&"Enter"==e.key&&window.confirm("Update this Form?")&&document.getElementById(L)?.click()},children:[_&&(0,l.jsx)(o.A,{}),(S&&!b?w.slice(0,3):w).map((e,t)=>{let a=h.filter(t=>t.name===e.dataType?.replace(/\d|\(|\)/g,""));return(0,l.jsx)(p.A,{fieldObject:e,dataTypeSchema:a[0],richTextEditors:u,currentRichTextEditorForms:D,entry:k,query:g,entryPage:b,confirmedDelegetedUser:N,jsonTextEditors:f,formButtonId:L},t+1)}),(0,l.jsx)("button",{type:"submit",className:_?" pointer-events-none opacity-40":"",id:L,children:"Update Entry"})]}),!b&&(0,l.jsx)(c.A,{collapse:S,setCollapse:C})]})}},80830:(e,t,a)=>{a.d(t,{A:()=>s});var l=a(8732),i=a(58526);function s({selectOptions:e,name:t,onChangeHandler:a,required:s,setAlert:d,title:n,defaultValue:r,info:c,id:o}){try{function p(e){if(e.type.match(/enter/i)&&window.innerWidth<1200)return;let t=e.target.closest(".info-wrapper"),a=t.querySelector(".info-dropdown");if(e.type.match(/leave/i)&&!a.classList.contains("hidden")){a.classList.add("hidden");return}if(!(e.type.match(/leave/i)&&a.classList.contains("hidden"))){if(!t){a.classList.add("hidden");return}if(a.classList.contains("hidden")){a.classList.remove("hidden");return}a.classList.add("hidden")}}return(0,l.jsxs)("div",{className:"form-select-block flex items-start flex-col gap-0.5 w-full relative"+(c?" pr-8":""),children:[n&&(0,l.jsxs)("label",{htmlFor:t,children:[n,s?"":" (optional)"]}),(0,l.jsxs)("div",{className:"flex items-center w-full relative",children:[(0,l.jsx)("select",{name:t,id:o||t,className:"w-full bg-white",required:s,onChange:e=>{d&&d(null),e.target.classList.remove("warning"),a&&a(e)},defaultValue:r||void 0,children:e.map((e,t)=>{let{payload:a,title:i}=e;return(0,l.jsx)("option",{value:a,selected:!!e.default,children:i},t+1)})}),(0,l.jsx)(i.A,{className:"absolute right-2 text-base text-slate-500 pointer-events-none",size:20}),c&&(0,l.jsxs)("div",{className:"info-wrapper absolute -right-10 w-8 h-8 rounded-full bg-white flex items-center justify-center z-10",style:{top:"50%",transform:"translate(0,-50%)"},onMouseEnter:p,onMouseLeave:p,onClick:p,children:[(0,l.jsx)("img",{src:"/images/info-outlined-black.png",alt:"",className:"w-6 h-6 object-contain opacity-60 pointer-events-none"}),(0,l.jsx)("div",{className:"info-dropdown absolute top-9 right-0 bg-white w-52 md:w-96 p-2 sm:p-6 shadow-xl rounded hidden text-center border border-slate-300 border-solid",children:(0,l.jsx)("span",{children:c})}),(0,l.jsx)("div",{className:"absolute -top-2 w-12",style:{height:"45px"}})]})]})]})}catch(e){return console.log("ERROR in FormSelect =>",e),(0,l.jsx)("div",{children:"Form Select Error"})}}a(82015)},95939:(e,t,a)=>{a.d(t,{A:()=>l});let l=(0,a(82544).A)("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]])}}; |