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

This commit is contained in:
StudioTem committed 2023-02-16 08:18:30 +01:00
commit 3fcf191cef
11 files changed
+36 -23

No files matched your search

@@ -38,7 +38,8 @@ export default {
methods: { methods: {
async submit() { async submit() {
if (!(await this.v$.$validate())) return console.log(this.v$) if (!(await this.v$.$validate()))
return
try { try {
await this.$store.dispatch('auth/login', this.form) await this.$store.dispatch('auth/login', this.form)
+13 -1
View File
@@ -56,10 +56,22 @@ export default {
state.teams = state.teams.filter(t => t.id != team.id) state.teams = state.teams.filter(t => t.id != team.id)
}, },
update_subtask(state: any, subtask: any) {
state.unscheduledSubtasks = state.unscheduledSubtasks.map(st => st.id == subtask.id ? subtask : st)
state.ongoingSubtasks = state.ongoingSubtasks.map(st => st.id == subtask.id ? subtask : st)
state.mastertasks = state.mastertasks.map(mastertask => {
mastertask.subtasks = mastertask.subtasks.map(st => st.id == subtask.id ? subtask : st)
return mastertask
})
},
delete_subtask(state: any, subtask: any) { delete_subtask(state: any, subtask: any) {
state.unscheduledSubtasks = state.unscheduledSubtasks.filter(st => st.id != subtask.id) state.unscheduledSubtasks = state.unscheduledSubtasks.filter(st => st.id != subtask.id)
state.ongoingSubtasks = state.ongoingSubtasks.filter(st => st.id != subtask.id) state.ongoingSubtasks = state.ongoingSubtasks.filter(st => st.id != subtask.id)
state.mastertasks = state.mastertasks.map(mastertask => mastertask.subtasks.filter(st => st.id != subtask.id)) state.mastertasks = state.mastertasks.map(mastertask => {
mastertask.subtasks = mastertask.subtasks.filter(st => st.id != subtask.id)
return mastertask
})
}, },
initialized(state: any) { initialized(state: any) {
@@ -4,7 +4,7 @@
v-model="selectedEmployee" v-model="selectedEmployee"
class="subheader-input" class="subheader-input"
:items="[null, ...employees]" :items="[null, ...employees]"
item-title="fullName" item-title="_fullName"
item-value="id" item-value="id"
label="Zamestnanec" label="Zamestnanec"
variant="outlined" variant="outlined"
@@ -77,7 +77,7 @@ export default {
async _getEmployees() { async _getEmployees() {
this.employees = await this.$axios.get_auth_data('v1/employees') this.employees = await this.$axios.get_auth_data('v1/employees')
this.employees.forEach(employee => { this.employees.forEach(employee => {
employee.fullName = `${employee.name} ${employee.surname}` employee._fullName = `${employee.name} ${employee.surname}`
if (employee.id == this.user.id) this.selectedEmployee = employee if (employee.id == this.user.id) this.selectedEmployee = employee
}) })
}, },
@@ -25,9 +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.name = mastertask.name this.task.master_task = mastertask
this.task.master_task.id = mastertask.id this.task.project_code = mastertask.project_code
this.task.project_code = mastertask.project_code
}, },
onEmployeeSelected({ key }) { onEmployeeSelected({ key }) {
@@ -142,6 +142,7 @@ export default {
}) })
this.$events.on('on-task-deleted', (task) => { this.$events.on('on-task-deleted', (task) => {
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)
}) })
@@ -116,8 +116,6 @@ export default {
async deleteTimeblock({ id }) { async deleteTimeblock({ id }) {
const task = JSON.parse(JSON.stringify(this.task)) const task = JSON.parse(JSON.stringify(this.task))
task.timeblocks = task.timeblocks.filter(timeblock => timeblock.id != id) task.timeblocks = task.timeblocks.filter(timeblock => timeblock.id != id)
console.log(task.timeblocks)
console.log(id)
this._update(task) this._update(task)
}, },
@@ -43,9 +43,9 @@ export default {
async deleteTask() { async deleteTask() {
try { try {
await this.$axios.delete(`v1/subtasks/${this.task.id}`) await this.$axios.delete(`v1/subtasks/${this.task.id}`)
// this.$emit('on-task-deleted', this.task)
this.$store.commit('tm/delete_subtask', this.task) this.$store.commit('tm/delete_subtask', this.task)
this.$emit('on-task-deleted', this.task)
this.closeModal() this.closeModal()
} catch (error) { } catch (error) {
this.$toast.error(error) this.$toast.error(error)
+11 -9
View File
@@ -69,6 +69,7 @@ import ZAutocomplete from "@/plugins/tm@_components/z-autocomplete.vue"
import ZTaskReadonlyInfo from "./_components/z-task-readonly-info.vue" import ZTaskReadonlyInfo from "./_components/z-task-readonly-info.vue"
import { mapGetters } from "vuex" import { mapGetters } from "vuex"
import moment from "moment"
export default { export default {
emits: ["close", "refresh"], emits: ["close", "refresh"],
@@ -132,7 +133,7 @@ export default {
this.$forceUpdate() this.$forceUpdate()
}) })
this.$events.on("on-task-deleted", (task) => { this.$events.on('on-task-deleted', (task) => {
if (task?.id == this.task?.id) this.closeModal() if (task?.id == this.task?.id) this.closeModal()
}) })
}, },
@@ -144,12 +145,11 @@ export default {
this.$nextTick(() => this.v$.$reset()) this.$nextTick(() => this.v$.$reset())
try { try {
if (task?.id) { if (task?.id) {
const fetchedTask = await this.$axios.get_auth_data(`v1/subtasks/${task.id}`) const subtask = await this.$axios.get_auth_data(`v1/subtasks/${task.id}`)
this.task = this._enrichTask(fetchedTask) this.task = this._enrichTask(subtask)
} else { } else {
this.task = { master_task: masterTask } this.task = { master_task: masterTask, timeblocks: [{start: tmUtils.formatDateTimeForBackend(moment()), end: tmUtils.formatDateTimeForBackend(moment())}] }
this.masterTaskIdSelect = masterTask.id this.masterTaskIdSelect = masterTask.id
} }
@@ -164,17 +164,19 @@ export default {
}, },
async save() { async save() {
if (!(await this.v$.$validate())) return console.log(this.v$) if (!(await this.v$.$validate()))
return
this.task.description = this.$refs["description"].getHTML() this.task.description = this.$refs["description"].getHTML()
try { try {
if (this.task?.id) { if (this.task?.id) {
await this.$axios.put_auth_data(`v1/subtasks/${this.task.id}`, this.task) const { subtask } = await this.$axios.put_auth(`v1/subtasks/${this.task.id}`, this.task)
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.task.master_task.id}/subtasks`, this.task)
console.log(subtask)
this.task.id = subtask.id this.task.id = subtask.id
this.$store.commit('tm/update_subtask', subtask)
} }
this.$events.emit("on-task-edited", this.task) this.$events.emit("on-task-edited", this.task)
@@ -219,7 +221,7 @@ export default {
_enrichTask(task) { _enrichTask(task) {
task.master_task = this.mastertasks.find((masterTask) => masterTask.id == task.master_task_id) task.master_task = this.mastertasks.find((masterTask) => masterTask.id == task.master_task_id)
task.employee = this.enrichedEmployees.find((employee) => employee.id == task.employee_id) task.employee = this.enrichedEmployees.find((employee) => employee.id == task.employee_id)
this.masterTaskIdSelect = task.master_task.id this.masterTaskIdSelect = task.master_task?.id
return task return task
} }
@@ -26,7 +26,7 @@
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
export default { export default {
emits: ['seach', 'employee-selected'], emits: ['search', 'employee-selected'],
data() { data() {
return { return {
@@ -45,7 +45,7 @@ export default {
methods: { methods: {
onInput() { onInput() {
this.$emit('query-changed', this.searchQuery) this.$emit('search', this.searchQuery)
} }
}, },
@@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<Z-tasks-search @seach="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 :tasks="filteredOngoingTasks" />
@@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<Z-tasks-search @seach="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 :tasks="filteredUnscheduledTasks" />