This commit is contained in:
romankko2 committed 2023-02-10 17:33:51 +01:00
1 parent 1024f73ab5
commit 4e8fa39e34
8 files changed
+79 -13

No files matched your search

@@ -9,9 +9,14 @@
</p>
<p class="ml-2">{{ task._employeeFullName }}</p>
</td>
<td>
<p class="text-light-green" v-if="task.is_finished">Ukončený</p>
<p v-if="!task.is_finished">Neukončený</p>
</td>
<td class="task-action">
<div class="d-flex justify-start">
<img class="pencil-icon" :src="require('@/plugins/tm@dashboard/_components/_img/checkmark.svg')" alt="checkmark-icon" :style="{opacity: 0.3}">
<img v-if="task.is_finished" class="pencil-icon is-finished" :src="require('@/plugins/tm@dashboard/_components/_img/checkmark.svg')" alt="checkmark-icon" @click.stop="clickCompleteTask(task)">
<img v-if="!task.is_finished" class="pencil-icon" :src="require('@/plugins/tm@dashboard/_components/_img/checkmark.svg')" alt="checkmark-icon" @click.stop="clickCompleteTask(task)">
<img class="pencil-icon ml-2" :src="require('@/plugins/tm@overview/_img/pencil-icon.svg')" alt="pencil-icon" @click.stop="openEditTaskModal(task)">
<img class="trash-icon" :src="require('@/plugins/tm@overview/_img/trash-icon.svg')" alt="trash-icon" @click.stop="openDeleteTaskModal(task)">
</div>
@@ -56,6 +61,24 @@ export default {
openEditTaskModal(task) {
this.$events.emit('show-task-modal', { task, editMode: false })
},
async clickCompleteTask(task) {
if (!task.is_finished) {
this.openCompleteTaskModal(task)
} else {
task.is_finished = !task.is_finished
try {
await this.$axios.patch_auth(`v1/subtasks/${task.id}`, task)
this.$emit('reopenTask', task)
} catch (error) {
this.$toast.error(error)
}
}
},
openCompleteTaskModal(task) {
this.$events.emit('show-complete-task-modal', { task })
}
}
}
@@ -24,6 +24,13 @@ export default {
this.masterTask.project_id = project.id
},
onMasterTaskSelected({ key }) {
const masterTask = this.masterTasks.find(masterTask => masterTask.id == key)
this.masterTask.name = masterTask.name
console.log(masterTask.name)
this.masterTask.master_task.id = masterTask.id
},
onEmployeeSelected({ key }) {
const employee = this.employees.find(employee => employee.id == key)
this.masterTask.employees.push(employee)
@@ -50,9 +57,11 @@ export default {
},
watch: {
'masterTask.team_id'(value) {
if (!value) return
'masterTask.team_id'(value, oldValue) {
if (!value || !oldValue) return
this.masterTask.team = this.teams.find(team => team.id == value)
this.masterTask.employees = this.masterTask.team.employees
}
}
}
@@ -24,11 +24,11 @@
</p>
</v-text-field>
<v-text-field v-for="(employee, index) in masterTask.team?.employees" :key="employee.id" @focus="onInputFocus" :class="{ error: !masterTask.team.employees[index].duration }" class="modal-input" :label="`${employee.name} ${employee.surname}`" variant="solo" placeholder="h" v-model="masterTask.team.employees[index].duration" type="number" min="1" @input="onEmployeeDurationChanged">
<!-- <v-text-field v-for="(employee, index) in masterTask.team?.employees" :key="employee.id" @focus="onInputFocus" :class="{ error: !masterTask.team.employees[index].duration }" class="modal-input" :label="`${employee.name} ${employee.surname}`" variant="solo" placeholder="h" v-model="masterTask.team.employees[index].duration" type="number" min="1" @input="onEmployeeDurationChanged">
<p class="employee-select-avatar d-flex justify-center align-center">
{{ employee.name.charAt(0) + employee.surname.charAt(0) }}
</p>
</v-text-field>
</v-text-field> -->
<Z-autocomplete label="Vyhľadať zamestnanca" v-if="showAddEmployeeInput" :options="employeesOptions" class="modal-input" @option-selected="onEmployeeSelected" />
@@ -184,6 +184,16 @@ export default {
this.masterTask.team_id = this.masterTask.team.id
this.masterTask.project_id = project.id
this.masterTask.project_code = project.code
// TODO refactor
this.masterTask.employees = this.masterTask.employees.map(employee => {
const subtask = this.masterTask?.subtasks.find(subtask => subtask.employee_id == employee.id)
employee.duration = subtask.duration
return employee
})
console.log(this.masterTask.employees)
} else {
this.masterTask = { employees: [], duration: 0 }
}
@@ -198,9 +208,15 @@ export default {
if (!(await this.v$.$validate())) return
this.masterTask.description = this.$refs['description'].getHTML()
this.masterTask.employees = [...this.masterTask.employees, ...this.masterTask.team?.employees]
this.masterTask.project_code = null
// this.masterTask.subtasks = this.masterTask.subtasks.map(subtask => {
// const employee = this.masterTask.employees.find(employee => employee.id == subtask.employee_id)
// subtask.duration = employee.duration
// return subtask
// })
// this.masterTask.project_code = null
try {
this.masterTask.deadline = moment(this.masterTask.deadline).format('YYYY-MM-DD HH:MM:SS')
@@ -2,8 +2,7 @@
<v-dialog v-model="visible" max-width="650">
<v-card>
<div class="d-flex justify-space-between align-center">
<h1>Ste si istý, že chcete ukončiť <b>{{ task.title }}</b>?</h1>
<h1>Ste si istý, že chcete {{ this.task?.id ? 'ukončiť' : 'obnoviť' }} task, z masterTasku <b>{{ task.master_task }}</b>?</h1>
<v-icon
@click.stop="visible = false"
icon="mdi-close"
@@ -38,7 +37,7 @@ export default {
async complete() {
try {
const task = {...this.task, is_finished: true}
await this.$axios.patch_auth(`v1/tasks/${this.task.id}`, task)
await this.$axios.patch_auth(`v1/subtasks/${this.task.id}`, task)
this.visible = false
this.$emit('task-completed', task)
} catch (error) {
+17 -2
View File
@@ -17,6 +17,17 @@
disabled
></v-text-field>
<!-- <Z-autocomplete
label="Master task"
:options="masterTasks.map((masterTask) => ({ key: masterTask.id, value: masterTask.name }))"
:validations="v$.task.master_task"
:clear-on-submit="false"
:value="task.master_task.name"
:class="{ error: v$.task.master_task.$errors.length }"
class="modal-input"
@option-selected="onMasterTaskSelected"
/> -->
<!-- Toto treba fixnut -->
<v-select
v-model="task.master_task.id"
@@ -373,18 +384,21 @@ import errorUtils from '@/plugins/lib@auth/_utils/error.utils'
import moment from 'moment'
import { QuillEditor } from '@vueup/vue-quill'
import VuetifyFixFocusMixin from '@/plugins/tm@modal/_mixins/vuetify-fix-focus'
import SelectsMixin from '../master-task/_mixins/selects.mixin'
import * as FileSaver from 'file-saver'
import tmUtils from '@/plugins/tm@_utils/tm.utils'
import '@vueup/vue-quill/dist/vue-quill.snow.css'
import ZAutocomplete from '@/plugins/tm@_components/z-autocomplete.vue'
export default {
emits: ['close', 'refresh'],
mixins: [VuetifyFixFocusMixin],
mixins: [VuetifyFixFocusMixin, SelectsMixin],
components: {
Datepicker,
ZFilesUpload,
QuillEditor,
// ZAutocomplete
},
data() {
@@ -469,8 +483,9 @@ export default {
},
async save() {
console.log(this.task)
if (!(await this.v$.$validate()))
return
return console.log(this.v$);
this.task.description = this.$refs['description'].getHTML()