"use strict";(self["webpackChunkjandl"]=self["webpackChunkjandl"]||[]).push([[6944],{22650:function(e,t,s){s.r(t),s.d(t,{default:function(){return S}});var i=s(73396);const l={ref:"page"};function a(e,t,s,a,n,r){const o=(0,i.up)("A-task-filter"),d=(0,i.up)("Z-timeline");return(0,i.wg)(),(0,i.iD)("div",l,[e.$store.getters["tm/isInitialized"]?((0,i.wg)(),(0,i.j4)(o,{key:0,"split-days":r.timelineData?r.splitDays:null,onFilterChanged:r.onFilterChanged,ref:"filter"},null,8,["split-days","onFilterChanged"])):(0,i.kq)("",!0),r.timelineData&&!n.hideCal?((0,i.wg)(),(0,i.j4)(d,{key:1,calData:r.timelineData,calConfig:n.config,splits:r.splitDays},null,8,["calData","calConfig","splits"])):(0,i.kq)("",!0)],512)}s(57658);var n=s(60988),r=s(67312),o=s(16824),d=s(45869);const h={class:"d-flex date-wrapper"},u=["src"],m=["src"];function c(e,t,l,a,c,f){return(0,i.wg)(),(0,i.j4)(o.o,{class:"px-7 py-5 subheader"},{default:(0,i.w5)((()=>[(0,i.Wm)(n.f,{"custom-filter":e.customFilter,"match-any":!0,modelValue:c.selectedEmployee,"onUpdate:modelValue":t[0]||(t[0]=e=>c.selectedEmployee=e),class:"subheader-input",items:e.enrichedEmployees,"menu-props":{maxHeight:500},"item-title":"_fullName","item-value":"id",label:"Zamestnanec",variant:"outlined"},null,8,["custom-filter","modelValue","items"]),(0,i._)("div",h,[(0,i.Wm)(r.T,{class:"subheader-icon-button prev",variant:"outlined",onClick:t[1]||(t[1]=e=>f.prevWeek())},{default:(0,i.w5)((()=>[(0,i._)("img",{src:s(38351),alt:""},null,8,u)])),_:1}),(0,i.Wm)(d.hw,{class:"subheader-input disabled",label:"Dátum",modelValue:c.selectedDate,"onUpdate:modelValue":t[2]||(t[2]=e=>c.selectedDate=e),variant:"outlined","append-inner-icon":"mdi-calendar-blank-outline"},null,8,["modelValue"]),(0,i.Wm)(r.T,{class:"subheader-icon-button next",variant:"outlined",onClick:t[3]||(t[3]=e=>f.nextWeek())},{default:(0,i.w5)((()=>[(0,i._)("img",{src:s(35902),alt:""},null,8,m)])),_:1})]),(0,i.Wm)(d.hw,{class:"subheader-input disabled",label:"Nenaplánované hodiny",variant:"outlined",disabled:!0,modelValue:c.time,"onUpdate:modelValue":t[4]||(t[4]=e=>c.time=e)},null,8,["modelValue"])])),_:1})}var f=s(83299),p=s(20065),k=s(11271),y=s(85174),_={mixins:[f.Z],emits:["filter-changed"],props:{splitDays:{type:[Array,null],default:()=>null}},data(){return{date:new Date,selectedEmployee:null,selectedDate:null,time:null,filter:{start:null,end:null,employee:null}}},computed:{...(0,p.Se)("auth",["user"]),...(0,p.Se)("tm",["enrichedEmployees"])},mounted(){this.selectedEmployee=this.user.id,this.$nextTick((()=>this._updateFilters()))},methods:{prevWeek(){this.date=(0,k.Z)(this.date,7),this._updateFilters()},nextWeek(){this.date=(0,y.Z)(this.date,7),this._updateFilters()},_updateFilters(){this.filter.start=(0,k.Z)(this.date,1),this.filter.end=(0,y.Z)(this.date,5),this.selectedDate=String(this.filter.start?.toLocaleDateString("sk-SK")+" - "+this.filter.end?.toLocaleDateString("sk-SK")),this._emitFilterChanged()},_emitFilterChanged(){this.filter.start&&this.filter.end&&this.filter.employee&&this.$emit("filter-changed",this.filter)}},watch:{selectedEmployee(e){this.filter.employee=this.enrichedEmployees.find((t=>t.id==e)),this._emitFilterChanged()},splitDays(){this.time=this.splitDays.map((e=>parseFloat(e.unscheduledTime))).reduce(((e,t)=>e+t),0)}}},g=s(40089);const b=(0,g.Z)(_,[["render",c],["__scopeId","data-v-0f275556"]]);var D=b,v=s(30592),w=s(36797),C=s.n(w),Z=s(2750),F=s(70026),$={mixins:[F.Z],components:{ATaskFilter:D,ZTimeline:v.Z},data(){return{hideCal:!1,filter:null,subtasks:null,config:{date:(0,k.Z)(new Date,1),scrollHour:7}}},computed:{...(0,p.Se)("auth",["user"]),splitDays(){const e=[],t={},s={},i=C()(),l=60*(this.user.work_end-this.user.work_start);this.timelineData.tasks.forEach((e=>{"non-working-hours"==e.type||e.subtask?.is_finished||e.blocker?.is_finished||(s[e.split]||(s[e.split]=0),i.isAfter(C()(e._real_end))||(i.isAfter(C()(e._real_start))&&i.isBefore(C()(e._real_end))?s[e.split]+=Z.Z._getDifferenceInMinutes(e._real_end,new Date):s[e.split]+=Z.Z._getDifferenceInMinutes(e._real_end,e._real_start)))})),s[1]=0,this.timelineData.homeoffices.forEach((e=>{t[e.split-1]=!0}));for(let a=0;a<7;a++){let n;s[a+1]||(s[a+1]=0);const r=C()((0,y.Z)(this.filter.start,a));if(r.isBefore(C()(),"days"))n=0;else if(r.isSame(C()(),"days")){const e=i.diff(i.clone().startOf("day"),"minutes"),t=60*this.user.work_start>e?this.user.work_start:e/60,l=60*(this.user.work_end-t);n=l-s[a+1]/60<0?0:l-s[a+1]}else n=l-s[a+1];isNaN(n)&&(n=l),e.push({id:a+1,fullname:`${this.filter.employee.name} ${this.filter.employee.surname}`,initials:this.filter.employee.name.charAt(0).toUpperCase()+this.filter.employee.surname.charAt(0).toUpperCase(),unscheduledTime:(n/60).toFixed(1),date:(0,y.Z)(this.filter.start,a),isHomeoffice:t[a],isWeekend:Z.Z.isWeekend((0,y.Z)(this.filter.start,a))})}return e},unscheduledTime(){return this.subtasks?Z.Z.getUnscheduledTime(this.subtasks):0},timelineData(){if(!this.subtasks||!this.filter)return null;const{tasks:e,blockers:t,nonWorkingHours:s,homeoffices:i}=Z.Z.generateTimelineTasks(this.subtasks,new Date(this.filter.start),this.filter.employee);return{name:this.filter.employee.name,surname:this.filter.employee.surname,unscheduledTime:this.unscheduledTime,tasks:[...e,...t,...s],homeoffices:i}}},mounted(){this.$events.on("on-subtask-edited",(()=>{this.onFilterChanged(this.filter)})),this.$events.on("on-subtask-deleted",(()=>{this.onFilterChanged(this.filter)})),this.$events.on("on-blocker-edited",(()=>{this.onFilterChanged(this.filter)})),this.$events.on("on-blocker-deleted",(()=>{this.onFilterChanged(this.filter)}))},unmounted(){this.$events.off("on-subtask-edited"),this.$events.off("on-subtask-deleted"),this.$events.off("on-blocker-edited"),this.$events.off("on-blocker-deleted")},methods:{async onFilterChanged(e){this.filter=e;const t={};e.start&&(t.start=C()(e.start).format("YYYY-MM-DD")),e.end&&(t.end=C()(e.end).format("YYYY-MM-DD")),e.employee&&(t.employee_id=e.employee.id);const s=new URLSearchParams(t).toString();try{const{subtasks:e,blockers:t}=await this.$axios.get_auth(`v1/subtasks?${s}`);this.config.scrollHour=this.filter?.employee.work_start-1,this.config.date=this.filter.start,this.subtasks=[...e,...t],this.hideCal=!0,setTimeout((()=>{this.hideCal=!1}),0)}catch(i){this.$toast.error("Nepodarilo sa nacitat data!")}this._initScrollListener()}}};const T=(0,g.Z)($,[["render",a],["__scopeId","data-v-d5f0e84a"]]);var S=T}}]); //# sourceMappingURL=6944.a2dd9a84.js.map