PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / trunk
Booking for Appointments and Events Calendar – Amelia vtrunk
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / v3 / src / store / modules / appointment.js
ameliabooking / v3 / src / store / modules Last commit date
appointment.js 1 day ago appointmentWaitingListOptions.js 1 day ago attendee.js 1 day ago auth.js 1 day ago bookableType.js 1 day ago booking.js 1 day ago cabinet.js 1 day ago cabinetFilters.js 1 day ago coupon.js 1 day ago customFields.js 1 day ago customerInfo.js 1 day ago employee.js 1 day ago entities.js 1 day ago event.js 1 day ago eventBooking.js 1 day ago eventEntities.js 1 day ago eventWaitingListOptions.js 1 day ago pagination.js 1 day ago params.js 1 day ago payment.js 1 day ago persons.js 1 day ago recurring.js 1 day ago shortcodeParams.js 1 day ago stepByStepFilters.js 1 day ago tickets.js 1 day ago
appointment.js
349 lines
1 function getDefaultAppointment() {
2 return {
3 id: null,
4 categoryId: null,
5 serviceId: null,
6 locationId: null,
7 lessonSpace: null,
8 providerId: null,
9 startDate: '',
10 startTime: '',
11 notifyParticipants: true,
12 createPaymentLinks: true,
13 internalNotes: '',
14 bookings: [],
15 customFields: [],
16 customFieldsRules: {},
17 employeeService: null,
18 targetedDate: null,
19 active: false,
20 }
21 }
22
23 export default {
24 namespaced: true,
25
26 state: getDefaultAppointment(),
27
28 getters: {
29 getSelection(state) {
30 return {
31 categoryId: state.categoryId,
32 serviceId: state.serviceId,
33 providerId: state.providerId,
34 locationId: state.locationId,
35 }
36 },
37
38 getId(state) {
39 return state.id
40 },
41
42 getCategoryId(state) {
43 return state.categoryId
44 },
45
46 getServiceId(state) {
47 return state.serviceId
48 },
49
50 getProviderId(state) {
51 return state.providerId
52 },
53
54 getLocationId(state) {
55 return state.locationId
56 },
57
58 getLessonSpace(state) {
59 return state.lessonSpace
60 },
61
62 getStartDate(state) {
63 return state.startDate
64 },
65
66 getStartTime(state) {
67 return state.startTime
68 },
69
70 getNotifyParticipants(state) {
71 return state.notifyParticipants
72 },
73
74 getCreatePaymentLinks(state) {
75 return state.createPaymentLinks
76 },
77
78 getInternalNotes(state) {
79 return state.internalNotes
80 },
81
82 getBooking: (state) => (index) => {
83 return state.bookings[index]
84 },
85
86 getBookings(state) {
87 return state.bookings
88 },
89
90 getAppointmentData(state) {
91 return {
92 id: state.id,
93 categoryId: state.categoryId,
94 serviceId: state.serviceId,
95 locationId: state.locationId,
96 lessonSpace: state.lessonSpace,
97 providerId: state.providerId,
98 startDate: state.startDate,
99 startTime: state.startTime,
100 notifyParticipants: state.notifyParticipants,
101 internalNotes: state.internalNotes,
102 bookings: state.bookings,
103 }
104 },
105
106 getEmployeeService(state) {
107 return state.employeeService
108 },
109
110 getTargetedDate(state) {
111 return state.targetedDate
112 },
113
114 getActive(state) {
115 return state.active
116 },
117
118 getCustomFields(state) {
119 return state.customFields
120 },
121
122 getCustomFieldsRules(state) {
123 return state.customFieldsRules
124 },
125 },
126
127 mutations: {
128 resetAppointment(state, payload) {
129 Object.assign(state, getDefaultAppointment(), payload)
130 },
131
132 setAppointment(state, payload) {
133 Object.assign(state, payload)
134 },
135
136 setCategoryId(state, payload) {
137 state.categoryId = payload
138 },
139
140 setServiceId(state, payload) {
141 state.serviceId = payload
142 },
143
144 setProviderId(state, payload) {
145 state.providerId = payload
146 },
147
148 setLocationId(state, payload) {
149 state.locationId = payload
150 },
151
152 setLessonSpace(state, payload) {
153 state.lessonSpace = payload
154 },
155
156 setStartDate(state, payload) {
157 state.startDate = payload
158 },
159
160 setStartTime(state, payload) {
161 state.startTime = payload
162 },
163
164 setNotifyParticipants(state, payload) {
165 state.notifyParticipants = payload
166 },
167
168 setCreatePaymentLinks(state, payload) {
169 state.createPaymentLinks = payload
170 },
171
172 setInternalNotes(state, payload) {
173 state.internalNotes = payload
174 },
175
176 setBooking(state, payload) {
177 if (state.bookings.length === payload.index) {
178 state.bookings.push(payload.value)
179 } else {
180 state.bookings[payload.index] = payload.value
181 }
182 },
183
184 setCustomFields(state, payload) {
185 state.customFields = payload
186 },
187
188 setEmployeeService(state, payload) {
189 state.employeeService = payload
190 },
191
192 setTargetedDate(state, payload) {
193 state.targetedDate = payload
194 },
195
196 setActive(state, payload) {
197 state.active = payload
198 },
199
200 setBookingStatus(state, payload) {
201 state.bookings[payload.index].status = payload.value
202 },
203
204 setAllBookingsStatus(state, payload) {
205 state.bookings.forEach((booking) => {
206 booking.status = payload
207 })
208 },
209
210 setBookingPersons(state, payload) {
211 state.bookings[payload.index].persons = payload.value
212 },
213
214 setBookingDuration(state, payload) {
215 state.bookings[payload.index].duration = payload.value
216 },
217 },
218
219 actions: {
220 serviceCustomFieldsFiltration({ state, commit, rootGetters }) {
221 if (state.employeeService !== null) {
222 let customFieldsEntity = rootGetters['entities/getCustomFields']
223 let filteredCustomFields = customFieldsEntity.filter(
224 (i) =>
225 i.allServices ||
226 (i.services.map((s) => s.id).indexOf(state.employeeService.id) !== -1 &&
227 i.type !== 'content'),
228 )
229
230 commit('setCustomFields', filteredCustomFields)
231 } else {
232 commit('setCustomFields', [])
233 }
234 },
235
236 updateEmployeeService({ state, commit, dispatch, rootGetters }, payload) {
237 if (payload) {
238 let employeeService = rootGetters['entities/getEmployees']
239 .find((i) => i.id === state.providerId)
240 .serviceList.find((i) => i.id === payload)
241
242 commit(
243 'setEmployeeService',
244 typeof employeeService !== 'undefined'
245 ? employeeService
246 : rootGetters['entities/getServices'].find((i) => i.id === state.serviceId),
247 )
248 // * Set custom fields based on service selection
249 dispatch('serviceCustomFieldsFiltration')
250 } else {
251 state.employeeService = null
252 }
253 },
254
255 resetBookingsExtras({ state }, index) {
256 state.bookings[index].extras = state.employeeService.extras.map(
257 (e) => new Object({ extraId: e.id, quantity: 0 }),
258 )
259 },
260
261 deleteAllBookingCustomFields({ state }) {
262 state.bookings.forEach((booking) => {
263 booking.customFields = {}
264 })
265 },
266
267 resetBookingCustomFields({ state, getters }, key) {
268 state.bookings[key].customFields = getters['getCustomFields'].reduce((actual, current) => {
269 actual[current.id] = {
270 label: current.label,
271 type: current.type,
272 value: current.type === 'checkbox' || current.type === 'file' ? [] : '',
273 }
274
275 return actual
276 }, {})
277 },
278
279 updateBookingCustomField({ state }, payload) {
280 const { bookingKey, fieldId, value } = payload
281 state.bookings[bookingKey].customFields[fieldId].value = value
282 },
283
284 deleteAllCustomFieldsFormRules({ state }) {
285 state.customFieldsRules = {}
286 },
287
288 addCustomFieldsFormRules({ state, getters }, payload) {
289 const { key, label } = payload
290 getters['getCustomFields'].forEach((field) => {
291 state.customFieldsRules[`${key}cf${field.id}`] = [
292 {
293 message: label,
294 required: field.required,
295 trigger: ['submit', 'change'],
296 },
297 ]
298 })
299 },
300
301 addAllCustomFieldsFormRules({ state, getters }, payload) {
302 const { label } = payload
303 state.bookings.forEach((booking, index) => {
304 getters['getCustomFields'].forEach((field) => {
305 state.customFieldsRules[`${index}cf${field.id}`] = [
306 {
307 message: label,
308 required: field.required,
309 trigger: ['submit', 'change'],
310 },
311 ]
312 })
313 })
314 },
315
316 recreateAllBookingCustomFields({ state, dispatch }, payload) {
317 const { label } = payload
318
319 if (state.bookings.length) {
320 // * Delete all booking custom fields
321 dispatch('deleteAllBookingCustomFields')
322 // * Delete all custom fields form rules
323 dispatch('deleteAllCustomFieldsFormRules')
324 }
325
326 state.bookings.forEach((booking, index) => {
327 // * Reset booking extras
328 dispatch('resetBookingsExtras', index)
329
330 // * Reset (Add blank) booking custom fields
331 dispatch('resetBookingCustomFields', index)
332
333 // * Add custom fields form rules
334 dispatch('addCustomFieldsFormRules', { key: index, label })
335 })
336 },
337
338 removeBooking({ state, getters, commit }, payload) {
339 state.bookings.splice(payload, 1)
340
341 commit(
342 'customerInfo/setCustomersIds',
343 getters['getBookings'].map((i) => i.customer.id),
344 { root: true },
345 )
346 },
347 },
348 }
349