mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 22:39:34 +00:00
[Refactoring]
This commit is contained in:
1 parent
26138f69b3
commit
ca1cbd723a
25 files changed
+215
-206
No files matched your search
@@ -42,7 +42,7 @@ export default {
|
||||
methods: {
|
||||
openMastertask() {
|
||||
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>
|
||||
</div>
|
||||
|
||||
<template v-if="task.timesheets.length">
|
||||
<div v-for="timesheet in task.timesheets" :key="timesheet.id" class="d-flex align-center mb-3">
|
||||
<template v-if="subtask.timesheets.length">
|
||||
<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" />
|
||||
|
||||
<div class="d-flex align-center flex-start width-100">
|
||||
@@ -61,7 +61,7 @@ export default {
|
||||
required: true
|
||||
},
|
||||
|
||||
task: {
|
||||
subtask: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
@@ -91,22 +91,22 @@ export default {
|
||||
if (!await this.v$.$validate())
|
||||
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,
|
||||
employee_id: task.employee_id,
|
||||
employee_id: subtask.employee_id,
|
||||
time: typeof this.form.hours == 'string' ? parseInt(this.form.hours) : this.form.hours
|
||||
})
|
||||
|
||||
this._update(task)
|
||||
this._update(subtask)
|
||||
},
|
||||
|
||||
async deleteTimesheet({ id }) {
|
||||
const task = JSON.parse(JSON.stringify(this.task))
|
||||
task.timesheets = task.timesheets.filter(timesheet => timesheet.id != id)
|
||||
const subtask = JSON.parse(JSON.stringify(this.subtask))
|
||||
subtask.timesheets = subtask.timesheets.filter(timesheet => timesheet.id != id)
|
||||
|
||||
this._update(task)
|
||||
this._update(subtask)
|
||||
},
|
||||
|
||||
closeModal() {
|
||||
@@ -118,9 +118,9 @@ export default {
|
||||
this.$nextTick(() => this.v$.$reset())
|
||||
},
|
||||
|
||||
async _update(task) {
|
||||
async _update(data) {
|
||||
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.$events.emit('on-subtask-edited', subtask)
|
||||
|
||||
@@ -62,7 +62,7 @@ export default {
|
||||
required: true
|
||||
},
|
||||
|
||||
task: {
|
||||
subtask: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
@@ -97,32 +97,32 @@ export default {
|
||||
if (!await this.v$.$validate())
|
||||
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 splittedEndsAtTime = this.form.ends_at_time.split(':')
|
||||
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()
|
||||
|
||||
task.timeblocks.push({
|
||||
subtask.timeblocks.push({
|
||||
id: null,
|
||||
start: tmUtils.formatDateTimeForBackend(start),
|
||||
end: tmUtils.formatDateTimeForBackend(end)
|
||||
})
|
||||
|
||||
this._update(task)
|
||||
this._update(subtask)
|
||||
},
|
||||
|
||||
async deleteTimeblock({ id }) {
|
||||
const task = JSON.parse(JSON.stringify(this.task))
|
||||
task.timeblocks = task.timeblocks.filter(timeblock => timeblock.id != id)
|
||||
const subtask = JSON.parse(JSON.stringify(this.subtask))
|
||||
subtask.timeblocks = subtask.timeblocks.filter(timeblock => timeblock.id != id)
|
||||
|
||||
this._update(task)
|
||||
this._update(subtask)
|
||||
},
|
||||
|
||||
async _update(task) {
|
||||
async _update(data) {
|
||||
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.$events.emit('on-subtask-edited', subtask)
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
<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-status :status="task.is_finished" />
|
||||
<A-task-timeblocks :timeblocks="task.timeblocks" :task="task" />
|
||||
<Z-created-by :employee-id="task.created_by" />
|
||||
<A-task-assigned-employee :employee="task.employee" />
|
||||
<A-task-planned-time :hours="task.duration" />
|
||||
<A-task-remaining-time :hours="task.duration - task.spent_time" />
|
||||
<A-task-spent-time :hours="task.spent_time" :task="task" />
|
||||
<A-task-description :description="task.description" :mastertask-description="task.master_task_description" />
|
||||
<Z-files :files="task.files" />
|
||||
<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="subtask.is_finished" />
|
||||
<A-task-timeblocks :timeblocks="subtask.timeblocks" :subtask="subtask" />
|
||||
<Z-created-by :employee-id="subtask.created_by" />
|
||||
<A-task-assigned-employee :employee="subtask.employee" />
|
||||
<A-task-planned-time :hours="subtask.duration" />
|
||||
<A-task-remaining-time :hours="subtask.duration - subtask.spent_time" />
|
||||
<A-task-spent-time :hours="subtask.spent_time" :subtask="subtask" />
|
||||
<A-task-description :description="subtask.description" :mastertask-description="subtask.master_task_description" />
|
||||
<Z-files :files="subtask.files" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
@@ -40,7 +40,7 @@ export default {
|
||||
},
|
||||
|
||||
props: {
|
||||
task: {
|
||||
subtask: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user