felicity-lims/felicity/templates/static/assets/Groups-c0027382.js
2024-11-01 08:48:45 +02:00

1 line
4.8 KiB
JavaScript

import{d as N,aL as S,D as x,r as c,C as T,o as d,c as p,b as e,F as _,p as w,t as b,f as a,q as O,G as k,e as g,v as P,at as R,H as D,au as I,w as M,i as L,x as B,j as U,_ as V,Q as n,bs as F,bt as j,O as $,k as H}from"./index-e48f6898.js";const z={class:"container w-full my-4"},K=e("hr",null,null,-1),Q=e("hr",null,null,-1),Y=e("hr",null,null,-1),q={class:"overflow-x-auto mt-4"},W={class:"align-middle inline-block min-w-full shadow overflow-hidden bg-white shadow-dashboard px-2 pt-1 rounded-bl-lg rounded-br-lg"},J={class:"min-w-full"},X=e("thead",null,[e("tr",null,[e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Group Name "),e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Access Pages "),e("th",{class:"px-1 py-1 border-b-2 border-gray-300"})])],-1),Z={class:"bg-white"},ee={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},te={class:"flex items-center"},se={class:"text-sm leading-5 text-gray-800"},oe={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},ne={class:"text-sm leading-5 text-sky-800"},le={class:"px-1 py-1 whitespace-no-wrap text-right border-b border-gray-500 text-sm leading-5"},ae=["onClick"],re={action:"post",class:"p-1"},ie={class:"grid grid-cols-2 gap-x-4 mb-4"},de={class:"block col-span-2 mb-2"},ue=e("span",{class:"text-gray-700"},"Group Name",-1),ce={class:"block col-span-2 mb-2"},pe=e("span",{class:"text-gray-700"},"Pages",-1),be=["size"],me=["value"],_e={for:"toggle",class:"text-xs text-gray-700 mr-4"},ge={class:"relative inline-block w-10 mr-2 align-middle select-none transition duration-200 ease-in"},he=e("label",{for:"toggle",class:"toggle-label block overflow-hidden h-6 rounded-full bg-gray-300 cursor-pointer"},null,-1),fe=e("hr",null,null,-1),ve=N({__name:"Groups",setup(ye){const A=U(()=>V(()=>import("./FelModal-3c028bd6.js"),["assets/FelModal-3c028bd6.js","assets/index-e48f6898.js","assets/index-7d22ceed.css","assets/FelModal-a7d23795.css"])),h=[n.ADMINISTRATION,n.DASHBOARD,n.CLIENTS,n.PATIENTS,n.PATIENTS_COMPACT,n.SAMPLES,n.QC_SAMPLES,n.WORKSHEETS,n.NOTICE_MANAGER,n.BIO_BANKING,n.INVENTORY,n.REFERRAL];let i=S();const{withClientMutation:f}=$();i.fetchGroupsAndPermissions();const E=x(()=>i.getGroups);c("permissions");let r=c(!1),v=c("");const m=c(!0);let l=T({});function y(o,s={}){m.value=o,r.value=!0,v.value=(o?"CREATE":"EDIT")+" ANALYSES PROFILE",o?Object.assign(l,{name:"",pages:[]}):Object.assign(l,{...s})}function C(){const o={...l},s=o.pages;o.pages=s.join(","),m.value===!0&&f(F,{payload:o},"createGroup").then(t=>i.addGroup(t)),m.value===!1&&f(j,{uid:l?.uid,payload:{name:o.name,pages:o.pages}},"updateGroup").then(t=>i.updateGroup(t)),r.value=!1}const G=(o,s)=>o?.reduce(function(t,u){return(t[u[s]]=t[u[s]]||[]).push(u),t},{});return x(()=>Array.from(Object.entries(G(i.getPermissions,"target")))),(o,s)=>(d(),p(_,null,[e("div",z,[K,e("button",{class:"px-2 py-1 border-sky-800 border text-sky-800 rounded-sm transition duration-300 hover:bg-sky-800 hover:text-white focus:outline-none",onClick:s[0]||(s[0]=t=>y(!0))},"Add Group"),Q]),Y,e("div",q,[e("div",W,[e("table",J,[X,e("tbody",Z,[(d(!0),p(_,null,w(E.value,t=>(d(),p("tr",{key:t.uid},[e("td",ee,[e("div",te,[e("div",se,b(t.name),1)])]),e("td",oe,[e("div",ne,b(t.pages),1)]),e("td",le,[e("button",{onClick:u=>y(!1,t),class:"px-2 py-1 mr-2 border-orange-500 border text-orange-500 rounded-sm transition duration-300 hover:bg-orange-700 hover:text-white focus:outline-none"}," Edit ",8,ae)])]))),128))])])])]),a(r)?(d(),O(a(A),{key:0,onClose:s[5]||(s[5]=t=>L(r)?r.value=!1:r=!1)},{header:k(()=>[e("h3",null,b(a(v)),1)]),body:k(()=>[e("form",re,[e("div",ie,[e("label",de,[ue,g(e("input",{class:"form-input mt-1 block w-full","onUpdate:modelValue":s[1]||(s[1]=t=>a(l).name=t),placeholder:"Name ..."},null,512),[[P,a(l).name]])]),e("label",ce,[pe,g(e("select",{name:"controlLevels",id:"controlLevels","onUpdate:modelValue":s[2]||(s[2]=t=>a(l).pages=t),class:"form-input mt-1 block w-full",multiple:"",size:h.length},[(d(),p(_,null,w(h,t=>e("option",{key:t,value:t},b(t),9,me)),64))],8,be),[[R,a(l).pages]])]),e("label",_e,[D("Active "),e("div",ge,[g(e("input",{type:"checkbox",name:"toggle",id:"toggle","onUpdate:modelValue":s[3]||(s[3]=t=>a(l).active=t),class:"toggle-checkbox absolute block w-6 h-6 rounded-full bg-white border-4 appearance-none cursor-pointer outline-none"},null,512),[[I,a(l).active]]),he])])]),fe,e("button",{type:"button",onClick:s[4]||(s[4]=M(t=>C(),["prevent"])),class:"-mb-4 w-full border border-sky-800 bg-sky-800 text-white rounded-sm px-4 py-2 m-2 transition-colors duration-500 ease select-none hover:bg-sky-800 focus:outline-none focus:shadow-outline"}," Save Form ")])]),_:1})):B("",!0)],64))}}),we=H(ve,[["__file","/home/aurthurm/Documents/Development/felicity/felicity-lims/webapp/views/admin/users/Groups.vue"]]);export{we as default};