[Mastertask] Added v-autocomplete

This commit is contained in:
Matej Glasnák committed 2023-04-11 14:22:56 +02:00
1 parent 5d6a2f9b66
commit 4a9dfc6520
4 files changed
+87 -86

No files matched your search

+21 -42
View File
@@ -1,53 +1,33 @@
<template>
<v-dialog v-model="visible" max-width="750" max-height="90%" height="700px">
<W-loadable :content="team && allEmployees" class="h-100">
<W-loadable :content="team" class="h-100">
<v-card height="100%" class="d-flex flex-column">
<div class="d-flex justify-space-between align-center modal-header">
<h1>{{ team.id ? 'Upraviť tím' : 'Vytvoriť tím' }}</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-text-field
class="modal-input"
label="Názov tímu"
variant="solo"
:class="{ error: v$.team.name.$errors.length }"
:hint="
<v-text-field class="modal-input" label="Názov tímu" variant="solo"
:class="{ error: v$.team.name.$errors.length }" :hint="
v$.team.name.$errors
? errorUtils.parseErrors(v$.team.name.$errors)
: null
"
v-model="team.name"
></v-text-field>
" v-model="team.name"></v-text-field>
<div
class="relative w-100"
v-for="(employee, index) in team.employees"
:key="employee.id"
>
<v-text-field
class="modal-input"
disabled
label="Zamestanec"
variant="solo"
v-model="team.employees[index]._fullName"
>
<div class="relative w-100" v-for="(employee, index) in team.employees" :key="employee.id">
<v-text-field class="modal-input" disabled label="Zamestanec" variant="solo"
v-model="team.employees[index]._fullName">
</v-text-field>
<v-icon
class="remove-input"
@click.stop="team.employees.splice(index, 1)"
icon="mdi-close"
size="small"
></v-icon>
<v-icon class="remove-input" @click.stop="team.employees.splice(index, 1)" icon="mdi-close"
size="small"></v-icon>
</div>
<v-autocomplete v-model="employeeSelect" label="Priradený" :class="{error: v$.team.employees.$errors.length}" :items="employeesOptions" item-title="_fullName" item-value="id" variant="solo" class="modal-input" clearable ref="autocomplete" />
<v-autocomplete v-model="employeeSelect" label="Priradený"
:class="{ error: v$.team.employees.$errors.length }" :items="employeesOptions"
item-title="_fullName" item-value="id" variant="solo" class="modal-input" clearable
ref="autocomplete" />
</v-card-actions>
<v-btn class="button primary block" @click="save()">{{ team.id ? 'UPRAVIŤ' : 'VYTVORIŤ' }}</v-btn>
@@ -57,11 +37,10 @@
</template>
<script>
// import ZAutocomplete from '@/plugins/tm@_components/z-autocomplete.vue'
import useVuelidate from '@vuelidate/core'
import { required } from '@vuelidate/validators'
import errorUtils from '@/plugins/lib@auth/_utils/error.utils'
import tmUtils from '@/plugins/tm@_utils/tm.utils'
import useVuelidate from '@vuelidate/core'
import { required } from '@vuelidate/validators'
import errorUtils from '@/plugins/lib@auth/_utils/error.utils'
import tmUtils from '@/plugins/tm@_utils/tm.utils'
import { mapGetters } from 'vuex'
const atLeastOne = (value) => value.length
@@ -103,7 +82,7 @@ export default {
},
methods: {
async showModal({ team = null}) {
async showModal({ team = null }) {
this.visible = true
this.team = null
this.$nextTick(() => this.v$.$reset())
@@ -111,9 +90,9 @@ export default {
try {
if (team?.id) {
const t = await this.$axios.get_auth_data(`v1/teams/${team.id}`)
this.team = this._enrichTeam(t)
this.team = this._enrichTeam(t)
} else {
this.team = {employees: []}
this.team = { employees: [] }
}
} catch (error) {
this.$toast.error(error)