[Mastertask modal] Duration edit fix

This commit is contained in:
Matej Glasnák committed 2023-09-11 12:27:02 +02:00
1 parent 1cfdf1b044
commit 561f8942b0
2 files changed
+21 -6

No files matched your search

@@ -2,7 +2,7 @@
<Z-status :status="mastertask.is_finished" /> <Z-status :status="mastertask.is_finished" />
<Z-deadline :deadline="mastertask.deadline" /> <Z-deadline :deadline="mastertask.deadline" />
<Z-created-by :employee-id="mastertask.created_by" /> <Z-created-by :employee-id="mastertask.created_by" />
<Z-team :team="mastertask.team" :employees="mastertask.employees" /> <Z-team :team="mastertask.team" :employees="mastertask._allEmployees || mastertask.employees" />
<Z-planned-time :hours="mastertask.duration" /> <Z-planned-time :hours="mastertask.duration" />
<Z-remaining-time :hours="mastertask.duration - mastertask.time_worked" /> <Z-remaining-time :hours="mastertask.duration - mastertask.time_worked" />
<Z-spent-time :hours="mastertask.time_worked" :is-exceeded="mastertask.time_worked > mastertask.duration" /> <Z-spent-time :hours="mastertask.time_worked" :is-exceeded="mastertask.time_worked > mastertask.duration" />
@@ -25,7 +25,7 @@
<v-select v-model="mastertask.team_id" @focus="onInputFocus" class="modal-input border-select" :class="{error: v$.mastertask.employees.$errors.length}" label="Tím" variant="solo" :items="teams" item-value="id" item-title="name"></v-select> <v-select v-model="mastertask.team_id" @focus="onInputFocus" class="modal-input border-select" :class="{error: v$.mastertask.employees.$errors.length}" label="Tím" variant="solo" :items="teams" item-value="id" item-title="name"></v-select>
<template v-if="mastertask.employees"> <template v-if="mastertask.id">
<v-text-field v-for="(employee, index) in mastertask.employees" :key="employee.id" @focus="onInputFocus" class="modal-input" :class="{error: employee.invalid}" :label="`${employee.name} ${employee.surname}`" variant="solo" placeholder="h" v-model="mastertask.employees[index].duration" type="number" min="1" @input="onEmployeeDurationChanged"> <v-text-field v-for="(employee, index) in mastertask.employees" :key="employee.id" @focus="onInputFocus" class="modal-input" :class="{error: employee.invalid}" :label="`${employee.name} ${employee.surname}`" variant="solo" placeholder="h" v-model="mastertask.employees[index].duration" type="number" min="1" @input="onEmployeeDurationChanged">
<p class="employee-select-avatar d-flex justify-center align-center"> <p class="employee-select-avatar d-flex justify-center align-center">
{{ employee?.name.charAt(0) + employee?.surname.charAt(0) }} {{ employee?.name.charAt(0) + employee?.surname.charAt(0) }}
@@ -35,6 +35,17 @@
</v-text-field> </v-text-field>
</template> </template>
<!-- mastertask._allEmployees is used in edit to combine team employees with extra employees and subtask durations -->
<template v-else>
<v-text-field v-for="employee in mastertask._allEmployees" :key="employee.id" class="modal-input" :label="`${employee.name} ${employee.surname}`" variant="solo" placeholder="h" v-model="employee.duration" type="number" :disabled="true">
<p class="employee-select-avatar d-flex justify-center align-center">
{{ employee?.name.charAt(0) + employee?.surname.charAt(0) }}
</p>
<v-icon @click.stop="removeEmployee(employee)" class="remove-input" icon="mdi-close" size="small"></v-icon>
</v-text-field>
</template>
<v-autocomplete :custom-filter="customFilter" :match-any="true" v-if="showAddEmployeeInput" :label="$t('Search for employee')" :class="{error: v$.mastertask.project_id.$errors.length}" :items="employeesOptions" item-title="_fullName" item-value="id" variant="solo" class="modal-input" clearable @update:model-value="onEmployeeSelected" /> <v-autocomplete :custom-filter="customFilter" :match-any="true" v-if="showAddEmployeeInput" :label="$t('Search for employee')" :class="{error: v$.mastertask.project_id.$errors.length}" :items="employeesOptions" item-title="_fullName" item-value="id" variant="solo" class="modal-input" clearable @update:model-value="onEmployeeSelected" />
<!-- <Z-autocomplete label="Vyhľadať zamestnanca" :options="employeesOptions" class="modal-input" @option-selected="onEmployeeSelected" /> --> <!-- <Z-autocomplete label="Vyhľadať zamestnanca" :options="employeesOptions" class="modal-input" @option-selected="onEmployeeSelected" /> -->
@@ -261,10 +272,14 @@ export default {
this.mastertask.project_id = project?.id || null this.mastertask.project_id = project?.id || null
this.mastertask.team_id = this.mastertask.team?.id || null this.mastertask.team_id = this.mastertask.team?.id || null
// this.mastertask.subtasks.forEach(({ employee_id, duration}) => { this.mastertask._allEmployees = this.mastertask.subtasks.map(({ employee_id, duration}) => {
// const employee = this.mastertask.employees.find(({ id }) => id == employee_id) const employee = this.enrichedEmployees.find(({ id }) => id == employee_id)
// employee.duration = duration employee.duration = duration
// })
return employee
})
console.log('NEW', this.mastertask)
// this.mastertask.project_code = project.code // this.mastertask.project_code = project.code
} else { } else {