@@ -5,6 +5,7 @@
|
|||||||
@save="submitForm"
|
@save="submitForm"
|
||||||
@toggleEdit="toggleEdit"
|
@toggleEdit="toggleEdit"
|
||||||
/>
|
/>
|
||||||
|
{{employeeStore.employee }}
|
||||||
|
|
||||||
<form class="text-start" @keyup.enter="submitForm">
|
<form class="text-start" @keyup.enter="submitForm">
|
||||||
<div class="row mb-5">
|
<div class="row mb-5">
|
||||||
@@ -170,7 +171,8 @@
|
|||||||
|
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { toRefs, ref, computed, onMounted } from 'vue'
|
import { ref, watch, computed, onMounted } from 'vue'
|
||||||
|
import { useRouter } from 'vue-router'
|
||||||
import { useVuelidate } from '@vuelidate/core'
|
import { useVuelidate } from '@vuelidate/core'
|
||||||
import { required, email, between, decimal, sameAs, requiredIf, helpers } from '@vuelidate/validators'
|
import { required, email, between, decimal, sameAs, requiredIf, helpers } from '@vuelidate/validators'
|
||||||
import { storeToRefs } from 'pinia'
|
import { storeToRefs } from 'pinia'
|
||||||
@@ -178,6 +180,7 @@ import { useUser } from '@/stores/user'
|
|||||||
import { useEmployee } from '@/stores/employee'
|
import { useEmployee } from '@/stores/employee'
|
||||||
import EmployeeFormControls from '@/components/Employees/EmployeeFormControls.vue'
|
import EmployeeFormControls from '@/components/Employees/EmployeeFormControls.vue'
|
||||||
import { IMaskComponent as MaskInput } from 'vue-imask'
|
import { IMaskComponent as MaskInput } from 'vue-imask'
|
||||||
|
import employees from '@/stores/employees'
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -193,6 +196,7 @@ const props = defineProps<{
|
|||||||
const userStore = useUser()
|
const userStore = useUser()
|
||||||
const employeeStore = useEmployee()
|
const employeeStore = useEmployee()
|
||||||
const { employee, userEnabled } = storeToRefs(employeeStore)
|
const { employee, userEnabled } = storeToRefs(employeeStore)
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Local Refs
|
* Local Refs
|
||||||
@@ -211,7 +215,7 @@ const editEmployee = ref(props.id ? false : true)
|
|||||||
})
|
})
|
||||||
|
|
||||||
if(error === undefined){
|
if(error === undefined){
|
||||||
return true
|
return true // return helpers.withMessage("", () => true) doesn't work!!!!
|
||||||
}
|
}
|
||||||
else return helpers.withMessage(error.message, () => false)
|
else return helpers.withMessage(error.message, () => false)
|
||||||
}
|
}
|
||||||
@@ -277,18 +281,26 @@ function toggleEdit() {
|
|||||||
async function submitForm(){
|
async function submitForm(){
|
||||||
if(await v$.value.$validate()) {
|
if(await v$.value.$validate()) {
|
||||||
if(employee.value.id){
|
if(employee.value.id){
|
||||||
employeeStore.patchEmployee()
|
await employeeStore.patchEmployee()
|
||||||
// werte apiValidation aus!!!
|
|
||||||
|
|
||||||
toggleEdit()
|
toggleEdit()
|
||||||
}
|
}
|
||||||
else {
|
else if(await employeeStore.postEmployee()){
|
||||||
employeeStore.postEmployee()
|
router.push({name: "Employees/Index"})
|
||||||
// werte apiValidation aus!!!
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Watch State
|
||||||
|
*/
|
||||||
|
watch(employee, () => {
|
||||||
|
v$.value.$reset()
|
||||||
|
employeeStore.apiValidationErrors = []
|
||||||
|
},{
|
||||||
|
deep: true
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the Component
|
* Initialize the Component
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import axios from '@/axios'
|
|||||||
import { useUser } from './user'
|
import { useUser } from './user'
|
||||||
import { useNotifications } from './notifications'
|
import { useNotifications } from './notifications'
|
||||||
import Axios from 'axios'
|
import Axios from 'axios'
|
||||||
|
import { stubFalse } from 'lodash'
|
||||||
|
|
||||||
const user = useUser()
|
const user = useUser()
|
||||||
const notifications = useNotifications()
|
const notifications = useNotifications()
|
||||||
@@ -142,6 +143,7 @@ export const useEmployee = defineStore({
|
|||||||
notifications.add('success', result.statusText)
|
notifications.add('success', result.statusText)
|
||||||
|
|
||||||
console.log(result)
|
console.log(result)
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
catch(error){
|
catch(error){
|
||||||
console.log("enter catch")
|
console.log("enter catch")
|
||||||
@@ -151,6 +153,7 @@ export const useEmployee = defineStore({
|
|||||||
console.log(data)
|
console.log(data)
|
||||||
this.apiValidationErrors = [...data.errors]
|
this.apiValidationErrors = [...data.errors]
|
||||||
}
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user