1import{_ as V,a as k,c as f,s as y}from"./app.js";import{E as w}from"./EventShortcut.js";import{D as S}from"./style.js";import{L as b}from"./LoadMoreButton.js";import"./swiper.js";const B={name:"EventFilter",props:{categories:{type:Array,required:!0},type:{type:String,default:"category"}},components:{DatePicker:S},data(){return{categoryFilterActive:!1,categoryFilterOpen:!1,dateFilterActive:!1,dateFilterOpen:!1,dateFilterStatus:!0,selectedCategory:-1,selectedDate:new Date}},computed:{categoryFilterClasses:function(){const e=[];return this.categoryFilterOpen&&e.push("--open"),this.categoryFilterActive&&e.push("--active"),e.join(" ")},dateFilterClasses:function(){const e=[];return this.dateFilterOpen&&e.push("--open"),this.dateFilterActive&&e.push("--active"),e.join(" ")}},methods:{openCategoryFilter(){this.categoryFilterOpen=!0,this.dateFilterOpen=!1},openDateFilter(){this.dateFilterStatus=!0,this.dateFilterOpen=!0,this.categoryFilterOpen=!1},setSelectedCategory(e){this.selectedCategory=e,this.categoryFilterOpen=!1,this.categoryFilterActive=!0,this.$emit("categoryChanged",e)},resetCategoryFilter(){this.categoryFilterOpen=!1,this.categoryFilterActive=!1,this.selectedCategory=-1,this.$emit("categoryChanged",-1)},resetDateFilter(){this.dateFilterStatus=!0,this.dateFilterOpen=!1,this.dateFilterActive=!1,this.selectedDate=new Date,this.selectedDate.setHours(0,0,0,0),this.$emit("dateChanged",{start:this.selectedDate,end:null}),this.dateFilterStatus=!1}},mounted(){document.addEventListener("click",e=>{e.target.closest(".filter-container")||(this.categoryFilterOpen=!1,this.dateFilterOpen=!1)})},watch:{selectedDate:function(e){this.dateFilterStatus&&(this.dateFilterActive=!0,this.dateFilterOpen=!1,this.$emit("dateChanged",e))}}},n=window.Vue.createElementVNode,r=window.Vue.withModifiers,E=window.Vue.resolveComponent,O=window.Vue.createVNode,m=window.Vue.normalizeClass,l=window.Vue.openBlock,d=window.Vue.createElementBlock,C=window.Vue.createCommentVNode,N=window.Vue.renderList,A=window.Vue.Fragment,M=window.Vue.toDisplayString,T={class:m(["event-filter"])},I={class:"button-container"},L={class:"button__label"},$={class:"filter --calendar"},R={class:"button__label"},z={class:"filter --category"},j=["onClick"];function H(e,t,o,D,u,a){const h=E("date-picker");return l(),d("div",T,[t[9]||(t[9]=n("h2",null,"Events",-1)),n("div",I,[o.type==="full"?(l(),d("div",{key:0,class:m(["filter-container",a.dateFilterClasses])},[n("div",{class:"button",onClick:t[1]||(t[1]=r((...s)=>a.openDateFilter&&a.openDateFilter(...s),["stop"])),title:"Nach Datum filtern"},[n("span",L,[t[5]||(t[5]=n("span",{class:"button__icon iconSet"},"event",-1)),n("span",{class:"button__icon iconSet --close",onClick:t[0]||(t[0]=r((...s)=>a.resetDateFilter&&a.resetDateFilter(...s),["stop"]))},"close"),t[6]||(t[6]=n("span",{class:"button__text"},"Zeitraum",-1))])]),n("div",$,[O(h,{modelValue:u.selectedDate,"onUpdate:modelValue":t[2]||(t[2]=s=>u.selectedDate=s),"is-range":""},null,8,["modelValue"])])],2)):C("",!0),o.categories.length?(l(),d("div",{key:1,class:m(["filter-container",a.categoryFilterClasses])},[n("div",{class:"button",onClick:t[4]||(t[4]=r((...s)=>a.openCategoryFilter&&a.openCategoryFilter(...s),["stop"])),title:"Nach Kategorie filtern"},[n("span",R,[t[7]||(t[7]=n("span",{class:"button__icon iconSet"},"local_offer",-1)),n("span",{class:"button__icon iconSet --close",onClick:t[3]||(t[3]=r((...s)=>a.resetCategoryFilter&&a.resetCategoryFilter(...s),["stop"]))},"close"),t[8]||(t[8]=n("span",{class:"button__text"},"Kategorie",-1))])]),n("div",z,[(l(!0),d(A,null,N(o.categories,s=>(l(),d("span",{key:s.term_id,class:m(u.selectedCategory===s.term_id?"--active":""),onClick:r(x=>a.setSelectedCategory(s.term_id),["stop"])},M(s.label),11,j))),128))])],2)):C("",!0)])])}const v=V(B,[["render",H]]),K={name:"SoylentEvents",components:{LoadMoreButton:b,EventFilter:v,EventShortcut:w,CmmsResponsiveImage:k},props:["element"],data(){return{category:parseInt(this.element.data.taxonomy)>0?this.element.data.taxonomy:0,searchTerm:"",date:{start:new Date,end:null},page:1,loading:!1,showMoreButton:!1}},computed:{eventFilterComponent(){return y.getByName("eventFilter",v)},eventShortcutComponent(){return y.getByName("eventShortcut",w)},amount:function(){if(this.element.data.amount)return this.element.data.amount},filterType:function(){return this.element.data._defaultAmount?"category":"full"},items:{get(){return this.element.data.items?this.element.data.items:[]},set(e){this.element.data.items=e}},categories:function(){return this.element.data.categories?this.element.data.categories:[]},total:{get(){return this.element.data.total?this.element.data.total:0},set(e){this.element.data.total=e}}},methods:{search(e){this.searchTerm=e,this.updateItems()},categoryChanged(e){this.category=e,this.updateItems()},dateChanged(e){this.date=e,this.updateItems()},updateItems(){const e={category:this.category,amount:this.amount,search:this.searchTerm};this.date||this.resetDateToCurrent(),this.date.start&&this.date.end?(this.date.start>0&&(e.from_date=this.date.start.getTime()/1e3),this.date.end!==null&&this.date.end>0&&(e.to_date=this.date.end.getTime()/1e3)):e.from_date=new Date().getTime()/1e3,f.post("/cmms-api-v2/soylent/element/events/get",e).then(t=>{this.items=[],this.handleResponse(t)}).catch(t=>{t.response||console.debug(t)}),this.page=1},loadMore:function(){this.loading=!0;const e={category:this.category,page:++this.page,amount:this.amount};this.date.start!==null&&this.date.start>0&&(e.from_date=this.date.start/1e3),this.date.end!==null&&this.date.end>0&&(e.to_date=this.date.end/1e3),f.post("/cmms-api-v2/soylent/element/events/get",e).then(t=>this.handleResponse(t)).catch(t=>{if(!t.response){console.debug(t);return}this.handleResponse(t.response)}).finally(()=>{this.loading=!1})},handleResponse:function(e){let t=e.data;this.total=t.total,this.showMoreButton=!1,t.items&&!Array.isArray(t.items)&&(t.items=[t.items]),t.items.length===parseInt(this.amount)&&this.page*this.amount<this.total&&(this.showMoreButton=!0);const o=[...this.element.data.items];this.element.data.items=o.concat(t.items)},resetDateToCurrent(){this.date={start:new Date,end:null},this.date.start.setHours(0,0,0,0)}},mounted(){this.resetDateToCurrent(),this.items.length===parseInt(this.amount)&&this.page*this.amount<this.total&&(this.showMoreButton=!0)}},P={name:"SoylentEvents",extends:K},_=window.Vue.resolveDynamicComponent,i=window.Vue.openBlock,p=window.Vue.createBlock,q=window.Vue.renderList,G=window.Vue.Fragment,g=window.Vue.createElementBlock,c=window.Vue.createElementVNode,U=window.Vue.vShow,W=window.Vue.withDirectives,Z=window.Vue.resolve
1Component,F=window.Vue.createCommentVNode,J=window.Vue.normalizeClass,Q={class:"post-shortcuts -col-3"},X={key:1,class:"loading-state"};function Y(e,t,o,D,u,a){const h=Z("LoadMoreButton");return i(),g("div",{class:J(["element",e.element.type,e.element.subtype])},[(i(),p(_(e.eventFilterComponent),{categories:this.categories,type:e.filterType,onCategoryChanged:e.categoryChanged,onSearch:e.search,onDateChanged:e.dateChanged,element:e.element},null,40,["categories","type","onCategoryChanged","onSearch","onDateChanged","element"])),c("div",Q,[(i(!0),g(G,null,q(e.items,s=>(i(),p(_(e.eventShortcutComponent),{key:s.id,event:s},null,8,["event"]))),128))]),W(c("span",null,"Es konnten keine Veranstaltungen gefunden werden",512),[[U,!Object.keys(e.items).length]]),!e.loading&&e.showMoreButton&&e.filterType==="full"?(i(),p(h,{key:0,onClick:e.loadMore},null,8,["onClick"])):F("",!0),e.loading?(i(),g("div",X,[...t[0]||(t[0]=[c("div",{class:"button"},[c("span",{class:"button__label"},[c("span",{class:"button__text"},"WIRD GELADEN")])],-1)])])):F("",!0)],2)}const oe=V(P,[["render",Y]]);export{oe 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.