2 lines
17 KiB
JavaScript
2 lines
17 KiB
JavaScript
"use strict";(self["webpackChunkmiriamgemeinde"]=self["webpackChunkmiriamgemeinde"]||[]).push([[285],{116:function(e,t,n){var a=n(6518),l=n(9565),o=n(2652),i=n(9306),s=n(8551),d=n(1767),r=n(9539),u=n(4549),c=u("find",TypeError);a({target:"Iterator",proto:!0,real:!0,forced:c},{find:function(e){s(this);try{i(e)}catch(a){r(this,"throw",a)}if(c)return l(c,this,e);var t=d(this),n=0;return o(t,function(t,a){if(e(t,n++))return a(t)},{IS_RECORD:!0,INTERRUPTED:!0}).result}})},513:function(e,t,n){n.d(t,{A:function(){return f}});var a=n(641),l=n(33);const o={key:0,class:"dialog-overlay"},i={class:"dialog-content"},s={class:"images-container"},d=["onClick"],r=["src"],u=["title"],c={key:1},m={class:"button-container"};function h(e,t,n,h,v,k){return(0,a.uX)(),(0,a.CE)("div",null,[h.isOpen?((0,a.uX)(),(0,a.CE)("div",o,[(0,a.Lk)("div",i,[t[2]||(t[2]=(0,a.Lk)("h3",null,"Bild auswählen",-1)),(0,a.Lk)("div",s,[((0,a.uX)(!0),(0,a.CE)(a.FK,null,(0,a.pI)(h.images,e=>((0,a.uX)(),(0,a.CE)("div",{key:e.id,class:(0,l.C4)(["image-block",{selected:e.id===h.selectedImage?.id}]),onClick:t=>h.selectImage(e)},[(0,a.Lk)("img",{src:"/images/uploads/"+e.filename},null,8,r),e.description?((0,a.uX)(),(0,a.CE)("span",{key:0,title:e.description},(0,l.v_)(e.title),9,u)):((0,a.uX)(),(0,a.CE)("span",c,(0,l.v_)(e.title),1))],10,d))),128))]),(0,a.Lk)("div",m,[(0,a.Lk)("button",{onClick:t[0]||(t[0]=(...e)=>h.confirmAddImageConfiguration&&h.confirmAddImageConfiguration(...e))},"Bestätigen"),(0,a.Lk)("button",{onClick:t[1]||(t[1]=(...e)=>h.closeAddImageDialog&&h.closeAddImageDialog(...e))},"Schließen")])])])):(0,a.Q3)("",!0)])}var v=n(953),k=n(6296),g={name:"AddImageDialog",emits:["confirm"],setup(e,{emit:t}){const n=(0,v.KR)(!1),a=(0,v.KR)([]),l=(0,v.KR)(null),o=()=>{n.value=!0,d()},i=()=>{n.value=!1},s=()=>{l.value&&t("confirm",`${l.value.id}`),i()},d=async()=>{try{const e=await k.A.get("/image");a.value=e.data}catch(e){console.error("Fehler beim Laden der Bilder:",e),a.value=[]}},r=e=>{console.log(e),l.value=e};return{isOpen:n,images:a,selectedImage:l,openAddImageDialog:o,closeAddImageDialog:i,confirmAddImageConfiguration:s,selectImage:r}}},p=n(6262);const L=(0,p.A)(g,[["render",h],["__scopeId","data-v-59dc7db8"]]);var f=L},3285:function(e,t,n){n.r(t),n.d(t,{default:function(){return V}});var a=n(641),l=n(3751),o=n(33);const i={class:"event-management"},s={class:"filter-section"},d={class:"checkbox-label"},r={key:0},u=["onClick"],c=["onClick"];function m(e,t,n,m,h,v){const k=(0,a.g2)("EventForm");return(0,a.uX)(),(0,a.CE)("div",i,[t[5]||(t[5]=(0,a.Lk)("h2",null,"Veranstaltungen",-1)),(0,a.Lk)("button",{onClick:t[0]||(t[0]=(...e)=>v.createEvent&&v.createEvent(...e))},"Neue Veranstaltung"),h.showForm?((0,a.uX)(),(0,a.Wv)(k,{key:0,ref:"eventForm",event:h.selectedEvent,institutions:h.institutions,eventPlaces:h.eventPlaces,contactPersons:h.contactPersons,onSaved:v.handleEventSaved,onCancelled:v.handleEventCancelled},null,8,["event","institutions","eventPlaces","contactPersons","onSaved","onCancelled"])):(0,a.Q3)("",!0),(0,a.Lk)("div",s,[(0,a.bo)((0,a.Lk)("input",{"onUpdate:modelValue":t[1]||(t[1]=e=>h.searchQuery=e),type:"text",placeholder:"Suche nach Name, Typ, Beschreibung...",class:"search-input"},null,512),[[l.Jo,h.searchQuery]]),(0,a.Lk)("label",d,[(0,a.bo)((0,a.Lk)("input",{"onUpdate:modelValue":t[2]||(t[2]=e=>h.showPastEvents=e),type:"checkbox"},null,512),[[l.lH,h.showPastEvents]]),t[3]||(t[3]=(0,a.eW)(" Vergangene Events anzeigen ",-1))])]),(0,a.Lk)("table",null,[t[4]||(t[4]=(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)),(0,a.Lk)("tbody",null,[((0,a.uX)(!0),(0,a.CE)(a.FK,null,(0,a.pI)(v.filteredEvents,e=>((0,a.uX)(),(0,a.CE)("tr",{key:e.id},[(0,a.Lk)("td",null,(0,o.v_)(e.name),1),(0,a.Lk)("td",null,(0,o.v_)(v.getEventTypeCaption(e.eventTypeId)),1),(0,a.Lk)("td",null,(0,o.v_)(e.date),1),(0,a.Lk)("td",null,[(0,a.eW)((0,o.v_)(v.formatTime(e.time)),1),e.endTime?((0,a.uX)(),(0,a.CE)("span",r," - "+(0,o.v_)(v.formatTime(e.endTime)),1)):(0,a.Q3)("",!0)]),(0,a.Lk)("td",null,(0,o.v_)(v.getWeekdayName(e.dayOfWeek)),1),(0,a.Lk)("td",null,(0,o.v_)(e.description),1),(0,a.Lk)("td",null,[(0,a.Lk)("button",{onClick:t=>v.editEvent(e)},"Bearbeiten",8,u),(0,a.Lk)("button",{onClick:t=>v.deleteEvent(e.id)},"Löschen",8,c)])]))),128))])])])}n(8111),n(2489),n(116);var h=n(4335);const v={class:"event-form"},k={key:0},g={key:1},p={key:2},L={colspan:"2"},f={key:0},y=["src"],b={key:1};function D(e,t,n,o,i,s){const d=(0,a.g2)("multiselect"),r=(0,a.g2)("AddImageDialog");return(0,a.uX)(),(0,a.CE)(a.FK,null,[(0,a.Lk)("div",v,[t[33]||(t[33]=(0,a.Lk)("h2",null,"Veranstaltung Formular",-1)),(0,a.Lk)("form",{onSubmit:t[15]||(t[15]=(0,l.D$)((...e)=>s.saveEvent&&s.saveEvent(...e),["prevent"]))},[(0,a.Lk)("table",null,[(0,a.Lk)("tbody",null,[(0,a.Lk)("tr",null,[t[16]||(t[16]=(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"name"},"Name:")],-1)),(0,a.Lk)("td",null,[(0,a.bo)((0,a.Lk)("input",{type:"text",id:"name","onUpdate:modelValue":t[0]||(t[0]=e=>i.eventData.name=e),required:""},null,512),[[l.Jo,i.eventData.name]])])]),(0,a.Lk)("tr",null,[t[17]||(t[17]=(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"eventType"},"Typ:")],-1)),(0,a.Lk)("td",null,[(0,a.bF)(d,{modelValue:i.selectedEventType,"onUpdate:modelValue":t[1]||(t[1]=e=>i.selectedEventType=e),options:i.eventTypes,label:"caption","track-by":"id",placeholder:"Typ wählen"},null,8,["modelValue","options"])])]),(0,a.Lk)("tr",null,[t[19]||(t[19]=(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"dateMode"},"Datum-Modus:")],-1)),(0,a.Lk)("td",null,[(0,a.bo)((0,a.Lk)("select",{"onUpdate:modelValue":t[2]||(t[2]=e=>i.dateMode=e)},[...t[18]||(t[18]=[(0,a.Lk)("option",{value:"date"},"Datum",-1),(0,a.Lk)("option",{value:"weekday"},"Wochentag",-1),(0,a.Lk)("option",{value:"interval"},"Intervall",-1),(0,a.Lk)("option",{value:"bulk"},"Bulk-Datum",-1)])],512),[[l.u1,i.dateMode]])])]),"date"===i.dateMode||"interval"===i.dateMode?((0,a.uX)(),(0,a.CE)("tr",k,[t[20]||(t[20]=(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"date"},"Datum:")],-1)),(0,a.Lk)("td",null,[(0,a.bo)((0,a.Lk)("input",{type:"date",id:"date","onUpdate:modelValue":t[3]||(t[3]=e=>i.eventData.date=e)},null,512),[[l.Jo,i.eventData.date]])])])):(0,a.Q3)("",!0),"bulk"===i.dateMode?((0,a.uX)(),(0,a.CE)("tr",g,[t[22]||(t[22]=(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"bulkDates"},"Bulk-Daten:")],-1)),(0,a.Lk)("td",null,[(0,a.bo)((0,a.Lk)("textarea",{id:"bulkDates","onUpdate:modelValue":t[4]||(t[4]=e=>i.bulkDates=e),placeholder:"Mehrere Daten, z.B. 27.03.2025,03.04.2025 oder je Zeile ein Datum"},null,512),[[l.Jo,i.bulkDates]]),t[21]||(t[21]=(0,a.Lk)("div",{style:{"font-size":"0.9em",color:"#888"}},"Format: TT.MM.JJJJ (optional weiterhin JJJJ-MM-TT). Trennen mit Komma oder Zeilenumbruch.",-1))])])):(0,a.Q3)("",!0),"weekday"===i.dateMode||"interval"===i.dateMode?((0,a.uX)(),(0,a.CE)("tr",p,[t[23]||(t[23]=(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"dayOfWeek"},"Wochentag:")],-1)),(0,a.Lk)("td",null,[(0,a.bF)(d,{modelValue:i.eventData.dayOfWeek,"onUpdate:modelValue":t[5]||(t[5]=e=>i.eventData.dayOfWeek=e),options:i.weekdays,label:"name","track-by":"value",placeholder:"Wochentag wählen"},null,8,["modelValue","options"])])])):(0,a.Q3)("",!0),(0,a.Lk)("tr",null,[t[24]||(t[24]=(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"time"},"Uhrzeit:")],-1)),(0,a.Lk)("td",null,[(0,a.bo)((0,a.Lk)("input",{type:"time",id:"time","onUpdate:modelValue":t[6]||(t[6]=e=>i.eventData.time=e)},null,512),[[l.Jo,i.eventData.time]])])]),(0,a.Lk)("tr",null,[t[25]||(t[25]=(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"endTime"},"Ende-Uhrzeit:")],-1)),(0,a.Lk)("td",null,[(0,a.bo)((0,a.Lk)("input",{type:"time",id:"endTime","onUpdate:modelValue":t[7]||(t[7]=e=>i.eventData.endTime=e)},null,512),[[l.Jo,i.eventData.endTime]])])]),(0,a.Lk)("tr",null,[t[26]||(t[26]=(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"description"},"Beschreibung:")],-1)),(0,a.Lk)("td",null,[(0,a.bo)((0,a.Lk)("textarea",{id:"description","onUpdate:modelValue":t[8]||(t[8]=e=>i.eventData.description=e),class:"descriptionedit"},null,512),[[l.Jo,i.eventData.description]])])]),(0,a.Lk)("tr",null,[t[27]||(t[27]=(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"institution"},"Institution:")],-1)),(0,a.Lk)("td",null,[(0,a.bF)(d,{modelValue:i.selectedInstitution,"onUpdate:modelValue":t[9]||(t[9]=e=>i.selectedInstitution=e),options:i.localInstitutions,label:"name","track-by":"id",placeholder:"Institution wählen"},null,8,["modelValue","options"])])]),(0,a.Lk)("tr",null,[t[28]||(t[28]=(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"eventPlace"},"Veranstaltungsort:")],-1)),(0,a.Lk)("td",null,[(0,a.bF)(d,{modelValue:i.selectedEventPlace,"onUpdate:modelValue":t[10]||(t[10]=e=>i.selectedEventPlace=e),options:i.localEventPlaces,label:"name","track-by":"id",placeholder:"Veranstaltungsort wählen"},null,8,["modelValue","options"])])]),(0,a.Lk)("tr",null,[t[29]||(t[29]=(0,a.Lk)("td",null,[(0,a.Lk)("label",{for:"contactPersons"},"Kontaktpersonen:")],-1)),(0,a.Lk)("td",null,[(0,a.bF)(d,{modelValue:i.selectedContactPersons,"onUpdate:modelValue":t[11]||(t[11]=e=>i.selectedContactPersons=e),options:i.localContactPersons,multiple:!0,label:"name","track-by":"id",placeholder:"Kontaktpersonen wählen"},null,8,["modelValue","options"])])]),(0,a.Lk)("tr",null,[(0,a.Lk)("td",L,[(0,a.Lk)("label",null,[(0,a.bo)((0,a.Lk)("input",{type:"checkbox","onUpdate:modelValue":t[12]||(t[12]=e=>i.onHomepage=e)},null,512),[[l.lH,i.onHomepage]]),t[30]||(t[30]=(0,a.eW)("Auf der Startseite anzeigen",-1))])])]),(0,a.Lk)("tr",null,[t[31]||(t[31]=(0,a.Lk)("td",null,"Zugewiesenes Bild:",-1)),(0,a.Lk)("td",null,[null!=i.assignedImage&&i.imageFilename?((0,a.uX)(),(0,a.CE)("div",f,[(0,a.Lk)("img",{src:s.getImagePath,class:"preview-image"},null,8,y),(0,a.Lk)("button",{onClick:t[13]||(t[13]=(...e)=>s.removeImage&&s.removeImage(...e)),type:"button"},"Bild entfernen")])):((0,a.uX)(),(0,a.CE)("div",b,[(0,a.Lk)("button",{type:"button",onClick:t[14]||(t[14]=(...e)=>s.openAddImageDialog&&s.openAddImageDialog(...e))},"Bild auswählen")]))])]),t[32]||(t[32]=(0,a.Lk)("tr",null,[(0,a.Lk)("td",{colspan:"2"},[(0,a.Lk)("button",{type:"submit"},"Speichern")])],-1))])])],32)]),(0,a.bF)(r,{ref:"addImageDialog",onConfirm:s.setImage},null,8,["onConfirm"])],64)}n(4114),n(1701);var E=n(5877),I=n(9654),T=n(513),w={name:"EventForm",components:{Multiselect:E.Ay,AddImageDialog:T.A},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],onHomepage:!1,assignedImage:null,imageFilename:"",bulkDates:""}},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.onHomepage=1==e.alsoOnHomepage,this.assignedImage=e.relatedImage||null,this.assignedImage&&this.fetchImageFilename(),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()},computed:{getImagePath(){return this.imageFilename?`/images/uploads/${this.imageFilename}`:""}},methods:{formatTime:I.fU,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),dayOfWeek:this.eventData.dayOfWeek?this.eventData.dayOfWeek.value??-1:-1,relatedImage:this.assignedImage,alsoOnHomepage:this.onHomepage?1:0};if("bulk"===this.dateMode&&this.bulkDates){const t=this.bulkDates.split(/,|\n/).map(e=>e.trim()).filter(e=>e.length>0),n=[],a=[],l=e=>e.toString().padStart(2,"0");for(const e of t){let t=e.match(/^(\d{1,2})\.(\d{1,2})\.(\d{4})$/);if(t){const o=parseInt(t[1],10),i=parseInt(t[2],10),s=parseInt(t[3],10);if(i>=1&&i<=12&&o>=1&&o<=31){n.push(`${s}-${l(i)}-${l(o)}`);continue}a.push(e);continue}/^\d{4}-\d{2}-\d{2}$/.test(e)?n.push(e):a.push(e)}if(0===n.length)return void alert("Keine gültigen Datumsangaben erkannt. Erlaubt: TT.MM.JJJJ oder JJJJ-MM-TT");a.length>0&&(console.warn("Ungültige Datumsangaben ignoriert:",a),alert("Folgende Einträge wurden ignoriert: "+a.join(", ")));const o=[];for(const i of n){const t={...e,date:i},n=await h.A.post("/events",t);o.push(n.data)}this.$emit("saved",o)}else{let t;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"},async fetchImageFilename(){try{const e=await h.A.get("/image/"+this.assignedImage);this.imageFilename=e.data.filename}catch(e){console.error("Bild konnte nicht geladen werden:",e)}},openAddImageDialog(){this.$refs.addImageDialog.openAddImageDialog()},async setImage(e){this.assignedImage=e;try{const t=await h.A.get("/image/"+e);this.imageFilename=t.data.filename}catch(t){console.error("Bild konnte nicht geladen werden:",t),this.imageFilename=""}},removeImage(){this.assignedImage=null,this.imageFilename=""},focusFirstField(){this.$nextTick(()=>{const e=document.getElementById("name");e&&e.focus()})}}},C=n(6262);const F=(0,C.A)(w,[["render",D],["__scopeId","data-v-51721748"]]);var P=F,A={components:{EventForm:P},data(){return{events:[],institutions:[],eventPlaces:[],contactPersons:[],eventTypes:[],selectedEvent:null,showForm:!1,searchQuery:"",showPastEvents:!1}},computed:{filteredEvents(){let e=this.events;if(!this.showPastEvents){const t=new Date;t.setHours(0,0,0,0),e=e.filter(e=>{if(null!==e.dayOfWeek&&void 0!==e.dayOfWeek&&!e.date)return!0;if(e.date){const n=new Date(e.date);return n.setHours(0,0,0,0),n>=t}return!0})}if(this.searchQuery.trim()){const t=this.searchQuery.toLowerCase();e=e.filter(e=>{const n=e.name?e.name.toLowerCase():"",a=e.description?e.description.toLowerCase():"",l=this.getEventTypeCaption(e.eventTypeId).toLowerCase();return n.includes(t)||a.includes(t)||l.includes(t)})}return e}},async created(){await this.fetchData()},methods:{formatTime:I.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,this.scrollToFormAndFocus()},editEvent(e){this.selectedEvent={...e},this.showForm=!0,this.scrollToFormAndFocus()},scrollToFormAndFocus(){this.$nextTick(()=>{window.scrollTo({top:0,behavior:"smooth"}),this.$refs.eventForm&&this.$refs.eventForm.focusFirstField()})},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]}}};const M=(0,C.A)(A,[["render",m],["__scopeId","data-v-a4941b4e"]]);var V=M},9654: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}})}}]);
|
|
//# sourceMappingURL=285.8dce7f6a.js.map
|