mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
[subTask] v-select employee, [refactor], [masterTaskDetail] formattedDates
This commit is contained in:
1 parent
e941534b5e
commit
0a842dcb32
41 files changed
+558
-965
No files matched your search
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<v-dialog v-model="visible" max-width="650" max-height="90%" height="700px">
|
||||
<W-loadable :content="blocker && allEmployees" class="h-100">
|
||||
<W-loadable :content="blocker" class="h-100">
|
||||
<v-card height="100%" class="d-flex flex-column">
|
||||
<div class="d-flex justify-space-between align-center modal-header">
|
||||
<h1>{{ blocker.id ? 'Upraviť' : 'Vytvoriť'}} blocker</h1>
|
||||
@@ -62,7 +62,6 @@
|
||||
select-text="Vybrať"
|
||||
cancel-text="Zrušiť"
|
||||
placeholder="Trvanie od - do"
|
||||
:start-time="startTime"
|
||||
range
|
||||
/>
|
||||
</v-card-actions>
|
||||
@@ -139,18 +138,22 @@ export default {
|
||||
|
||||
methods: {
|
||||
async create(blocker = null) {
|
||||
this.visible = true
|
||||
this.blocker = null
|
||||
|
||||
if (blocker) {
|
||||
this.blocker = blocker
|
||||
await this._load()
|
||||
} else {
|
||||
this.blocker = {
|
||||
const blocker = {
|
||||
name: '',
|
||||
date: null,
|
||||
employees: []
|
||||
}
|
||||
}
|
||||
|
||||
this.visible = true
|
||||
setTimeout(() => {
|
||||
this.blocker = blocker
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
employeeSelected(selectedOption) {
|
||||
@@ -171,14 +174,13 @@ export default {
|
||||
this.close()
|
||||
this.$router.push({ name: 'Dashboard - Tasks' })
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
this.$toast(error)
|
||||
}
|
||||
},
|
||||
|
||||
close() {
|
||||
this.visible = false
|
||||
this.$emit('close', this.blocker)
|
||||
this.blocker = null
|
||||
},
|
||||
|
||||
async _create() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<v-dialog v-model="visible" max-width="650" max-height="90%" height="700px">
|
||||
<W-loadable :content="masterTask && employees" class="h-100">
|
||||
<W-loadable :content="masterTask" 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>
|
||||
@@ -69,7 +69,9 @@
|
||||
class="modal-input border-select"
|
||||
label="Tím"
|
||||
variant="solo"
|
||||
:items="teamsOptions"
|
||||
:items="teams"
|
||||
item-value="id"
|
||||
item-title="name"
|
||||
></v-select>
|
||||
|
||||
<v-text-field
|
||||
@@ -170,7 +172,7 @@
|
||||
</v-col>
|
||||
<v-col cols="7">
|
||||
<v-sheet class="ma-2">
|
||||
<p class="text-red-darken-4">{{ formattedDeadline }}</p>
|
||||
<p :class="`${compareDates ? 'text-black' : 'text-red-darken-4'}`">{{ formattedDeadline }}</p>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -212,7 +214,7 @@
|
||||
</v-col>
|
||||
<v-col cols="7">
|
||||
<v-sheet class="ma-2">
|
||||
<p>{{ (masterTask.duration / 60 / 60).toFixed(2) }} h</p>
|
||||
<p>{{ (masterTask.duration).toFixed(2) }} h</p>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -230,7 +232,7 @@
|
||||
</v-col>
|
||||
<v-col cols="7">
|
||||
<v-sheet class="ma-2">
|
||||
<p class="text-red-darken-4">{{ masterTask.worked_time }} h</p>
|
||||
<p :class="masterTask.worked_time > masterTask.duration ? 'text-red-darken-4': 'text-black'">{{ (masterTask.worked_time).toFixed(2) }} h</p>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -248,7 +250,7 @@
|
||||
</v-col>
|
||||
<v-col cols="7">
|
||||
<v-sheet class="ma-2">
|
||||
<p class="text-red-darken-4">{{ masterTask.remaining_time }} h</p>
|
||||
<p :class="masterTask.worked_time > masterTask.duration ? 'text-red-darken-4': 'text-black'">{{ (masterTask.duration - masterTask.worked_time).toFixed(2) }} h</p>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -359,10 +361,14 @@ export default {
|
||||
|
||||
methods: {
|
||||
async create(masterTaskId = null, editMode = false) {
|
||||
this.visible = true
|
||||
this.masterTask = null
|
||||
|
||||
if (masterTaskId) {
|
||||
await this._load(masterTaskId)
|
||||
this.editMode = editMode || (!this.masterTask?.id)
|
||||
} else {
|
||||
this.masterTask = {
|
||||
const masterTask = {
|
||||
project_code: null,
|
||||
name: null,
|
||||
deadline: null,
|
||||
@@ -372,10 +378,12 @@ export default {
|
||||
employees: [],
|
||||
files: []
|
||||
}
|
||||
}
|
||||
|
||||
this.editMode = editMode || (!this.masterTask.id)
|
||||
this.visible = true
|
||||
setTimeout(() => {
|
||||
this.masterTask = masterTask
|
||||
this.editMode = editMode || (!this.masterTask.id)
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
async save() {
|
||||
@@ -391,14 +399,13 @@ export default {
|
||||
this.close()
|
||||
this.$router.push({ name: 'Dashboard - Tasks' })
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
this.$toast(error)
|
||||
}
|
||||
},
|
||||
|
||||
close() {
|
||||
this.visible = false
|
||||
this.$emit('close', this.masterTask)
|
||||
this.masterTask = null
|
||||
},
|
||||
|
||||
async _load(masterTaskId) {
|
||||
@@ -460,9 +467,6 @@ export default {
|
||||
},
|
||||
|
||||
computed: {
|
||||
teamsOptions() {
|
||||
return this.teams.map(team => `${team.name} - ${team.id}`)
|
||||
},
|
||||
|
||||
totalHours() {
|
||||
let hours = 0
|
||||
@@ -470,7 +474,6 @@ export default {
|
||||
this.masterTask.employees.forEach(function(employee) {
|
||||
if(employee.hours > 0) hours += parseFloat(employee.hours)
|
||||
})
|
||||
console.log(hours)
|
||||
|
||||
return hours ? hours : 0
|
||||
},
|
||||
@@ -495,12 +498,18 @@ export default {
|
||||
let deadline = moment(this.masterTask.deadline)
|
||||
let date = deadline.format('DD.MM.yyyy')
|
||||
return date
|
||||
},
|
||||
|
||||
compareDates() {
|
||||
const date1 = moment()
|
||||
const date2 = moment(this.masterTask.deadline)
|
||||
return moment(date1).isBefore(date2)
|
||||
}
|
||||
},
|
||||
|
||||
watch: {
|
||||
selectedTeam() {
|
||||
this.masterTask.team = this.teams.find(team => `${team.name} - ${team.id}` == this.selectedTeam)
|
||||
this.masterTask.team = this.teams.find(team => team.id == this.selectedTeam)
|
||||
this.masterTask.employees = this.masterTask.team.employees
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,10 @@
|
||||
<template>
|
||||
<v-dialog v-model="visible" max-width="650" max-height="90%" height="700px">
|
||||
<W-loadable :content="task && employees" class="h-100">
|
||||
<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>
|
||||
<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">
|
||||
@@ -27,38 +23,21 @@
|
||||
class="modal-input border-select"
|
||||
label="MasterTask"
|
||||
variant="solo"
|
||||
:items="masterTaskOptions"
|
||||
:items="masterTasks"
|
||||
item-value="id"
|
||||
item-title="name"
|
||||
></v-select>
|
||||
|
||||
<p v-if="task.team.employees" class="d-flex justify-start align-center w-100 mb-3 text-grey">Priradení zamestnanci</p>
|
||||
|
||||
<v-text-field
|
||||
v-for="(employee, index) in task.employees"
|
||||
:key="employee.id"
|
||||
<v-select
|
||||
v-model="selectedEmployee"
|
||||
@focus="onInputFocus"
|
||||
class="modal-input"
|
||||
:value="`${employee.name} ${employee.surname}`"
|
||||
class="modal-input border-select"
|
||||
label="Priradený"
|
||||
variant="solo"
|
||||
v-model="task.employees[index].name"
|
||||
disabled
|
||||
>
|
||||
<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$.task.employees"
|
||||
:class="{ error: v$.task.employees.$errors.length }"
|
||||
class="modal-input"
|
||||
@option-selected="employeeSelected"
|
||||
/>
|
||||
|
||||
<v-btn class="w-100 mb-5 add-employee-btn" :disabled="!task.team.employees" @click="showAddEmployeeInput = true">
|
||||
<v-icon class="mx-1" icon="mdi-plus" />Pridať zamestnanca
|
||||
</v-btn>
|
||||
:items="task.team.employees"
|
||||
item-value="id"
|
||||
item-title="_fullName"
|
||||
></v-select>
|
||||
|
||||
<Datepicker
|
||||
class="modal-input mb-5"
|
||||
@@ -71,7 +50,6 @@
|
||||
select-text="Vybrať"
|
||||
cancel-text="Zrušiť"
|
||||
placeholder="Trvanie od - do"
|
||||
:start-time="startTime"
|
||||
range
|
||||
/>
|
||||
|
||||
@@ -92,6 +70,7 @@
|
||||
></v-text-field>
|
||||
|
||||
<v-textarea
|
||||
v-model="task.description"
|
||||
label="Popis"
|
||||
class="modal-input"
|
||||
variant="solo"
|
||||
@@ -101,13 +80,14 @@
|
||||
? errorUtils.parseErrors(v$.task.description.$errors)
|
||||
: null
|
||||
"
|
||||
v-model="task.description"
|
||||
></v-textarea>
|
||||
|
||||
<Z-files-upload @files-uploaded="filesUploaded"/>
|
||||
<Z-files-upload @files-uploaded="filesUploaded" />
|
||||
</v-card-actions>
|
||||
|
||||
<v-btn class="z-btn" @click="save()">{{ task.id ? 'UPRAVIŤ' : 'VYTVORIŤ' }}</v-btn>
|
||||
<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">
|
||||
@@ -120,11 +100,23 @@
|
||||
class="pb-5"
|
||||
></v-icon>
|
||||
</div>
|
||||
<div class="d-flex justify-space-between align-center modal-header border-bottom pb-4">
|
||||
<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()"/>
|
||||
<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>
|
||||
|
||||
@@ -134,17 +126,16 @@
|
||||
<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>
|
||||
<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>
|
||||
<p class="task-badge px-4 py-2 rounded-pill">
|
||||
{{ task.master_task }}
|
||||
</p>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -162,8 +153,18 @@
|
||||
</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>
|
||||
<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>
|
||||
@@ -181,7 +182,11 @@
|
||||
</v-col>
|
||||
<v-col cols="7">
|
||||
<v-sheet class="ma-2">
|
||||
<p v-html="`${formattedStartDate} - ${formattedEndDate}`" />
|
||||
<p
|
||||
v-html="
|
||||
`${formattedStartDate} - ${formattedEndDate}`
|
||||
"
|
||||
/>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -199,11 +204,25 @@
|
||||
</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) }}
|
||||
<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}`" />
|
||||
<p
|
||||
class="ml-2"
|
||||
v-html="
|
||||
`${task.employees[index].name} ${task.employees[index].surname}`
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
@@ -241,11 +260,11 @@
|
||||
<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-model="task.spent_time"
|
||||
class="modal-input"
|
||||
variant="solo"
|
||||
type="number"
|
||||
placeholder="h"
|
||||
></v-text-field>
|
||||
</v-sheet>
|
||||
</v-col>
|
||||
@@ -270,20 +289,34 @@
|
||||
</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>
|
||||
<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']">
|
||||
<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-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>
|
||||
<v-btn class="add-employee-btn" @click="save()"
|
||||
>Uložiť zmeny</v-btn
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</v-card-actions>
|
||||
@@ -293,15 +326,12 @@
|
||||
</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
|
||||
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'],
|
||||
@@ -309,7 +339,6 @@ export default {
|
||||
components: {
|
||||
Datepicker,
|
||||
ZFilesUpload,
|
||||
ZAutocomplete
|
||||
},
|
||||
|
||||
data() {
|
||||
@@ -323,8 +352,9 @@ export default {
|
||||
employees: null,
|
||||
selectedMasterTask: '',
|
||||
showAddEmployeeInput: false,
|
||||
masterTasks: null
|
||||
}
|
||||
masterTasks: null,
|
||||
selectedEmployee: null,
|
||||
};
|
||||
},
|
||||
|
||||
validations() {
|
||||
@@ -335,164 +365,178 @@ export default {
|
||||
team: { required },
|
||||
duration: { required },
|
||||
description: { required },
|
||||
employees: { atLeastOne }
|
||||
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')
|
||||
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)
|
||||
this.$toast.error(error);
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
async create(taskId = null, editMode = false) {
|
||||
this.visible = true;
|
||||
this.task = null;
|
||||
|
||||
if (taskId) {
|
||||
await this._load(taskId)
|
||||
await this._load(taskId);
|
||||
this.editMode = editMode || !this.task?.id;
|
||||
} else {
|
||||
this.task = {
|
||||
const task = {
|
||||
project_code: null,
|
||||
date: null,
|
||||
team: {},
|
||||
employees: [],
|
||||
employee: null,
|
||||
duration: null,
|
||||
description: null,
|
||||
files: []
|
||||
}
|
||||
}
|
||||
files: [],
|
||||
};
|
||||
|
||||
this.editMode = editMode || (!this.task.id)
|
||||
this.visible = true
|
||||
setTimeout(() => {
|
||||
this.task = task;
|
||||
this.editMode = editMode || !this.task.id;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
async save() {
|
||||
if (!(await this.v$.$validate()))
|
||||
return
|
||||
if (!(await this.v$.$validate())) return;
|
||||
|
||||
try {
|
||||
if (this.task.id)
|
||||
await this._update()
|
||||
else
|
||||
await this._create()
|
||||
if (this.task.id) await this._update();
|
||||
else await this._create();
|
||||
|
||||
this.close()
|
||||
this.$router.push({ name: 'Dashboard - Tasks' })
|
||||
this.close();
|
||||
this.$router.push({ name: 'Dashboard - Tasks' });
|
||||
} catch (error) {
|
||||
this.$toast.error(error)
|
||||
this.$toast.error(error);
|
||||
}
|
||||
},
|
||||
|
||||
close() {
|
||||
this.visible = false
|
||||
this.$emit('close', this.task)
|
||||
this.task = null
|
||||
this.visible = false;
|
||||
this.$emit('close', this.task);
|
||||
},
|
||||
|
||||
async _load(taskId) {
|
||||
try {
|
||||
this.task = await this.$axios.get_auth_data(`v1/tasks/${taskId}`)
|
||||
console.log(this.task)
|
||||
this.task = await this.$axios.get_auth_data(`v1/tasks/${taskId}`);
|
||||
} catch (error) {
|
||||
this.$toast.error(error)
|
||||
this.$toast.error(error);
|
||||
}
|
||||
},
|
||||
|
||||
async _create() {
|
||||
try {
|
||||
await this.$axios.post_auth('v1/master-tasks')
|
||||
await this.$axios.post_auth('v1/master-tasks');
|
||||
} catch (error) {
|
||||
this.$toast.error(error)
|
||||
this.$toast.error(error);
|
||||
}
|
||||
},
|
||||
|
||||
async _update() {
|
||||
try {
|
||||
await this.$axios.post_auth(`v1/master-tasks/${this.task.id}`)
|
||||
await this.$axios.post_auth(`v1/master-tasks/${this.task.id}`);
|
||||
} catch (error) {
|
||||
this.$toast.error(error)
|
||||
this.$toast.error(error);
|
||||
}
|
||||
},
|
||||
|
||||
async deleteTask(taskId) {
|
||||
try {
|
||||
await this.$axios.delete(`v1/tasks/${taskId}`)
|
||||
this.close()
|
||||
await this.$axios.delete(`v1/tasks/${taskId}`);
|
||||
this.close();
|
||||
} catch (error) {
|
||||
this.$toast.error(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
|
||||
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
|
||||
this.preventInputFocus = true;
|
||||
}
|
||||
},
|
||||
|
||||
onInputFocus($event) {
|
||||
if (this.preventInputFocus) {
|
||||
$event.target.blur()
|
||||
this.preventInputFocus = false
|
||||
$event.target.blur();
|
||||
this.preventInputFocus = false;
|
||||
}
|
||||
},
|
||||
|
||||
filesUploaded(files) {
|
||||
this.task.files = files
|
||||
}
|
||||
this.task.files = files;
|
||||
},
|
||||
},
|
||||
|
||||
computed: {
|
||||
masterTaskOptions() {
|
||||
return this.masterTasks.map(masterTask => `${masterTask.name} - ${masterTask.id}`)
|
||||
},
|
||||
|
||||
employeesOptions() {
|
||||
const selectedEmployeesIds = this.task.employees.map(
|
||||
(employee) => employee.id
|
||||
)
|
||||
const employees = this.employees.filter(
|
||||
(employee) => !selectedEmployeesIds.includes(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
|
||||
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
|
||||
}
|
||||
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.name} - ${masterTask.id}` == this.selectedMasterTask)
|
||||
this.task.employees = this.task.team.employees
|
||||
this.task.project_code = this.masterTasks.filter(x => `${x.name} - ${x.id}` == this.selectedMasterTask)[0].project_code
|
||||
}
|
||||
}
|
||||
}
|
||||
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>
|
||||
@@ -558,4 +602,4 @@ export default {
|
||||
color: #fff !important
|
||||
height: 50px
|
||||
width: 203px
|
||||
</style>
|
||||
</style>
|
||||
@@ -1,17 +1,17 @@
|
||||
<template>
|
||||
<v-dialog v-model="show" max-width="650">
|
||||
<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 zmazať tím <b>{{ team.name }}</b>?</h1>
|
||||
<v-icon
|
||||
@click.stop="show = false"
|
||||
icon="mdi-close"
|
||||
size="large"
|
||||
></v-icon>
|
||||
<h1>
|
||||
Ste si istý, že chcete zmazať tím <b>{{ team.name }}</b
|
||||
>?
|
||||
</h1>
|
||||
<v-icon @click.stop="visible = false" icon="mdi-close" size="large"></v-icon>
|
||||
</div>
|
||||
|
||||
<v-card-actions class="mt-10 d-flex justify-start align-center">
|
||||
<v-btn class="z-btn" variant="flat" @click="deleteTeam()">ÁNO</v-btn>
|
||||
<v-btn class="ml-7 cancel-btn" @click.stop="show = false">ZRUŠIŤ</v-btn>
|
||||
<v-btn class="ml-7 cancel-btn" @click.stop="visible = false">ZRUŠIŤ</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
@@ -19,41 +19,31 @@
|
||||
|
||||
<script>
|
||||
export default {
|
||||
emits: ['delete-team', 'close'],
|
||||
emits: ['deleted'],
|
||||
|
||||
props: {
|
||||
visible: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
},
|
||||
|
||||
team: {
|
||||
type: Object,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
show: {
|
||||
get() {
|
||||
return this.visible
|
||||
},
|
||||
|
||||
set(value) {
|
||||
if (!value) this.$emit('close')
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
visible: false,
|
||||
team: null,
|
||||
};
|
||||
},
|
||||
|
||||
methods: {
|
||||
async delete(team) {
|
||||
this.team = team
|
||||
this.visible = true
|
||||
},
|
||||
|
||||
async deleteTeam() {
|
||||
try {
|
||||
await this.$axios.delete(`v1/teams/${this.team.id}`)
|
||||
this.show = false
|
||||
|
||||
this.visible = false
|
||||
this.$emit('deleted', this.team)
|
||||
} catch (error) {
|
||||
this.$toast.error(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -116,28 +116,31 @@ export default {
|
||||
|
||||
this.close()
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
this.$toast(error)
|
||||
}
|
||||
},
|
||||
|
||||
async create(team = null) {
|
||||
if (team) {
|
||||
this.team = team
|
||||
async create(id = null) {
|
||||
this.visible = true
|
||||
this.team = null
|
||||
|
||||
if (id) {
|
||||
await this._load()
|
||||
} else {
|
||||
this.team = {
|
||||
const team = {
|
||||
name: '',
|
||||
employees: []
|
||||
}
|
||||
}
|
||||
|
||||
this.visible = true
|
||||
setTimeout(() => {
|
||||
this.team = team
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
close() {
|
||||
this.visible = false
|
||||
this.$emit('close', this.team)
|
||||
this.team = null
|
||||
},
|
||||
|
||||
async _create() {
|
||||
@@ -156,9 +159,9 @@ export default {
|
||||
}
|
||||
},
|
||||
|
||||
async _load() {
|
||||
async _load(id) {
|
||||
try {
|
||||
const team = await this.$axios.get_auth_data(`v1/teams/${this.team.id}`)
|
||||
const team = await this.$axios.get_auth_data(`v1/teams/${id}`)
|
||||
team.employees = this._enrichEmployeesByFullName(team.employees)
|
||||
|
||||
this.team = team
|
||||
|
||||
Reference in new issue
Block a user