mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
606 lines
14 KiB
Vue
606 lines
14 KiB
Vue
<template>
|
|
<v-dialog v-model="visible" max-width="650" max-height="90%" height="700px">
|
|
<W-loadable :content="task" 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>{{ task.id ? 'Upraviť task' : 'Vytvoriť 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="task.project_code"
|
|
@focus="onInputFocus"
|
|
class="modal-input"
|
|
label="Kód projektu"
|
|
variant="solo"
|
|
disabled
|
|
></v-text-field>
|
|
|
|
<v-select
|
|
v-model="selectedMasterTask"
|
|
@focus="onInputFocus"
|
|
class="modal-input border-select"
|
|
label="MasterTask"
|
|
variant="solo"
|
|
:items="masterTasks"
|
|
item-value="id"
|
|
item-title="name"
|
|
></v-select>
|
|
|
|
<v-select
|
|
v-model="selectedEmployee"
|
|
@focus="onInputFocus"
|
|
class="modal-input border-select"
|
|
label="Priradený"
|
|
variant="solo"
|
|
:items="task.team.employees"
|
|
item-value="id"
|
|
item-title="_fullName"
|
|
></v-select>
|
|
|
|
<Datepicker
|
|
class="modal-input mb-5"
|
|
v-model="task.date"
|
|
format="dd.MM.yyyy, HH:mm"
|
|
locale="sk"
|
|
:class="{ error: v$.task.date.$errors.length }"
|
|
@focus="onDateFocus"
|
|
:validations="v$.task.date"
|
|
select-text="Vybrať"
|
|
cancel-text="Zrušiť"
|
|
placeholder="Trvanie od - do"
|
|
range
|
|
/>
|
|
|
|
<v-text-field
|
|
v-model="task.duration"
|
|
@focus="onInputFocus"
|
|
class="modal-input"
|
|
variant="solo"
|
|
type="number"
|
|
label="Časový odhad"
|
|
:class="{ error: v$.task.duration.$errors.length }"
|
|
:hint="
|
|
v$.task.duration.$errors
|
|
? errorUtils.parseErrors(v$.task.duration.$errors)
|
|
: null
|
|
"
|
|
append-inner-icon="mdi-clock-outline"
|
|
></v-text-field>
|
|
|
|
<v-textarea
|
|
v-model="task.description"
|
|
label="Popis"
|
|
class="modal-input"
|
|
variant="solo"
|
|
:class="{ error: v$.task.description.$errors.length }"
|
|
:hint="
|
|
v$.task.description.$errors
|
|
? errorUtils.parseErrors(v$.task.description.$errors)
|
|
: null
|
|
"
|
|
></v-textarea>
|
|
|
|
<Z-files-upload @files-uploaded="filesUploaded" />
|
|
</v-card-actions>
|
|
|
|
<v-btn class="z-btn" @click="save()">{{
|
|
task.id ? 'UPRAVIŤ' : '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>{{ task.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>{{ task.master_task }}</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-link" size="large"></v-icon>
|
|
<p class="mx-3">Mastertask</p>
|
|
</div>
|
|
</v-sheet>
|
|
</v-col>
|
|
<v-col cols="7">
|
|
<v-sheet class="ma-2">
|
|
<p class="task-badge px-4 py-2 rounded-pill">
|
|
{{ task.master_task }}
|
|
</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-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="task.is_finished"
|
|
class="status-badge px-4 py-2 rounded-pill"
|
|
>
|
|
Ukončený
|
|
</p>
|
|
<p
|
|
v-if="!task.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">Trvanie</p>
|
|
</div>
|
|
</v-sheet>
|
|
</v-col>
|
|
<v-col cols="7">
|
|
<v-sheet class="ma-2">
|
|
<p
|
|
v-html="
|
|
`${formattedStartDate} - ${formattedEndDate}`
|
|
"
|
|
/>
|
|
</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-outline"
|
|
size="large"
|
|
></v-icon>
|
|
<p class="mx-3">Priradený</p>
|
|
</div>
|
|
</v-sheet>
|
|
</v-col>
|
|
<v-col cols="7">
|
|
<v-sheet class="ma-2 d-flex flex-wrap">
|
|
<div
|
|
class="d-flex align-center mb-2 me-2"
|
|
v-for="(employee, index) in task.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="
|
|
`${task.employees[index].name} ${task.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>{{ (task.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">
|
|
<v-text-field
|
|
v-model="task.spent_time"
|
|
class="modal-input"
|
|
variant="solo"
|
|
type="number"
|
|
placeholder="h"
|
|
></v-text-field>
|
|
</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>{{ 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"
|
|
>
|
|
{{ task.description }}
|
|
</section>
|
|
<p class="mt-5">Prílohy</p>
|
|
<div class="w-100 d-flex align-center">
|
|
<div
|
|
v-for="(file, index) in task.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="done-btn">Dokončené</v-btn>
|
|
<v-btn class="add-employee-btn" @click="save()"
|
|
>Uložiť zmeny</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 moment from 'moment';
|
|
|
|
export default {
|
|
emits: ['close'],
|
|
|
|
components: {
|
|
Datepicker,
|
|
ZFilesUpload,
|
|
},
|
|
|
|
data() {
|
|
return {
|
|
editMode: false,
|
|
visible: false,
|
|
task: null,
|
|
errorUtils,
|
|
v$: useVuelidate(),
|
|
preventInputFocus: false,
|
|
employees: null,
|
|
selectedMasterTask: '',
|
|
showAddEmployeeInput: false,
|
|
masterTasks: null,
|
|
selectedEmployee: null,
|
|
};
|
|
},
|
|
|
|
validations() {
|
|
return {
|
|
task: {
|
|
project_code: { required },
|
|
date: { required },
|
|
team: { required },
|
|
duration: { required },
|
|
description: { required },
|
|
employee: { required },
|
|
},
|
|
};
|
|
},
|
|
|
|
async created() {
|
|
try {
|
|
this.masterTasks = await this.$axios.get_auth_data('v1/master-tasks');
|
|
this.employees = await this.$axios.get_auth_data('v1/employees');
|
|
} catch (error) {
|
|
this.$toast.error(error);
|
|
}
|
|
},
|
|
|
|
methods: {
|
|
async create(taskId = null, editMode = false) {
|
|
this.visible = true;
|
|
this.task = null;
|
|
|
|
if (taskId) {
|
|
await this._load(taskId);
|
|
this.editMode = editMode || !this.task?.id;
|
|
} else {
|
|
const task = {
|
|
project_code: null,
|
|
date: null,
|
|
team: {},
|
|
employee: null,
|
|
duration: null,
|
|
description: null,
|
|
files: [],
|
|
};
|
|
|
|
setTimeout(() => {
|
|
this.task = task;
|
|
this.editMode = editMode || !this.task.id;
|
|
});
|
|
}
|
|
},
|
|
|
|
async save() {
|
|
if (!(await this.v$.$validate())) return;
|
|
|
|
try {
|
|
if (this.task.id) await this._update();
|
|
else await this._create();
|
|
|
|
this.close();
|
|
this.$router.push({ name: 'Dashboard - Tasks' });
|
|
} catch (error) {
|
|
this.$toast.error(error);
|
|
}
|
|
},
|
|
|
|
close() {
|
|
this.visible = false;
|
|
this.$emit('close', this.task);
|
|
},
|
|
|
|
async _load(taskId) {
|
|
try {
|
|
this.task = await this.$axios.get_auth_data(`v1/tasks/${taskId}`);
|
|
} 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.task.id}`);
|
|
} catch (error) {
|
|
this.$toast.error(error);
|
|
}
|
|
},
|
|
|
|
async deleteTask(taskId) {
|
|
try {
|
|
await this.$axios.delete(`v1/tasks/${taskId}`);
|
|
this.close();
|
|
} catch (error) {
|
|
this.$toast.error(error);
|
|
}
|
|
},
|
|
|
|
employeeSelected(selectedOption) {
|
|
const employee = this.employees.find((empl) => empl.id == selectedOption.key);
|
|
this.task.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.task.files = files;
|
|
},
|
|
},
|
|
|
|
computed: {
|
|
employeesOptions() {
|
|
const selectedEmployeesIds = this.task.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}`,
|
|
};
|
|
});
|
|
},
|
|
|
|
formattedStartDate() {
|
|
let startDate = moment(this.task.starts_at);
|
|
let date = startDate.format('DD.MM.yyyy, HH:mm');
|
|
return date;
|
|
},
|
|
|
|
formattedEndDate() {
|
|
let endDate = moment(this.task.ends_at);
|
|
let date = endDate.format('DD.MM.yyyy, HH:mm');
|
|
return date;
|
|
},
|
|
},
|
|
|
|
watch: {
|
|
selectedMasterTask() {
|
|
this.task.team = this.masterTasks.find(
|
|
(masterTask) => masterTask.id == this.selectedMasterTask
|
|
);
|
|
console.log(this.task.team.employees)
|
|
this.task.team.employees.forEach(
|
|
(employee) => {
|
|
employee._fullName = `${employee.name} ${employee.surname}`
|
|
});
|
|
console.log(this.task.team.employees)
|
|
this.task.employee = null;
|
|
this.task.project_code = this.masterTasks.filter(
|
|
(x) => x.id == this.selectedMasterTask
|
|
)[0].project_code;
|
|
},
|
|
|
|
selectedEmployee() {
|
|
this.task.employee = this.task.team.employees.find(
|
|
(employee) => employee.id == this.selectedEmployee
|
|
);
|
|
},
|
|
},
|
|
};
|
|
</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
|
|
|
|
.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
|
|
width: 203px
|
|
.scrolling
|
|
overflow: hidden !important
|
|
|
|
.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)
|
|
|
|
.done-btn
|
|
background: #7f39fb !important
|
|
border-radius: 4px !important
|
|
color: #fff !important
|
|
height: 50px
|
|
width: 203px
|
|
</style>
|