mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
587 lines
16 KiB
Vue
587 lines
16 KiB
Vue
<template>
|
|
<v-dialog v-model="visible" max-width="650" max-height="90%" height="700px">
|
|
<W-loadable :content="masterTask && employees" class="h-100">
|
|
<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="close()"
|
|
icon="mdi-close"
|
|
size="large"
|
|
></v-icon>
|
|
</div>
|
|
|
|
<v-card-actions class="d-flex flex-column modal-content">
|
|
<v-text-field
|
|
v-model="masterTask.project_code"
|
|
@focus="onInputFocus"
|
|
class="modal-input"
|
|
label="Kód projektu"
|
|
variant="solo"
|
|
:class="{ error: v$.masterTask.project_code.$errors.length }"
|
|
:hint="
|
|
v$.masterTask.project_code.$errors
|
|
? errorUtils.parseErrors(v$.masterTask.project_code.$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"
|
|
/>
|
|
|
|
<v-text-field
|
|
v-model="masterTask.duration"
|
|
@focus="onInputFocus"
|
|
class="modal-input mt-5"
|
|
variant="solo"
|
|
type="number"
|
|
:value="totalHours"
|
|
disabled
|
|
:label="totalHours + ' h'"
|
|
></v-text-field>
|
|
|
|
<v-select
|
|
v-model="selectedTeam"
|
|
@focus="onInputFocus"
|
|
class="modal-input border-select"
|
|
label="Tím"
|
|
variant="solo"
|
|
:items="teamsOptions"
|
|
></v-select>
|
|
|
|
<v-text-field
|
|
v-for="(employee, index) in masterTask.employees"
|
|
:key="employee.id"
|
|
@focus="onInputFocus"
|
|
:class="{ error: masterTask.employees[index].hours < 0 }"
|
|
class="modal-input"
|
|
:label="`${employee.name} ${employee.surname}`"
|
|
variant="solo"
|
|
placeholder="h"
|
|
v-model="masterTask.employees[index].hours"
|
|
type="number"
|
|
min="1"
|
|
>
|
|
<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-btn class="w-100 mb-5 add-employee-btn" :disabled="!masterTask.team.employees" @click="showAddEmployeeInput = true">
|
|
<v-icon class="mx-1" icon="mdi-plus" />Pridať zamestnanca
|
|
</v-btn>
|
|
|
|
<v-textarea
|
|
:class="{ error: v$.masterTask.description.$errors.length }"
|
|
label="Popis"
|
|
class="modal-input"
|
|
variant="solo"
|
|
v-model="masterTask.description"
|
|
></v-textarea>
|
|
|
|
<Z-files-upload @files-uploaded="filesUploaded"/>
|
|
</v-card-actions>
|
|
|
|
<v-btn class="z-btn" @click="save()">VYTVORIŤ</v-btn>
|
|
</v-card>
|
|
|
|
<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="close()"
|
|
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>
|
|
<div class="d-flex justify-start">
|
|
<img class="pencil-icon" :src="require('@/plugins/tm@overview/_img/pencil-icon.svg')" alt="pencil-icon" @click.stop="editMode = !editMode" />
|
|
<img class="trash-icon" :src="require('@/plugins/tm@overview/_img/trash-icon.svg')" alt="trash-icon" @click.stop="deleteTask()"/>
|
|
</div>
|
|
</div>
|
|
|
|
<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="text-red-darken-4">{{ formattedDeadline }}</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-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="ma-2 d-flex scroll-employees">
|
|
<p class="task-badge px-4 py-2 rounded-pill flex-shrink-0">{{ masterTask.team }}</p>
|
|
<div class="d-flex align-center flex-shrink-0 mx-3" 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 / 60 / 60).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="text-red-darken-4">{{ masterTask.worked_time }} 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="text-red-darken-4">{{ masterTask.remaining_time }} h</p>
|
|
</v-sheet>
|
|
</v-col>
|
|
</v-row>
|
|
<div class="px-5 py-5 border-bottom">
|
|
<p>Popis zadania</p>
|
|
<section class="description-detail px-2 py-2 w-100 rounded mt-2">{{ masterTask.description }}</section>
|
|
<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">
|
|
{{ file.name }}
|
|
<v-icon class="mx-1" icon="mdi-paperclip"></v-icon>
|
|
</v-chip>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="d-flex justify-start align-center mt-8">
|
|
<v-btn class="z-btn" @click="save()">Ukončiť mastertask</v-btn>
|
|
</div>
|
|
<v-table class="mt-7 mb-5">
|
|
<tbody class="px-5 py-5">
|
|
<tr v-for="(employee, index) in masterTask.employees" :key="employee.id">
|
|
<td class="w-25">{{ masterTask.name }}</td>
|
|
<td class="d-flex align-center">
|
|
<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}`" />
|
|
</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" :style="{opacity: 0.3}">
|
|
<img class="trash-icon" :src="require('@/plugins/tm@overview/_img/trash-icon.svg')" alt="trash-icon" :style="{opacity: 0.3}">
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</v-table>
|
|
<div class="d-flex align-center ">
|
|
<v-btn class="subtask-btn w-100"><v-icon class="mx-1" icon="mdi-plus" />Pridať Subtask</v-btn>
|
|
</div>
|
|
</div>
|
|
</v-card-actions>
|
|
</v-card>
|
|
</W-loadable>
|
|
</v-dialog>
|
|
</template>
|
|
|
|
<script>
|
|
import Datepicker from '@vuepic/vue-datepicker'
|
|
import ZFilesUpload from '@/plugins/tm@_components/z-files-upload.vue'
|
|
import useVuelidate from '@vuelidate/core'
|
|
import { required } from '@vuelidate/validators'
|
|
import errorUtils from '@/plugins/lib@auth/_utils/error.utils'
|
|
import ZAutocomplete from '@/plugins/tm@_components/z-autocomplete.vue'
|
|
import moment from 'moment'
|
|
|
|
const atLeastOne = (value) => value.length
|
|
|
|
export default {
|
|
emits: ['close'],
|
|
|
|
components: {
|
|
Datepicker,
|
|
ZFilesUpload,
|
|
ZAutocomplete
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
editMode: false,
|
|
visible: false,
|
|
errorUtils,
|
|
v$: useVuelidate(),
|
|
preventInputFocus: false,
|
|
teams: null,
|
|
employees: null,
|
|
selectedTeam: '',
|
|
showAddEmployeeInput: false,
|
|
masterTask: null
|
|
}
|
|
},
|
|
|
|
validations() {
|
|
return {
|
|
masterTask: {
|
|
project_code: { required },
|
|
name: { required },
|
|
team: { required },
|
|
deadline: { required },
|
|
description: { required },
|
|
employees: { atLeastOne }
|
|
},
|
|
}
|
|
},
|
|
|
|
async created() {
|
|
try {
|
|
this.teams = await this.$axios.get_auth_data('v1/teamsx')
|
|
this.employees = await this.$axios.get_auth_data('v1/employees')
|
|
// this.masterTask = await this.$axios.get_auth_data(`v1/master-task/${this.masterTaksId}`)
|
|
// this.selectedTeam = `${this.masterTask.team.name} - ${this.masterTask.team.id}`)
|
|
} catch (error) {
|
|
this.$toast.error(error)
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
async create(masterTaskId = null, editMode = false) {
|
|
if (masterTaskId) {
|
|
await this._load(masterTaskId)
|
|
} else {
|
|
this.masterTask = {
|
|
project_code: null,
|
|
name: null,
|
|
deadline: null,
|
|
duration: null,
|
|
team: {},
|
|
description: null,
|
|
employees: [],
|
|
files: []
|
|
}
|
|
}
|
|
|
|
this.editMode = editMode || (!this.masterTask.id)
|
|
this.visible = true
|
|
},
|
|
|
|
async save() {
|
|
if (!(await this.v$.$validate()))
|
|
return
|
|
|
|
try {
|
|
if (this.masterTask.id)
|
|
await this._update()
|
|
else
|
|
await this._create()
|
|
|
|
this.close()
|
|
this.$router.push({ name: 'Dashboard - Tasks' })
|
|
} catch (error) {
|
|
console.log(error)
|
|
}
|
|
},
|
|
|
|
close() {
|
|
this.visible = false
|
|
this.$emit('close', this.masterTask)
|
|
this.masterTask = null
|
|
},
|
|
|
|
async _load(masterTaskId) {
|
|
try {
|
|
this.masterTask = await this.$axios.get_auth_data(`v1/master-tasks/${masterTaskId}`)
|
|
} catch (error) {
|
|
this.$toast.error(error)
|
|
}
|
|
},
|
|
|
|
async _create() {
|
|
try {
|
|
await this.$axios.post_auth('v1/master-tasks')
|
|
} catch (error) {
|
|
this.$toast.error(error)
|
|
}
|
|
},
|
|
|
|
async _update() {
|
|
try {
|
|
await this.$axios.post_auth(`v1/master-tasks/${this.masterTask.id}`)
|
|
} catch (error) {
|
|
this.$toast.error(error)
|
|
}
|
|
},
|
|
|
|
async deleteTask(masterTaskId) {
|
|
try {
|
|
await this.$axios.delete(`v1/master-tasks/${masterTaskId}`)
|
|
this.close()
|
|
} catch (error) {
|
|
this.$toast.error(error)
|
|
}
|
|
},
|
|
|
|
employeeSelected(selectedOption) {
|
|
const employee = this.employees.find((empl) => empl.id == selectedOption.key)
|
|
this.masterTask.employees.push(employee)
|
|
this.showAddEmployeeInput = false
|
|
},
|
|
|
|
// Vuetify input was automatically focus after date input was clicked. This will prevent this unwanted behavior
|
|
onDateFocus($event) {
|
|
if ($event == undefined) {
|
|
this.preventInputFocus = true
|
|
}
|
|
},
|
|
|
|
onInputFocus($event) {
|
|
if (this.preventInputFocus) {
|
|
$event.target.blur()
|
|
this.preventInputFocus = false
|
|
}
|
|
},
|
|
|
|
filesUploaded(files) {
|
|
this.masterTask.files = files
|
|
}
|
|
},
|
|
|
|
computed: {
|
|
teamsOptions() {
|
|
return this.teams.map(team => `${team.name} - ${team.id}`)
|
|
},
|
|
|
|
totalHours() {
|
|
let hours = 0
|
|
|
|
this.masterTask.employees.forEach(function(employee) {
|
|
if(employee.hours > 0) hours += parseFloat(employee.hours)
|
|
})
|
|
console.log(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}`,
|
|
}
|
|
})
|
|
},
|
|
|
|
formattedDeadline() {
|
|
let deadline = moment(this.masterTask.deadline)
|
|
let date = deadline.format('DD.MM.yyyy')
|
|
return date
|
|
}
|
|
},
|
|
|
|
watch: {
|
|
selectedTeam() {
|
|
this.masterTask.team = this.teams.find(team => `${team.name} - ${team.id}` == this.selectedTeam)
|
|
this.masterTask.employees = this.masterTask.team.employees
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="sass" scoped>
|
|
.modal-input
|
|
width: 100% !important
|
|
flex: 0 0 auto
|
|
.modal-header
|
|
flex: 0 0 auto
|
|
|
|
.modal-content
|
|
flex: 1 1 100%
|
|
margin: 10px 0
|
|
overflow-y: scroll
|
|
|
|
.z-btn
|
|
height: 50px
|
|
width: 100%
|
|
flex: 0 0 auto
|
|
|
|
.remove-input
|
|
pointer-events: auto
|
|
opacity: 2
|
|
position: absolute
|
|
left: 92%
|
|
top: 25%
|
|
|
|
.employee-position
|
|
position: relative
|
|
|
|
.employee-select-avatar
|
|
background: #6200EE
|
|
color: #fff
|
|
border-radius: 50%
|
|
padding: 13px
|
|
font-size: 11.5px
|
|
height: 24px
|
|
width: 24px
|
|
position: absolute
|
|
top: 50%
|
|
right: 0
|
|
transform: translate(-50%, -50%)
|
|
|
|
.add-employee-btn
|
|
color: #6200EE
|
|
border: 1px solid #E0E0E0
|
|
border-radius: 4px
|
|
height: 50px
|
|
.scrolling
|
|
overflow: hidden !important
|
|
|
|
.scroll-employees
|
|
overflow-x: scroll
|
|
.trash-icon
|
|
padding: 10px
|
|
background: rgba(0, 0, 0, 0.04)
|
|
margin-left: 12px
|
|
border-radius: 50%
|
|
cursor: pointer
|
|
.pencil-icon
|
|
padding: 10px
|
|
background: rgba(0, 0, 0, 0.04)
|
|
border-radius: 50%
|
|
cursor: pointer
|
|
|
|
.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))
|
|
</style> |