Merge branch 'main' of bitbucket.org:studiotem/jandl-taskmanager-app

This commit is contained in:
StudioTem committed 2023-03-03 14:22:46 +01:00
commit 2e8dd25ab8
27 files changed
+235 -206

No files matched your search

+30 -23
View File
@@ -9,7 +9,7 @@
<Z-delete-team-modal ref="z-delete-team-modal" @update="onTeamUpdate" /> <Z-delete-team-modal ref="z-delete-team-modal" @update="onTeamUpdate" />
<Z-task-modal ref="z-task-modal" @on-subtask-edited="onTaskEdited" /> <Z-task-modal ref="z-task-modal" @on-subtask-edited="onTaskEdited" />
<Z-delete-task-modal ref="z-delete-task-modal" @on-task-deleted="onTaskDeleted" /> <Z-delete-task-modal ref="z-delete-task-modal" @on-subtask-deleted="onTaskDeleted" />
<Z-delete-master-task-modal ref="z-delete-master-task-modal" @on-mastertask-deleted="onMasterTaskDeleted" /> <Z-delete-master-task-modal ref="z-delete-master-task-modal" @on-mastertask-deleted="onMasterTaskDeleted" />
<Z-complete-task-modal ref="z-complete-task-modal" @on-subtask-edited="onTaskEdited" /> <Z-complete-task-modal ref="z-complete-task-modal" @on-subtask-edited="onTaskEdited" />
<Z-task-add-time-modal ref="z-task-add-time-modal" /> <Z-task-add-time-modal ref="z-task-add-time-modal" />
@@ -44,35 +44,35 @@ export default {
mounted() { mounted() {
this.$events.on('show-delete-team-modal', ({team}) => { this.$events.on('show-delete-team-modal', ({team}) => {
this.$refs['z-delete-team-modal'].showModal(team) this.$refs['z-delete-team-modal'].showModal({ team })
}) })
this.$events.on('show-team-modal', ({team}) => { this.$events.on('show-team-modal', ({ team }) => {
this.$refs['z-team-modal'].showModal(team) this.$refs['z-team-modal'].showModal({ team })
}) })
this.$events.on('show-delete-task-modal', ({task}) => { this.$events.on('show-delete-task-modal', ({subtask}) => {
this.$refs['z-delete-task-modal'].showModal(task) this.$refs['z-delete-task-modal'].showModal({subtask})
}) })
this.$events.on('show-delete-master-task-modal', ({mastertask}) => { this.$events.on('show-delete-master-task-modal', ({mastertask}) => {
this.$refs['z-delete-master-task-modal'].showModal(mastertask) this.$refs['z-delete-master-task-modal'].showModal({mastertask})
}) })
this.$events.on('show-task-modal', ({task, editMode, mastertask}) => { this.$events.on('show-subtask-modal', ({subtask, editMode, mastertask}) => {
if(task && task.id) { if(subtask && subtask.id) {
const id = task.id const id = subtask.id
this.$router.push({ query: { 'task': id }}) this.$router.push({ query: { 'subtask': id }})
} }
this.$refs['z-task-modal'].showModal(task, editMode, mastertask) this.$refs['z-task-modal'].showModal({subtask, editMode, mastertask})
}) })
this.$events.on('show-master-task-modal', ({ mastertask, editMode }) => { this.$events.on('show-mastertask-modal', ({ mastertask, editMode }) => {
if (mastertask && mastertask.id) { if (mastertask && mastertask.id) {
const id = mastertask.id const id = mastertask.id
this.$router.push({ query: { 'master-task': id } }) this.$router.push({ query: { 'mastertask': id } })
} }
this.$refs['z-master-task-modal'].showModal(mastertask, editMode) this.$refs['z-master-task-modal'].showModal({mastertask, editMode})
}) })
this.$events.on('show-complete-task-modal', ({ subtask }) => { this.$events.on('show-complete-task-modal', ({ subtask }) => {
@@ -98,6 +98,8 @@ export default {
this.$events.on('on-mastertask-deleted', () => { this.$events.on('on-mastertask-deleted', () => {
this.$store.dispatch('tm/reloadMastertasks') this.$store.dispatch('tm/reloadMastertasks')
}) })
this._showModalsAfterInicialization()
}, },
methods: { methods: {
@@ -106,7 +108,7 @@ export default {
}, },
onTaskDeleted(task) { onTaskDeleted(task) {
this.$events.emit('on-task-deleted', task) this.$events.emit('on-subtask-deleted', task)
}, },
onTaskEdited(task) { onTaskEdited(task) {
@@ -119,14 +121,19 @@ export default {
onMasterTaskEdited(mastertask){ onMasterTaskEdited(mastertask){
this.$events.emit('on-mastertask-edited', mastertask) this.$events.emit('on-mastertask-edited', mastertask)
} },
},
watch: { _showModalsAfterInicialization(repeat = 0) {
'$route'() { setTimeout(() => {
// if (this.$route.query['master-task']) { if (repeat > 50)
// this.$events.emit('show-master-task-modal', { mastertask: { id: this.$route.query['master-task'] }, editMode: false }) return this.$router.push({name: this.$route.name})
// } else if (!this.$store.getters['tm/isInitialized'])
return this._showModalsAfterInicialization(repeat + 1)
else if (this.$route.query['mastertask'])
return this.$events.emit('show-mastertask-modal', { mastertask: { id: this.$route.query['mastertask'] }, editMode: false })
else if (this.$route.query['subtask'])
return this.$events.emit('show-subtask-modal', { subtask: { id: this.$route.query['subtask'] }, editMode: false })
}, 300)
} }
} }
} }
@@ -79,11 +79,11 @@ export default {
}, },
createMasterTask() { createMasterTask() {
this.$events.emit('show-master-task-modal', {}) this.$events.emit('show-mastertask-modal', {})
}, },
createTask() { createTask() {
this.$events.emit('show-task-modal', {}) this.$events.emit('show-subtask-modal', {})
}, },
createTeam() { createTeam() {
@@ -24,7 +24,7 @@ export default {
v$: useVuelidate(), v$: useVuelidate(),
form: {}, form: {},
// form: { // form: {
// email: 'zachariah.vonrueden@jandl.sk', // email: 'jan.fajnor@jandl.sk',
// password: 'testpassword' // password: 'testpassword'
// }, // },
showPassword: false showPassword: false
@@ -3,13 +3,13 @@
<h1 class="px-3 py-3">Tasks</h1> <h1 class="px-3 py-3">Tasks</h1>
<v-table> <v-table>
<tbody> <tbody>
<tr v-for="task in tasks" :key="task.id"> <tr v-for="subtask in subtasks" :key="subtask.id">
<td>{{ task.project_code }}</td> <td>{{ subtask.project_code }}</td>
<td>{{ task.title }}</td> <td>{{ subtask.title }}</td>
<td> <td>
<p>{{ task.user.name + task.user.surname }}</p> <p>{{ subtask.user.name + subtask.user.surname }}</p>
<p class="employee-avatar d-flex justify-center align-center"> <p class="employee-avatar d-flex justify-center align-center">
{{ task.user.name.charAt(0) }} {{ subtask.user.name.charAt(0) }}
</p> </p>
</td> </td>
<td class="task-action"> <td class="task-action">
@@ -29,7 +29,7 @@
export default { export default {
props: { props: {
tasks: { subtasks: {
type: Array, type: Array,
required: true required: true
} }
+1 -1
View File
@@ -1,7 +1,7 @@
<template> <template>
<form> <form>
<A-search-result-team v-if="searchResults?.teams" :teams="searchResults.teams" /> <A-search-result-team v-if="searchResults?.teams" :teams="searchResults.teams" />
<A-search-result-tasks v-if="searchResults?.tasks" :tasks="searchResults.tasks" /> <A-search-result-tasks v-if="searchResults?.tasks" :subtasks="searchResults.tasks" />
</form> </form>
</template> </template>
@@ -195,10 +195,10 @@ export default {
return event.end.getTime() - event.start.getTime() return event.end.getTime() - event.start.getTime()
}, },
taskClicked(task) { taskClicked(subtask) {
if (task.nonWorking) return if (subtask.nonWorking) return
// console.log("task", task) // console.log("task", task)
if (task.end.getTime() - task.start.getTime() <= 3600000) { if (subtask.end.getTime() - subtask.start.getTime() <= 3600000) {
// console.log("ShortTask") // console.log("ShortTask")
} }
}, },
@@ -212,12 +212,12 @@ export default {
this.$events.emit('show-complete-task-modal', { subtask }) this.$events.emit('show-complete-task-modal', { subtask })
}, },
editTask(task, editMode) { editTask(subtask, editMode) {
this.$events.emit('show-task-modal', {task, editMode}) this.$events.emit('show-subtask-modal', {subtask, editMode})
}, },
deleteTask(task) { deleteTask(subtask) {
this.$events.emit('show-delete-task-modal', {task}) this.$events.emit('show-delete-task-modal', {subtask})
} }
} }
} }
@@ -81,7 +81,7 @@ export default {
openMasterTaskModal(mastertaskId) { openMasterTaskModal(mastertaskId) {
const mastertask = this.mastertasks.find(mastertask => mastertask.id == mastertaskId) const mastertask = this.mastertasks.find(mastertask => mastertask.id == mastertaskId)
this.$events.emit('show-master-task-modal', {mastertask, editMode: false}) this.$events.emit('show-mastertask-modal', {mastertask, editMode: false})
} }
} }
} }
@@ -82,10 +82,15 @@ export default {
this.$events.on('on-subtask-edited', () => { this.$events.on('on-subtask-edited', () => {
this.onFilterChanged(this.filter) this.onFilterChanged(this.filter)
}) })
this.$events.on('on-subtask-deleted', () => {
this.onFilterChanged(this.filter)
})
}, },
unmounted() { unmounted() {
this.$events.off('on-subtask-edited') this.$events.off('on-subtask-edited')
this.$events.off('on-subtask-deleted')
}, },
methods: { methods: {
@@ -74,6 +74,21 @@ export default {
} }
}, },
mounted() {
this.$events.on('on-subtask-edited', () => {
this.onFilterChanged(this.filter)
})
this.$events.on('on-subtask-deleted', () => {
this.onFilterChanged(this.filter)
})
},
unmounted() {
this.$events.off('on-subtask-edited')
this.$events.off('on-subtask-deleted')
},
methods: { methods: {
_generateTasks() { _generateTasks() {
const tasks = [] const tasks = []
@@ -133,9 +133,10 @@ export default {
}, },
methods: { methods: {
async showModal(blocker = null) { async showModal({ blocker }) {
this.visible = true this.visible = true
this.blocker = null this.blocker = null
this.$nextTick(() => this.v$.$reset())
try { try {
const employees = await this.$axios.get_auth_data('v1/employees') const employees = await this.$axios.get_auth_data('v1/employees')
@@ -1,24 +1,24 @@
<template> <template>
<v-table class="mt-7 mb-5"> <v-table class="mt-7 mb-5">
<tbody class="px-5 py-5"> <tbody class="px-5 py-5">
<tr v-for="task in enrichedtasks" :key="task.id"> <tr v-for="subtask in enrichedtasks" :key="subtask.id">
<td class="w-25">{{ task.project_code }}</td> <td class="w-25">{{ subtask.project_code }}</td>
<td class="d-flex align-center"> <td class="d-flex align-center">
<p class="employee-selected-avatar d-flex justify-center align-center"> <p class="employee-selected-avatar d-flex justify-center align-center">
{{ task._employeeInitials }} {{ subtask._employeeInitials }}
</p> </p>
<p class="ml-2">{{ task._employeeFullName }}</p> <p class="ml-2">{{ subtask._employeeFullName }}</p>
</td> </td>
<td> <td>
<p class="text-light-green" v-if="task.is_finished">Ukončený</p> <p class="text-light-green" v-if="subtask.is_finished">Ukončený</p>
<p v-if="!task.is_finished">Neukončený</p> <p v-if="!subtask.is_finished">Neukončený</p>
</td> </td>
<td class="task-action"> <td class="task-action">
<div class="d-flex justify-start"> <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="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="!task.is_finished" class="pencil-icon" :src="require('@/plugins/app/_img/icons/checkmark.svg')" alt="checkmark-icon" @click.stop="clickCompleteTask(task)"> <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(task)"> <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(task)"> <img class="trash-icon" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="openDeleteTaskModal(subtask)">
</div> </div>
</td> </td>
</tr> </tr>
@@ -27,40 +27,39 @@
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'
export default { export default {
props: { props: {
tasks: { subtasks: {
type: Array, type: Array,
required: true required: true
}, },
employees: {
type: Array,
required: true
}
}, },
computed: { computed: {
...mapGetters('tm', ['enrichedEmployees']),
enrichedtasks() { enrichedtasks() {
return this.tasks.map(task => { return this.subtasks.map(subtask => {
const employee = this.employees.find(employee => employee.id == task.employee_id) const employee = this.enrichedEmployees.find(employee => employee.id == subtask.employee_id)
return { return {
...task, ...subtask,
_employeeInitials: employee.name.charAt(0) + employee.surname.charAt(0), _employeeInitials: employee._initials,
_employeeFullName: `${employee.name} ${employee.surname}` _employeeFullName: employee._fullName
} }
}) })
} }
}, },
methods: { methods: {
openDeleteTaskModal(task) { openDeleteTaskModal(subtask) {
this.$events.emit('show-delete-task-modal', { task }) this.$events.emit('show-delete-task-modal', { subtask })
}, },
openTaskModal(task) { openTaskModal(subtask) {
this.$events.emit('show-task-modal', { task, editMode: false }) this.$events.emit('show-subtask-modal', { subtask, editMode: false })
}, },
async clickCompleteTask(subtask) { async clickCompleteTask(subtask) {
@@ -25,8 +25,8 @@ export default {
onMasterTaskSelected({ key }) { 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.subtask.master_task = mastertask
this.task.project_code = mastertask.project_code this.subtask.project_code = mastertask.project_code
}, },
onEmployeeSelected({ key }) { onEmployeeSelected({ key }) {
@@ -31,7 +31,7 @@ export default {
}, },
methods: { methods: {
async showModal(mastertask) { async showModal({ mastertask }) {
this.mastertask = mastertask this.mastertask = mastertask
this.visible = true this.visible = true
}, },
@@ -61,7 +61,7 @@
<v-btn class="button primary" @click="save()">Ukončiť mastertask</v-btn> <v-btn class="button primary" @click="save()">Ukončiť mastertask</v-btn>
</div> </div>
<A-tasks-table :tasks="mastertask.subtasks" :employees="enrichedEmployees" /> <A-tasks-table :subtasks="mastertask.subtasks" />
<div class="d-flex align-center "> <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> <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: { computed: {
...mapGetters('tm', [ ...mapGetters('tm', [
'teams', 'teams',
'projects', 'projects'
'enrichedEmployees'
]) ])
}, },
@@ -147,7 +146,7 @@ export default {
if (mastertask?.id == this.mastertask?.id) this.closeModal() 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 if (!this.mastertask) return
this.mastertask.subtasks = this.mastertask.subtasks.filter((subtask) => subtask.id != task.id) this.mastertask.subtasks = this.mastertask.subtasks.filter((subtask) => subtask.id != task.id)
}) })
@@ -165,15 +164,15 @@ export default {
beforeUnmount() { beforeUnmount() {
this.$events.off('on-mastertask-deleted') this.$events.off('on-mastertask-deleted')
this.$events.off('on-task-deleted') this.$events.off('on-subtask-deleted')
this.$events.off('on-subtask-edited') this.$events.off('on-subtask-edited')
}, },
methods: { methods: {
async showModal(mastertask, editMode = false) { async showModal({mastertask, editMode = false}) {
this.v$.$reset()
this.visible = true this.visible = true
this.mastertask = null this.mastertask = null
this.$nextTick(() => this.v$.$reset())
try { try {
if (mastertask?.id) { if (mastertask?.id) {
@@ -234,7 +233,7 @@ export default {
}, },
addTask() { 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 })
} }
}, },
@@ -42,7 +42,7 @@ export default {
methods: { methods: {
openMastertask() { openMastertask() {
this.$emit('close-modal') this.$emit('close-modal')
this.$events.emit('show-master-task-modal', {mastertask: {id: this.id}, editMode: false}) this.$events.emit('show-mastertask-modal', {mastertask: {id: this.id}, editMode: false})
} }
} }
} }
@@ -20,8 +20,8 @@
<p class="task-badge rounded-pill">Pridať záznam</p> <p class="task-badge rounded-pill">Pridať záznam</p>
</div> </div>
<template v-if="task.timesheets.length"> <template v-if="subtask.timesheets.length">
<div v-for="timesheet in task.timesheets" :key="timesheet.id" class="d-flex align-center mb-3"> <div v-for="timesheet in subtask.timesheets" :key="timesheet.id" class="d-flex align-center mb-3">
<v-icon @click.stop="deleteTimesheet(timesheet)" class="remove-date cursor-pointer mr-2" icon="mdi-minus" size="medium" /> <v-icon @click.stop="deleteTimesheet(timesheet)" class="remove-date cursor-pointer mr-2" icon="mdi-minus" size="medium" />
<div class="d-flex align-center flex-start width-100"> <div class="d-flex align-center flex-start width-100">
@@ -61,7 +61,7 @@ export default {
required: true required: true
}, },
task: { subtask: {
type: Object, type: Object,
required: true required: true
} }
@@ -91,22 +91,22 @@ export default {
if (!await this.v$.$validate()) if (!await this.v$.$validate())
return return
const task = JSON.parse(JSON.stringify(this.task)) const subtask = JSON.parse(JSON.stringify(this.subtask))
task.timesheets.push({ subtask.timesheets.push({
id: null, id: null,
employee_id: task.employee_id, employee_id: subtask.employee_id,
time: typeof this.form.hours == 'string' ? parseInt(this.form.hours) : this.form.hours time: typeof this.form.hours == 'string' ? parseInt(this.form.hours) : this.form.hours
}) })
this._update(task) this._update(subtask)
}, },
async deleteTimesheet({ id }) { async deleteTimesheet({ id }) {
const task = JSON.parse(JSON.stringify(this.task)) const subtask = JSON.parse(JSON.stringify(this.subtask))
task.timesheets = task.timesheets.filter(timesheet => timesheet.id != id) subtask.timesheets = subtask.timesheets.filter(timesheet => timesheet.id != id)
this._update(task) this._update(subtask)
}, },
closeModal() { closeModal() {
@@ -118,9 +118,9 @@ export default {
this.$nextTick(() => this.v$.$reset()) this.$nextTick(() => this.v$.$reset())
}, },
async _update(task) { async _update(data) {
try { try {
const { subtask } = await this.$axios.put_auth(`v1/subtasks/${task.id}`, task) const { subtask } = await this.$axios.put_auth(`v1/subtasks/${data.id}`, data)
this.closeModal() this.closeModal()
this.$events.emit('on-subtask-edited', subtask) this.$events.emit('on-subtask-edited', subtask)
@@ -62,7 +62,7 @@ export default {
required: true required: true
}, },
task: { subtask: {
type: Object, type: Object,
required: true required: true
} }
@@ -97,32 +97,32 @@ export default {
if (!await this.v$.$validate()) if (!await this.v$.$validate())
return return
const task = JSON.parse(JSON.stringify(this.task)) const subtask = JSON.parse(JSON.stringify(this.subtask))
const splittedStartsAtTime = this.form.starts_at_time.split(':') const splittedStartsAtTime = this.form.starts_at_time.split(':')
const splittedEndsAtTime = this.form.ends_at_time.split(':') const splittedEndsAtTime = this.form.ends_at_time.split(':')
const start = moment(this.form.date).hours(parseInt(splittedStartsAtTime[0])).minutes(parseInt(splittedStartsAtTime[1])).toISOString() const start = moment(this.form.date).hours(parseInt(splittedStartsAtTime[0])).minutes(parseInt(splittedStartsAtTime[1])).toISOString()
const end = moment(this.form.date).hours(parseInt(splittedEndsAtTime[0])).minutes(parseInt(splittedEndsAtTime[1])).toISOString() const end = moment(this.form.date).hours(parseInt(splittedEndsAtTime[0])).minutes(parseInt(splittedEndsAtTime[1])).toISOString()
task.timeblocks.push({ subtask.timeblocks.push({
id: null, id: null,
start: tmUtils.formatDateTimeForBackend(start), start: tmUtils.formatDateTimeForBackend(start),
end: tmUtils.formatDateTimeForBackend(end) end: tmUtils.formatDateTimeForBackend(end)
}) })
this._update(task) this._update(subtask)
}, },
async deleteTimeblock({ id }) { async deleteTimeblock({ id }) {
const task = JSON.parse(JSON.stringify(this.task)) const subtask = JSON.parse(JSON.stringify(this.subtask))
task.timeblocks = task.timeblocks.filter(timeblock => timeblock.id != id) subtask.timeblocks = subtask.timeblocks.filter(timeblock => timeblock.id != id)
this._update(task) this._update(subtask)
}, },
async _update(task) { async _update(data) {
try { try {
const { subtask } = await this.$axios.put_auth(`v1/subtasks/${task.id}`, task) const { subtask } = await this.$axios.put_auth(`v1/subtasks/${data.id}`, data)
this.closeModal() this.closeModal()
this.$events.emit('on-subtask-edited', subtask) this.$events.emit('on-subtask-edited', subtask)
@@ -1,14 +1,14 @@
<template> <template>
<A-mastertask-name :name="task.master_task?.name || task.master_task" :id="task.master_task.id" :color="task.master_task.color" @close-modal="$emit('close-modal')" /> <A-mastertask-name :name="subtask.master_task?.name || task.master_task" :id="subtask.master_task.id" :color="subtask.master_task.color" @close-modal="$emit('close-modal')" />
<A-mastertask-status :status="task.is_finished" /> <A-mastertask-status :status="subtask.is_finished" />
<A-task-timeblocks :timeblocks="task.timeblocks" :task="task" /> <A-task-timeblocks :timeblocks="subtask.timeblocks" :subtask="subtask" />
<Z-created-by :employee-id="task.created_by" /> <Z-created-by :employee-id="subtask.created_by" />
<A-task-assigned-employee :employee="task.employee" /> <A-task-assigned-employee :employee="subtask.employee" />
<A-task-planned-time :hours="task.duration" /> <A-task-planned-time :hours="subtask.duration" />
<A-task-remaining-time :hours="task.duration - task.spent_time" /> <A-task-remaining-time :hours="subtask.duration - subtask.spent_time" />
<A-task-spent-time :hours="task.spent_time" :task="task" /> <A-task-spent-time :hours="subtask.spent_time" :subtask="subtask" />
<A-task-description :description="task.description" :mastertask-description="task.master_task_description" /> <A-task-description :description="subtask.description" :mastertask-description="subtask.master_task_description" />
<Z-files :files="task.files" /> <Z-files :files="subtask.files" />
</template> </template>
<script> <script>
@@ -40,7 +40,7 @@ export default {
}, },
props: { props: {
task: { subtask: {
type: Object, type: Object,
required: true required: true
} }
@@ -2,7 +2,7 @@
<v-dialog v-model="visible" max-width="750"> <v-dialog v-model="visible" max-width="750">
<v-card> <v-card>
<div class="d-flex justify-space-between align-center"> <div class="d-flex justify-space-between align-center">
<h1>Ste si istý, že chcete zmazať task z mastertasku <b>{{ task.project_code }}</b>?</h1> <h1>Ste si istý, že chcete zmazať task z mastertasku <b>{{ subtask.project_code }}</b>?</h1>
<v-icon <v-icon
@click.stop="closeModal()" @click.stop="closeModal()"
@@ -21,18 +21,18 @@
<script> <script>
export default { export default {
emits: ['on-task-deleted'], emits: ['on-subtask-deleted'],
data() { data() {
return { return {
visible: false, visible: false,
task: null subtask: null
} }
}, },
methods: { methods: {
async showModal(task) { async showModal({ subtask }) {
this.task = task this.subtask = subtask
this.visible = true this.visible = true
}, },
@@ -42,10 +42,10 @@ export default {
async deleteTask() { async deleteTask() {
try { try {
await this.$axios.delete_auth(`v1/subtasks/${this.task.id}`) await this.$axios.delete_auth(`v1/subtasks/${this.subtask.id}`)
this.$store.commit('tm/delete_subtask', this.task) this.$store.commit('tm/delete_subtask', this.subtask)
this.$emit('on-task-deleted', this.task) this.$emit('on-subtask-deleted', this.subtask)
this.closeModal() this.closeModal()
} catch (error) { } catch (error) {
this.$toast.error(error) this.$toast.error(error)
@@ -46,6 +46,7 @@ export default {
async showModal({ subtask }) { async showModal({ subtask }) {
this.subtask = subtask this.subtask = subtask
this.visible = true this.visible = true
this.$nextTick(() => this.v$.$reset())
}, },
async submit() { async submit() {
+59 -58
View File
@@ -1,50 +1,50 @@
<template> <template>
<v-dialog v-model="visible" max-width="750" max-height="90%" height="700px"> <v-dialog v-model="visible" max-width="750" max-height="90%" height="700px">
<W-loadable :content="task" class="h-100"> <W-loadable :content="subtask" class="h-100">
<v-card v-if="editMode" height="100%" class="d-flex flex-column scrolling"> <v-card v-if="editMode" height="100%" class="d-flex flex-column scrolling">
<div class="d-flex justify-space-between align-center modal-header"> <div class="d-flex justify-space-between align-center modal-header">
<h1>{{ task.id ? "Upraviť task" : "Vytvoriť task" }}</h1> <h1>{{ subtask.id ? "Upraviť task" : "Vytvoriť task" }}</h1>
<v-icon @click.stop="closeModal()" icon="mdi-close" size="large"></v-icon> <v-icon @click.stop="closeModal()" icon="mdi-close" size="large"></v-icon>
</div> </div>
<v-card-actions class="d-flex flex-column modal-content"> <v-card-actions class="d-flex flex-column modal-content">
<v-text-field v-model="task.project_code" label="Kód projektu" :value="task.project_code" @focus="onInputFocus" class="modal-input" variant="solo" disabled></v-text-field> <v-text-field v-model="subtask.project_code" label="Kód projektu" :value="subtask.project_code" @focus="onInputFocus" class="modal-input" variant="solo" disabled></v-text-field>
<Z-autocomplete label="Master task" :options="mastertasks.map((mastertask) => ({ key: mastertask.id, value: mastertask.name }))" :validations="v$.task.master_task.id" :clear-on-submit="false" :value="task?.master_task?.name" :class="{ error: v$.task.master_task.id.$errors.length }" class="modal-input" @option-selected="onMasterTaskSelected" /> <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="task.employee_id" ref="employee-select" @focus="onInputFocus" class="modal-input border-select" label="Priradený" :class="{ error: v$.task.employee_id.$errors.length }" variant="solo" :items="filteredEmployees" item-value="id" item-title="_fullName"></v-select> <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>
<v-text-field v-model="task.duration" @focus="onInputFocus" class="modal-input" variant="solo" type="number" label="Časový odhad" :class="{ error: v$.task.duration.$errors.length }" :hint="v$.task.duration.$errors ? errorUtils.parseErrors(v$.task.duration.$errors) : null" append-inner-icon="mdi-clock-outline"></v-text-field> <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"> <div class="w-100 modal-input">
<QuillEditor ref="description" v-model="task.description" placeholder="Popis" theme="snow" class="rich-text-editor" @input="task.description = $event.srcElement.innerHTML" /> <QuillEditor ref="description" v-model="subtask.description" placeholder="Popis" theme="snow" class="rich-text-editor" @input="subtask.description = $event.srcElement.innerHTML" />
</div> </div>
<Z-files-upload class="mt-15 files" :files="task.files" @files-uploaded="filesUploaded" /> <Z-files-upload class="mt-15 files" :files="subtask.files" @files-uploaded="filesUploaded" />
</v-card-actions> </v-card-actions>
<v-btn class="button primary" @click="save()">{{ task.id ? "UPRAVIŤ" : "VYTVORIŤ" }}</v-btn> <v-btn class="button primary" @click="save()">{{ subtask.id ? "UPRAVIŤ" : "VYTVORIŤ" }}</v-btn>
</v-card> </v-card>
<v-card v-else height="100%" class="d-flex flex-column scrolling"> <v-card v-else height="100%" class="d-flex flex-column scrolling">
<div class="d-flex justify-space-between align-center"> <div class="d-flex justify-space-between align-center">
<p>{{ task.project_code }}</p> <p>{{ subtask.project_code }}</p>
<v-icon @click.stop="closeModal()" icon="mdi-close" size="large" class="pb-5"></v-icon> <v-icon @click.stop="closeModal()" icon="mdi-close" size="large" class="pb-5"></v-icon>
</div> </div>
<div class="d-flex justify-space-between align-center modal-header border-bottom pb-4"> <div class="d-flex justify-space-between align-center modal-header border-bottom pb-4">
<h1>{{ task.title }}</h1> <h1>{{ subtask.title }}</h1>
<div class="d-flex justify-start"> <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" :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="openDeleteTaskModal(task)" /> <img class="icon trash" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="openDeleteTaskModal(subtask)" />
</div> </div>
</div> </div>
<v-card-actions class="d-flex flex-column modal-content"> <v-card-actions class="d-flex flex-column modal-content">
<div class="w-100"> <div class="w-100">
<Z-task-readonly-info :task="task" @close-modal="closeModal" /> <Z-task-readonly-info :subtask="subtask" @close-modal="closeModal" />
<div class="d-flex justify-start align-center mt-8"> <div class="d-flex justify-start align-center mt-8">
<v-btn class="done-btn" v-if="!task.is_finished" @click.stop="showCompleteTaskModal()">Dokončiť</v-btn> <v-btn class="done-btn" v-if="!subtask.is_finished" @click.stop="showCompleteTaskModal()">Dokončiť</v-btn>
<v-btn class="button secondary" v-else @click.stop="showCompleteTaskModal()">Znovu otvoriť</v-btn> <v-btn class="button secondary" v-else @click.stop="showCompleteTaskModal()">Znovu otvoriť</v-btn>
<v-btn class="button secondary" @click="save()">Uložiť zmeny</v-btn> <v-btn class="button secondary" @click="save()">Uložiť zmeny</v-btn>
</div> </div>
@@ -88,7 +88,7 @@ export default {
tmUtils, tmUtils,
editMode: false, editMode: false,
visible: false, visible: false,
task: null, subtask: null,
errorUtils, errorUtils,
v$: useVuelidate(), v$: useVuelidate(),
preventInputFocus: false, preventInputFocus: false,
@@ -105,16 +105,16 @@ export default {
]), ]),
filteredEmployees() { filteredEmployees() {
if (!this.enrichedEmployees || !this.task?.master_task) return [] if (!this.enrichedEmployees || !this.subtask?.master_task) return []
const selectedEmployees = this.task.master_task.employees?.map((employee) => employee.id) || [] const selectedEmployees = this.subtask.master_task.employees?.map((employee) => employee.id) || []
return this.enrichedEmployees.filter((employee) => !selectedEmployees.includes(employee.id)) return this.enrichedEmployees.filter((employee) => !selectedEmployees.includes(employee.id))
} }
}, },
validations() { validations() {
return { return {
task: { subtask: {
master_task: { master_task: {
id: { required } id: { required }
}, },
@@ -125,35 +125,35 @@ export default {
}, },
mounted() { mounted() {
this.$events.on("on-subtask-edited", (task) => { this.$events.on("on-subtask-edited", (subtask) => {
if (task?.id == this.task?.id) if (subtask?.id == this.subtask?.id)
this.task = this._enrichTask(task) this.subtask = this._enrichTask(subtask)
// TODO: Remove? riesil som neodstranovanie jedineho zanamu v trvani a odpracovanom case // TODO: Remove? riesil som neodstranovanie jedineho zanamu v trvani a odpracovanom case
this.$forceUpdate() this.$forceUpdate()
}) })
this.$events.on('on-task-deleted', (task) => { this.$events.on('on-subtask-deleted', (subtask) => {
if (task?.id == this.task?.id) this.closeModal() if (subtask?.id == this.subtask?.id) this.closeModal()
}) })
}, },
methods: { methods: {
async showModal(task, editMode = false, mastertask = {}) { async showModal({subtask, editMode = false, mastertask = {}}) {
this.task = null this.subtask = null
this.visible = true this.visible = true
this.$nextTick(() => this.v$.$reset()) this.$nextTick(() => this.v$.$reset())
try { try {
if (task?.id) { if (subtask?.id) {
const subtask = await this.$axios.get_auth_data(`v1/subtasks/${task.id}`) const data = await this.$axios.get_auth_data(`v1/subtasks/${subtask.id}`)
this.task = this._enrichTask(subtask) this.subtask = this._enrichTask(data)
} else { } else {
this.task = { master_task: mastertask, timeblocks: [{start: tmUtils.formatDateTimeForBackend(moment()), end: tmUtils.formatDateTimeForBackend(moment())}] } this.subtask = { master_task: mastertask, timeblocks: [{start: tmUtils.formatDateTimeForBackend(moment()), end: tmUtils.formatDateTimeForBackend(moment())}] }
this.mastertaskIdSelect = mastertask.id this.mastertaskIdSelect = mastertask.id
} }
this.editMode = editMode || !this.task.id this.editMode = editMode || !this.subtask.id
} catch (error) { } catch (error) {
this.$toast.error(error) this.$toast.error(error)
} }
@@ -161,25 +161,26 @@ export default {
closeModal() { closeModal() {
this.visible = false this.visible = false
this.$router.replace({name: this.$route.name})
}, },
async save() { async save() {
if (!(await this.v$.$validate())) if (!(await this.v$.$validate()))
return return
this.task.description = this.$refs["description"].getHTML() this.subtask.description = this.$refs["description"].getHTML()
try { try {
if (this.task?.id) { if (this.subtask?.id) {
const { subtask } = await this.$axios.put_auth(`v1/subtasks/${this.task.id}`, this.task) const { subtask } = await this.$axios.put_auth(`v1/subtasks/${this.subtask.id}`, this.subtask)
this.$store.commit('tm/update_subtask', subtask) this.$store.commit('tm/update_subtask', subtask)
} else { } else {
const { subtask } = await this.$axios.post_auth(`v1/mastertasks/${this.task.master_task.id}/subtasks`, this.task) const { subtask } = await this.$axios.post_auth(`v1/mastertasks/${this.subtask.master_task.id}/subtasks`, this.subtask)
this.task.id = subtask.id this.subtask.id = subtask.id
this.$store.commit('tm/update_subtask', subtask) this.$store.commit('tm/update_subtask', subtask)
} }
this.$events.emit("on-subtask-edited", this.task) this.$events.emit("on-subtask-edited", this.subtask)
this.closeModal() this.closeModal()
} catch (error) { } catch (error) {
this.$toast.error(error) this.$toast.error(error)
@@ -188,7 +189,7 @@ export default {
async addNewDate() { async addNewDate() {
if (this.selectedNewDate) { if (this.selectedNewDate) {
this.task.timeblocks.push({ this.subtask.timeblocks.push({
start: this.selectedNewDate[0], start: this.selectedNewDate[0],
end: this.selectedNewDate[1] end: this.selectedNewDate[1]
}) })
@@ -199,7 +200,7 @@ export default {
async downloadFile(id) { async downloadFile(id) {
try { try {
const file = await this.$axios.get_auth_data(`v1/subtasks/${this.task.id}`, { responseType: "arraybuffer" }) const file = await this.$axios.get_auth_data(`v1/subtasks/${this.subtask.id}`, { responseType: "arraybuffer" })
FileSaver.saveAs(file.files[id].path, file.files[id].name) FileSaver.saveAs(file.files[id].path, file.files[id].name)
} catch (error) { } catch (error) {
this.$toast.error(error) this.$toast.error(error)
@@ -207,55 +208,55 @@ export default {
}, },
removeDate(index) { removeDate(index) {
this.task.timeblocks.splice(index, 1) this.subtask.timeblocks.splice(index, 1)
}, },
openDeleteTaskModal(task) { openDeleteTaskModal(subtask) {
this.$events.emit("show-delete-task-modal", { task }) this.$events.emit("show-delete-task-modal", { subtask })
}, },
showCompleteTaskModal() { showCompleteTaskModal() {
this.$events.emit('show-complete-task-modal', { subtask: this.task }) this.$events.emit('show-complete-task-modal', { subtask: this.subtask })
}, },
filesUploaded(files) { filesUploaded(files) {
this.task.files = files this.subtask.files = files
}, },
_enrichTask(task) { _enrichTask(subtask) {
task.master_task = this.mastertasks.find((mastertask) => mastertask.id == task.master_task_id) subtask.master_task = this.mastertasks.find((mastertask) => mastertask.id == subtask.master_task_id)
task.employee = this.enrichedEmployees.find((employee) => employee.id == task.employee_id) subtask.employee = this.enrichedEmployees.find((employee) => employee.id == subtask.employee_id)
task._created_by = this.enrichedEmployees.find((employee) => employee.id == task.created_by) subtask._created_by = this.enrichedEmployees.find((employee) => employee.id == subtask.created_by)
this.mastertaskIdSelect = task.master_task?.id this.mastertaskIdSelect = subtask.master_task?.id
return task return subtask
} }
}, },
watch: { watch: {
mastertaskIdSelect(value) { mastertaskIdSelect(value) {
if (!value || !this.task) return if (!value || !this.subtask) return
this.task.master_task = this.mastertasks.find((mastertask) => mastertask.id == value) this.subtask.master_task = this.mastertasks.find((mastertask) => mastertask.id == value)
this.task.project_code = this.task.master_task.project_code this.subtask.project_code = this.subtask.master_task.project_code
}, },
"task.employee_id"(value, oldValue) { "subtask.employee_id"(value, oldValue) {
if (!value) return if (!value) return
if (value && oldValue) if (value && oldValue)
this.task.timeblocks = [] this.subtask.timeblocks = []
this.task.employee = this.enrichedEmployees.find((employee) => employee.id == value) this.subtask.employee = this.enrichedEmployees.find((employee) => employee.id == value)
}, },
editMode() { editMode() {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs["description"]?.setHTML(this.task.description || "") this.$refs["description"]?.setHTML(this.subtask.description || "")
const employeeSelect = this.$refs['employee-select']?.$el?.querySelector('.v-select__selection-text') const employeeSelect = this.$refs['employee-select']?.$el?.querySelector('.v-select__selection-text')
if (employeeSelect) if (employeeSelect)
employeeSelect.innerHTML = this.task?.employee?._fullName || '' employeeSelect.innerHTML = this.subtask?.employee?._fullName || ''
}) })
} }
} }
@@ -28,7 +28,7 @@ export default {
}, },
methods: { methods: {
async showModal(team) { async showModal({team}) {
this.team = team this.team = team
this.visible = true this.visible = true
}, },
@@ -98,9 +98,10 @@ export default {
}, },
methods: { methods: {
async showModal(team = null) { async showModal({ team = null}) {
this.visible = true this.visible = true
this.team = null this.team = null
this.$nextTick(() => this.v$.$reset())
try { try {
const allEmployees = await this.$axios.get_auth_data('v1/employees') const allEmployees = await this.$axios.get_auth_data('v1/employees')
@@ -11,16 +11,16 @@
</thead> </thead>
<tbody> <tbody>
<tr class="cursor-pointer" v-for="task in tasks" :key="task.id" @click.stop="editTask(task, false)"> <tr class="cursor-pointer" v-for="subtask in subtasks" :key="subtask.id" @click.stop="editTask(subtask, false)">
<td>{{ task.project_code }}</td> <td>{{ subtask.project_code }}</td>
<td>{{ task.master_task?.name || task.master_task }}</td> <td>{{ subtask.master_task?.name || subtask.master_task }}</td>
<td>{{ task.duration }} h</td> <td>{{ subtask.duration }} h</td>
<td>{{ task.duration - task.spent_time }} h</td> <td>{{ subtask.duration - subtask.spent_time }} h</td>
<td class="task-action"> <td class="task-action">
<div class="d-flex justify-start"> <div class="d-flex justify-start">
<img class="pencil-icon mr-3" :src="require('@/plugins/app/_img/icons/eye.svg')" alt="pencil-icon" @click.stop="editTask(task, false)"> <img class="pencil-icon mr-3" :src="require('@/plugins/app/_img/icons/eye.svg')" alt="pencil-icon" @click.stop="editTask(subtask, false)">
<img class="pencil-icon" :src="require('@/plugins/app/_img/icons/pencil.svg')" alt="pencil-icon" @click.stop="editTask(task, true)" /> <img class="pencil-icon" :src="require('@/plugins/app/_img/icons/pencil.svg')" alt="pencil-icon" @click.stop="editTask(subtask, true)" />
<img class="trash-icon" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="deleteTask(task)" /> <img class="trash-icon" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="deleteTask(subtask)" />
</div> </div>
</td> </td>
</tr> </tr>
@@ -33,19 +33,19 @@
<script> <script>
export default { export default {
props: { props: {
tasks: { subtasks: {
type: Array, type: Array,
required: true required: true
} }
}, },
methods: { methods: {
editTask(task, editMode = false) { editTask(subtask, editMode = false) {
this.$events.emit('show-task-modal', {task, editMode}) this.$events.emit('show-subtask-modal', {subtask, editMode})
}, },
deleteTask(task) { deleteTask(subtask) {
this.$events.emit('show-delete-task-modal', {task}) this.$events.emit('show-delete-task-modal', {subtask})
} }
} }
} }
@@ -4,7 +4,7 @@
<Z-tasks-search @search="onSearch" @employee-selected="onEmployeeSelected" /> <Z-tasks-search @search="onSearch" @employee-selected="onEmployeeSelected" />
<W-loadable :content="filteredOngoingTasks" :emptyMessage="searchQuery.length ? 'Neboli nájdené žiadne úlohy' : 'Nenašli sa žiadne záznamy'"> <W-loadable :content="filteredOngoingTasks" :emptyMessage="searchQuery.length ? 'Neboli nájdené žiadne úlohy' : 'Nenašli sa žiadne záznamy'">
<A-ongoing-table :tasks="filteredOngoingTasks" /> <A-ongoing-table :subtasks="filteredOngoingTasks" />
</W-loadable> </W-loadable>
</div> </div>
@@ -10,16 +10,16 @@
</thead> </thead>
<tbody> <tbody>
<tr class="cursor-pointer" v-for="task in tasks" :key="task.id" @click.stop="editTask(task, false)"> <tr class="cursor-pointer" v-for="subtask in subtasks" :key="subtask.id" @click.stop="editTask(subtask, false)">
<td>{{ task.project_code }}</td> <td>{{ subtask.project_code }}</td>
<td>{{ task.master_task?.name || task.master_task }}</td> <td>{{ subtask.master_task?.name || subtask.master_task }}</td>
<td>{{ task.spent_time }} h</td> <td>{{ subtask.spent_time }} h</td>
<td class="task-action"> <td class="task-action">
<div class="d-flex justify-start"> <div class="d-flex justify-start">
<img class="pencil-icon mr-3" :src="require('@/plugins/app/_img/icons/eye.svg')" alt="pencil-icon" @click.stop="editTask(task, false)"> <img class="pencil-icon mr-3" :src="require('@/plugins/app/_img/icons/eye.svg')" alt="pencil-icon" @click.stop="editTask(subtask, false)">
<img class="pencil-icon" :src="require('@/plugins/app/_img/icons/pencil.svg')" alt="pencil-icon" @click.stop="editTask(task, true)"> <img class="pencil-icon" :src="require('@/plugins/app/_img/icons/pencil.svg')" alt="pencil-icon" @click.stop="editTask(subtask, true)">
<img class="trash-icon" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="deleteTask(task)"> <img class="trash-icon" :src="require('@/plugins/app/_img/icons/bin.svg')" alt="trash-icon" @click.stop="deleteTask(subtask)">
</div> </div>
</td> </td>
</tr> </tr>
@@ -30,19 +30,19 @@
<script> <script>
export default { export default {
props: { props: {
tasks: { subtasks: {
type: Array, type: Array,
required: true required: true
} }
}, },
methods: { methods: {
editTask(task, editMode) { editTask(subtask, editMode) {
this.$events.emit('show-task-modal', {task, editMode}) this.$events.emit('show-subtask-modal', {subtask, editMode})
}, },
deleteTask(task) { deleteTask(subtask) {
this.$events.emit('show-delete-task-modal', {task}) this.$events.emit('show-delete-task-modal', {subtask})
} }
} }
} }
@@ -4,7 +4,7 @@
<Z-tasks-search @search="onSearch" @employee-selected="onEmployeeSelected" /> <Z-tasks-search @search="onSearch" @employee-selected="onEmployeeSelected" />
<W-loadable :content="filteredUnscheduledTasks" :emptyMessage="searchQuery.length ? 'Neboli nájdené žiadne úlohy' : 'Nenašli sa žiadne záznamy'"> <W-loadable :content="filteredUnscheduledTasks" :emptyMessage="searchQuery.length ? 'Neboli nájdené žiadne úlohy' : 'Nenašli sa žiadne záznamy'">
<A-unscheduled-table :tasks="filteredUnscheduledTasks" /> <A-unscheduled-table :subtasks="filteredUnscheduledTasks" />
</W-loadable> </W-loadable>
</div> </div>