appointment.js
1 year ago
attendee.js
1 year ago
auth.js
1 year ago
bookableType.js
3 years ago
booking.js
1 year ago
cabinet.js
1 year ago
cabinetFilters.js
1 year ago
coupon.js
2 years ago
customFields.js
2 years ago
customerInfo.js
1 year ago
employee.js
1 year ago
entities.js
1 year ago
event.js
1 year ago
eventBooking.js
3 years ago
eventEntities.js
1 year ago
eventWaitingListOptions.js
1 year ago
pagination.js
3 years ago
params.js
1 year ago
payment.js
2 years ago
persons.js
1 year ago
recurring.js
1 year ago
shortcodeParams.js
2 years ago
tickets.js
1 year ago
customFields.js
88 lines
| 1 | export default { |
| 2 | namespaced: true, |
| 3 | |
| 4 | state: () => ({ |
| 5 | customFieldsArray: [], |
| 6 | customFields: {}, |
| 7 | }), |
| 8 | |
| 9 | getters: { |
| 10 | getFilteredCustomFieldsArray (state) { |
| 11 | return state.customFieldsArray |
| 12 | }, |
| 13 | getCustomFields (state) { |
| 14 | return state.customFields |
| 15 | }, |
| 16 | |
| 17 | getCustomFieldValue: (state) => (field) => { |
| 18 | return state.customFields[field].value |
| 19 | }, |
| 20 | |
| 21 | getAllData (state) { |
| 22 | return { |
| 23 | // customFieldsArray: state.customFieldsArray, |
| 24 | customFields: state.customFields, |
| 25 | } |
| 26 | } |
| 27 | }, |
| 28 | |
| 29 | mutations: { |
| 30 | setFilteredCustomFieldsArray (state, payload) { |
| 31 | state.customFieldsArray = payload |
| 32 | }, |
| 33 | |
| 34 | setCustomFields (state, payload) { |
| 35 | state.customFields = payload |
| 36 | }, |
| 37 | |
| 38 | setCustomFieldValue (state, payload) { |
| 39 | state.customFields[payload.key].value = payload.value |
| 40 | }, |
| 41 | |
| 42 | setAllData (state, payoad) { |
| 43 | // state.customFieldsArray = payoad.customFieldsArray |
| 44 | state.customFields = payoad.customFields |
| 45 | } |
| 46 | }, |
| 47 | |
| 48 | actions: { |
| 49 | filterEventCustomFields ({ commit, getters, rootGetters }) { |
| 50 | let eventId = rootGetters['eventBooking/getSelectedEventId'] |
| 51 | let filteredCustomFieldsArr = [] |
| 52 | let customFields = {} |
| 53 | rootGetters['eventEntities/getCustomFields'].forEach(c => { |
| 54 | if (c.events.find(event => event.id === parseInt(eventId)) || c.allEvents) { |
| 55 | filteredCustomFieldsArr.push(c) |
| 56 | |
| 57 | customFields[`cf${c.id}`] = { |
| 58 | id: c.id, |
| 59 | label: c.label, |
| 60 | type: c.type, |
| 61 | position: c.position, |
| 62 | options: c.options, |
| 63 | required: c.required, |
| 64 | width: c.width |
| 65 | } |
| 66 | |
| 67 | switch (c.type) { |
| 68 | case ('checkbox'): |
| 69 | case ('file'): |
| 70 | customFields[`cf${c.id}`].value = [] |
| 71 | |
| 72 | break |
| 73 | |
| 74 | default: |
| 75 | customFields[`cf${c.id}`].value = '' |
| 76 | } |
| 77 | |
| 78 | if (getters['getCustomFields'][`cf${c.id}`]) { |
| 79 | customFields[`cf${c.id}`].value = getters['getCustomFields'][`cf${c.id}`]['value'] |
| 80 | } |
| 81 | } |
| 82 | }) |
| 83 | |
| 84 | commit('setFilteredCustomFieldsArray', filteredCustomFieldsArr) |
| 85 | commit('setCustomFields', customFields) |
| 86 | } |
| 87 | } |
| 88 | } |