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