1+ <template >
2+ <v-flex md12 class =" pt-4" >
3+ <v-card class =" elevation-12" >
4+ <v-toolbar dark color =" orange" >
5+ <v-btn icon :loading =" isLoading" :to =" { name: 'logs' }" >
6+ <v-icon >arrow_back</v-icon >
7+ </v-btn >
8+ <v-toolbar-title >Update Attendance Settings</v-toolbar-title >
9+ <v-spacer ></v-spacer >
10+ </v-toolbar >
11+ <v-card-text >
12+ <v-container grid-list-md >
13+ <v-form ref =" form" >
14+
15+ <v-layout row wrap >
16+ <v-flex md6 >
17+ <v-menu
18+ ref =" menu"
19+ :close-on-content-click =" false"
20+ v-model =" menu.timeIn"
21+ :nudge-right =" 40"
22+ :return-value.sync =" form.timeIn"
23+ lazy
24+ transition =" scale-transition"
25+ offset-y
26+ full-width
27+ max-width =" 290px"
28+ min-width =" 290px" >
29+
30+ <v-text-field
31+ box
32+ color =" orange"
33+ slot =" activator"
34+ v-model =" form.timeIn"
35+ label =" Time In"
36+ readonly ></v-text-field >
37+
38+ <v-time-picker
39+ v-if =" menu.timeIn"
40+ v-model =" form.timeIn"
41+ full-width
42+ format =" 24hr"
43+ @change =" $refs.menu.save(form.timeIn)" ></v-time-picker >
44+ </v-menu >
45+ </v-flex >
46+ </v-layout >
47+
48+ <v-layout row wrap >
49+ <v-flex md6 >
50+ <v-menu
51+ ref =" menu"
52+ :close-on-content-click =" false"
53+ v-model =" menu.timeOut"
54+ :nudge-right =" 40"
55+ :return-value.sync =" form.timeOut"
56+ lazy
57+ transition =" scale-transition"
58+ offset-y
59+ full-width
60+ max-width =" 290px"
61+ min-width =" 290px" >
62+
63+ <v-text-field
64+ box
65+ color =" orange"
66+ slot =" activator"
67+ v-model =" form.timeOut"
68+ label =" Time Out"
69+ readonly ></v-text-field >
70+
71+ <v-time-picker
72+ v-if =" menu.timeOut"
73+ v-model =" form.timeOut"
74+ full-width
75+ format =" 24hr"
76+ @change =" $refs.menu.save(form.timeOut)" ></v-time-picker >
77+ </v-menu >
78+ </v-flex >
79+ </v-layout >
80+
81+ <v-layout row wrap >
82+ <v-flex md6 >
83+ <v-text-field
84+ box
85+ label =" Grace Period (Minutes)"
86+ color =" orange"
87+ v-model =" form.gracePeriod"
88+ v-validate =" 'required|numeric|min_value:0|max_value:60'"
89+ data-vv-name =" Grace Period"
90+ :error-messages =" errors.collect('Grace Period')" ></v-text-field >
91+ </v-flex >
92+ </v-layout >
93+
94+ <v-layout row wrap >
95+ <v-btn color =" success" :loading =" isLoading" @click.prevent =" submit" >Update</v-btn >
96+ </v-layout >
97+ </v-form >
98+ </v-container >
99+ </v-card-text >
100+ </v-card >
101+ </v-flex >
102+ </template >
103+
104+ <script >
105+ import { mapGetters } from ' vuex'
106+
107+ export default {
108+ data () {
109+ return {
110+ form: {},
111+ menu: {
112+ timeIn: false ,
113+ timeOut: false
114+ }
115+ }
116+ },
117+
118+ computed: {
119+ ... mapGetters ([" isLoading" , " settings" ]),
120+ },
121+
122+ methods: {
123+ async submit () {
124+ // validate form
125+ await this .$validator .validateAll ()
126+
127+ // Check if all fields are valid
128+ if (this .errors .items .length === 0 ) {
129+ const result = await this .$axios .put (' config' , JSON .stringify (this .form ))
130+ await this .$store .dispatch (' SET_SETTINGS' , result)
131+
132+ this .$notify ({ type: ' success' , text: ' Attendance Settings has been updated!' })
133+ this .$router .push ({ name: ' logs' })
134+ }
135+ }
136+ },
137+
138+ mounted () {
139+ this .form = this .settings
140+ }
141+ }
142+ </script >
0 commit comments