[Projects] Added filters

This commit is contained in:
Matej Glasnák committed 2023-03-01 14:19:33 +01:00
1 parent 919b2eebbe
commit 302286bff8
29 files changed
+508 -350

No files matched your search

@@ -1,153 +1,44 @@
<template>
<v-row no-gutters class="align-center">
<v-col cols="5">
<v-sheet class="py-3">
<div class="d-flex align-center">
<v-icon icon="mdi-drag-vertical" size="large"></v-icon>
<p class="mx-3">Status</p>
</div>
</v-sheet>
</v-col>
<v-col cols="7">
<v-sheet class="py-3">
<p v-if="masterTask.is_finished" class="status-badge px-4 py-2 rounded-pill">Ukončený</p>
<p v-if="!masterTask.is_finished" class="status-badge px-4 py-2 rounded-pill">Neukončený</p>
</v-sheet>
</v-col>
</v-row>
<v-row no-gutters class="align-center">
<v-col cols="5">
<v-sheet class="py-3">
<div class="d-flex align-center">
<v-icon icon="mdi-calendar-week" size="large"></v-icon>
<p class="mx-3">Deadline</p>
</div>
</v-sheet>
</v-col>
<v-col cols="7">
<v-sheet class="py-3">
<p :class="`${tmUtils.isAfter(masterTask.deadline) ? 'text-black' : 'text-red-darken-4'}`">{{ tmUtils.formatDateTime(masterTask.deadline) }}</p>
</v-sheet>
</v-col>
</v-row>
<v-row no-gutters>
<v-col cols="5">
<v-sheet class="pa-2 pt-0">
<div class="d-flex align-center">
<v-icon icon="mdi-account-multiple-outline" size="large"></v-icon>
<p class="mx-3">Tím</p>
</div>
</v-sheet>
</v-col>
<v-col cols="7">
<v-sheet class="d-flex flex-wrap flex-column">
<p class="task-badge px-4 py-2 rounded-pill flex-shrink-0">{{ masterTask.team?.name }}</p>
<div class="d-flex align-center flex-shrink-0 mt-2 task-badge px-4 py-2 rounded-pill" v-for="(employee, index) in masterTask.employees" :key="employee.id">
<p class="employee-selected-avatar d-flex justify-center align-center">
{{ employee.name.charAt(0) + employee.surname.charAt(0) }}
</p>
<p class="ml-2" v-html="`${masterTask.employees[index].name} ${masterTask.employees[index].surname}`" />
</div>
</v-sheet>
</v-col>
</v-row>
<v-row no-gutters class="align-center">
<v-col cols="5">
<v-sheet class="py-3">
<div class="d-flex align-center">
<v-icon icon="mdi-clock-time-three-outline" size="large"></v-icon>
<p class="mx-3">Naplánovaný čas</p>
</div>
</v-sheet>
</v-col>
<v-col cols="7">
<v-sheet class="py-3">
<p>{{ masterTask?.duration?.toFixed(2) }} h</p>
</v-sheet>
</v-col>
</v-row>
<v-row no-gutters class="align-center">
<v-col cols="5">
<v-sheet class="py-3">
<div class="d-flex align-center">
<v-icon icon="mdi-timer-outline" size="large"></v-icon>
<p class="mx-3">Odpracovaný čas</p>
</div>
</v-sheet>
</v-col>
<v-col cols="7">
<v-sheet class="py-3">
<p :class="masterTask.time_worked > masterTask.duration ? 'text-red-darken-4' : 'text-black'">{{ masterTask.time_worked?.toFixed(2) }} h</p>
</v-sheet>
</v-col>
</v-row>
<v-row no-gutters class="align-center border-bottom">
<v-col cols="5">
<v-sheet class="py-3">
<div class="d-flex align-center">
<v-icon icon="mdi-clock-time-three-outline" size="large"></v-icon>
<p class="mx-3">Zostávajúci čas</p>
</div>
</v-sheet>
</v-col>
<v-col cols="7">
<v-sheet class="py-3">
<p :class="masterTask.time_worked > masterTask.duration ? 'text-red-darken-4' : 'text-black'">{{ (masterTask.duration - masterTask.time_worked)?.toFixed(2) }} h</p>
</v-sheet>
</v-col>
</v-row>
<div class="px-5 py-5 border-bottom">
<p>Popis zadania</p>
<section v-html="masterTask.description" class="description-detail px-2 py-2 w-100 rounded mt-2" />
<template v-if="masterTask.files?.length">
<p class="mt-5">Prílohy</p>
<div class="w-100 d-flex align-center">
<div v-for="(file, index) in masterTask.files" :key="file.id" class="d-flex align-center flex-wrap" :class="[index === 0 ? 'ml-0' : 'ml-2']">
<v-chip class="mt-2">
<p @click="downloadFile(index)" class="cursor-pointer">{{ file.name }}</p>
<v-icon class="mx-1" icon="mdi-paperclip"></v-icon>
</v-chip>
</div>
</div>
</template>
</div>
<Z-status :status="mastertask.is_finished" />
<Z-deadline :deadline="mastertask.deadline" />
<Z-created-by :employee="mastertask.created_by" />
<Z-team :team="mastertask.team" :employees="mastertask.employees" />
<Z-planned-time :hours="mastertask.duration" />
<Z-remaining-time :hours="mastertask.duration - mastertask.time_worked" />
<Z-spent-time :hours="mastertask.time_worked" :is-exceeded="mastertask.time_worked > mastertask.duration" />
<Z-description :description="mastertask.description" />
<Z-files :files="mastertask.files" />
</template>
<script>
import tmUtils from '@/plugins/tm@_utils/tm.utils'
import * as FileSaver from 'file-saver'
import ZCreatedBy from '../../_components/read-only/z-created-by.vue'
import ZDeadline from '../../_components/read-only/z-deadline.vue'
import ZDescription from '../../_components/read-only/z-description.vue'
import ZFiles from '../../_components/read-only/z-files.vue'
import ZPlannedTime from '../../_components/read-only/z-planned-time.vue'
import ZRemainingTime from '../../_components/read-only/z-remaining-time.vue'
import ZSpentTime from '../../_components/read-only/z-spent-time.vue'
import ZStatus from '../../_components/read-only/z-status.vue'
import ZTeam from '../../_components/read-only/z-team.vue'
export default {
components: {
ZCreatedBy,
ZDeadline,
ZDescription,
ZFiles,
ZPlannedTime,
ZRemainingTime,
ZSpentTime,
ZStatus,
ZTeam
},
props: {
masterTask: {
mastertask: {
type: Object,
required: true
}
},
data() {
return {
tmUtils
}
},
methods: {
async downloadFile(id) {
try {
const file = await this.$axios.get_auth_data(`v1/mastertasks/${this.masterTask.id}`, { responseType: 'arraybuffer' })
FileSaver.saveAs(file.files[id].path, file.files[id].name)
} catch(error) {
this.$toast.error(error)
}
}
}
}
</script>
<style lang="sass" scoped>
@media screen and (max-width: 522px)
.files
margin-top: 104px !important
</style>
</script>
@@ -1,7 +1,7 @@
export default {
computed: {
employeesOptions() {
const selectedEmployees = [...this.masterTask.employees].map(employee => employee.id)
const selectedEmployees = [...this.mastertask.employees].map(employee => employee.id)
const employees = this.employees.filter(
(employee) => !selectedEmployees.includes(employee.id)
@@ -19,26 +19,26 @@ export default {
methods: {
onProjectSelected({ key }) {
const project = this.projects.find(project => project.id == key)
this.masterTask.project_code = project.code
this.masterTask.project_id = project.id
this.mastertask.project_code = project.code
this.mastertask.project_id = project.id
},
onMasterTaskSelected({ key }) {
const mastertask = this.mastertasks.find(masterTask => masterTask.id == key)
const mastertask = this.mastertasks.find(mastertask => mastertask.id == key)
this.task.master_task = mastertask
this.task.project_code = mastertask.project_code
},
onEmployeeSelected({ key }) {
const employee = this.employees.find(employee => employee.id == key)
this.masterTask.employees.push(employee)
this.mastertask.employees.push(employee)
this.showAddEmployeeInput = false
},
onEmployeeDurationChanged() {
let totalDuration = 0
this.masterTask.employees = this.masterTask.employees.map(employee => {
this.mastertask.employees = this.mastertask.employees.map(employee => {
if (typeof employee.duration == 'string') {
totalDuration += parseInt(employee.duration)
employee.duration = parseInt(employee.duration)
@@ -50,16 +50,16 @@ export default {
return employee
})
this.masterTask.duration = totalDuration
this.mastertask.duration = totalDuration
}
},
watch: {
'masterTask.team_id'(value, oldValue) {
'mastertask.team_id'(value, oldValue) {
if (!value || !oldValue) return
this.masterTask.team = this.teams.find(team => team.id == value)
this.masterTask.employees = this.masterTask.team.employees
this.mastertask.team = this.teams.find(team => team.id == value)
this.mastertask.employees = this.mastertask.team.employees
}
}
}
@@ -2,7 +2,7 @@
<v-dialog v-model="visible" max-width="750">
<v-card>
<div class="d-flex justify-space-between align-center">
<h1>Ste si istý, že chcete zmazať <b>{{ masterTask.name }}</b>?</h1>
<h1>Ste si istý, že chcete zmazať <b>{{ mastertask.name }}</b>?</h1>
<v-icon
@click.stop="closeModal()"
@@ -26,13 +26,13 @@ export default {
data() {
return {
visible: false,
masterTask: null
mastertask: null
}
},
methods: {
async showModal(masterTask) {
this.masterTask = masterTask
async showModal(mastertask) {
this.mastertask = mastertask
this.visible = true
},
@@ -42,8 +42,8 @@ export default {
async deleteMasterTask() {
try {
await this.$axios.delete_auth(`v1/mastertasks/${this.masterTask.id}`)
this.$emit('on-master-task-deleted', this.masterTask)
await this.$axios.delete_auth(`v1/mastertasks/${this.mastertask.id}`)
this.$emit('on-master-task-deleted', this.mastertask)
this.closeModal()
} catch (error) {
this.$toast.error(error)
@@ -1,25 +1,25 @@
<template>
<v-dialog v-model="visible" max-width="750" max-height="90%" height="700px">
<W-loadable :content="masterTask" class="h-100">
<W-loadable :content="mastertask" class="h-100">
<v-card v-if="editMode" height="100%" class="d-flex flex-column scrolling">
<div class="d-flex justify-space-between align-center modal-header">
<h1>{{ masterTask?.id ? 'Upraviť master task' : 'Vytvoriť master task' }}</h1>
<h1>{{ mastertask?.id ? 'Upraviť master task' : 'Vytvoriť master task' }}</h1>
<v-icon @click.stop="closeModal()" icon="mdi-close" size="large"></v-icon>
</div>
<v-card-actions class="d-flex flex-column modal-content">
<Z-autocomplete label="Kód projektu" :options="projects.map((project) => ({ key: project.id, value: project.code }))" :validations="v$.masterTask.project_code" :clear-on-submit="false" :value="masterTask.project_code" :class="{ error: v$.masterTask.project_code.$errors.length }" class="modal-input" @option-selected="onProjectSelected" />
<Z-autocomplete label="Kód projektu" :options="projects.map((project) => ({ key: project.id, value: project.code }))" :validations="v$.mastertask.project_code" :clear-on-submit="false" :value="mastertask.project_code" :class="{ error: v$.mastertask.project_code.$errors.length }" class="modal-input" @option-selected="onProjectSelected" />
<v-text-field v-model="masterTask.name" @focus="onInputFocus" class="modal-input" label="Názov mastertasku" variant="solo" :class="{ error: v$.masterTask.name.$errors.length }" :hint="v$.masterTask.name.$errors ? errorUtils.parseErrors(v$.masterTask.name.$errors) : null"></v-text-field>
<v-text-field v-model="mastertask.name" @focus="onInputFocus" class="modal-input" label="Názov mastertasku" variant="solo" :class="{ error: v$.mastertask.name.$errors.length }" :hint="v$.mastertask.name.$errors ? errorUtils.parseErrors(v$.mastertask.name.$errors) : null"></v-text-field>
<Datepicker v-model="masterTask.deadline" @focus="onDateFocus" class="modal-input" format="dd.MM.yyyy, HH:mm" locale="sk" :class="{ error: v$.masterTask.deadline.$errors.length }" select-text="Vybrať" cancel-text="Zrušiť" placeholder="Deadline" />
<Datepicker v-model="mastertask.deadline" @focus="onDateFocus" class="modal-input" format="dd.MM.yyyy, HH:mm" locale="sk" :class="{ error: v$.mastertask.deadline.$errors.length }" select-text="Vybrať" cancel-text="Zrušiť" placeholder="Deadline" />
<v-text-field v-model="masterTask.duration" @focus="onInputFocus" class="modal-input mt-5" variant="solo" type="number" disabled :label="`${masterTask.duration} h`"></v-text-field>
<v-text-field v-model="mastertask.duration" @focus="onInputFocus" class="modal-input mt-5" variant="solo" type="number" disabled :label="`${mastertask.duration} h`"></v-text-field>
<v-select v-model="this.masterTask.team_id" @focus="onInputFocus" class="modal-input border-select" :class="{ error: v$.masterTask.team_id.$errors.length }" label="Tím" variant="solo" :items="teams" item-value="id" item-title="name"></v-select>
<v-select v-model="this.mastertask.team_id" @focus="onInputFocus" class="modal-input border-select" :class="{ error: v$.mastertask.team_id.$errors.length }" label="Tím" variant="solo" :items="teams" item-value="id" item-title="name"></v-select>
<template v-if="!masterTask.id">
<v-text-field v-for="(employee, index) in masterTask.employees" :key="employee.id" @focus="onInputFocus" :class="{ error: !masterTask.employees[index].duration }" class="modal-input" :label="`${employee.name} ${employee.surname}`" variant="solo" placeholder="h" v-model="masterTask.employees[index].duration" type="number" min="1" @input="onEmployeeDurationChanged">
<template v-if="!mastertask.id">
<v-text-field v-for="(employee, index) in mastertask.employees" :key="employee.id" @focus="onInputFocus" :class="{ error: !mastertask.employees[index].duration }" class="modal-input" :label="`${employee.name} ${employee.surname}`" variant="solo" placeholder="h" v-model="mastertask.employees[index].duration" type="number" min="1" @input="onEmployeeDurationChanged">
<p class="employee-select-avatar d-flex justify-center align-center">
{{ employee.name.charAt(0) + employee.surname.charAt(0) }}
</p>
@@ -28,40 +28,40 @@
<Z-autocomplete label="Vyhľadať zamestnanca" v-if="showAddEmployeeInput" :options="employeesOptions" class="modal-input" @option-selected="onEmployeeSelected" />
<v-btn class="w-100 mb-5 button secondary" :disabled="!masterTask.team?.id" @click="showAddEmployeeInput = true"> <v-icon class="mx-1" icon="mdi-plus" />Pridať zamestnanca </v-btn>
<v-btn class="w-100 mb-5 button secondary" :disabled="!mastertask.team?.id" @click="showAddEmployeeInput = true"> <v-icon class="mx-1" icon="mdi-plus" />Pridať zamestnanca </v-btn>
<div class="w-100 modal-input" :class="{ error: v$.masterTask.description.$errors.length }">
<QuillEditor ref="description" v-model="masterTask.description" placeholder="Popis" theme="snow" class="rich-text-editor" @input="masterTask.description = $event.srcElement.innerHTML" />
<div class="w-100 modal-input" :class="{ error: v$.mastertask.description.$errors.length }">
<QuillEditor ref="description" v-model="mastertask.description" placeholder="Popis" theme="snow" class="rich-text-editor" @input="mastertask.description = $event.srcElement.innerHTML" />
</div>
<Z-files-upload class="mt-15 files" :files="masterTask.files" @files-uploaded="filesUploaded" />
<Z-files-upload class="mt-15 files" :files="mastertask.files" @files-uploaded="filesUploaded" />
</v-card-actions>
<v-btn class="button primary" @click="save()">{{ masterTask.id ? 'ULOŽIŤ' : 'VYTVORIŤ' }}</v-btn>
<v-btn class="button primary" @click="save()">{{ mastertask.id ? 'ULOŽIŤ' : 'VYTVORIŤ' }}</v-btn>
</v-card>
<v-card v-else height="100%" class="d-flex flex-column scrolling">
<div class="d-flex justify-space-between align-center">
<p>{{ masterTask.project_code }}</p>
<p>{{ mastertask.project_code }}</p>
<v-icon @click.stop="closeModal()" icon="mdi-close" size="large" class="pb-5"></v-icon>
</div>
<div class="d-flex justify-space-between align-center modal-header border-bottom pb-4">
<h1>{{ masterTask.name }}</h1>
<h1>{{ mastertask.name }}</h1>
<div class="d-flex justify-start">
<img class="icon" :src="require('@/plugins/app/_img/icons/pencil.svg')" alt="pencil-icon" @click.stop="editMode = !editMode" />
<img class="icon trash" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="openDeleteMasterTaskModal(masterTask)" />
<img class="icon trash" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="openDeleteMasterTaskModal(mastertask)" />
</div>
</div>
<v-card-actions class="d-flex flex-column modal-content">
<div class="w-100">
<A-mastertask-description :master-task="masterTask" />
<A-mastertask-description :mastertask="mastertask" />
<div class="d-flex justify-start align-center mt-8">
<v-btn class="button primary" @click="save()">Ukončiť mastertask</v-btn>
</div>
<A-tasks-table :tasks="masterTask.subtasks" :employees="enrichedEmployees" />
<A-tasks-table :tasks="mastertask.subtasks" :employees="enrichedEmployees" />
<div class="d-flex align-center ">
<v-btn class="subtask-btn w-100" @click="addTask()" ><v-icon class="mx-1" icon="mdi-plus" />Pridať task</v-btn>
@@ -96,7 +96,7 @@ export default {
// MIXINS
// computed: employeesOptions
// methods: onProjectSelected, onEmployeeSelected, onEmployeeDurationChanged
// watch: masterTask.team_id
// watch: mastertask.team_id
emits: ['master-task-edited', 'close'],
mixins: [VuetifyFixFocusMixin, SelectsMixin],
@@ -116,7 +116,7 @@ export default {
visible: false,
errorUtils,
v$: useVuelidate(),
masterTask: null,
mastertask: null,
showAddEmployeeInput: false,
date: null,
}
@@ -132,7 +132,7 @@ export default {
validations() {
return {
masterTask: {
mastertask: {
project_code: { required },
team_id: { required },
name: { required },
@@ -143,22 +143,22 @@ export default {
},
mounted() {
this.$events.on('on-master-task-deleted', (masterTask) => {
if (masterTask?.id == this.masterTask?.id) this.closeModal()
this.$events.on('on-master-task-deleted', (mastertask) => {
if (mastertask?.id == this.mastertask?.id) this.closeModal()
})
this.$events.on('on-task-deleted', (task) => {
if (!this.masterTask) return
this.masterTask.subtasks = this.masterTask.subtasks.filter((subtask) => subtask.id != task.id)
if (!this.mastertask) return
this.mastertask.subtasks = this.mastertask.subtasks.filter((subtask) => subtask.id != task.id)
})
this.$events.on('on-subtask-edited', (task) => {
if (!this.masterTask?.subtasks) return
if (!this.mastertask?.subtasks) return
if (this.masterTask.subtasks.find(subtask => subtask.id == task.id)) {
this.masterTask.subtasks = this.masterTask.subtasks.map(t => t.id == task.id ? task : t)
if (this.mastertask.subtasks.find(subtask => subtask.id == task.id)) {
this.mastertask.subtasks = this.mastertask.subtasks.map(t => t.id == task.id ? task : t)
} else {
this.masterTask.subtasks.push(task)
this.mastertask.subtasks.push(task)
}
})
},
@@ -170,25 +170,25 @@ export default {
},
methods: {
async showModal(masterTask, editMode = false) {
async showModal(mastertask, editMode = false) {
this.v$.$reset()
this.visible = true
this.masterTask = null
this.mastertask = null
try {
if (masterTask?.id) {
this.masterTask = await this.$axios.get_auth_data(`v1/mastertasks/${masterTask.id}`)
if (mastertask?.id) {
this.mastertask = await this.$axios.get_auth_data(`v1/mastertasks/${mastertask.id}`)
const project = this.projects.find((project) => project.code == this.masterTask?.project_code)
const project = this.projects.find((project) => project.code == this.mastertask?.project_code)
this.masterTask.team_id = this.masterTask.team.id
this.masterTask.project_id = project.id
this.masterTask.project_code = project.code
this.mastertask.team_id = this.mastertask.team?.id || null
this.mastertask.project_id = project.id
this.mastertask.project_code = project.code
} else {
this.masterTask = { employees: [], duration: 0 }
this.mastertask = { employees: [], duration: 0 }
}
this.editMode = editMode || !this.masterTask.id
this.editMode = editMode || !this.mastertask.id
} catch (error) {
this.$toast.error(error)
}
@@ -197,24 +197,24 @@ export default {
async save() {
if (!(await this.v$.$validate())) return
this.masterTask.description = this.$refs['description'].getHTML()
this.mastertask.description = this.$refs['description'].getHTML()
// this.masterTask.subtasks = this.masterTask.subtasks.map(subtask => {
// const employee = this.masterTask.employees.find(employee => employee.id == subtask.employee_id)
// this.mastertask.subtasks = this.mastertask.subtasks.map(subtask => {
// const employee = this.mastertask.employees.find(employee => employee.id == subtask.employee_id)
// subtask.duration = employee.duration
// return subtask
// })
// this.masterTask.project_code = null
// this.mastertask.project_code = null
try {
this.masterTask.deadline = moment(this.masterTask.deadline).format('YYYY-MM-DD HH:MM:SS')
this.mastertask.deadline = moment(this.mastertask.deadline).format('YYYY-MM-DD HH:MM:SS')
if (this.masterTask.id) await this.$axios.put_auth_data(`v1/mastertasks/${this.masterTask.id}`, this.masterTask)
else await this.$axios.post_auth_data('v1/mastertasks', this.masterTask)
if (this.mastertask.id) await this.$axios.put_auth_data(`v1/mastertasks/${this.mastertask.id}`, this.mastertask)
else await this.$axios.post_auth_data('v1/mastertasks', this.mastertask)
this.$emit('master-task-edited', this.masterTask)
this.$emit('master-task-edited', this.mastertask)
this.closeModal()
} catch (error) {
this.$toast.error(error)
@@ -222,26 +222,26 @@ export default {
},
filesUploaded(files) {
this.masterTask.files = files
this.mastertask.files = files
},
closeModal() {
this.visible = false
},
openDeleteMasterTaskModal(masterTask) {
this.$events.emit('show-delete-master-task-modal', { masterTask })
openDeleteMasterTaskModal(mastertask) {
this.$events.emit('show-delete-master-task-modal', { mastertask })
},
addTask() {
this.$events.emit('show-task-modal', { task: null, editMode: false, masterTask: this.masterTask })
this.$events.emit('show-task-modal', { task: null, editMode: false, mastertask: this.mastertask })
}
},
watch: {
editMode() {
this.$nextTick(() => {
this.$refs['description']?.setHTML(this.masterTask.description || '')
this.$refs['description']?.setHTML(this.mastertask.description || '')
})
}
}