Files
miriamgemeinde/public/js/6959.5a9ab1e8.js
2024-06-24 19:42:30 +00:00

2 lines
10 KiB
JavaScript

"use strict";(self["webpackChunkmiriamgemeinde"]=self["webpackChunkmiriamgemeinde"]||[]).push([[6959],{8899:function(e,t,n){function a(e){const[t,n]=e.split(":");return`${t}:${n}`}function l(e){const t={year:"numeric",month:"2-digit",day:"2-digit"};return new Date(e).toLocaleDateString("de-DE",t)}function o(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),a=String(t.getMinutes()).padStart(2,"0");return`${n}:${a}`}n.d(t,{Yq:function(){return l},fU:function(){return a},ry:function(){return o}})},6959:function(e,t,n){n.r(t),n.d(t,{default:function(){return z}});var a=n(6768),l=n(5187);const o=e=>((0,a.Qi)("data-v-97f69b82"),e=e(),(0,a.jt)(),e),s={class:"event-management"},i=o((()=>(0,a.Lk)("h2",null,"Veranstaltungen",-1))),d=o((()=>(0,a.Lk)("thead",null,[(0,a.Lk)("tr",null,[(0,a.Lk)("th",null,"Name"),(0,a.Lk)("th",null,"Typ"),(0,a.Lk)("th",null,"Datum"),(0,a.Lk)("th",null,"Uhrzeit"),(0,a.Lk)("th",null,"Wochentag"),(0,a.Lk)("th",null,"Beschreibung"),(0,a.Lk)("th",null,"Aktionen")])],-1))),u={key:0},c=["onClick"],r=["onClick"];function v(e,t,n,o,v,h){const k=(0,a.g2)("EventForm");return(0,a.uX)(),(0,a.CE)("div",s,[i,(0,a.Lk)("button",{onClick:t[0]||(t[0]=(...e)=>h.createEvent&&h.createEvent(...e))},"Neue Veranstaltung"),v.showForm?((0,a.uX)(),(0,a.Wv)(k,{key:0,event:v.selectedEvent,institutions:v.institutions,eventPlaces:v.eventPlaces,contactPersons:v.contactPersons,onSaved:h.handleEventSaved,onCancelled:h.handleEventCancelled},null,8,["event","institutions","eventPlaces","contactPersons","onSaved","onCancelled"])):(0,a.Q3)("",!0),(0,a.Lk)("table",null,[d,(0,a.Lk)("tbody",null,[((0,a.uX)(!0),(0,a.CE)(a.FK,null,(0,a.pI)(v.events,(e=>((0,a.uX)(),(0,a.CE)("tr",{key:e.id},[(0,a.Lk)("td",null,(0,l.v_)(e.name),1),(0,a.Lk)("td",null,(0,l.v_)(h.getEventTypeCaption(e.eventTypeId)),1),(0,a.Lk)("td",null,(0,l.v_)(e.date),1),(0,a.Lk)("td",null,[(0,a.eW)((0,l.v_)(h.formatTime(e.time)),1),e.endTime?((0,a.uX)(),(0,a.CE)("span",u," - "+(0,l.v_)(h.formatTime(e.endTime)),1)):(0,a.Q3)("",!0)]),(0,a.Lk)("td",null,(0,l.v_)(h.getWeekdayName(e.dayOfWeek)),1),(0,a.Lk)("td",null,(0,l.v_)(e.description),1),(0,a.Lk)("td",null,[(0,a.Lk)("button",{onClick:t=>h.editEvent(e)},"Bearbeiten",8,c),(0,a.Lk)("button",{onClick:t=>h.deleteEvent(e.id)},"Löschen",8,r)])])))),128))])])])}var h=n(4373),k=n(5688);const p=e=>((0,a.Qi)("data-v-529bdc3a"),e=e(),(0,a.jt)(),e),m={class:"event-form"},L=p((()=>(0,a.Lk)("h2",null,"Veranstaltung Formular",-1))),y=p((()=>(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"name"},"Name:")],-1))),f=p((()=>(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"eventType"},"Typ:")],-1))),b=p((()=>(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"dateMode"},"Datum-Modus:")],-1))),E=p((()=>(0,a.Lk)("option",{value:"date"},"Datum",-1))),g=p((()=>(0,a.Lk)("option",{value:"weekday"},"Wochentag",-1))),D=p((()=>(0,a.Lk)("option",{value:"interval"},"Intervall",-1))),P=[E,g,D],T={key:0},w=p((()=>(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"date"},"Datum:")],-1))),C={key:1},V=p((()=>(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"dayOfWeek"},"Wochentag:")],-1))),F=p((()=>(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"time"},"Uhrzeit:")],-1))),M=p((()=>(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"endTime"},"Ende-Uhrzeit:")],-1))),I=p((()=>(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"description"},"Beschreibung:")],-1))),A=p((()=>(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"institution"},"Institution:")],-1))),U=p((()=>(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"eventPlace"},"Veranstaltungsort:")],-1))),W=p((()=>(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"contactPersons"},"Kontaktpersonen:")],-1))),S=p((()=>(0,a.Lk)("tr",null,[(0,a.Lk)("td",{colspan:"2"},[(0,a.Lk)("button",{type:"submit"},"Speichern")])],-1)));function _(e,t,n,l,o,s){const i=(0,a.g2)("multiselect");return(0,a.uX)(),(0,a.CE)("div",m,[L,(0,a.Lk)("form",{onSubmit:t[11]||(t[11]=(0,k.D$)(((...e)=>s.saveEvent&&s.saveEvent(...e)),["prevent"]))},[(0,a.Lk)("table",null,[(0,a.Lk)("tr",null,[y,(0,a.Lk)("td",null,[(0,a.bo)((0,a.Lk)("input",{type:"text",id:"name","onUpdate:modelValue":t[0]||(t[0]=e=>o.eventData.name=e),required:""},null,512),[[k.Jo,o.eventData.name]])])]),(0,a.Lk)("tr",null,[f,(0,a.Lk)("td",null,[(0,a.bF)(i,{modelValue:o.selectedEventType,"onUpdate:modelValue":t[1]||(t[1]=e=>o.selectedEventType=e),options:o.eventTypes,label:"caption","track-by":"id",placeholder:"Typ wählen"},null,8,["modelValue","options"])])]),(0,a.Lk)("tr",null,[b,(0,a.Lk)("td",null,[(0,a.bo)((0,a.Lk)("select",{"onUpdate:modelValue":t[2]||(t[2]=e=>o.dateMode=e)},P,512),[[k.u1,o.dateMode]])])]),"date"===o.dateMode||"interval"===o.dateMode?((0,a.uX)(),(0,a.CE)("tr",T,[w,(0,a.Lk)("td",null,[(0,a.bo)((0,a.Lk)("input",{type:"date",id:"date","onUpdate:modelValue":t[3]||(t[3]=e=>o.eventData.date=e)},null,512),[[k.Jo,o.eventData.date]])])])):(0,a.Q3)("",!0),"weekday"===o.dateMode||"interval"===o.dateMode?((0,a.uX)(),(0,a.CE)("tr",C,[V,(0,a.Lk)("td",null,[(0,a.bF)(i,{modelValue:o.eventData.dayOfWeek,"onUpdate:modelValue":t[4]||(t[4]=e=>o.eventData.dayOfWeek=e),options:o.weekdays,label:"name","track-by":"value",placeholder:"Wochentag wählen"},null,8,["modelValue","options"])])])):(0,a.Q3)("",!0),(0,a.Lk)("tr",null,[F,(0,a.Lk)("td",null,[(0,a.bo)((0,a.Lk)("input",{type:"time",id:"time","onUpdate:modelValue":t[5]||(t[5]=e=>o.eventData.time=e)},null,512),[[k.Jo,o.eventData.time]])])]),(0,a.Lk)("tr",null,[M,(0,a.Lk)("td",null,[(0,a.bo)((0,a.Lk)("input",{type:"time",id:"endTime","onUpdate:modelValue":t[6]||(t[6]=e=>o.eventData.endTime=e)},null,512),[[k.Jo,o.eventData.endTime]])])]),(0,a.Lk)("tr",null,[I,(0,a.Lk)("td",null,[(0,a.bo)((0,a.Lk)("textarea",{id:"description","onUpdate:modelValue":t[7]||(t[7]=e=>o.eventData.description=e),class:"descriptionedit"},null,512),[[k.Jo,o.eventData.description]])])]),(0,a.Lk)("tr",null,[A,(0,a.Lk)("td",null,[(0,a.bF)(i,{modelValue:o.selectedInstitution,"onUpdate:modelValue":t[8]||(t[8]=e=>o.selectedInstitution=e),options:o.localInstitutions,label:"name","track-by":"id",placeholder:"Institution wählen"},null,8,["modelValue","options"])])]),(0,a.Lk)("tr",null,[U,(0,a.Lk)("td",null,[(0,a.bF)(i,{modelValue:o.selectedEventPlace,"onUpdate:modelValue":t[9]||(t[9]=e=>o.selectedEventPlace=e),options:o.localEventPlaces,label:"name","track-by":"id",placeholder:"Veranstaltungsort wählen"},null,8,["modelValue","options"])])]),(0,a.Lk)("tr",null,[W,(0,a.Lk)("td",null,[(0,a.bF)(i,{modelValue:o.selectedContactPersons,"onUpdate:modelValue":t[10]||(t[10]=e=>o.selectedContactPersons=e),options:o.localContactPersons,multiple:!0,label:"name","track-by":"id",placeholder:"Kontaktpersonen wählen"},null,8,["modelValue","options"])])]),S])],32)])}var O=n(8074),X={name:"EventForm",components:{Multiselect:O.Ay},props:{event:{type:Object,required:!0,default:()=>({})},institutions:{type:Array,required:!0,default:()=>[]},eventPlaces:{type:Array,required:!0,default:()=>[]},contactPersons:{type:Array,required:!0,default:()=>[]}},data(){return{eventData:{...this.event},selectedEventType:null,selectedInstitution:this.event.institution||null,selectedEventPlace:this.event.eventPlace||null,selectedContactPersons:this.event.contactPersons||[],eventTypes:[],dateMode:"date",weekdays:[{name:"Montag",value:1},{name:"Dienstag",value:2},{name:"Mittwoch",value:3},{name:"Donnerstag",value:4},{name:"Freitag",value:5},{name:"Samstag",value:6},{name:"Sonntag",value:7}],localInstitutions:[...this.institutions],localEventPlaces:[...this.eventPlaces],localContactPersons:[...this.contactPersons]}},watch:{event(e){this.eventData={...e},this.selectedEventType=this.eventTypes.find((t=>t.id===e.eventTypeId))||null,this.selectedInstitution=e.institution||null,this.selectedEventPlace=e.eventPlace||null,this.selectedContactPersons=e.contactPersons||[],this.determineDateMode()},institutions(e){this.localInstitutions=[...e]},eventPlaces(e){this.localEventPlaces=[...e]},contactPersons(e){this.localContactPersons=[...e]}},async created(){try{const e=await h.A.get("/event-types");this.eventTypes=e.data,this.selectedEventType=this.eventTypes.find((e=>e.id===this.event.eventTypeId))||null}catch(e){console.error("Failed to fetch event types:",e)}this.determineDateMode()},methods:{async saveEvent(){try{const e={...this.eventData,eventTypeId:this.selectedEventType?this.selectedEventType.id:null,institution_id:this.selectedInstitution?this.selectedInstitution.id:null,event_place_id:this.selectedEventPlace?this.selectedEventPlace.id:null,contactPersonIds:this.selectedContactPersons.map((e=>e.id))};let t;e.dayOfWeek=e.dayOfWeek?e.dayOfWeek.value??-1:-1,t=this.eventData.id?await h.A.put(`/events/${this.eventData.id}`,e):await h.A.post("/events",e),this.$emit("saved",t.data)}catch(e){console.error("Failed to save event:",e)}},determineDateMode(){this.eventData.date&&this.eventData.dayOfWeek?this.dateMode="interval":this.eventData.date?this.dateMode="date":this.eventData.dayOfWeek?this.dateMode="weekday":this.dateMode="date"}}},$=n(1241);const q=(0,$.A)(X,[["render",_],["__scopeId","data-v-529bdc3a"]]);var Q=q,J=n(8899),N={components:{EventForm:Q},data(){return{events:[],institutions:[],eventPlaces:[],contactPersons:[],eventTypes:[],selectedEvent:null,showForm:!1}},async created(){await this.fetchData()},methods:{formatTime:J.fU,async fetchData(){try{const[e,t,n,a,l]=await Promise.all([h.A.get("/events"),h.A.get("/institutions"),h.A.get("/event-places"),h.A.get("/contact-persons"),h.A.get("/event-types")]);this.events=e.data,this.institutions=t.data,this.eventPlaces=n.data,this.contactPersons=a.data,this.eventTypes=l.data}catch(e){console.error("Fehler beim Abrufen der Daten:",e)}},createEvent(){this.selectedEvent={},this.showForm=!0},editEvent(e){this.selectedEvent={...e},this.showForm=!0},async deleteEvent(e){try{await h.A.delete(`/events/${e}`),this.fetchData()}catch(t){console.error("Fehler beim Löschen der Veranstaltung:",t)}},handleEventSaved(){this.showForm=!1,this.fetchData()},handleEventCancelled(){this.showForm=!1},getEventTypeCaption(e){const t=this.eventTypes.find((t=>t.id===e));return t?t.caption:"Unbekannt"},getWeekdayName(e){const t=["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"];return t[e-1]}}};const j=(0,$.A)(N,[["render",v],["__scopeId","data-v-97f69b82"]]);var z=j}}]);
//# sourceMappingURL=6959.5a9ab1e8.js.map