2 lines
4.9 KiB
JavaScript
2 lines
4.9 KiB
JavaScript
"use strict";(self["webpackChunkmiriamgemeinde"]=self["webpackChunkmiriamgemeinde"]||[]).push([[636],{636:function(e,t,a){a.r(t),a.d(t,{default:function(){return D}});var n=a(641),i=a(3751),l=a(33);const r=e=>((0,n.Qi)("data-v-403a0e0b"),e=e(),(0,n.jt)(),e),o=r((()=>(0,n.Lk)("h1",null,"Bild hochladen",-1))),u=r((()=>(0,n.Lk)("label",{for:"title"},"Titel",-1))),s=r((()=>(0,n.Lk)("label",{for:"description"},"Beschreibung",-1))),d=r((()=>(0,n.Lk)("label",{for:"image"},"Bild",-1))),c=r((()=>(0,n.Lk)("label",{for:"page"},"Seite",-1))),p=r((()=>(0,n.Lk)("option",{value:""},"Keine Seite",-1))),m=["value"],g=r((()=>(0,n.Lk)("button",{type:"submit"},"Hochladen",-1))),h={key:0},f=r((()=>(0,n.Lk)("h2",null,"Hochgeladene Bilder",-1))),k=["src","alt"],v=["onUpdate:modelValue","onChange"],b=["onUpdate:modelValue","onChange"];function y(e,t,a,r,y,L){return(0,n.uX)(),(0,n.CE)("div",null,[o,(0,n.Lk)("form",{onSubmit:t[4]||(t[4]=(0,i.D$)(((...e)=>L.uploadImage&&L.uploadImage(...e)),["prevent"]))},[(0,n.Lk)("div",null,[u,(0,n.bo)((0,n.Lk)("input",{type:"text",id:"title","onUpdate:modelValue":t[0]||(t[0]=e=>y.title=e)},null,512),[[i.Jo,y.title]])]),(0,n.Lk)("div",null,[s,(0,n.bo)((0,n.Lk)("textarea",{id:"description","onUpdate:modelValue":t[1]||(t[1]=e=>y.description=e)},null,512),[[i.Jo,y.description]])]),(0,n.Lk)("div",null,[d,(0,n.Lk)("input",{type:"file",id:"image",onChange:t[2]||(t[2]=(...e)=>L.onFileChange&&L.onFileChange(...e))},null,32)]),(0,n.Lk)("div",null,[c,(0,n.bo)((0,n.Lk)("select",{id:"page","onUpdate:modelValue":t[3]||(t[3]=e=>y.selectedPage=e)},[p,((0,n.uX)(!0),(0,n.CE)(n.FK,null,(0,n.pI)(y.pages,(e=>((0,n.uX)(),(0,n.CE)("option",{key:e.value,value:e.value},(0,l.v_)(e.caption),9,m)))),128))],512),[[i.u1,y.selectedPage]])]),g],32),y.images.length?((0,n.uX)(),(0,n.CE)("div",h,[f,((0,n.uX)(!0),(0,n.CE)(n.FK,null,(0,n.pI)(y.images,(e=>((0,n.uX)(),(0,n.CE)("div",{key:e.id,class:"uploaded-image"},[(0,n.Lk)("img",{src:`/images/uploads/${e.filename}`,alt:e.title,width:"100"},null,8,k),(0,n.bo)((0,n.Lk)("input",{type:"text","onUpdate:modelValue":t=>e.title=t,onChange:t=>L.updateImage(e)},null,40,v),[[i.Jo,e.title]]),(0,n.bo)((0,n.Lk)("textarea",{"onUpdate:modelValue":t=>e.description=t,onChange:t=>L.updateImage(e)},null,40,b),[[i.Jo,e.description]]),(0,n.Lk)("p",null,(0,l.v_)(L.formatDate(e.uploadDate))+" "+(0,l.v_)(L.formatTimeFromDate(e.uploadDate)),1)])))),128))])):(0,n.Q3)("",!0)])}a(8992),a(670);var L=a(6296),C=a(9654),I={name:"ImageUpload",data(){return{title:"",description:"",image:null,selectedPage:"",pages:[],images:[]}},methods:{formatDate:C.Yq,formatTimeFromDate:C.ry,onFileChange(e){this.image=e.target.files[0]},async uploadImage(){const e=new FormData;e.append("title",this.title),e.append("description",this.description),e.append("image",this.image),e.append("page",this.selectedPage);try{await L.A.post("/image/",e),this.fetchImages(),this.resetForm()}catch(t){console.error("Fehler beim Hochladen des Bildes:",t)}},async fetchImages(){try{const e=await L.A.get("/image");this.images=e.data}catch(e){console.error("Fehler beim Abrufen der Bilder:",e)}},async fetchPages(){try{const e=await L.A.get("/menu-data"),t=function(e,a=""){return e.flatMap((e=>{let n=[];return e.submenu&&e.submenu.length&&(n=t(e.submenu,a+e.name+" -> ")),[{value:e.link,caption:a+e.name},...n]}))};this.pages=t(e.data)}catch(e){console.error("Fehler beim Abrufen der Seiten:",e)}},async updateImage(e){try{await L.A.put(`/image/${e.id}`,{title:e.title,description:e.description}),this.fetchImages()}catch(t){console.error("Fehler beim Aktualisieren des Bildes:",t)}},resetForm(){this.title="",this.description="",this.image=null,this.selectedPage="",document.getElementById("image").value=null}},mounted(){this.fetchImages(),this.fetchPages()}},w=a(6262);const F=(0,w.A)(I,[["render",y],["__scopeId","data-v-403a0e0b"]]);var D=F},670:function(e,t,a){var n=a(6518),i=a(9565),l=a(9306),r=a(8551),o=a(1767),u=a(8646),s=a(9462),d=a(9539),c=a(6395),p=s((function(){var e,t,a=this.iterator,n=this.mapper;while(1){if(t=this.inner)try{if(e=r(i(t.next,t.iterator)),!e.done)return e.value;this.inner=null}catch(l){d(a,"throw",l)}if(e=r(i(this.next,a)),this.done=!!e.done)return;try{this.inner=u(n(e.value,this.counter++),!1)}catch(l){d(a,"throw",l)}}}));n({target:"Iterator",proto:!0,real:!0,forced:c},{flatMap:function(e){return r(this),l(e),new p(o(this),{mapper:e,inner:null})}})},8646:function(e,t,a){var n=a(9565),i=a(8551),l=a(1767),r=a(851);e.exports=function(e,t){t&&"string"===typeof e||i(e);var a=r(e);return l(i(void 0!==a?n(a,e):e))}},9654:function(e,t,a){function n(e){const[t,a]=e.split(":");return`${t}:${a}`}function i(e){const t={year:"numeric",month:"2-digit",day:"2-digit"};return new Date(e).toLocaleDateString("de-DE",t)}function l(e){const t=new Date(e),a=String(t.getHours()).padStart(2,"0"),n=String(t.getMinutes()).padStart(2,"0");return`${a}:${n}`}a.d(t,{Yq:function(){return i},fU:function(){return n},ry:function(){return l}})}}]);
|
|
//# sourceMappingURL=636.07b5ab77.js.map
|