[create-master-task-modal] input forms, upload files

This commit is contained in:
romankko2 committed 2022-12-06 17:46:57 +01:00
1 parent cae9832d87
commit bc26a84080
10 files changed
+263 -83

No files matched your search

@@ -11,22 +11,13 @@
></v-icon> ></v-icon>
</div> </div>
<v-card-actions class="d-flex flex-column-reverse modal-content"> <v-card-actions class="d-flex flex-column modal-content">
<Datepicker <v-text-field
@focus="onInputFocus"
class="modal-input" class="modal-input"
v-model="date" label="Názov blokeru"
:format="dateFormat" variant="solo"
locale="sk" ></v-text-field>
select-text="Vybrať"
cancel-text="Zrušiť"
placeholder="02.12.2022,10:17 - 18.12.2022,10:17"
range
/>
<W-autocomplete
:options="employeesOptions"
class="modal-input"
@option-selected="employeeSelected"
/>
<div <div
class="employee-position w-100" class="employee-position w-100"
v-for="(employee, index) in selectedEmployees" v-for="(employee, index) in selectedEmployees"
@@ -47,11 +38,22 @@
size="small" size="small"
></v-icon> ></v-icon>
</div> </div>
<v-text-field <W-autocomplete
:options="employeesOptions"
class="modal-input" class="modal-input"
label="Názov blokeru" @option-selected="employeeSelected"
variant="outlined" />
></v-text-field> <Datepicker
class="modal-input"
v-model="date"
:format="dateFormat"
locale="sk"
@focus="onDateFocus"
select-text="Vybrať"
cancel-text="Zrušiť"
placeholder="02.12.2022,10:17 - 18.12.2022,10:17"
range
/>
</v-card-actions> </v-card-actions>
<v-btn class="z-btn" @click="createBloker()">VYTVORIŤ</v-btn> <v-btn class="z-btn" @click="createBloker()">VYTVORIŤ</v-btn>
@@ -70,7 +72,12 @@ export default {
Datepicker, Datepicker,
}, },
props: ['visible'], props: {
visible: {
type: Boolean,
required: true
}
},
data() { data() {
return { return {
@@ -111,6 +118,20 @@ export default {
this.$toast.error(error.response.data.error) this.$toast.error(error.response.data.error)
} }
}, },
// 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
}
}
}, },
computed: { computed: {
@@ -166,7 +187,6 @@ export default {
flex: 1 1 100% flex: 1 1 100%
margin: 10px 0 margin: 10px 0
overflow-y: scroll overflow-y: scroll
justify-content: flex-end
.z-btn .z-btn
height: 50px height: 50px
@@ -0,0 +1,66 @@
<template>
<div>
<input
type="file"
multiple
name="file"
id="fileInput"
class="hidden-input"
@change="onChange"
ref="fileUpload"
accept="*"
/>
<v-btn class="upload-btn" @click="$refs.fileUpload.click()">
<v-icon class="mx-1" icon="mdi-cloud-upload-outline"></v-icon>NAHRAŤ
</v-btn>
<div v-if="files.length">
<div
v-for="file in files"
:key="file.name"
>
<v-chip>
{{ file.name }}
<v-icon class="mx-1" icon="mdi-paperclip"></v-icon>
<v-icon size="small" icon="mdi-close" @click.stop="remove(files.indexOf(file))"></v-icon>
</v-chip>
</div>
</div>
</div>
</template>
<script>
export default {
emit: ['files-uploaded'],
data() {
return {
files: [],
}
},
methods: {
onChange() {
this.files = [...this.files, ...this.$refs.fileUpload.files]
this.$emit('files-uploaded', this.files)
},
remove(index) {
this.files.splice(index, 1)
},
},
}
</script>
<style lang="sass" scoped>
.upload-btn
color: #6200EE
border-radius: 4px
border: 1px solid #E5E5E5
.hidden-input
opacity: 0
overflow: hidden
position: absolute
width: 1px
height: 1px
</style>
@@ -10,20 +10,21 @@
></v-icon> ></v-icon>
</div> </div>
<v-card-actions class="d-flex flex-column-reverse modal-content"> <v-card-actions class="d-flex flex-column modal-content">
<v-select
class="modal-input"
label="Tím"
variant="outlined"
></v-select>
<v-text-field <v-text-field
class="modal-input mt-5" @focus="onInputFocus"
label="Celkový odhad" class="modal-input"
variant="outlined" label="Kód projektu"
type="number" variant="solo"
placeholder="h" ></v-text-field>
<v-text-field
@focus="onInputFocus"
class="modal-input"
label="Názov mastertasku"
variant="solo"
></v-text-field> ></v-text-field>
<Datepicker <Datepicker
@focus="onDateFocus"
class="modal-input" class="modal-input"
v-model="date" v-model="date"
:format="dateFormat" :format="dateFormat"
@@ -33,15 +34,25 @@
placeholder="Deadline" placeholder="Deadline"
/> />
<v-text-field <v-text-field
class="modal-input" @focus="onInputFocus"
label="Názov mastertasku" class="modal-input mt-5"
variant="outlined" label="Celkový odhad"
variant="solo"
type="number"
placeholder="h"
></v-text-field> ></v-text-field>
<v-text-field <v-select
@focus="onInputFocus"
class="modal-input border-select"
label="Tím"
variant="solo"
></v-select>
<v-textarea
label="Popis"
class="modal-input" class="modal-input"
label="Kód projektu" variant="solo"
variant="outlined" ></v-textarea>
></v-text-field> <A-files-upload @files-uploaded="filesUploaded"/>
</v-card-actions> </v-card-actions>
<v-btn class="z-btn" @click="createMasterTask()">VYTVORIŤ</v-btn> <v-btn class="z-btn" @click="createMasterTask()">VYTVORIŤ</v-btn>
@@ -51,18 +62,26 @@
<script> <script>
import Datepicker from '@vuepic/vue-datepicker' import Datepicker from '@vuepic/vue-datepicker'
import AFilesUpload from '@/plugins/app/_components/a-files-upload.vue'
export default { export default {
props: ['visible'],
components: { components: {
Datepicker Datepicker,
AFilesUpload
},
props: {
visible: {
type: Boolean,
required: true
}
}, },
data() { data() {
return { return {
date: '', date: '',
dateFormat: 'dd.MM.yyyy, HH:mm' dateFormat: 'dd.MM.yyyy, HH:mm',
preventInputFocus: false
} }
}, },
@@ -76,6 +95,24 @@ export default {
this.$toast.error(error.response.data.error) this.$toast.error(error.response.data.error)
} }
}, },
// 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) {
console.log(files.length)
}
}, },
computed: { computed: {
@@ -103,7 +140,6 @@ export default {
flex: 1 1 100% flex: 1 1 100%
margin: 10px 0 margin: 10px 0
overflow-y: scroll overflow-y: scroll
justify-content: flex-end
.z-btn .z-btn
height: 50px height: 50px
@@ -34,7 +34,7 @@
class="modal-input" class="modal-input"
disabled disabled
label="Zamestanec" label="Zamestanec"
variant="outlined" variant="solo"
v-model="team.employees[index]._fullName" v-model="team.employees[index]._fullName"
> >
</v-text-field> </v-text-field>
@@ -1,7 +1,7 @@
<template> <template>
<v-dialog v-model="show" max-width="650" max-height="90%" height="700px"> <v-dialog v-model="show" max-width="650" max-height="90%" height="700px">
<W-loadable :content="employees" class="h-100"> <W-loadable :content="allEmployees" class="h-100">
<v-card v-if="employees" height="100%" class="d-flex flex-column"> <v-card height="100%" class="d-flex flex-column">
<div class="d-flex justify-space-between align-center modal-header"> <div class="d-flex justify-space-between align-center modal-header">
<h1>Vytvoriť tím</h1> <h1>Vytvoriť tím</h1>
<v-icon <v-icon
@@ -27,15 +27,15 @@
<div <div
class="employee-position w-100" class="employee-position w-100"
v-for="(employee, index) in selectedEmployees" v-for="(employee, index) in team.employees"
:key="employee.id" :key="employee.id"
> >
<v-text-field <v-text-field
class="modal-input" class="modal-input"
disabled disabled
label="Zamestanec" label="Zamestanec"
variant="outlined" variant="solo"
v-model="selectedEmployees[index]._fullName" v-model="team.employees[index]._fullName"
> >
</v-text-field> </v-text-field>
<v-icon <v-icon
@@ -48,6 +48,7 @@
<W-autocomplete <W-autocomplete
:options="employeesOptions" :options="employeesOptions"
:validations="v$.team.employees"
class="modal-input" class="modal-input"
@option-selected="employeeSelected" @option-selected="employeeSelected"
/> />
@@ -62,24 +63,38 @@
<script> <script>
import WAutocomplete from './w-autocomplete.vue' import WAutocomplete from './w-autocomplete.vue'
import useVuelidate from '@vuelidate/core' import useVuelidate from '@vuelidate/core'
import { required } from '@vuelidate/validators' import { required, minLength } from '@vuelidate/validators'
import errorUtils from '@/plugins/lib@auth/_utils/error.utils' import errorUtils from '@/plugins/lib@auth/_utils/error.utils'
const atLeastOne = (value) => value.length
export default { export default {
components: { components: {
WAutocomplete, WAutocomplete,
}, },
props: ['visible'], props: {
visible: {
type: Boolean,
required: true
},
teamId: {
type: Number || null,
required: false,
default: null
}
},
data() { data() {
return { return {
selectedEmployee: '', allEmployees: null,
selectedEmployees: [],
employees: null,
v$: useVuelidate(), v$: useVuelidate(),
errorUtils, errorUtils,
team: {}, team: {
name: '',
employees: []
},
} }
}, },
@@ -87,31 +102,45 @@ export default {
return { return {
team: { team: {
name: { required }, name: { required },
employees: { atLeastOne }
}, },
} }
}, },
async created() { async created() {
try { try {
this.employees = await this.$axios.get_auth_data('v1/employees') const allEmployees = await this.$axios.get_auth_data('v1/employees')
this.allEmployees = this._enrichEmployeesByFullName(allEmployees)
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
if (this.teamId) {
try {
const team = await this.$axios.get_auth_data(`v1/teams/${this.teamId}`)
team.employees = this._enrichEmployeesByFullName(this.team.employees)
this.team = team
} catch (error) {
console.log(error)
}
}
}, },
methods: { methods: {
removeInput(index) { removeInput(index) {
this.selectedEmployees.splice(index, 1) this.team.employees.splice(index, 1)
}, },
employeeSelected(selectedOption) { employeeSelected(selectedOption) {
const employee = this.employees.find((empl) => empl.id == selectedOption.key) const employee = this.allEmployees.find((empl) => empl.id == selectedOption.key)
employee._fullName = `${employee.name} ${employee.surname}` this.team.employees.push(employee)
this.selectedEmployees.push(employee)
}, },
async createTeam() { async createTeam() {
console.log(this.team)
if (!(await this.v$.$validate())) return console.log(this.v$) if (!(await this.v$.$validate())) return console.log(this.v$)
try { try {
@@ -122,14 +151,21 @@ export default {
this.$toast.error(error.response.data.error) this.$toast.error(error.response.data.error)
} }
}, },
_enrichEmployeesByFullName(employees) {
return employees.map(employee => {
employee._fullName = `${employee.name} ${employee.surname}`
return employee
})
}
}, },
computed: { computed: {
employeesOptions() { employeesOptions() {
const selectedEmployeesIds = this.selectedEmployees.map( const selectedEmployeesIds = this.team.employees.map(
(employee) => employee.id (employee) => employee.id
) )
const employees = this.employees.filter( const employees = this.allEmployees.filter(
(employee) => !selectedEmployeesIds.includes(employee.id) (employee) => !selectedEmployeesIds.includes(employee.id)
) )
@@ -150,19 +186,7 @@ export default {
if (!value) this.$emit('close') if (!value) this.$emit('close')
}, },
}, },
}, }
watch: {
selectedEmployee() {
const selectedEmployee = this.selectedEmployee.split(' ')
const employee = this.employees.find(
(e) => e.name == selectedEmployee[0] && e.surname == selectedEmployee[1]
)
this.selectedEmployees.push(JSON.parse(JSON.stringify(employee)))
},
},
} }
</script> </script>
@@ -2,9 +2,15 @@
<div class="wrapper"> <div class="wrapper">
<v-text-field <v-text-field
label="Vyhľadať zamestnanca" label="Vyhľadať zamestnanca"
variant="outlined" variant="solo"
v-model="search" v-model="search"
@keydown.enter="optionSelected()" @keydown.enter="optionSelected()"
:class="{ error: validations?.$errors?.length }"
:hint="
validations?.$errors
? errorUtils.parseErrors(validations?.$errors)
: null
"
/> />
<div class="suggestion" v-if="suggestion"> <div class="suggestion" v-if="suggestion">
@@ -15,6 +21,8 @@
</template> </template>
<script> <script>
import errorUtils from '@/plugins/lib@auth/_utils/error.utils'
export default { export default {
emits: ['option-selected'], emits: ['option-selected'],
@@ -22,11 +30,17 @@ export default {
options: { options: {
type: Array, type: Array,
required: true required: true
},
validations: {
type: Object || null,
required: false
} }
}, },
data() { data() {
return { return {
errorUtils,
search: '' search: ''
} }
}, },
@@ -84,7 +98,7 @@ export default {
.suggestion .suggestion
position: absolute position: absolute
top: 15.5px top: 27px
left: 15.5px left: 15.5px
opacity: 0.5 opacity: 0.5
letter-spacing: 0.009375em letter-spacing: 0.009375em
@@ -43,7 +43,7 @@
<v-list class="text-center"> <v-list class="text-center">
<v-list-item class="cursor-pointer hover-background">Working hours </v-list-item> <v-list-item class="cursor-pointer hover-background">Working hours </v-list-item>
<v-list-item> <v-list-item>
<v-btn class="button">Odhlásiť sa</v-btn> <v-btn class="button" @click="logOut()">Odhlásiť sa</v-btn>
</v-list-item> </v-list-item>
</v-list> </v-list>
</v-menu> </v-menu>
@@ -83,6 +83,18 @@ export default {
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
},
methods: {
async logOut() {
try {
await this.$store.dispatch('wAuth/logout')
this.$router.push('/')
this.$toast.success('Boli ste odhlásený')
} catch (error) {
this.$toast.error(error.data.error)
}
}
} }
} }
</script> </script>
+1 -1
View File
@@ -1,6 +1,6 @@
.dp__input .dp__input
height: 56px height: 56px
border: 1px solid #ABABAB !important border: 1px solid #E5E5E5 !important
.dp__range_end, .dp__range_start, .dp__active_date .dp__range_end, .dp__range_start, .dp__active_date
background: #7F39FB !important background: #7F39FB !important
+8
View File
@@ -25,3 +25,11 @@ th
.hover-background:hover .hover-background:hover
background-color: rgba(0, 0, 0, var(--v-hover-opacity)) background-color: rgba(0, 0, 0, var(--v-hover-opacity))
.v-input__control
border-radius: 4px
.border-select .v-input__control
border: 1px solid #E5E5E5 !important
@@ -1,4 +1,4 @@
.v-dialog .v-dialog
h1 h1
font-size: 22px font-size: 26px
font-weight: 300 font-weight: 500