[Refactoring]

This commit is contained in:
Matej Glasnák committed 2023-03-03 10:36:11 +01:00
1 parent 26138f69b3
commit ca1cbd723a
25 files changed
+215 -206

No files matched your search

@@ -1,24 +1,24 @@
<template>
<v-table class="mt-7 mb-5">
<tbody class="px-5 py-5">
<tr v-for="task in enrichedtasks" :key="task.id">
<td class="w-25">{{ task.project_code }}</td>
<tr v-for="subtask in enrichedtasks" :key="subtask.id">
<td class="w-25">{{ subtask.project_code }}</td>
<td class="d-flex align-center">
<p class="employee-selected-avatar d-flex justify-center align-center">
{{ task._employeeInitials }}
{{ subtask._employeeInitials }}
</p>
<p class="ml-2">{{ task._employeeFullName }}</p>
<p class="ml-2">{{ subtask._employeeFullName }}</p>
</td>
<td>
<p class="text-light-green" v-if="task.is_finished">Ukončený</p>
<p v-if="!task.is_finished">Neukončený</p>
<p class="text-light-green" v-if="subtask.is_finished">Ukončený</p>
<p v-if="!subtask.is_finished">Neukončený</p>
</td>
<td class="task-action">
<div class="d-flex justify-start">
<img v-if="task.is_finished" class="pencil-icon is-finished" :src="require('@/plugins/app/_img/icons/checkmark.svg')" alt="checkmark-icon" @click.stop="clickCompleteTask(task)">
<img v-if="!task.is_finished" class="pencil-icon" :src="require('@/plugins/app/_img/icons/checkmark.svg')" alt="checkmark-icon" @click.stop="clickCompleteTask(task)">
<img class="pencil-icon ml-2" :src="require('@/plugins/app/_img/icons/eye.svg')" alt="pencil-icon" @click.stop="openTaskModal(task)">
<img class="trash-icon" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="openDeleteTaskModal(task)">
<img v-if="subtask.is_finished" class="pencil-icon is-finished" :src="require('@/plugins/app/_img/icons/checkmark.svg')" alt="checkmark-icon" @click.stop="clickCompleteTask(subtask)">
<img v-if="!subtask.is_finished" class="pencil-icon" :src="require('@/plugins/app/_img/icons/checkmark.svg')" alt="checkmark-icon" @click.stop="clickCompleteTask(subtask)">
<img class="pencil-icon ml-2" :src="require('@/plugins/app/_img/icons/eye.svg')" alt="pencil-icon" @click.stop="openTaskModal(subtask)">
<img class="trash-icon" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="openDeleteTaskModal(subtask)">
</div>
</td>
</tr>
@@ -27,40 +27,39 @@
</template>
<script>
import { mapGetters } from 'vuex'
export default {
props: {
tasks: {
subtasks: {
type: Array,
required: true
},
employees: {
type: Array,
required: true
}
},
computed: {
...mapGetters('tm', ['enrichedEmployees']),
enrichedtasks() {
return this.tasks.map(task => {
const employee = this.employees.find(employee => employee.id == task.employee_id)
return this.subtasks.map(subtask => {
const employee = this.enrichedEmployees.find(employee => employee.id == subtask.employee_id)
return {
...task,
_employeeInitials: employee.name.charAt(0) + employee.surname.charAt(0),
_employeeFullName: `${employee.name} ${employee.surname}`
...subtask,
_employeeInitials: employee._initials,
_employeeFullName: employee._fullName
}
})
}
},
methods: {
openDeleteTaskModal(task) {
this.$events.emit('show-delete-task-modal', { task })
openDeleteTaskModal(subtask) {
this.$events.emit('show-delete-task-modal', { subtask })
},
openTaskModal(task) {
this.$events.emit('show-task-modal', { task, editMode: false })
openTaskModal(subtask) {
this.$events.emit('show-subtask-modal', { subtask, editMode: false })
},
async clickCompleteTask(subtask) {
@@ -25,8 +25,8 @@ export default {
onMasterTaskSelected({ key }) {
const mastertask = this.mastertasks.find(mastertask => mastertask.id == key)
this.task.master_task = mastertask
this.task.project_code = mastertask.project_code
this.subtask.master_task = mastertask
this.subtask.project_code = mastertask.project_code
},
onEmployeeSelected({ key }) {
@@ -31,7 +31,7 @@ export default {
},
methods: {
async showModal(mastertask) {
async showModal({ mastertask }) {
this.mastertask = mastertask
this.visible = true
},
@@ -61,7 +61,7 @@
<v-btn class="button primary" @click="save()">Ukončiť mastertask</v-btn>
</div>
<A-tasks-table :tasks="mastertask.subtasks" :employees="enrichedEmployees" />
<A-tasks-table :subtasks="mastertask.subtasks" />
<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>
@@ -125,8 +125,7 @@ export default {
computed: {
...mapGetters('tm', [
'teams',
'projects',
'enrichedEmployees'
'projects'
])
},
@@ -147,7 +146,7 @@ export default {
if (mastertask?.id == this.mastertask?.id) this.closeModal()
})
this.$events.on('on-task-deleted', (task) => {
this.$events.on('on-subtask-deleted', (task) => {
if (!this.mastertask) return
this.mastertask.subtasks = this.mastertask.subtasks.filter((subtask) => subtask.id != task.id)
})
@@ -165,15 +164,15 @@ export default {
beforeUnmount() {
this.$events.off('on-mastertask-deleted')
this.$events.off('on-task-deleted')
this.$events.off('on-subtask-deleted')
this.$events.off('on-subtask-edited')
},
methods: {
async showModal(mastertask, editMode = false) {
this.v$.$reset()
async showModal({mastertask, editMode = false}) {
this.visible = true
this.mastertask = null
this.$nextTick(() => this.v$.$reset())
try {
if (mastertask?.id) {
@@ -234,7 +233,7 @@ export default {
},
addTask() {
this.$events.emit('show-task-modal', { task: null, editMode: false, mastertask: this.mastertask })
this.$events.emit('show-subtask-modal', { subtask: null, editMode: false, mastertask: this.mastertask })
}
},