uprava modalov, [ongoing, unscheduled tasks] filter

This commit is contained in:
romankko2 committed 2022-12-26 13:04:54 +01:00
1 parent 278bdeabc7
commit 67afa56736
16 files changed
+647 -353

No files matched your search

@@ -1,120 +1,122 @@
<template>
<v-dialog v-model="show" max-width="650" max-height="90%" height="700px">
<v-card height="100%" class="d-flex flex-column scrolling">
<div class="d-flex justify-space-between align-center modal-header">
<h1>Vytvoriť master task</h1>
<v-icon
@click.stop="show = false"
icon="mdi-close"
size="large"
></v-icon>
</div>
<v-dialog v-model="visible" max-width="650" max-height="90%" height="700px">
<W-loadable :content="masterTask" class="h-100">
<v-card height="100%" class="d-flex flex-column scrolling">
<div class="d-flex justify-space-between align-center modal-header">
<h1>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-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>
<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"
:value="totalHours"
disabled
:label="totalHours + ' h'"
></v-text-field>
<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-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>
<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"
/>
<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-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>
<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>
<Z-files-upload @files-uploaded="filesUploaded"/>
</v-card-actions>
<v-btn class="z-btn" @click="save()">VYTVORIŤ</v-btn>
</v-card>
<v-btn class="z-btn" @click="save()">VYTVORIŤ</v-btn>
</v-card>
</W-loadable>
</v-dialog>
</template>
@@ -129,44 +131,25 @@ import ZAutocomplete from '@/plugins/tm@_components/z-autocomplete.vue'
const atLeastOne = (value) => value.length
export default {
emits: ['close'],
components: {
Datepicker,
ZFilesUpload,
ZAutocomplete
},
props: {
visible: {
type: Boolean,
required: true
},
masterTaskId: {
type: Number || null,
required: false,
default: null
}
},
data() {
return {
masterTask: {
project_code: null,
name: null,
deadline: null,
duration: null,
team: {},
description: null,
employees: [],
files: []
},
visible: false,
errorUtils,
v$: useVuelidate(),
preventInputFocus: false,
teams: null,
employees: null,
selectedTeam: '',
showAddEmployeeInput: false
showAddEmployeeInput: false,
masterTask: null
}
},
@@ -187,7 +170,6 @@ export default {
try {
this.teams = await this.$axios.get_auth_data('v1/teams')
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) {
@@ -196,8 +178,29 @@ export default {
},
methods: {
async create(masterTask = null) {
if (masterTask) {
this.masterTask = masterTask
await this._load()
} else {
this.masterTask = {
project_code: null,
name: null,
deadline: null,
duration: null,
team: {},
description: null,
employees: [],
files: []
}
}
this.visible = true
},
async save() {
if (!(await this.v$.$validate())) return console.log(this.v$)
if (!(await this.v$.$validate()))
return
try {
if (this.masterTask.id)
@@ -205,13 +208,19 @@ export default {
else
await this._create()
this.close()
this.$router.push({ name: 'Dashboard - Tasks' })
this.show = false
} catch (error) {
console.log(error)
}
},
close() {
this.visible = false
this.$emit('close', this.masterTask)
this.masterTask = null
},
async _create() {
try {
await this.$axios.post_auth('v1/master-tasks')
@@ -283,17 +292,7 @@ export default {
value: `${employee.name} ${employee.surname}`,
}
})
},
show: {
get() {
return this.visible
},
set(value) {
if (!value) this.$emit('close')
}
},
}
},
watch: {