mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
[Task modal, subtask modal] BE
This commit is contained in:
1 parent
37331335ce
commit
1024f73ab5
12 files changed
+457
-469
No files matched your search
@@ -69,10 +69,16 @@ input::-webkit-inner-spin-button
|
||||
.v-select .v-field--variant-solo
|
||||
border: none !important
|
||||
|
||||
.rich-text-editor
|
||||
border: 1px solid rgba(0, 0, 0, 0.1)
|
||||
|
||||
.error .dp__input,
|
||||
.v-input.error .v-input__control,
|
||||
.rich-text-editor.error
|
||||
.v-input.error .v-input__control
|
||||
border: 1px solid red !important
|
||||
|
||||
.error .ql-toolbar.ql-snow,
|
||||
.error .ql-container.ql-snow
|
||||
border-color: red !important
|
||||
|
||||
.v-messages__message
|
||||
color: red !important
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="wrapper">
|
||||
<v-text-field
|
||||
label="Vyhľadať zamestnanca"
|
||||
:label="label"
|
||||
variant="solo"
|
||||
v-model="search"
|
||||
@keydown.enter="optionSelected()"
|
||||
@@ -27,6 +27,11 @@ export default {
|
||||
emits: ['option-selected'],
|
||||
|
||||
props: {
|
||||
label: {
|
||||
type: String,
|
||||
required: false,
|
||||
},
|
||||
|
||||
options: {
|
||||
type: Array,
|
||||
required: true
|
||||
@@ -35,6 +40,16 @@ export default {
|
||||
validations: {
|
||||
type: Object || null,
|
||||
required: false
|
||||
},
|
||||
|
||||
clearOnSubmit: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: () => true
|
||||
},
|
||||
|
||||
value: {
|
||||
required: false
|
||||
}
|
||||
},
|
||||
|
||||
@@ -72,22 +87,39 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
if (this.value)
|
||||
this.search = this.value
|
||||
},
|
||||
|
||||
methods: {
|
||||
optionSelected() {
|
||||
if (!this.suggestion)
|
||||
return
|
||||
|
||||
this.$emit('option-selected', this.suggestion)
|
||||
|
||||
if (this.clearOnSubmit)
|
||||
this.search = ''
|
||||
else
|
||||
this.search = this.suggestion.value
|
||||
},
|
||||
|
||||
_normalize(value) {
|
||||
if (!value) return ''
|
||||
|
||||
return value
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.normalize("NFD")
|
||||
.replace(/[\u0300-\u036f]/g, "")
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
value(value) {
|
||||
this.search = value
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -84,6 +84,7 @@ export default {
|
||||
})
|
||||
|
||||
this.$events.on('on-master-task-edited', (masterTask) => {
|
||||
this.masterTasks = this.masterTasks.map(mTask => mTask.id == masterTask.id ? masterTask : mTask)
|
||||
this._getData()
|
||||
})
|
||||
},
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
></v-icon>
|
||||
</div>
|
||||
<Z-autocomplete
|
||||
label="Vyhľadať zamestnanca"
|
||||
:options="employeesOptions"
|
||||
class="modal-input"
|
||||
:class="{ error: v$.blocker.employees.$errors.length }"
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
<template>
|
||||
<v-row no-gutters class="align-center">
|
||||
<v-col cols="5">
|
||||
<v-sheet class="pa-2 ma-2">
|
||||
<div class="d-flex align-center">
|
||||
<v-icon icon="mdi-drag-vertical" size="large"></v-icon>
|
||||
<p class="mx-3">Status</p>
|
||||
</div>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
<v-col cols="7">
|
||||
<v-sheet class="ma-2">
|
||||
<p v-if="masterTask.is_finished" class="status-badge px-4 py-2 rounded-pill">Ukončený</p>
|
||||
<p v-if="!masterTask.is_finished" class="status-badge px-4 py-2 rounded-pill">Neukončený</p>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row no-gutters class="align-center">
|
||||
<v-col cols="5">
|
||||
<v-sheet class="pa-2 ma-2">
|
||||
<div class="d-flex align-center">
|
||||
<v-icon icon="mdi-calendar-week" size="large"></v-icon>
|
||||
<p class="mx-3">Deadline</p>
|
||||
</div>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
<v-col cols="7">
|
||||
<v-sheet class="ma-2">
|
||||
<p :class="`${tmUtils.isAfter(masterTask.deadline) ? 'text-black' : 'text-red-darken-4'}`">{{ tmUtils.formatDateTime(masterTask.deadline) }}</p>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row no-gutters>
|
||||
<v-col cols="5">
|
||||
<v-sheet class="pa-2 ma-2 pt-0">
|
||||
<div class="d-flex align-center">
|
||||
<v-icon icon="mdi-account-multiple-outline" size="large"></v-icon>
|
||||
<p class="mx-3">Tím</p>
|
||||
</div>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
<v-col cols="7">
|
||||
<v-sheet class="d-flex flex-wrap flex-column">
|
||||
<p class="task-badge px-4 py-2 rounded-pill flex-shrink-0">{{ masterTask.team?.name }}</p>
|
||||
<div class="d-flex align-center flex-shrink-0 mt-2 task-badge px-4 py-2 rounded-pill" v-for="(employee, index) in masterTask.employees" :key="employee.id">
|
||||
<p class="employee-selected-avatar d-flex justify-center align-center">
|
||||
{{ employee.name.charAt(0) + employee.surname.charAt(0) }}
|
||||
</p>
|
||||
<p class="ml-2" v-html="`${masterTask.employees[index].name} ${masterTask.employees[index].surname}`" />
|
||||
</div>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row no-gutters class="align-center">
|
||||
<v-col cols="5">
|
||||
<v-sheet class="pa-2 ma-2">
|
||||
<div class="d-flex align-center">
|
||||
<v-icon icon="mdi-clock-time-three-outline" size="large"></v-icon>
|
||||
<p class="mx-3">Naplánovaný čas</p>
|
||||
</div>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
<v-col cols="7">
|
||||
<v-sheet class="ma-2">
|
||||
<p>{{ masterTask?.duration?.toFixed(2) }} h</p>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row no-gutters class="align-center">
|
||||
<v-col cols="5">
|
||||
<v-sheet class="pa-2 ma-2">
|
||||
<div class="d-flex align-center">
|
||||
<v-icon icon="mdi-timer-outline" size="large"></v-icon>
|
||||
<p class="mx-3">Odpracovaný čas</p>
|
||||
</div>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
<v-col cols="7">
|
||||
<v-sheet class="ma-2">
|
||||
<p :class="masterTask.time_worked > masterTask.duration ? 'text-red-darken-4' : 'text-black'">{{ masterTask.time_worked?.toFixed(2) }} h</p>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row no-gutters class="align-center border-bottom">
|
||||
<v-col cols="5">
|
||||
<v-sheet class="pa-2 ma-2">
|
||||
<div class="d-flex align-center">
|
||||
<v-icon icon="mdi-clock-time-three-outline" size="large"></v-icon>
|
||||
<p class="mx-3">Zostávajúci čas</p>
|
||||
</div>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
<v-col cols="7">
|
||||
<v-sheet class="ma-2">
|
||||
<p :class="masterTask.time_worked > masterTask.duration ? 'text-red-darken-4' : 'text-black'">{{ (masterTask.duration - masterTask.time_worked)?.toFixed(2) }} h</p>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<div class="px-5 py-5 border-bottom">
|
||||
<p>Popis zadania</p>
|
||||
<section v-html="masterTask.description" class="description-detail px-2 py-2 w-100 rounded mt-2" />
|
||||
<p class="mt-5">Prílohy</p>
|
||||
<div class="w-100 d-flex align-center">
|
||||
<div v-for="(file, index) in masterTask.files" :key="file.id" class="d-flex align-center flex-wrap" :class="[index === 0 ? 'ml-0' : 'ml-2']">
|
||||
<v-chip class="mt-2">
|
||||
<p @click="downloadFile(index)" class="cursor-pointer">{{ file.name }}</p>
|
||||
<v-icon class="mx-1" icon="mdi-paperclip"></v-icon>
|
||||
</v-chip>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import tmUtils from '@/plugins/tm@_utils/tm.utils'
|
||||
import * as FileSaver from 'file-saver'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
masterTask: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
tmUtils
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
async downloadFile(id) {
|
||||
try {
|
||||
const file = await this.$axios.get_auth_data(`v1/mastertasks/${this.masterTask.id}`, { responseType: 'arraybuffer' })
|
||||
FileSaver.saveAs(file.files[id].path, file.files[id].name)
|
||||
} catch(error) {
|
||||
this.$toast.error(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="sass" scoped>
|
||||
@media screen and (max-width: 522px)
|
||||
.files
|
||||
margin-top: 104px !important
|
||||
</style>
|
||||
@@ -0,0 +1,71 @@
|
||||
<template>
|
||||
<v-table class="mt-7 mb-5">
|
||||
<tbody class="px-5 py-5">
|
||||
<tr v-for="task in enrichedtasks" :key="task.id">
|
||||
<td class="w-25">{{ task.project_code }}</td>
|
||||
<td class="d-flex align-center">
|
||||
<p class="employee-selected-avatar d-flex justify-center align-center">
|
||||
{{ task._employeeInitials }}
|
||||
</p>
|
||||
<p class="ml-2">{{ task._employeeFullName }}</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 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>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</v-table>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
tasks: {
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
|
||||
employees: {
|
||||
type: Array,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
enrichedtasks() {
|
||||
return this.tasks.map(task => {
|
||||
const employee = this.employees.find(employee => employee.id == task.employee_id)
|
||||
|
||||
return {
|
||||
...task,
|
||||
_employeeInitials: employee.name.charAt(0) + employee.surname.charAt(0),
|
||||
_employeeFullName: `${employee.name} ${employee.surname}`
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
openDeleteTaskModal(task) {
|
||||
this.$events.emit('show-delete-task-modal', { task })
|
||||
},
|
||||
|
||||
openEditTaskModal(task) {
|
||||
this.$events.emit('show-task-modal', { task, editMode: false })
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="sass" scoped>
|
||||
v-table, tbody
|
||||
border-top: thin solid rgba(var(--v-border-color), var(--v-border-opacity))
|
||||
border-bottom: thin solid rgba(var(--v-border-color), var(--v-border-opacity))
|
||||
|
||||
td:not(:last-child)
|
||||
border-right: thin solid rgba(var(--v-border-color), var(--v-border-opacity))
|
||||
</style>
|
||||
@@ -0,0 +1,58 @@
|
||||
export default {
|
||||
computed: {
|
||||
employeesOptions() {
|
||||
const selectedEmployees = [...this.masterTask.employees, ...this.masterTask.team?.employees]
|
||||
.map(employee => employee.id)
|
||||
|
||||
const employees = this.employees.filter(
|
||||
(employee) => !selectedEmployees.includes(employee.id)
|
||||
) || []
|
||||
|
||||
return employees.map((employee) => {
|
||||
return {
|
||||
key: employee.id,
|
||||
value: `${employee.name} ${employee.surname}`,
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
onProjectSelected({ key }) {
|
||||
const project = this.projects.find(project => project.id == key)
|
||||
this.masterTask.project_code = project.code
|
||||
this.masterTask.project_id = project.id
|
||||
},
|
||||
|
||||
onEmployeeSelected({ key }) {
|
||||
const employee = this.employees.find(employee => employee.id == key)
|
||||
this.masterTask.employees.push(employee)
|
||||
this.showAddEmployeeInput = false
|
||||
},
|
||||
|
||||
onEmployeeDurationChanged() {
|
||||
let totalDuration = 0
|
||||
|
||||
this.masterTask.employees = this.masterTask.employees.map(employee => {
|
||||
if (typeof employee.duration == 'string') {
|
||||
totalDuration += parseInt(employee.duration)
|
||||
employee.duration = parseInt(employee.duration)
|
||||
}
|
||||
else if (typeof employee.duration == 'number') {
|
||||
totalDuration += employee.duration
|
||||
}
|
||||
|
||||
return employee
|
||||
})
|
||||
|
||||
this.masterTask.duration = totalDuration
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
'masterTask.team_id'(value) {
|
||||
if (!value) return
|
||||
this.masterTask.team = this.teams.find(team => team.id == value)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,121 +4,38 @@
|
||||
<v-card v-if="editMode" height="100%" class="d-flex flex-column scrolling">
|
||||
<div class="d-flex justify-space-between align-center modal-header">
|
||||
<h1>{{ masterTask?.id ? 'Upraviť master task' : 'Vytvoriť master task' }}</h1>
|
||||
<v-icon
|
||||
@click.stop="closeModal()"
|
||||
icon="mdi-close"
|
||||
size="large"
|
||||
></v-icon>
|
||||
<v-icon @click.stop="closeModal()" icon="mdi-close" size="large"></v-icon>
|
||||
</div>
|
||||
|
||||
<v-card-actions class="d-flex flex-column modal-content">
|
||||
<v-select
|
||||
v-model="projectCodeSelect"
|
||||
@focus="onInputFocus"
|
||||
class="modal-input border-select"
|
||||
label="Kód projektu"
|
||||
variant="solo"
|
||||
:items="projects"
|
||||
item-value="id"
|
||||
item-title="code"
|
||||
:class="{ error: v$.masterTask.project_id.$errors.length }"
|
||||
:hint="
|
||||
v$.masterTask.project_id.$errors
|
||||
? errorUtils.parseErrors(v$.masterTask.project_id.$errors)
|
||||
: null
|
||||
"
|
||||
></v-select>
|
||||
<Z-autocomplete label="Kód projektu" :options="projects.map((project) => ({ key: project.id, value: project.code }))" :validations="v$.masterTask.project_code" :clear-on-submit="false" :value="masterTask.project_code" :class="{ error: v$.masterTask.project_code.$errors.length }" class="modal-input" @option-selected="onProjectSelected" />
|
||||
|
||||
<v-text-field
|
||||
v-model="masterTask.name"
|
||||
@focus="onInputFocus"
|
||||
class="modal-input"
|
||||
label="Názov mastertasku"
|
||||
variant="solo"
|
||||
:class="{ error: v$.masterTask.name.$errors.length }"
|
||||
:hint="
|
||||
v$.masterTask.name.$errors
|
||||
? errorUtils.parseErrors(v$.masterTask.name.$errors)
|
||||
: null
|
||||
"
|
||||
></v-text-field>
|
||||
<v-text-field v-model="masterTask.name" @focus="onInputFocus" class="modal-input" label="Názov mastertasku" variant="solo" :class="{ error: v$.masterTask.name.$errors.length }" :hint="v$.masterTask.name.$errors ? errorUtils.parseErrors(v$.masterTask.name.$errors) : null"></v-text-field>
|
||||
|
||||
<Datepicker
|
||||
v-model="masterTask.deadline"
|
||||
@focus="onDateFocus"
|
||||
class="modal-input"
|
||||
format="dd.MM.yyyy, HH:mm"
|
||||
locale="sk"
|
||||
:class="{ error: v$.masterTask.deadline.$errors.length }"
|
||||
select-text="Vybrať"
|
||||
cancel-text="Zrušiť"
|
||||
placeholder="Deadline"
|
||||
/>
|
||||
<Datepicker v-model="masterTask.deadline" @focus="onDateFocus" class="modal-input" format="dd.MM.yyyy, HH:mm" locale="sk" :class="{ error: v$.masterTask.deadline.$errors.length }" select-text="Vybrať" cancel-text="Zrušiť" placeholder="Deadline" />
|
||||
|
||||
<v-text-field
|
||||
v-model="masterTask.duration"
|
||||
@focus="onInputFocus"
|
||||
class="modal-input mt-5"
|
||||
variant="solo"
|
||||
type="number"
|
||||
disabled
|
||||
:label="`${masterTask.duration} h`"
|
||||
></v-text-field>
|
||||
<v-text-field v-model="masterTask.duration" @focus="onInputFocus" class="modal-input mt-5" variant="solo" type="number" disabled :label="`${masterTask.duration} h`"></v-text-field>
|
||||
|
||||
<v-select
|
||||
v-model="teamSelect"
|
||||
@focus="onInputFocus"
|
||||
class="modal-input border-select"
|
||||
:class="{ error: v$.masterTask.team.$errors.length }"
|
||||
label="Tím"
|
||||
variant="solo"
|
||||
:items="teams"
|
||||
item-value="id"
|
||||
item-title="name"
|
||||
></v-select>
|
||||
<v-select v-model="this.masterTask.team_id" @focus="onInputFocus" class="modal-input border-select" :class="{ error: v$.masterTask.team_id.$errors.length }" label="Tím" variant="solo" :items="teams" item-value="id" item-title="name"></v-select>
|
||||
|
||||
<v-text-field
|
||||
v-for="(employee, index) in masterTask.employees"
|
||||
:key="employee.id"
|
||||
@focus="onInputFocus"
|
||||
:class="{ error: !masterTask.employees[index].duration }"
|
||||
class="modal-input"
|
||||
: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="{ error: !masterTask.employees[index].duration }" class="modal-input" :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">
|
||||
{{ employee.name.charAt(0) + employee.surname.charAt(0) }}
|
||||
</p>
|
||||
</v-text-field>
|
||||
|
||||
<Z-autocomplete
|
||||
v-if="showAddEmployeeInput"
|
||||
:options="employeesOptions"
|
||||
:validations="v$.masterTask.employees"
|
||||
:class="{ error: v$.masterTask.employees.$errors.length }"
|
||||
class="modal-input"
|
||||
@option-selected="employeeSelected"
|
||||
/>
|
||||
<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-btn class="w-100 mb-5 button secondary" :disabled="!masterTask.team?.id" @click="showAddEmployeeInput = true">
|
||||
<v-icon class="mx-1" icon="mdi-plus" />Pridať zamestnanca
|
||||
</v-btn>
|
||||
<Z-autocomplete label="Vyhľadať zamestnanca" v-if="showAddEmployeeInput" :options="employeesOptions" class="modal-input" @option-selected="onEmployeeSelected" />
|
||||
|
||||
<div class="w-100 modal-input">
|
||||
<QuillEditor
|
||||
ref="description"
|
||||
v-model="masterTask.description"
|
||||
placeholder="Popis"
|
||||
theme="snow"
|
||||
class="rich-text-editor"
|
||||
:class="{ error: v$.masterTask.deadline.$errors.length }"
|
||||
@input="masterTask.description = $event.srcElement.innerHTML"
|
||||
/>
|
||||
<v-btn class="w-100 mb-5 button secondary" :disabled="!masterTask.team?.id" @click="showAddEmployeeInput = true"> <v-icon class="mx-1" icon="mdi-plus" />Pridať zamestnanca </v-btn>
|
||||
|
||||
<div class="w-100 modal-input" :class="{ error: v$.masterTask.description.$errors.length }">
|
||||
<QuillEditor ref="description" v-model="masterTask.description" placeholder="Popis" theme="snow" class="rich-text-editor" @input="masterTask.description = $event.srcElement.innerHTML" />
|
||||
</div>
|
||||
|
||||
<Z-files-upload class="mt-15 files" @files-uploaded="filesUploaded" />
|
||||
@@ -130,12 +47,7 @@
|
||||
<v-card v-else height="100%" class="d-flex flex-column scrolling">
|
||||
<div class="d-flex justify-space-between align-center">
|
||||
<p>{{ masterTask.project_code }}</p>
|
||||
<v-icon
|
||||
@click.stop="closeModal()"
|
||||
icon="mdi-close"
|
||||
size="large"
|
||||
class="pb-5"
|
||||
></v-icon>
|
||||
<v-icon @click.stop="closeModal()" icon="mdi-close" size="large" class="pb-5"></v-icon>
|
||||
</div>
|
||||
<div class="d-flex justify-space-between align-center modal-header border-bottom pb-4">
|
||||
<h1>{{ masterTask.name }}</h1>
|
||||
@@ -147,159 +59,15 @@
|
||||
|
||||
<v-card-actions class="d-flex flex-column modal-content">
|
||||
<div class="w-100">
|
||||
<v-row no-gutters class="align-center">
|
||||
<v-col cols="5">
|
||||
<v-sheet class="pa-2 ma-2">
|
||||
<div class="d-flex align-center">
|
||||
<v-icon
|
||||
icon="mdi-drag-vertical"
|
||||
size="large"
|
||||
></v-icon>
|
||||
<p class="mx-3">Status</p>
|
||||
</div>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
<v-col cols="7">
|
||||
<v-sheet class="ma-2">
|
||||
<p v-if="masterTask.is_finished" class="status-badge px-4 py-2 rounded-pill">Ukončený</p>
|
||||
<p v-if="!masterTask.is_finished" class="status-badge px-4 py-2 rounded-pill">Neukončený</p>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row no-gutters class="align-center">
|
||||
<v-col cols="5">
|
||||
<v-sheet class="pa-2 ma-2">
|
||||
<div class="d-flex align-center">
|
||||
<v-icon
|
||||
icon="mdi-calendar-week"
|
||||
size="large"
|
||||
></v-icon>
|
||||
<p class="mx-3">Deadline</p>
|
||||
</div>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
<v-col cols="7">
|
||||
<v-sheet class="ma-2">
|
||||
<p :class="`${tmUtils.isAfter(masterTask.deadline) ? 'text-black' : 'text-red-darken-4'}`">{{ tmUtils.formatDateTime(masterTask.deadline) }}</p>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row no-gutters>
|
||||
<v-col cols="5">
|
||||
<v-sheet class="pa-2 ma-2 pt-0">
|
||||
<div class="d-flex align-center">
|
||||
<v-icon
|
||||
icon="mdi-account-multiple-outline"
|
||||
size="large"
|
||||
></v-icon>
|
||||
<p class="mx-3">Tím</p>
|
||||
</div>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
<v-col cols="7">
|
||||
<v-sheet class="d-flex flex-wrap flex-column">
|
||||
<p class="task-badge px-4 py-2 rounded-pill flex-shrink-0">{{ masterTask.team?.name }}</p>
|
||||
<div class="d-flex align-center flex-shrink-0 mt-2 task-badge px-4 py-2 rounded-pill" v-for="(employee, index) in masterTask.employees" :key="employee.id">
|
||||
<p class="employee-selected-avatar d-flex justify-center align-center">
|
||||
{{ employee.name.charAt(0) + employee.surname.charAt(0) }}
|
||||
</p>
|
||||
<p class="ml-2" v-html="`${masterTask.employees[index].name} ${masterTask.employees[index].surname}`" />
|
||||
</div>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row no-gutters class="align-center">
|
||||
<v-col cols="5">
|
||||
<v-sheet class="pa-2 ma-2">
|
||||
<div class="d-flex align-center">
|
||||
<v-icon
|
||||
icon="mdi-clock-time-three-outline"
|
||||
size="large"
|
||||
></v-icon>
|
||||
<p class="mx-3">Naplánovaný čas</p>
|
||||
</div>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
<v-col cols="7">
|
||||
<v-sheet class="ma-2">
|
||||
<p>{{ masterTask?.duration?.toFixed(2) }} h</p>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row no-gutters class="align-center">
|
||||
<v-col cols="5">
|
||||
<v-sheet class="pa-2 ma-2">
|
||||
<div class="d-flex align-center">
|
||||
<v-icon
|
||||
icon="mdi-timer-outline"
|
||||
size="large"
|
||||
></v-icon>
|
||||
<p class="mx-3">Odpracovaný čas</p>
|
||||
</div>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
<v-col cols="7">
|
||||
<v-sheet class="ma-2">
|
||||
<p :class="masterTask.time_worked > masterTask.duration ? 'text-red-darken-4': 'text-black'">{{ (masterTask.time_worked)?.toFixed(2) }} h</p>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row no-gutters class="align-center border-bottom">
|
||||
<v-col cols="5">
|
||||
<v-sheet class="pa-2 ma-2">
|
||||
<div class="d-flex align-center">
|
||||
<v-icon
|
||||
icon="mdi-clock-time-three-outline"
|
||||
size="large"
|
||||
></v-icon>
|
||||
<p class="mx-3">Zostávajúci čas</p>
|
||||
</div>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
<v-col cols="7">
|
||||
<v-sheet class="ma-2">
|
||||
<p :class="masterTask.time_worked > masterTask.duration ? 'text-red-darken-4': 'text-black'">{{ (masterTask.duration - masterTask.time_worked)?.toFixed(2) }} h</p>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<div class="px-5 py-5 border-bottom">
|
||||
<p>Popis zadania</p>
|
||||
<section v-html="masterTask.description" class="description-detail px-2 py-2 w-100 rounded mt-2" />
|
||||
<p class="mt-5">Prílohy</p>
|
||||
<div class="w-100 d-flex align-center">
|
||||
<div v-for="(file, index) in masterTask.files" :key="file.id" class="d-flex align-center flex-wrap" :class="[index === 0 ? 'ml-0': 'ml-2']">
|
||||
<v-chip class="mt-2">
|
||||
<p @click="downloadFile(index)" class="cursor-pointer">{{ file.name }}</p>
|
||||
<v-icon class="mx-1" icon="mdi-paperclip"></v-icon>
|
||||
</v-chip>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<A-task-description :master-task="masterTask" />
|
||||
<div class="d-flex justify-start align-center mt-8">
|
||||
<v-btn class="button primary" @click="save()">Ukončiť mastertask</v-btn>
|
||||
</div>
|
||||
<v-table class="mt-7 mb-5">
|
||||
<tbody class="px-5 py-5">
|
||||
<tr v-for="task in masterTask.subtasks" :key="task.id">
|
||||
<td class="w-25">{{ task.project_code }}</td>
|
||||
<td class="d-flex align-center">
|
||||
<p class="employee-selected-avatar d-flex justify-center align-center">
|
||||
{{ getFullNameByEmployeeId(task.employee_id).initials }}
|
||||
</p>
|
||||
<p class="ml-2">{{ getFullNameByEmployeeId(task.employee_id).fullName }}</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 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>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</v-table>
|
||||
|
||||
<A-tasks-table :tasks="masterTask.subtasks" :employees="employees" />
|
||||
|
||||
<div class="d-flex align-center ">
|
||||
<v-btn class="subtask-btn w-100" @click="addTask()" ><v-icon class="mx-1" icon="mdi-plus" />Pridať Subtask</v-btn>
|
||||
<v-btn class="subtask-btn w-100" @click="addTask()" ><v-icon class="mx-1" icon="mdi-plus" />Pridať task</v-btn>
|
||||
</div>
|
||||
</div>
|
||||
</v-card-actions>
|
||||
@@ -319,16 +87,25 @@ import VuetifyFixFocusMixin from '@/plugins/tm@modal/_mixins/vuetify-fix-focus'
|
||||
import moment from 'moment'
|
||||
import { QuillEditor } from '@vueup/vue-quill'
|
||||
import tmUtils from '@/plugins/tm@_utils/tm.utils'
|
||||
import * as FileSaver from 'file-saver'
|
||||
|
||||
import '@vueup/vue-quill/dist/vue-quill.snow.css'
|
||||
|
||||
const atLeastOne = (value) => value.length
|
||||
import SelectsMixin from './_mixins/selects.mixin'
|
||||
import ATasksTable from './_components/a-tasks-table.vue'
|
||||
import ATaskDescription from './_components/a-task-description.vue'
|
||||
|
||||
export default {
|
||||
// MIXINS
|
||||
// computed: employeesOptions
|
||||
// methods: onProjectSelected, onEmployeeSelected, onEmployeeDurationChanged
|
||||
// watch: masterTask.team_id
|
||||
|
||||
emits: ['master-task-edited', 'close'],
|
||||
mixins: [VuetifyFixFocusMixin],
|
||||
mixins: [VuetifyFixFocusMixin, SelectsMixin],
|
||||
|
||||
components: {
|
||||
ATaskDescription,
|
||||
ATasksTable,
|
||||
Datepicker,
|
||||
ZFilesUpload,
|
||||
ZAutocomplete,
|
||||
@@ -337,7 +114,6 @@ export default {
|
||||
|
||||
data() {
|
||||
return {
|
||||
tmUtils,
|
||||
editMode: false,
|
||||
visible: false,
|
||||
errorUtils,
|
||||
@@ -345,11 +121,7 @@ export default {
|
||||
teams: null,
|
||||
projects: null,
|
||||
employees: null,
|
||||
employeeSelect: null,
|
||||
projectCodeSelect: null,
|
||||
teamSelect: '',
|
||||
masterTask: null,
|
||||
|
||||
showAddEmployeeInput: false
|
||||
}
|
||||
},
|
||||
@@ -357,14 +129,12 @@ export default {
|
||||
validations() {
|
||||
return {
|
||||
masterTask: {
|
||||
project_id: { required },
|
||||
project_code: { required },
|
||||
team_id: { required },
|
||||
name: { required },
|
||||
team: { required },
|
||||
// duration: { required },
|
||||
// description: { required },
|
||||
deadline: { required },
|
||||
employees: { atLeastOne }
|
||||
},
|
||||
description: { required },
|
||||
deadline: { required }
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -374,80 +144,69 @@ export default {
|
||||
})
|
||||
|
||||
this.$events.on('on-task-deleted', (task) => {
|
||||
this.masterTask.subtasks = this.masterTask.subtasks.filter(subtask => subtask.id != task.id)
|
||||
this.masterTask.subtasks = this.masterTask.subtasks.filter((subtask) => subtask.id != task.id)
|
||||
})
|
||||
|
||||
this.$events.on('on-task-edited', (task) => {
|
||||
if (!this.masterTask.subtasks) return
|
||||
|
||||
if (this.masterTask.subtasks.find(subtask => subtask.id == task.id)) {
|
||||
this.masterTask.subtasks = this.masterTask.subtasks.map(t => t.id == task.id ? task : t)
|
||||
} else {
|
||||
this.masterTask.subtasks.push(task)
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
beforeUnmount() {
|
||||
this.$events.off('on-master-task-deleted')
|
||||
this.$events.off('on-task-deleted')
|
||||
this.$events.off('on-task-edited')
|
||||
},
|
||||
|
||||
methods: {
|
||||
getFullNameByEmployeeId(employee_id) {
|
||||
let fullName = ''
|
||||
let initials = ''
|
||||
this.employees.forEach(employee => {
|
||||
if (employee.id === employee_id) {
|
||||
fullName = `${employee.name} ${employee.surname}`
|
||||
initials = employee.name.charAt(0) + employee.surname.charAt(0)
|
||||
}
|
||||
})
|
||||
return {
|
||||
fullName,
|
||||
initials
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
async downloadFile(id) {
|
||||
try {
|
||||
const file = await this.$axios.get_auth_data(`v1/mastertasks/${this.masterTask.id}`, { responseType: 'arraybuffer' })
|
||||
FileSaver.saveAs(file.files[id].path, file.files[id].name)
|
||||
} catch(error) {
|
||||
this.$toast.error(error)
|
||||
}
|
||||
},
|
||||
|
||||
async showModal(masterTask, editMode = false) {
|
||||
this.v$.$reset()
|
||||
this.visible = true
|
||||
this.masterTask = null
|
||||
this.teamSelect = null
|
||||
this.employeeSelect = null
|
||||
this.projectCodeSelect = null
|
||||
|
||||
try {
|
||||
this.teams = await this.$axios.get_auth_data('v1/teams')
|
||||
const employees = await this.$axios.get_auth_data('v1/employees')
|
||||
this.projects = await this.$axios.get_auth_data('v1/projects')
|
||||
const employees = await this.$axios.get_auth_data('v1/employees')
|
||||
this.employees = tmUtils.enrichEmployeesByFullName(employees)
|
||||
|
||||
if (masterTask?.id) {
|
||||
this.masterTask = await this.$axios.get_auth_data(`v1/mastertasks/${masterTask.id}`)
|
||||
|
||||
const project = this.projects.find(project => project.code == this.masterTask?.project_code)
|
||||
this.teamSelect = this.masterTask.team.id
|
||||
this.projectCodeSelect = project.id
|
||||
const project = this.projects.find((project) => project.code == this.masterTask?.project_code)
|
||||
|
||||
this.masterTask.team_id = this.masterTask.team.id
|
||||
this.masterTask.project_id = project.id
|
||||
this.masterTask.project_code = project.code
|
||||
} else {
|
||||
this.masterTask = {team: {}, employees: [], duration: 0}
|
||||
this.masterTask = { employees: [], duration: 0 }
|
||||
}
|
||||
|
||||
this.editMode = (editMode || !this.masterTask.id)
|
||||
this.editMode = editMode || !this.masterTask.id
|
||||
} catch (error) {
|
||||
this.$toast.error(error)
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
async save() {
|
||||
if (!(await this.v$.$validate()))
|
||||
return console.log(this.v$)
|
||||
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
|
||||
|
||||
try {
|
||||
this.masterTask.deadline = moment(this.masterTask.deadline).format("YYYY-MM-DD HH:MM:SS")
|
||||
this.masterTask.deadline = moment(this.masterTask.deadline).format('YYYY-MM-DD HH:MM:SS')
|
||||
|
||||
if (this.masterTask.id)
|
||||
await this.$axios.put_auth(`v1/mastertasks/${this.masterTask.id}`, this.masterTask)
|
||||
|
||||
else
|
||||
await this.$axios.post_auth_data('v1/mastertasks', this.masterTask)
|
||||
if (this.masterTask.id) await this.$axios.put_auth_data(`v1/mastertasks/${this.masterTask.id}`, this.masterTask)
|
||||
else await this.$axios.post_auth_data('v1/mastertasks', this.masterTask)
|
||||
|
||||
this.$emit('master-task-edited', this.masterTask)
|
||||
this.closeModal()
|
||||
@@ -456,111 +215,24 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
filesUploaded(files) {
|
||||
this.masterTask.files = files
|
||||
},
|
||||
|
||||
closeModal() {
|
||||
this.visible = false
|
||||
this.$emit('close', this.masterTask)
|
||||
},
|
||||
|
||||
openDeleteMasterTaskModal(masterTask) {
|
||||
this.$events.emit('show-delete-master-task-modal', { masterTask })
|
||||
},
|
||||
|
||||
openDeleteTaskModal(task) {
|
||||
this.$events.emit('show-delete-task-modal', { task })
|
||||
},
|
||||
|
||||
openEditTaskModal(task) {
|
||||
this.$events.emit('show-task-modal', { task, editMode: false })
|
||||
},
|
||||
|
||||
employeeSelected(selectedOption) {
|
||||
const employee = this.employees.find((empl) => empl.id == selectedOption.key)
|
||||
this.masterTask.employees.push(employee)
|
||||
this.showAddEmployeeInput = false
|
||||
},
|
||||
|
||||
filesUploaded(files) {
|
||||
this.masterTask.files = files
|
||||
},
|
||||
|
||||
addTask() {
|
||||
this.$events.emit('show-task-modal', { task: null, editMode: false, masterTask: this.masterTask })
|
||||
},
|
||||
|
||||
onEmployeeDurationChanged() {
|
||||
let totalDuration = 0
|
||||
|
||||
this.masterTask.employees = this.masterTask.employees.map(employee => {
|
||||
if (typeof employee.duration == 'string') {
|
||||
totalDuration += parseInt(employee.duration)
|
||||
employee.duration = parseInt(employee.duration)
|
||||
}
|
||||
else if (typeof employee.duration == 'number') {
|
||||
totalDuration += employee.duration
|
||||
}
|
||||
|
||||
return employee
|
||||
})
|
||||
|
||||
this.masterTask.duration = totalDuration
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
totalHours() {
|
||||
let hours = 0
|
||||
|
||||
this.masterTask.employees.forEach(function(employee) {
|
||||
if(employee.hours > 0) hours += parseFloat(employee.hours)
|
||||
})
|
||||
|
||||
return hours ? hours : 0
|
||||
},
|
||||
|
||||
employeesOptions() {
|
||||
const selectedEmployeesIds = this.masterTask.employees.map(
|
||||
(employee) => employee.id
|
||||
)
|
||||
const employees = this.employees.filter(
|
||||
(employee) => !selectedEmployeesIds.includes(employee.id)
|
||||
) || []
|
||||
|
||||
return employees.map((employee) => {
|
||||
return {
|
||||
key: employee.id,
|
||||
value: `${employee.name} ${employee.surname}`,
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
teamSelect(value) {
|
||||
if (!value || !this.masterTask) return
|
||||
|
||||
this.masterTask.team = this.teams.find(team => team.id == value)
|
||||
this.masterTask.team_id = this.masterTask.team.id
|
||||
this.masterTask.employees = this.masterTask.team.employees
|
||||
this.$nextTick(() => this.v$.$reset())
|
||||
},
|
||||
|
||||
employeeSelect(value) {
|
||||
if (!value || !this.masterTask) return
|
||||
|
||||
const employee = this.employees.find(employee => employee.id == value)
|
||||
this.masterTask.employees.push(employee)
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.employeeSelect = null
|
||||
this.$el.activeElement.blur()
|
||||
})
|
||||
},
|
||||
|
||||
projectCodeSelect(value) {
|
||||
if (!value || !this.masterTask) return
|
||||
this.masterTask.project_id = value
|
||||
},
|
||||
|
||||
editMode() {
|
||||
this.$nextTick(() => {
|
||||
this.$refs['description']?.setHTML(this.masterTask.description || '')
|
||||
@@ -589,20 +261,10 @@ export default {
|
||||
.border-bottom
|
||||
border-bottom: 1px solid rgba(0,0,0,.1)
|
||||
|
||||
|
||||
.subtask-btn
|
||||
border: thin solid rgba(var(--v-border-color), var(--v-border-opacity)) !important
|
||||
color: #7f39fb !important
|
||||
height: 53px
|
||||
text-align: center
|
||||
|
||||
v-table, tbody
|
||||
border-top: thin solid rgba(var(--v-border-color), var(--v-border-opacity))
|
||||
border-bottom: thin solid rgba(var(--v-border-color), var(--v-border-opacity))
|
||||
|
||||
td:not(:last-child)
|
||||
border-right: thin solid rgba(var(--v-border-color), var(--v-border-opacity))
|
||||
|
||||
@media screen and (max-width: 522px)
|
||||
.files
|
||||
margin-top: 104px !important
|
||||
</style>
|
||||
@@ -19,31 +19,32 @@
|
||||
|
||||
<!-- Toto treba fixnut -->
|
||||
<v-select
|
||||
v-model="masterTaskIdSelect"
|
||||
v-model="task.master_task.id"
|
||||
@focus="onInputFocus"
|
||||
class="modal-input border-select"
|
||||
label="MasterTask"
|
||||
label="Master task"
|
||||
variant="solo"
|
||||
:items="masterTasks"
|
||||
:class="{ error: v$.task.master_task.id.$errors.length }"
|
||||
item-value="id"
|
||||
item-title="name"
|
||||
></v-select>
|
||||
|
||||
<v-select
|
||||
v-model="employeeIdSelect"
|
||||
v-model="task.employee_id"
|
||||
@focus="onInputFocus"
|
||||
class="modal-input border-select"
|
||||
label="Priradený"
|
||||
:class="{ error: v$.task.employee_id.$errors.length }"
|
||||
variant="solo"
|
||||
:items="employees"
|
||||
:items="filteredEmployees"
|
||||
item-value="id"
|
||||
item-title="_fullName"
|
||||
></v-select>
|
||||
|
||||
<Datepicker
|
||||
<!-- <Datepicker
|
||||
class="modal-input mb-5"
|
||||
v-model="task.date"
|
||||
v-model="task.timeblocks"
|
||||
format="dd.MM.yyyy, HH:mm"
|
||||
locale="sk"
|
||||
:class="{ error: v$.task.date.$errors.length }"
|
||||
@@ -53,7 +54,7 @@
|
||||
cancel-text="Zrušiť"
|
||||
placeholder="Trvanie od - do"
|
||||
range
|
||||
/>
|
||||
/> -->
|
||||
|
||||
<v-text-field
|
||||
v-model="task.duration"
|
||||
@@ -71,12 +72,14 @@
|
||||
append-inner-icon="mdi-clock-outline"
|
||||
></v-text-field>
|
||||
|
||||
<div class="w-100 modal-input">
|
||||
<div class="w-100 modal-input" :class="{ error: v$.task.description.$errors.length }">
|
||||
<QuillEditor
|
||||
ref="description"
|
||||
v-model="task.description"
|
||||
placeholder="Popis"
|
||||
theme="snow"
|
||||
class="rich-text-editor"
|
||||
@input="task.description = $event.srcElement.innerHTML"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -394,29 +397,34 @@ export default {
|
||||
v$: useVuelidate(),
|
||||
preventInputFocus: false,
|
||||
masterTasks: [],
|
||||
employees: null,
|
||||
masterTaskIdSelect: null,
|
||||
employeeIdSelect: null,
|
||||
showDatePicker: false,
|
||||
selectedNewDate: []
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
employees() {
|
||||
if (!this.task?.master_task?.employees)
|
||||
filteredEmployees() {
|
||||
if (!this.employees || !this.task?.master_task)
|
||||
return []
|
||||
|
||||
return tmUtils.enrichEmployeesByFullName(this.task.master_task.employees)
|
||||
const selectedEmployees = this.task.master_task.employees?.map(employee => employee.id) || []
|
||||
const filteredEmployees = this.employees.filter(employee => !selectedEmployees.includes(employee.id))
|
||||
|
||||
return tmUtils.enrichEmployeesByFullName(filteredEmployees)
|
||||
}
|
||||
},
|
||||
|
||||
validations() {
|
||||
return {
|
||||
task: {
|
||||
date: { required },
|
||||
// team_id: { required },
|
||||
description: { required },
|
||||
master_task: {
|
||||
id: { required }
|
||||
},
|
||||
duration: { required },
|
||||
employee_id: { required },
|
||||
employee_id: { required }
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -428,32 +436,28 @@ export default {
|
||||
},
|
||||
|
||||
methods: {
|
||||
async showModal(task, editMode = false, masterTask = null) {
|
||||
async showModal(task, editMode = false, masterTask = {}) {
|
||||
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')
|
||||
this.employees = await this.$axios.get_auth_data('v1/employees')
|
||||
|
||||
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)
|
||||
t.employee = this.employees.find(employee => employee.id == t.employee_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: masterTask}
|
||||
this.masterTaskIdSelect = masterTask ? masterTask.id : null
|
||||
this.masterTaskIdSelect = masterTask.id
|
||||
}
|
||||
|
||||
console.log(this.task)
|
||||
|
||||
this.editMode = (editMode || !this.task.id)
|
||||
} catch (error) {
|
||||
this.$toast.error(error)
|
||||
@@ -468,14 +472,17 @@ export default {
|
||||
if (!(await this.v$.$validate()))
|
||||
return
|
||||
|
||||
this.task.description = this.$refs['description'].getHTML()
|
||||
|
||||
try {
|
||||
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)
|
||||
await this.$axios.put_auth_data(`v1/subtasks/${this.task.id}`, this.task)
|
||||
} else {
|
||||
await this.$axios.post_auth(`v1/mastertasks/${this.task.master_task.id}/subtasks`, this.task)
|
||||
const { subtask } = await this.$axios.post_auth(`v1/mastertasks/${this.task.master_task.id}/subtasks`, this.task)
|
||||
this.task.id = subtask.id
|
||||
}
|
||||
|
||||
this.$events.emit('on-task-edited', this.task)
|
||||
this.closeModal()
|
||||
} catch (error) {
|
||||
this.$toast.error(error)
|
||||
@@ -520,19 +527,20 @@ export default {
|
||||
if (!value || !this.task) return
|
||||
|
||||
this.task.master_task = this.masterTasks.find(masterTask => masterTask.id == value)
|
||||
const selectedMasterTask = this.masterTasks.find(masterTask => masterTask.id === value)
|
||||
if (selectedMasterTask) {
|
||||
this.task.project_code = selectedMasterTask.project_code
|
||||
this.task.project_code = this.task.master_task.project_code
|
||||
},
|
||||
|
||||
'task.employee_id'(value) {
|
||||
if (!value) return
|
||||
this.task.employee = this.employees.find(employee => employee.id == value)
|
||||
},
|
||||
|
||||
editMode() {
|
||||
this.$nextTick(() => {
|
||||
this.$refs['description']?.setHTML(this.task.description || '')
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
employeeIdSelect(value) {
|
||||
if (!value || !this.task) return
|
||||
|
||||
this.task.employee = this.task.master_task.employees.find(employee => employee.id == value)
|
||||
this.task.employee_id = value
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
</div>
|
||||
|
||||
<Z-autocomplete
|
||||
label="Vyhľadať zamestnanca"
|
||||
:options="employeesOptions"
|
||||
:validations="v$.team.employees"
|
||||
class="modal-input"
|
||||
|
||||
@@ -34,7 +34,7 @@ export default {
|
||||
|
||||
async post(url: string, params = null, config?: any) {
|
||||
|
||||
return axios.post(url, {data: params}, config)
|
||||
return axios.post(url, params, config)
|
||||
.then(response => response.data)
|
||||
.catch(error => Promise.reject(error))
|
||||
},
|
||||
@@ -42,14 +42,14 @@ export default {
|
||||
async post_auth(url: string, params = null, config?: any) {
|
||||
config = this._config(config)
|
||||
|
||||
return axios.post(url, {data: params}, config)
|
||||
return axios.post(url, params, config)
|
||||
.then(response => response.data)
|
||||
.catch(error => Promise.reject(error))
|
||||
},
|
||||
|
||||
async post_data(url: string, params = null, config?: any) {
|
||||
|
||||
return axios.post(url, {data: params}, config)
|
||||
return axios.post(url, params, config)
|
||||
.then(response => response.data.data)
|
||||
.catch(error => Promise.reject(error.response || error))
|
||||
},
|
||||
@@ -57,7 +57,7 @@ export default {
|
||||
async post_auth_data(url: string, params = null, config?: any) {
|
||||
config = this._config(config)
|
||||
|
||||
return axios.post(url, {data: params}, config)
|
||||
return axios.post(url, params, config)
|
||||
.then(response => response.data.data)
|
||||
.catch(error => Promise.reject(error.response || error))
|
||||
},
|
||||
@@ -91,7 +91,7 @@ export default {
|
||||
},
|
||||
|
||||
async patch(url: string, params = null, config?: any) {
|
||||
return axios.patch(url, {data: params}, config)
|
||||
return axios.patch(url, params, config)
|
||||
.then(response => response.data)
|
||||
.catch(error => Promise.reject(error))
|
||||
},
|
||||
@@ -99,13 +99,13 @@ export default {
|
||||
async patch_auth(url: string, params = null, config?: any) {
|
||||
config = this._config(config)
|
||||
|
||||
return axios.patch(url, {data: params}, config)
|
||||
return axios.patch(url, params, config)
|
||||
.then(response => response.data)
|
||||
.catch(error => Promise.reject(error))
|
||||
},
|
||||
|
||||
async patch_data(url: string, params = null, config?: any) {
|
||||
return axios.patch(url, {data: params}, config)
|
||||
return axios.patch(url, params, config)
|
||||
.then(response => response.data.data)
|
||||
.catch(error => Promise.reject(error.response || error))
|
||||
},
|
||||
@@ -113,13 +113,13 @@ export default {
|
||||
async patch_auth_data(url: string, params = null, config?: any) {
|
||||
config = this._config(config)
|
||||
|
||||
return axios.patch(url, {data: params}, config)
|
||||
return axios.patch(url, params, config)
|
||||
.then(response => response.data.data)
|
||||
.catch(error => Promise.reject(error.response || error))
|
||||
},
|
||||
|
||||
async put(url: string, params = null, config?: any) {
|
||||
return axios.put(url, {data: params}, config)
|
||||
return axios.put(url, params, config)
|
||||
.then(response => response.data)
|
||||
.catch(error => Promise.reject(error))
|
||||
},
|
||||
@@ -133,7 +133,7 @@ export default {
|
||||
},
|
||||
|
||||
async put_data(url: string, params = null, config?: any) {
|
||||
return axios.put(url, {data: params}, config)
|
||||
return axios.put(url, params, config)
|
||||
.then(response => response.data.data)
|
||||
.catch(error => Promise.reject(error.response || error))
|
||||
},
|
||||
@@ -141,7 +141,7 @@ export default {
|
||||
async put_auth_data(url: string, params = null, config?: any) {
|
||||
config = this._config(config)
|
||||
|
||||
return axios.put(url, {data: params}, config)
|
||||
return axios.put(url, params, config)
|
||||
.then(response => response.data.data)
|
||||
.catch(error => Promise.reject(error.response || error))
|
||||
},
|
||||
|
||||
@@ -142,7 +142,7 @@ export default {
|
||||
async put_auth_data(url: string, params = null, config?: any) {
|
||||
config = this._config(config)
|
||||
|
||||
return axios.put(url, this._objectToFormData(params), config)
|
||||
return axios.put(url, {data: params}, config)
|
||||
.then(response => response.data.data)
|
||||
.catch(error => Promise.reject(toastUtils.parseAndTranslate(error.response || error)))
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user