mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 06:20:21 +00:00
[Subtask] Possible to add multiple employees
This commit is contained in:
1 parent
2aec357f76
commit
e3373ef513
1 file changed
+23
-3
@@ -12,7 +12,15 @@
|
||||
|
||||
<v-autocomplete v-model="subtask.master_task_id" label="Master task" :class="{error: v$.subtask.master_task_id.$errors.length}" :items="mastertasks" item-title="name" item-value="id" variant="solo" class="modal-input" clearable />
|
||||
|
||||
<v-autocomplete v-model="subtask.employee_id" label="Priradený" :class="{error: v$.subtask.employee_id.$errors.length}" :items="enrichedEmployees" item-title="_fullName" item-value="id" variant="solo" class="modal-input" clearable />
|
||||
<v-text-field v-model="subtask.name" @focus="onInputFocus" class="modal-input" label="Názov subtasku" variant="solo" :class="{ error: v$.subtask.name.$errors.length }" :hint="v$.subtask.name.$errors ? errorUtils.parseErrors(v$.subtask.name.$errors) : null"></v-text-field>
|
||||
|
||||
<template v-if="subtask.id">
|
||||
<v-autocomplete v-model="subtask.employee_id" :class="{error: employeeError}" label="Priradený" :items="enrichedEmployees" item-title="_fullName" item-value="id" variant="solo" class="modal-input" clearable />
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<v-autocomplete v-for="(employee, index) in [...subtask.employees, null]" v-model="subtask.employees[index]" :key="`employee-${index}`" :class="{error: employeeError}" label="Priradený" :items="enrichedEmployees" item-title="_fullName" item-value="id" variant="solo" class="modal-input" clearable />
|
||||
</template>
|
||||
|
||||
<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>
|
||||
|
||||
@@ -97,6 +105,7 @@ export default {
|
||||
v$: useVuelidate(),
|
||||
preventInputFocus: false,
|
||||
showDatePicker: false,
|
||||
employeeError: false,
|
||||
selectedNewDate: []
|
||||
}
|
||||
},
|
||||
@@ -113,7 +122,7 @@ export default {
|
||||
subtask: {
|
||||
master_task_id: { required },
|
||||
duration: { required },
|
||||
employee_id: { required }
|
||||
name: { required }
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -143,7 +152,7 @@ export default {
|
||||
const data = await this.$axios.get_auth_data(`v1/subtasks/${subtask.id}`)
|
||||
this.subtask = this._enrichTask(data)
|
||||
} else {
|
||||
this.subtask = { master_task: mastertask, timeblocks: [{start: tmUtils.formatDateTimeForBackend(moment()), end: tmUtils.formatDateTimeForBackend(moment())}] }
|
||||
this.subtask = { master_task: mastertask, employees: [], timeblocks: [] }
|
||||
}
|
||||
|
||||
this.editMode = editMode || !this.subtask.id
|
||||
@@ -158,9 +167,15 @@ export default {
|
||||
},
|
||||
|
||||
async save() {
|
||||
if (!this.subtask.employee_id && !this.subtask.employees.length)
|
||||
this.employeeError = true
|
||||
|
||||
if (!(await this.v$.$validate()))
|
||||
return
|
||||
|
||||
if (!this.subtask.employee_id && !this.subtask.employees.length)
|
||||
return
|
||||
|
||||
this.subtask.description = this.$refs['description'].getHTML()
|
||||
|
||||
try {
|
||||
@@ -213,12 +228,17 @@ export default {
|
||||
|
||||
watch: {
|
||||
'subtask.employee_id'(value, oldValue) {
|
||||
this.employeeError = false
|
||||
if (!value || !oldValue) return
|
||||
|
||||
this.subtask.timeblocks = []
|
||||
this.subtask._employee = this.enrichedEmployees.find((employee) => employee.id == this.subtask.employee_id)
|
||||
},
|
||||
|
||||
'subtask.employees'() {
|
||||
this.employeeError = false
|
||||
},
|
||||
|
||||
'subtask.master_task_id'(value) {
|
||||
if (!value) return
|
||||
this.subtask._master_task = this.mastertasks.find((mastertask) => mastertask.id == this.subtask.master_task_id)
|
||||
|
||||
Reference in new issue
Block a user