mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
[Master task, sub task] API
This commit is contained in:
1 parent
4429e3e566
commit
6e8f57d06d
11 files changed
+188
-111
No files matched your search
@@ -34,6 +34,7 @@
|
||||
@focus="onInputFocus"
|
||||
class="modal-input border-select"
|
||||
label="Priradený"
|
||||
:class="{ error: v$.task.employee_id.$errors.length }"
|
||||
variant="solo"
|
||||
:items="employees"
|
||||
item-value="id"
|
||||
@@ -181,9 +182,9 @@
|
||||
<v-sheet class="ma-2">
|
||||
<div v-for="(date, index) in task.timeblocks" :key="date.id">
|
||||
<div class="d-flex align-center m-5">
|
||||
<v-icon
|
||||
<v-icon
|
||||
@click.stop="removeDate(index)"
|
||||
class="remove-date cursor-pointer mr-2" icon="mdi-minus" size="medium"
|
||||
class="remove-date cursor-pointer mr-2" icon="mdi-minus" size="medium"
|
||||
/>
|
||||
<p
|
||||
class="task-badge px-4 py-2 rounded-pill mt-2"
|
||||
@@ -193,9 +194,9 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<v-icon
|
||||
<v-icon
|
||||
@click="showDatePicker = true"
|
||||
class="add-date cursor-pointer mt-5" icon="mdi-plus" size="medium"
|
||||
class="add-date cursor-pointer mt-5" icon="mdi-plus" size="medium"
|
||||
/>
|
||||
<v-dialog max-width="650" v-model="showDatePicker">
|
||||
<v-card>
|
||||
@@ -413,9 +414,9 @@ export default {
|
||||
return {
|
||||
task: {
|
||||
date: { required },
|
||||
// team: { required },
|
||||
// team_id: { required },
|
||||
duration: { required },
|
||||
employee: { required },
|
||||
employee_id: { required },
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -427,21 +428,28 @@ export default {
|
||||
},
|
||||
|
||||
methods: {
|
||||
async showModal(task, editMode = false) {
|
||||
this.visible = true
|
||||
this.task = null
|
||||
async showModal(task, editMode = false, masterTask = null) {
|
||||
this.v$.$reset()
|
||||
this.visible = true
|
||||
this.task = null
|
||||
this.employeeIdSelect = null
|
||||
this.masterTaskIdSelect = null
|
||||
|
||||
try {
|
||||
this.masterTasks = await this.$axios.get_auth_data('v1/mastertasks')
|
||||
if (task?.id) {
|
||||
const t = await this.$axios.get_auth_data(`v1/subtasks/${task.id}`)
|
||||
|
||||
this.employeeIdSelect = t.employee.id
|
||||
this.masterTaskIdSelect = t.master_task.id
|
||||
this.task = t
|
||||
this.task.spent_time = ((t.spent_time) / 3600000).toFixed(2)
|
||||
if (task?.id) {
|
||||
const t = await this.$axios.get_auth_data(`v1/subtasks/${task.id}`)
|
||||
t.master_task = this.masterTasks.find(mt => mt.id == t.master_task_id)
|
||||
t.employee = t.master_task.employees.find(e => t.employee_id == e.id)
|
||||
|
||||
this.employeeIdSelect = t.employee.id
|
||||
this.masterTaskIdSelect = t.master_task.id
|
||||
this.task = t
|
||||
this.task.spent_time = ((t.spent_time) / 3600000).toFixed(2)
|
||||
} else {
|
||||
this.task = {master_task: {}}
|
||||
this.task = {master_task: masterTask}
|
||||
this.masterTaskIdSelect = masterTask ? masterTask.id : null
|
||||
}
|
||||
|
||||
this.editMode = (editMode || !this.task.id)
|
||||
@@ -455,14 +463,15 @@ export default {
|
||||
},
|
||||
|
||||
async save() {
|
||||
if (!(await this.v$.$validate())) return console.log(this.v$)
|
||||
if (!(await this.v$.$validate()))
|
||||
return
|
||||
|
||||
try {
|
||||
if (this.task.id) {
|
||||
await this.$axios.put_auth(`v1/mastertasks/${this.task.id}`, this.task)
|
||||
if (this.task?.id) {
|
||||
await this.$axios.put_auth(`v1/mastertasks/subtasks/${this.task.id}`, this.task)
|
||||
this.$events.emit('on-task-edited', this.task)
|
||||
} else {
|
||||
await this.$axios.post_auth('v1/subtasks', this.task)
|
||||
await this.$axios.post_auth(`v1/mastertasks/${this.task.master_task.id}/subtasks`, this.task)
|
||||
}
|
||||
|
||||
this.closeModal()
|
||||
@@ -509,7 +518,8 @@ export default {
|
||||
employeeIdSelect(value) {
|
||||
if (!value || !this.task) return
|
||||
|
||||
this.task.employee = this.task.master_task.employees.find(employee => employee.id == value)
|
||||
this.task.employee = this.task.master_task.employees.find(employee => employee.id == value)
|
||||
this.task.employee_id = value
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user