[tm@store] Added store

This commit is contained in:
Matej Glasnák committed 2023-02-15 15:56:24 +01:00
1 parent a1a410c54d
commit 774ca7b607
44 files changed
+989 -720

No files matched your search

+13 -9
View File
@@ -1,5 +1,5 @@
<template>
<v-dialog v-model="visible" max-width="650" max-height="90%" height="700px">
<v-dialog v-model="visible" max-width="750" max-height="90%" height="700px">
<W-loadable :content="team && allEmployees" class="h-100">
<v-card height="100%" class="d-flex flex-column">
<div class="d-flex justify-space-between align-center modal-header">
@@ -68,7 +68,6 @@ 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 axios from 'axios'
const atLeastOne = (value) => value.length
@@ -109,7 +108,7 @@ export default {
if (team?.id) {
const t = await this.$axios.get_auth_data(`v1/teams/${team.id}`)
this.team = {...t, employees: tmUtils.enrichEmployeesByFullName(t.employees)}
this.team = this._enrichTeam(t)
} else {
this.team = {employees: []}
}
@@ -126,16 +125,15 @@ export default {
async save() {
if (!(await this.v$.$validate())) return
try {
if (this.team.id) {
// await this.$axios.put_auth_data(`v1/teams/${this.team.id}`, this.team)
await axios.put(`v1/teams/${this.team.id}`, {data: this.team})
const { team } = await this.$axios.put_auth(`v1/teams/${this.team.id}`, this.team)
this.$store.commit('tm/update_team', team)
} else {
const { team } = await this.$axios.post_auth(`v1/teams`, this.team)
this.$store.commit('tm/save_team', team)
}
else
await this.$axios.post_auth_data(`v1/teams`, this.team)
this.$emit('update', this.team)
this.closeModal()
} catch (error) {
this.$toast.error(error)
@@ -145,6 +143,11 @@ export default {
employeeSelected(selectedOption) {
const employee = this.allEmployees.find((empl) => empl.id == selectedOption.key)
this.team.employees.push(employee)
},
_enrichTeam(team) {
team.employees = tmUtils.enrichEmployeesByFullName(team.employees)
return team
}
},
@@ -153,6 +156,7 @@ export default {
const selectedEmployeesIds = this.team.employees.map(
(employee) => employee.id
)
const employees = this.allEmployees.filter(
(employee) => !selectedEmployeesIds.includes(employee.id)
)