import{m as _,o as C,w as $,bD as T,bm as v,af as y,at as h,ah as n,d as l,ak as B,al as D,am as N,E as U,an as S,B as I,V as d,as as O,ap as q,ai as f,bS as P,Q as b,ar as A,bj as E,aG as w,ag as F,bt as L}from"./index.14cbc3e2.js";import{Q as M}from"./QToolbar.5456f6d3.js";import{Q as V}from"./QTd.329d91e3.js";import{Q as R}from"./QTable.1309c809.js";import{Q as z}from"./QPage.91f292ed.js";import{Q as k}from"./QSelect.86e92876.js";import{u as j}from"./use-dialog-plugin-component.3669c11d.js";import{b as Q}from"./route-block.7fdbc26a.js";import"./QLinearProgress.49ce6557.js";import"./QChip.ece4defb.js";import"./QMenu.0f841ec0.js";import"./rtl.87fd3dfc.js";const G={class:"pt-3"},K={class:"q-gutter-md"},H={__name:"create",props:{item:null},setup(x){const r=x,{dialogRef:a,onDialogOK:c,onDialogCancel:p}=j(),m={collection:"",visibleFields:""},e=_({loading:!1,roles:[],collections:[],isCollection:{},entry:{name:null,active:!1,config:{},rolesIds:[],description:null}});r.item&&(e.entry=r.item),e.entry.config={...m,...e.entry.config},C(()=>{o(),g()}),$(()=>e.entry.name,s=>{s&&(e.entry.name=s.toLowerCase().replace(/\s/g,""))});async function o(){e.collections=await T()}async function u(){e.loading=!0;var s={...e.entry};r.item?await v.updateOne("modelviews",{where:{id:r.item.id},data:s}).then(t=>{c()}).catch(t=>{}):await v.createOne("modelviews",{data:s}).then(t=>{c()}).catch(t=>{}),e.loading=!1}function g(){v.findMany("roles").then(s=>{e.roles=s})}return(s,t)=>(y(),h(A,{ref_key:"dialogRef",ref:a,maximized:"",position:"right"},{default:n(()=>[l(B,{style:{"min-width":"70vh"}},{default:n(()=>[l(D,null,{default:n(()=>[l(N,{shrink:""},{default:n(()=>[U(" Create view ")]),_:1}),l(S),I(l(d,{outline:"",icon:"mdi-close"},null,512),[[O]]),l(d,{loading:e.loading,onClick:t[0]||(t[0]=i=>u()),color:"green",icon:"mdi-check"},null,8,["loading"])]),_:1}),l(q,{class:"p-10"},{default:n(()=>[f("div",G,[f("div",K,[l(P,{color:"green",label:"Active",modelValue:e.entry.active,"onUpdate:modelValue":t[1]||(t[1]=i=>e.entry.active=i)},null,8,["modelValue"]),l(b,{modelValue:e.entry.name,"onUpdate:modelValue":t[2]||(t[2]=i=>e.entry.name=i),outlined:"",dark:"",mask:"xxxxxxxxxxxxxxxxxxxxxx",color:"white",label:"name"},null,8,["modelValue"]),l(k,{multiple:"",outlined:"",color:"white","option-value":"id","emit-value":"","map-options":"",modelValue:e.entry.rolesIds,"onUpdate:modelValue":t[3]||(t[3]=i=>e.entry.rolesIds=i),"option-label":"name",options:e.roles,"use-chips":"",label:"Roles"},null,8,["modelValue","options"]),l(k,{label:"Collection",outlined:"",modelValue:e.entry.config.collection,"onUpdate:modelValue":t[4]||(t[4]=i=>e.entry.config.collection=i),color:"white","option-label":"slug",options:e.collections},null,8,["modelValue","options"]),l(b,{label:"Visibles fields",outlined:"",modelValue:e.entry.config.visibleFields,"onUpdate:modelValue":t[5]||(t[5]=i=>e.entry.config.visibleFields=i),color:"white",type:"textarea"},null,8,["modelValue"])])])]),_:1})]),_:1})]),_:1},512))}},J={class:"q-gutter-md"},W={class:"pt-10"},X={key:0},Y={class:"q-gutter-md"},Z={__name:"index",setup(x){const r=E(),a=_({filter:"",loading:!1,views:[]});C(()=>{p()});function c(m=null){r.dialog({component:H,componentProps:{item:m?{...m}:null}}).onOk(()=>{p()})}async function p(){a.loading=!0,a.views=await v.findMany("modelviews"),a.loading=!1}return(m,e)=>(y(),h(z,{padding:""},{default:n(()=>[l(M,null,{default:n(()=>[l(b,{dense:"",dark:"",standout:"",modelValue:a.filter,"onUpdate:modelValue":e[0]||(e[0]=o=>a.filter=o),color:"white",label:"Search"},{prepend:n(()=>[l(w,{name:"mdi-magnify"})]),_:1},8,["modelValue"]),l(S),f("div",J,[l(d,{outline:"",icon:"mdi-sync",onClick:e[1]||(e[1]=o=>p())}),l(d,{color:"green",onClick:e[2]||(e[2]=o=>c()),icon:"mdi-plus"})])]),_:1}),f("div",W,[l(R,{filter:a.filter,flat:"",class:"border-2",dark:"",columns:[{name:"status",label:"status",align:"left",field:o=>o.active,sortable:!0},{name:"Name",label:"Name of view",align:"left",field:o=>o.name,sortable:!0},{name:"Linked to",label:"Linked to",align:"left",field:o=>{var u,g;return(g=(u=o.config)==null?void 0:u.collection)==null?void 0:g.slug},sortable:!0},{name:"actions"}],loading:a.loading,rows:a.views},{"body-cell-status":n(o=>[l(V,{props:o},{default:n(()=>[o.value?(y(),F("div",X,[l(w,{size:"sm",name:"mdi-circle",color:"green"})])):L("",!0)]),_:2},1032,["props"])]),"body-cell-actions":n(o=>[l(V,{props:o},{default:n(()=>[f("div",Y,[l(d,{onClick:u=>c(o.row),outline:"",dense:"",icon:"mdi-pencil"},null,8,["onClick"]),l(d,{class:"text-black",color:"red",dense:"",icon:"mdi-delete"})])]),_:2},1032,["props"])]),_:1},8,["filter","columns","loading","rows"])])]),_:1}))}};typeof Q=="function"&&Q(Z);export{Z as default};
