1import"./D0b9Gkca.js";import{u as m}from"./Bx9bGCmp.js";import{d as F,i as T,R as P,s as g,f as Y,o as h,w as Z,b as r,c as w,g as z,F as q,q as H,t as O,u as k,_ as j,X as B,N as M,a as U,P as J}from"./CNS0JZGO.js";import{D as f}from"./DSmCMhwO.js";import"./6aCOVfiM.js";import{C as Q}from"./B-7cGRgE.js";import{D as ee}from"./C1C0dzHG.js";import{D as K}from"./DNxcLYdX.js";import"./DuUQDhK2.js";const te={class:"date"},se={class:"text"},ne=F({__name:"shift-assignment-log",async setup(G){let t,l;const p=([t,l]=T(()=>m("/person/find",{method:"GET",query:{roles:[P.Admin.value,P.PowerUser.value].toString()}})),t=await t,l(),t).toMap(n=>n.id),D=([t,l]=T(()=>m("/shift/assignments",{method:"GET"})),t=await t,l(),t).toMap(n=>n.id),A=([t,l]=T(()=>m("/shift",{method:"GET"})),t=await t,l(),t).toMap(n=>n.id),E=g(([t,l]=T(()=>m("/shift/log?limit=10",{method:"GET"})),t=await t,l(),t)),y=([t,l]=T(()=>m("/shift/log/count",{method:"GET"})),t=await t,l(),t),e=g(10);function i(n){var R,V;const _=(R=p.get(n.updatePersonId))==null?void 0:R.firstName,N=n.createdShiftAssignmentId||n.deletedShiftAssignmentId,v=D.get(N),I=n.updatePersonId===v.personId?"sich selbst":(V=p.get(v.personId))==null?void 0:V.firstName,C=f.formatDate(v.assignmentDate,!1,"dd.MM.yy"),S=A.get(v.shiftId),b=`${S.startTime.substring(0,5)} - ${S.endTime.substring(0,5)}`;return n.createdShiftAssignmentId?`${_} hat ${I} für die Schicht ${b} am ${C} eingetragen.`:`${_} hat ${I} von der Schicht ${b} am ${C} ausgetragen.`}async function c(){const n=e.value+10;E.value.push(...await m(`/shift/log?skip=${e.value}&limit=${n}`,{method:"GET"})),e.value=n}return(n,_)=>(h(),Y(Q,{title:"Log"},{default:Z(()=>[r("ul",null,[(h(!0),w(q,null,H(E.value,N=>(h(),w("li",null,[r("span",te,O(k(f).formatDate(N.updateDate,!1,"dd.MM.yy hh:mm")),1),r("span",se,O(i(N)),1)]))),256))]),e.value<k(y)?(h(),w("button",{key:0,onClick:c,class:"load"},"Mehr laden")):z("",!0)]),_:1}))}}),ae=j(ne,[["__scopeId","data-v-8317103c"]]),ie={class:"card"},oe={class:"heading"},le={key:0},de=F({__name:"shift-assignment-card",props:{day:{},shifts:{},shiftAssignments:{},assignees:{}},emits:["assigned","unassigned"],setup(G,{emit:t}){const l=G,p=g(A()),D=t;B(l,()=>{p.value=A()});function A(){return l.shifts.map(e=>l.shiftAssignments.find(i=>i.shiftId===e.id)||{shiftId:e.id})}function E(e,i){const c=l.shiftAssignments.find(n=>n.shiftId===i);if(e===-1&&c){D("unassigned",c.id),p.value.find(n=>n.shiftId===i).personId=void 0;return}e!==(c==null?void 0:c.personId)&&D("assigned",{personId:e,shiftId:i,assignmentDate:l.day})}function y(e,i){return e.name===(i==null?void 0:i.name)&&e.startTime===(i==null?void 0:i.startTime)&&e.endTime===(i==null?void 0:i.endTime)?void 0:`${e.name} ${e.startTime.substring(0,5)} - ${e.endTime.substring(0,5)}`}return(e,i)=>(h(),w("article",ie,[r("section",oe,[r("h2",null,O(k(f).formatDate(e.day,!1)),1)]),e.shifts.length===0?(h(),w("p",le,"Keine Schichten")):z("",!0),(h(!0),w(q,null,H(k(p),(c,n)=>(h(),Y(K,{data:c.personId?e.assignees:e.assignees.slice(1),"model-value":c.personId,"onUpdate:modelValue":_=>E(_,e.shifts[n].id),placeholder:"Nicht zugewiesen",label:y(e.shifts[n],n>0?e.shifts[n-1]:void 0)},null,8,["data","model-value","onUpdate:modelValue","label"]))),256))]))}}),ce=j(de,[["__scopeId","data-v-140ab68a"]]),re={class:"page"},ue={class:"shifts"},me={class:"header"},fe={class:"controls"},he={class:"controls date"},ge={class:"days"},pe=F({__name:"shift-planing",async setup(G){let t,l;const p=([t,l]=T(()=>m("/shift",{method:"GET"})),t=await t,l(),t),D=g(([t,l]=T(()=>m("/shift/assignments",{method:"GET"})),t=await t,l(),t)),A=([t,l]=T(()=>m("/person/find",{method:"GET",query:{roles:[P.Admin.value,P.PowerUser.value].toString()}})),t=await t,l(),t),E=[new M("Nicht zugewiesen",-1),...A.map(o=>new M(o.firstName,o.id))],y=new Date;y.setHours(12,0,0,0);const e=g(y),i=g(y),c=g([]),n=g([]),_=g([]),N=[new M("Woche",1),new M("Monat",2)],v=g(1);B(e,()=>{I()}),B(i,()=>{I()});function I(){if(i.value.getTime()<e.value.getTime())return;e.value.setHours(12,0,0),i.value.setHours(12,0,0);const o=[...Array(f.dateDifference(e.value,i.value)+1).keys()].map(s=>f.addDays(e.value,s)),a=o.map(s=>p.filter(d=>(d.weekDay===f.getDayOfWeek(s)+1||f.dayEquals(d.customDate,s))&&!d.deleteDate)),u=o.map(s=>D.value.filter(d=>f.dayEquals(d.assignmentDate,s)&&!d.deleteDate));c.value=[],n.value=[],_.value=[];for(let s=0;s<a.length;s++)a[s].length>0&&(c.value.push(o[s]),n.value.push(a[s]),_.value.push(u[s]))}function C(o){v.value===1?e.value=f.addDays(e.value,7*o):e.value=new Date(e.value.getFullYear(),e.value.getMonth()+o,1)}async function S(o){await m("/shift/assign",{method:"POST",body:o}),D.value=await m("/shift/assignments",{method:"GET"}),I()}async function b(o){await m(`/shift/assignment/${o}/unassign`,{method:"POST"}),D.value=await m("/shift/assignments",{method:"GET"}),I()}function R(){const o=V(D.value,p,J()),a=new Blob([o],{type:"text/calendar"}),u=URL.createObjectURL(a),s=document.createElement("a");s.href=u,s.download=`fumo-e-fiori-schichten_${f.formatDate(new Date,!1,"YYYY-MM-dd")}.ics`,s.click(),URL.revokeObjectURL(u)}function V(o,a,u){return`BEGIN:VCALENDAR 2VERSION:2.0 3PRODID:-//Fumo e Fiori//Schichtplaner//DE 4CALSCALE:GREGORIAN 5${o.filter($=>$.personId===u&&($.assignmentDate>new Date||f.dayEquals($.assignmentDate,new Date))).map($=>
5W(a,$,u)).filter(Boolean).join(` 6`)} 7END:VCALENDAR`}function W(o,a,u){const s=o.find(X=>X.id===a.shiftId);if(!s)return"";const d=L(new Date(a.assignmentDate),s.startTime),$=L(new Date(a.assignmentDate),s.endTime);return` 8BEGIN:VEVENT 9UID:${`${a.id}-${u}@shiftscheduler`} 10DTSTAMP:${L(new Date,"00:00")} 11DTSTART:${d} 12DTEND:${$} 13SUMMARY:Fumo e Fiori ${s.name} 14DESCRIPTION:Schicht im Social Club 15${x("-P1D")} 16${x("-PT2H")} 17END:VEVENT`}function L(o,a){const[u,s]=a.split(":").map(Number),d=new Date(o);return d.setHours(u,s,0,0),d.toISOString().replace(/[-:]/g,"").split(".")[0]+"Z"}function x(o){return` 18BEGIN:VALARM 19TRIGGER:${o} 20ACTION:DISPLAY 21DESCRIPTION:Schicht Reminder 22END:VALARM`}return(o,a)=>{const u=ae;return h(),w("section",re,[a[5]||(a[5]=r("h1",null,"Schichtplan",-1)),r("section",ue,[r("section",me,[r("div",fe,[U(K,{modelValue:v.value,"onUpdate:modelValue":a[0]||(a[0]=s=>v.value=s),data:N},null,8,["modelValue"]),r("button",{onClick:R,class:"icon calendar-export"})]),r("div",he,[r("button",{onClick:a[1]||(a[1]=s=>C(-1)),class:"icon chevron"}),U(ee,{modelValue:e.value,"onUpdate:modelValue":a[2]||(a[2]=s=>e.value=s),"end-date":i.value,"onUpdate:endDate":a[3]||(a[3]=s=>i.value=s),placeholder:"Datum",precision:v.value===1?"week":"month","display-format-range":"dd.MM.yy","no-shorthands":""},null,8,["modelValue","end-date","precision"]),r("button",{onClick:a[4]||(a[4]=s=>C(1)),class:"icon chevron"})])]),r("section",ge,[(h(!0),w(q,null,H(c.value,(s,d)=>(h(),Y(ce,{onAssigned:S,onUnassigned:b,"shift-assignments":_.value[d],shifts:n.value[d],assignees:E,day:s},null,8,["shift-assignments","shifts","day"]))),256))])]),U(u)])}}}),Ne=j(pe,[["__scopeId","data-v-c4276702"]]);export{Ne as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.