mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
[Calendar] Fixed non working hours, added blockers to teams
This commit is contained in:
1 parent
f3f86261f4
commit
11c73b2b37
8 files changed
+279
-210
No files matched your search
@@ -79,7 +79,7 @@
|
||||
<div class="event-initials d-flex justify-center align-center">
|
||||
<small>{{ event.initials }}</small>
|
||||
</div>
|
||||
<small class="event-initials-date">{{ event.date.toLocaleDateString('sk-SK') }}</small>
|
||||
<small class="event-initials-date">{{ event.date?.toLocaleDateString('sk-SK') }}</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -99,11 +99,13 @@ export default {
|
||||
generateTimelineNonWorkingHours(date, employee) {
|
||||
const events = []
|
||||
|
||||
const { start: dayStart, end: dayEnd } = this._getDayStartEnd(date)
|
||||
|
||||
for (let i = 0; i < 7; i++) {
|
||||
events.push({
|
||||
title: "Non working hours",
|
||||
start: setMinutes(setHours(date, 0), 0),
|
||||
end: setMinutes(setHours(date, employee.work_start), 0),
|
||||
start: dayStart,
|
||||
end: this._setMinutesToDate(employee.work_start, date),
|
||||
type: 'non-working-hours',
|
||||
split: i + 1,
|
||||
draggable: false
|
||||
@@ -111,14 +113,16 @@ export default {
|
||||
|
||||
events.push({
|
||||
title: "Non working hours",
|
||||
start: setMinutes(setHours(date, employee.work_end), 0),
|
||||
end: setMinutes(setHours(date, 23), 59),
|
||||
start: this._setMinutesToDate(employee.work_end, date),
|
||||
end: dayEnd,
|
||||
type: 'non-working-hours',
|
||||
split: i + 1,
|
||||
draggable: false
|
||||
})
|
||||
}
|
||||
|
||||
console.log(events)
|
||||
|
||||
return events
|
||||
},
|
||||
|
||||
@@ -130,5 +134,18 @@ export default {
|
||||
let diff =(date1.getTime() - date2.getTime()) / 1000;
|
||||
diff /= (60 * 60)
|
||||
return Math.abs(Math.round(diff))
|
||||
},
|
||||
|
||||
_getDayStartEnd(date) {
|
||||
return {
|
||||
start: this._setMinutesToDate(0, date),
|
||||
end: this._setMinutesToDate(1439, date)
|
||||
}
|
||||
},
|
||||
|
||||
_setMinutesToDate(minutes, date) {
|
||||
const newDate = new Date(date)
|
||||
newDate.setHours(Math.floor(minutes / 60), minutes % 60, 0, 0)
|
||||
return newDate
|
||||
}
|
||||
}
|
||||
@@ -88,11 +88,11 @@ export default {
|
||||
this.onFilterChanged(this.filter)
|
||||
})
|
||||
|
||||
this.$events.on('on-blocker-edited', () => {
|
||||
this.$events.on('on-subtask-deleted', () => {
|
||||
this.onFilterChanged(this.filter)
|
||||
})
|
||||
|
||||
this.$events.on('on-subtask-deleted', () => {
|
||||
this.$events.on('on-blocker-edited', () => {
|
||||
this.onFilterChanged(this.filter)
|
||||
})
|
||||
|
||||
@@ -104,6 +104,8 @@ export default {
|
||||
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: {
|
||||
|
||||
@@ -0,0 +1,162 @@
|
||||
import { setHours, setMinutes } from 'date-fns'
|
||||
import moment from 'moment'
|
||||
import timelineUtils from '@/plugins/tm@dashboard/tasks/_utils/timeline.utils'
|
||||
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
calendarData() {
|
||||
if (!this.subtasks || !this.blockers)
|
||||
return
|
||||
|
||||
return {
|
||||
unscheduledTime: 333,
|
||||
tasks: [...this._generateNonWorking(), ...this._generateTasks(), ...this._generateBlockers()]
|
||||
}
|
||||
},
|
||||
|
||||
splitDays() {
|
||||
const days = []
|
||||
|
||||
this.filter.team.employees.forEach((employee, index) => {
|
||||
let workingHours = 0
|
||||
|
||||
this.calendarData.tasks.forEach(task => {
|
||||
if (task?.subtask?.employee_id == employee.id)
|
||||
workingHours += timelineUtils._getDifferenceInHours(task.end, task.start)
|
||||
})
|
||||
|
||||
days.push({
|
||||
id: index + 1,
|
||||
name: employee.name,
|
||||
fullname: `${employee.name} ${employee.surname}`,
|
||||
initials: employee.name.charAt(0).toUpperCase() + employee.surname.charAt(0).toUpperCase(),
|
||||
unscheduledTime: workingHours
|
||||
})
|
||||
})
|
||||
|
||||
return days
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
_generateNonWorking() {
|
||||
const nonWorkingHours = []
|
||||
const date = new Date(this.filter.start)
|
||||
let earliestStartHour = null
|
||||
this.calendarConfig.date = date
|
||||
|
||||
const { start: dayStart, end: dayEnd } = this._getDayStartEnd()
|
||||
|
||||
this.filter.team.employees.forEach((employee, index) => {
|
||||
if (!earliestStartHour || employee.work_start < earliestStartHour)
|
||||
earliestStartHour = employee.work_start
|
||||
|
||||
|
||||
nonWorkingHours.push({
|
||||
title: "Non working hours",
|
||||
start: dayStart,
|
||||
end: this._setMinutesToDate(employee.work_start),
|
||||
split: index + 1,
|
||||
type: 'non-working-hours',
|
||||
draggable: false
|
||||
})
|
||||
|
||||
nonWorkingHours.push({
|
||||
title: "Non working hours",
|
||||
start: this._setMinutesToDate(employee.work_end),
|
||||
end: dayEnd,
|
||||
split: index + 1,
|
||||
type: 'non-working-hours',
|
||||
draggable: false
|
||||
})
|
||||
})
|
||||
|
||||
this.calendarConfig.scrollHour = earliestStartHour - 1
|
||||
return nonWorkingHours
|
||||
},
|
||||
|
||||
_generateTasks() {
|
||||
const tasks = []
|
||||
const calendarDate = moment(this.filter.start).format('DD-MM-YYYY')
|
||||
|
||||
this.subtasks.forEach(subtask => {
|
||||
let split = null
|
||||
let employee = null
|
||||
|
||||
this.filter.team.employees.forEach((e, index) => {
|
||||
if (e.id == subtask.employee_id) {
|
||||
split = index + 1
|
||||
employee = e
|
||||
}
|
||||
})
|
||||
|
||||
subtask.timeblocks.forEach(timeblock => {
|
||||
const formattedDate = moment(timeblock.start).format('DD-MM-YYYY')
|
||||
|
||||
if (formattedDate == calendarDate) {
|
||||
tasks.push({
|
||||
id: subtask.id,
|
||||
start: new Date(timeblock.start),
|
||||
end: new Date(timeblock.end),
|
||||
master_task: subtask.master_task,
|
||||
name: employee?.name,
|
||||
surname: employee?.surname,
|
||||
// date: new Date(timeblock.start),
|
||||
isWeekend: moment(timeblock.start).day() % 6 == 0,
|
||||
initials: employee?.name?.charAt(0)?.toUpperCase() + employee?.surname?.charAt(0)?.toUpperCase(),
|
||||
split: split,
|
||||
project_code: subtask.project_code,
|
||||
subtask: subtask,
|
||||
_timeblock_id: timeblock.id
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
return tasks
|
||||
},
|
||||
|
||||
_generateBlockers() {
|
||||
const blockers = []
|
||||
|
||||
this.blockers.forEach(blocker => {
|
||||
let split = null
|
||||
let employee = null
|
||||
|
||||
this.filter.team.employees.forEach((e, index) => {
|
||||
if (e.id == blocker.employee?.id) {
|
||||
split = index + 1
|
||||
employee = e
|
||||
}
|
||||
})
|
||||
|
||||
blockers.push({
|
||||
blocker,
|
||||
split,
|
||||
start: new Date(blocker.start),
|
||||
end: new Date(blocker.end),
|
||||
type: 'blocker',
|
||||
initials: `${employee?.name[0]}${employee?.surname[0]}`,
|
||||
color: '#B00020',
|
||||
draggable: false,
|
||||
isWeekend: moment(blocker.start).day() % 6 == 0,
|
||||
})
|
||||
})
|
||||
|
||||
return blockers
|
||||
},
|
||||
|
||||
_getDayStartEnd() {
|
||||
return {
|
||||
start: this._setMinutesToDate(0),
|
||||
end: this._setMinutesToDate(1439)
|
||||
}
|
||||
},
|
||||
|
||||
_setMinutesToDate(minutes, date = new Date(this.filter.start)) {
|
||||
date.setHours(Math.floor(minutes / 60), minutes % 60, 0, 0)
|
||||
return date
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
<template>
|
||||
<div>
|
||||
<A-team-filter v-if="$store.getters['tm/isInitialized']" :unscheduledTime="timelineData?.unscheduledTime || 0" @filter-changed="onFilterChanged" />
|
||||
<A-team-filter v-if="$store.getters['tm/isInitialized']" :unscheduledTime="calendarData?.unscheduledTime || 0" @filter-changed="onFilterChanged" />
|
||||
|
||||
<Z-timeline v-if="timelineData" :calData="timelineData" :calConfig="config" :splits="splitDays" />
|
||||
<Z-timeline v-if="calendarData" :cal-data="calendarData" :cal-config="calendarConfig" :splits="splitDays" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import ATeamFilter from './_components/a-team-filter.vue'
|
||||
import ZTimeline from '@/plugins/tm@dashboard/_components/z-timeline.vue'
|
||||
|
||||
import { setHours, setMinutes, addDays } from 'date-fns'
|
||||
import moment from 'moment'
|
||||
import timelineUtils from '../tasks/_utils/timeline.utils'
|
||||
import TeamsCalendar from './_mixins/TeamsCalendar.mixin'
|
||||
|
||||
export default {
|
||||
mixins: [TeamsCalendar],
|
||||
|
||||
components: {
|
||||
ATeamFilter,
|
||||
ZTimeline,
|
||||
@@ -24,48 +24,14 @@ export default {
|
||||
return {
|
||||
filter: null,
|
||||
subtasks: null,
|
||||
config: {
|
||||
blockers: null,
|
||||
calendarConfig: {
|
||||
date: new Date(),
|
||||
scrollHour: 7,
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
splitDays() {
|
||||
const days = []
|
||||
|
||||
this.filter.team.employees.forEach((employee, index) => {
|
||||
let workingHours = 0
|
||||
|
||||
this.timelineData.tasks.forEach(task => {
|
||||
if (task?.subtask?.employee_id == employee.id)
|
||||
workingHours += timelineUtils._getDifferenceInHours(task.end, task.start)
|
||||
})
|
||||
|
||||
days.push({
|
||||
id: index + 1,
|
||||
name: employee.name,
|
||||
fullname: `${employee.name} ${employee.surname}`,
|
||||
initials: employee.name.charAt(0).toUpperCase() + employee.surname.charAt(0).toUpperCase(),
|
||||
unscheduledTime: workingHours
|
||||
})
|
||||
})
|
||||
|
||||
return days
|
||||
},
|
||||
|
||||
timelineData() {
|
||||
if (!this.subtasks)
|
||||
return
|
||||
|
||||
return {
|
||||
unscheduledTime: 333,
|
||||
tasks: [...this._generateNonWorking(), ...this._generateTasks()]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.$events.on('on-subtask-edited', () => {
|
||||
this.onFilterChanged(this.filter)
|
||||
@@ -74,91 +40,24 @@ export default {
|
||||
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: {
|
||||
_generateTasks() {
|
||||
const tasks = []
|
||||
const calendarDate = moment(this.filter.start).format('DD-MM-YYYY')
|
||||
|
||||
this.subtasks.forEach(subtask => {
|
||||
// TODO Implement blockers
|
||||
if (subtask.type == 'blocker') return
|
||||
|
||||
let split = null
|
||||
let employee = null
|
||||
|
||||
this.filter.team.employees.forEach((e, index) => {
|
||||
if (e.id == subtask.employee_id) {
|
||||
split = index + 1
|
||||
employee = e
|
||||
}
|
||||
})
|
||||
|
||||
subtask.timeblocks.forEach(timeblock => {
|
||||
const formattedDate = moment(timeblock.start).format('DD-MM-YYYY')
|
||||
|
||||
if (formattedDate == calendarDate) {
|
||||
tasks.push({
|
||||
id: subtask.id,
|
||||
start: new Date(timeblock.start),
|
||||
end: new Date(timeblock.end),
|
||||
master_task: subtask.master_task,
|
||||
name: employee?.name,
|
||||
surname: employee?.surname,
|
||||
// date: new Date(timeblock.start),
|
||||
isWeekend: moment(timeblock.start).day() % 6 == 0,
|
||||
initials: employee?.name?.charAt(0)?.toUpperCase() + employee?.surname?.charAt(0)?.toUpperCase(),
|
||||
split: split,
|
||||
project_code: subtask.project_code,
|
||||
subtask: subtask,
|
||||
_timeblock_id: timeblock.id
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
return tasks
|
||||
},
|
||||
|
||||
_generateNonWorking() {
|
||||
const tasks = []
|
||||
const date = new Date(this.filter.start)
|
||||
let earliestStartHour = null
|
||||
this.config.date = date
|
||||
|
||||
this.filter.team.employees.forEach((employee, index) => {
|
||||
if (!earliestStartHour || employee.work_start < earliestStartHour)
|
||||
earliestStartHour = employee.work_start
|
||||
|
||||
tasks.push({
|
||||
title: "Non working hours",
|
||||
start: setMinutes(setHours(date, 0), 0),
|
||||
end: setMinutes(setHours(date, employee.work_start), 0),
|
||||
split: index + 1,
|
||||
type: 'non-working-hours',
|
||||
draggable: false
|
||||
})
|
||||
|
||||
tasks.push({
|
||||
title: "Non working hours",
|
||||
start: setMinutes(setHours(date, employee.work_end), 0),
|
||||
end: setMinutes(setHours(date, 23), 59),
|
||||
split: index + 1,
|
||||
type: 'non-working-hours',
|
||||
draggable: false
|
||||
})
|
||||
})
|
||||
|
||||
this.config.scrollHour = earliestStartHour - 1
|
||||
return tasks
|
||||
},
|
||||
|
||||
async onFilterChanged(filter) {
|
||||
this.filter = filter
|
||||
|
||||
@@ -172,7 +71,8 @@ export default {
|
||||
|
||||
try {
|
||||
const { subtasks, blockers } = await this.$axios.get_auth(`v1/subtasks?${queryParameters}`)
|
||||
this.subtasks = [...subtasks, ...blockers.map(blocker => ({...blocker, type: 'blocker'}))]
|
||||
this.subtasks = subtasks
|
||||
this.blockers = blockers
|
||||
} catch (error) {
|
||||
this.$toast.error('Nepodarilo sa nacitat data!')
|
||||
}
|
||||
|
||||
@@ -3,70 +3,44 @@
|
||||
<W-loadable :content="blocker" class="h-100">
|
||||
<v-card height="100%" class="d-flex flex-column">
|
||||
<div class="d-flex justify-space-between align-center modal-header">
|
||||
<h1>{{ blocker.id ? 'Upraviť' : 'Vytvoriť'}} blocker</h1>
|
||||
<v-icon
|
||||
@click.stop="closeModal()"
|
||||
icon="mdi-close"
|
||||
size="large"
|
||||
></v-icon>
|
||||
<h1>{{ blocker.id ? "Upraviť" : "Vytvoriť" }} blocker</h1>
|
||||
<v-icon @click.stop="closeModal()" icon="mdi-close" size="large"></v-icon>
|
||||
</div>
|
||||
|
||||
<v-card-actions class="d-flex flex-column modal-content">
|
||||
<v-text-field
|
||||
@focus="onInputFocus"
|
||||
class="modal-input"
|
||||
label="Názov blockeru"
|
||||
:class="{ error: v$.blocker.name.$errors.length }"
|
||||
:hint="
|
||||
v$.blocker.name.$errors
|
||||
? errorUtils.parseErrors(v$.blocker.name.$errors)
|
||||
: null
|
||||
"
|
||||
v-model="blocker.name"
|
||||
variant="solo"
|
||||
></v-text-field>
|
||||
<v-select v-model="blocker.employee_id" ref="employee-select" @focus="onInputFocus" class="modal-input border-select" label="Priradený" :class="{ error: v$.blocker.employee_id.$errors.length }" variant="solo" :items="enrichedEmployees" item-value="id" item-title="_fullName"></v-select>
|
||||
<Datepicker
|
||||
class="modal-input mb-5"
|
||||
v-model="datepicker"
|
||||
format="dd.MM.yyyy"
|
||||
locale="sk"
|
||||
:class="{ error: v$.datepicker.$errors?.length }"
|
||||
:validations="v$.datepicker"
|
||||
select-text="Vybrať"
|
||||
cancel-text="Zrušiť"
|
||||
placeholder="Dátum"
|
||||
:enable-time-picker="false"
|
||||
ref="datepicker"
|
||||
/>
|
||||
<v-text-field @focus="onInputFocus" class="modal-input" label="Názov blockeru" :class="{ error: v$.blocker.name.$errors.length }" :hint="v$.blocker.name.$errors ? errorUtils.parseErrors(v$.blocker.name.$errors) : null" v-model="blocker.name" variant="solo"></v-text-field>
|
||||
|
||||
<Z-autocomplete label="Vyhľadať zamestnanca" :value="blocker?.employee ? `${blocker?.employee?.name} ${blocker?.employee?.surname}` : ''" :options="enrichedEmployees.map(employee => ({key: employee.id, value: employee._fullName}))" :clear-on-submit="false" :class="{ error: v$.blocker.employee.$errors.length }" class="modal-input" @option-selected="onEmployeeSelected" />
|
||||
<Datepicker class="modal-input mb-5" v-model="datepicker" format="dd.MM.yyyy" locale="sk" :class="{ error: v$.datepicker.$errors?.length }" :validations="v$.datepicker" select-text="Vybrať" cancel-text="Zrušiť" placeholder="Dátum" :enable-time-picker="false" ref="datepicker" />
|
||||
|
||||
<v-text-field v-model="starts_at_time" type="time" variant="solo" bg-color="white" :hint="v$.starts_at_time.$errors ? errorUtils.parseErrors(v$.starts_at_time.$errors) : null" :class="{ error: v$.starts_at_time.$errors.length }" class="mb-1 modal-input" label="Začiatok" />
|
||||
<v-text-field v-model="ends_at_time" type="time" variant="solo" bg-color="white" :hint="v$.ends_at_time.$errors ? errorUtils.parseErrors(v$.ends_at_time.$errors) : null" :class="{ error: v$.ends_at_time.$errors.length }" class="modal-input" label="Koniec" />
|
||||
<v-text-field v-model="ends_at_time" type="time" variant="solo" bg-color="white" :hint="v$.ends_at_time.$errors ? errorUtils.parseErrors(v$.ends_at_time.$errors) : null" :class="{ error: v$.ends_at_time.$errors.length }" class="modal-input" label="Koniec" />
|
||||
</v-card-actions>
|
||||
|
||||
<v-btn class="button primary" @click="save()">{{ blocker.id ? 'UPRAVIŤ' : 'VYTVORIŤ'}}</v-btn>
|
||||
<v-btn class="button primary" @click="save()">{{ blocker.id ? "UPRAVIŤ" : "VYTVORIŤ" }}</v-btn>
|
||||
</v-card>
|
||||
</W-loadable>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Datepicker from '@vuepic/vue-datepicker'
|
||||
import useVuelidate from '@vuelidate/core'
|
||||
import { required } from '@vuelidate/validators'
|
||||
import errorUtils from '@/plugins/lib@auth/_utils/error.utils'
|
||||
import VuetifyFixFocusMixin from '@/plugins/tm@modal/_mixins/vuetify-fix-focus'
|
||||
import tmUtils from '@/plugins/tm@_utils/tm.utils'
|
||||
import { mapGetters } from 'vuex'
|
||||
import moment from 'moment'
|
||||
import Datepicker from "@vuepic/vue-datepicker"
|
||||
import useVuelidate from "@vuelidate/core"
|
||||
import { required } from "@vuelidate/validators"
|
||||
import errorUtils from "@/plugins/lib@auth/_utils/error.utils"
|
||||
import VuetifyFixFocusMixin from "@/plugins/tm@modal/_mixins/vuetify-fix-focus"
|
||||
import { mapGetters } from "vuex"
|
||||
import moment from "moment"
|
||||
import ZAutocomplete from '@/plugins/tm@_components/z-autocomplete.vue'
|
||||
|
||||
export default {
|
||||
mixins: [VuetifyFixFocusMixin],
|
||||
|
||||
emits: ['close'],
|
||||
emits: ["close"],
|
||||
|
||||
components: {
|
||||
Datepicker
|
||||
Datepicker,
|
||||
ZAutocomplete
|
||||
},
|
||||
|
||||
data() {
|
||||
@@ -82,13 +56,9 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
...mapGetters('tm', [
|
||||
'enrichedEmployees'
|
||||
]),
|
||||
...mapGetters("tm", ["enrichedEmployees"]),
|
||||
|
||||
...mapGetters('auth', [
|
||||
'user'
|
||||
])
|
||||
...mapGetters("auth", ["user"])
|
||||
},
|
||||
|
||||
validations() {
|
||||
@@ -97,7 +67,7 @@ export default {
|
||||
name: { required },
|
||||
start: { required },
|
||||
end: { required },
|
||||
employee_id: { required }
|
||||
employee: { required }
|
||||
},
|
||||
|
||||
starts_at_time: { required },
|
||||
@@ -108,26 +78,25 @@ export default {
|
||||
|
||||
methods: {
|
||||
async showModal({ blocker }) {
|
||||
this.visible = true
|
||||
this.blocker = null
|
||||
this.datepicker = null
|
||||
this.starts_at_time = null
|
||||
this.ends_at_time = null
|
||||
this.visible = true
|
||||
this.blocker = null
|
||||
this.datepicker = null
|
||||
this.starts_at_time = null
|
||||
this.ends_at_time = null
|
||||
|
||||
this.$nextTick(() => this.v$.$reset())
|
||||
|
||||
try {
|
||||
if (blocker?.id) {
|
||||
blocker = await this.$axios.get_auth_data(`v1/blockers/${blocker.id}`)
|
||||
blocker.employee_id = blocker.employee.id
|
||||
|
||||
this.starts_at_time = moment(blocker.start).format('HH:mm')
|
||||
this.ends_at_time = moment(blocker.end).format('HH:mm')
|
||||
this.datepicker = new Date(blocker.start)
|
||||
this.starts_at_time = moment(blocker.start).format("HH:mm")
|
||||
this.ends_at_time = moment(blocker.end).format("HH:mm")
|
||||
this.datepicker = new Date(blocker.start)
|
||||
|
||||
this.blocker = blocker
|
||||
} else {
|
||||
this.blocker = {start: null}
|
||||
this.blocker = { start: null }
|
||||
}
|
||||
} catch (error) {
|
||||
this.$toast.error(error)
|
||||
@@ -135,15 +104,16 @@ export default {
|
||||
},
|
||||
|
||||
async save() {
|
||||
if (!(await this.v$.$validate()))
|
||||
return
|
||||
if (!(await this.v$.$validate())) return
|
||||
|
||||
try {
|
||||
this.blocker.employee_id = this.blocker.employee?.id
|
||||
|
||||
if (this.blocker.id) {
|
||||
const { blocker } = await this.$axios.put_auth(`v1/blockers/${this.blocker.id}`, this.blocker)
|
||||
this.blocker = blocker
|
||||
} else {
|
||||
const { blocker } = await this.$axios.post_auth('v1/blockers', this.blocker)
|
||||
const { blocker } = await this.$axios.post_auth("v1/blockers", this.blocker)
|
||||
this.blocker = blocker
|
||||
}
|
||||
|
||||
@@ -155,20 +125,27 @@ export default {
|
||||
},
|
||||
|
||||
closeModal() {
|
||||
this.$refs['datepicker'].clearValue()
|
||||
this.$refs["datepicker"].clearValue()
|
||||
this.visible = false
|
||||
this.$emit('close', this.blocker)
|
||||
this.$emit("close", this.blocker)
|
||||
},
|
||||
|
||||
onEmployeeSelected({ key }) {
|
||||
this.blocker.employee = this.enrichedEmployees.find(employee => employee.id == key)
|
||||
},
|
||||
|
||||
_syncDatesTimes() {
|
||||
if (!this.starts_at_time || !this.ends_at_time || !this.datepicker)
|
||||
return
|
||||
if (!this.starts_at_time || !this.ends_at_time || !this.datepicker) return
|
||||
|
||||
const splittedStart = this.starts_at_time.split(':')
|
||||
const splittedEnd = this.ends_at_time.split(':')
|
||||
const splittedStart = this.starts_at_time.split(":")
|
||||
const splittedEnd = this.ends_at_time.split(":")
|
||||
|
||||
this.blocker.start = moment(this.datepicker).set({hours: parseInt(splittedStart[0]), minutes: parseInt(splittedStart[1])}).format('YYYY-MM-DD HH:mm')
|
||||
this.blocker.end = moment(this.datepicker).set({hours: parseInt(splittedEnd[0]), minutes: parseInt(splittedEnd[1])}).format('YYYY-MM-DD HH:mm')
|
||||
this.blocker.start = moment(this.datepicker)
|
||||
.set({ hours: parseInt(splittedStart[0]), minutes: parseInt(splittedStart[1]) })
|
||||
.format("YYYY-MM-DD HH:mm")
|
||||
this.blocker.end = moment(this.datepicker)
|
||||
.set({ hours: parseInt(splittedEnd[0]), minutes: parseInt(splittedEnd[1]) })
|
||||
.format("YYYY-MM-DD HH:mm")
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -12,8 +12,7 @@
|
||||
|
||||
<Z-autocomplete label="Master task" :options="mastertasks.map((mastertask) => ({ key: mastertask.id, value: mastertask.name }))" :validations="v$.subtask.master_task.id" :clear-on-submit="false" :value="subtask?.master_task?.name" :class="{ error: v$.subtask.master_task.id.$errors.length }" class="modal-input" @option-selected="onMasterTaskSelected" />
|
||||
|
||||
<v-select v-model="subtask.employee_id" ref="employee-select" @focus="onInputFocus" class="modal-input border-select" label="Priradený" :class="{ error: v$.subtask.employee_id.$errors.length }" variant="solo" :items="filteredEmployees" item-value="id" item-title="_fullName"></v-select>
|
||||
|
||||
<Z-autocomplete label="Priradený" :value="subtask?.employee ? `${subtask?.employee?.name} ${subtask?.employee?.surname}` : ''" :options="enrichedEmployees.map(employee => ({key: employee.id, value: employee._fullName}))" :clear-on-submit="false" :class="{ error: v$.subtask.employee.$errors.length }" class="modal-input" @option-selected="onEmployeeSelected" />
|
||||
<v-text-field v-model="subtask.duration" @focus="onInputFocus" class="modal-input" variant="solo" type="number" label="Časový odhad" :class="{ error: v$.subtask.duration.$errors.length }" :hint="v$.subtask.duration.$errors ? errorUtils.parseErrors(v$.subtask.duration.$errors) : null" append-inner-icon="mdi-clock-outline"></v-text-field>
|
||||
|
||||
<div class="w-100 modal-input">
|
||||
@@ -123,7 +122,7 @@ export default {
|
||||
id: { required }
|
||||
},
|
||||
duration: { required },
|
||||
employee_id: { required }
|
||||
employee: { required }
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -227,6 +226,10 @@ export default {
|
||||
this.subtask.files = files
|
||||
},
|
||||
|
||||
onEmployeeSelected({ key }) {
|
||||
this.subtask.employee_id = key
|
||||
},
|
||||
|
||||
_enrichTask(subtask) {
|
||||
subtask.master_task = this.mastertasks.find((mastertask) => mastertask.id == subtask.master_task_id)
|
||||
subtask.employee = this.enrichedEmployees.find((employee) => employee.id == subtask.employee_id)
|
||||
@@ -257,10 +260,6 @@ export default {
|
||||
editMode() {
|
||||
this.$nextTick(() => {
|
||||
this.$refs["description"]?.setHTML(this.subtask.description || "")
|
||||
|
||||
const employeeSelect = this.$refs['employee-select']?.$el?.querySelector('.v-select__selection-text')
|
||||
if (employeeSelect)
|
||||
employeeSelect.innerHTML = this.subtask?.employee?._fullName || ''
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,10 +50,13 @@ export default {
|
||||
async updateUserInfo() {
|
||||
if (!(await this.v$.$validate())) return
|
||||
|
||||
const [sHours, sMinutes] = this.form.work_start.split(':');
|
||||
const [eHours, eMinutes] = this.form.work_end.split(':');
|
||||
|
||||
const data = {
|
||||
id: this.user.id,
|
||||
work_start: parseInt(this.form.work_start.split(':')[0]),
|
||||
work_end: parseInt(this.form.work_end.split(':')[0])
|
||||
work_start: parseFloat(sHours) * 60 + parseFloat(sMinutes),
|
||||
work_end: parseFloat(eHours) * 60 + parseFloat(eMinutes)
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -66,9 +69,18 @@ export default {
|
||||
|
||||
_setDates() {
|
||||
this.form = {
|
||||
work_start: this.user.work_start < 10 ? `0${this.user.work_start}:00` : `${this.user.work_start}:00`,
|
||||
work_end: this.user.work_end < 10 ? `0${this.user.work_end}:00` : `${this.user.work_end}:00`
|
||||
work_start: this.minutesToTime(this.user.work_start),
|
||||
work_end: this.minutesToTime(this.user.work_end)
|
||||
}
|
||||
},
|
||||
|
||||
minutesToTime(minutes) {
|
||||
var hours = Math.floor(minutes / 60)
|
||||
var mins = minutes % 60
|
||||
hours = (hours < 10 ? '0' : '') + hours
|
||||
mins = (mins < 10 ? '0' : '') + mins
|
||||
|
||||
return hours + ':' + mins
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user