PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.6
Booking for Appointments and Events Calendar – Amelia v2.4.6
2.4.7 2.4.6 2.4.5 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 / public / js / tinymce / amelia-mce.js
ameliabooking / public / js / tinymce Last commit date
amelia-mce.js 1 month ago amelia-tinymce-styles.css 2 years ago
amelia-mce.js
848 lines
1 /* eslint-disable */
2 (function () {
3 tinymce.create('tinymce.plugins.ameliaBookingPlugin', {
4
5 init: function (editor) {
6 if (!('wpAmeliaLabels' in window)) {
7 return
8 }
9
10 let win = null
11
12 let entities = null
13 let categories = null
14 let services = null
15 let employees = null
16 let locations = null
17 let servicesList = null
18 let packages = null
19 let events = null
20 let tags = null
21 let ivy = null
22 let catalogView = null
23
24 let setSharedShortcodeElements = function (viewBody, data) {
25 viewBody.push({
26 type: 'textbox',
27 label: wpAmeliaLabels.manually_loading,
28 name: 'am_trigger',
29 tooltip: wpAmeliaLabels.manually_loading_description,
30 classes: 'am-booking-trigger',
31 onKeyUp: function (e) {
32 syncTriggerFields(!!e.target.value)
33 }
34 })
35
36 viewBody.push({
37 type: 'listbox',
38 label: wpAmeliaLabels.trigger_type,
39 name: 'am_trigger_type',
40 values: [
41 {value: 'id', text: wpAmeliaLabels.trigger_type_id},
42 {value: 'class', text: wpAmeliaLabels.trigger_type_class}
43 ],
44 classes: 'am-booking-trigger-type',
45 })
46
47 viewBody.push({
48 type: 'checkbox',
49 label: wpAmeliaLabels.in_dialog,
50 name: 'am_in_dialog',
51 classes: 'am-booking-dialog',
52 })
53
54 viewBody.push({
55 type: 'listbox',
56 label: wpAmeliaLabels.ivy,
57 name: 'am_ivy',
58 values: data.ivy,
59 classes: 'am-booking-ivy',
60 })
61 }
62
63 let getSharedShortcodeString = function (e) {
64 let shortCodeString = ''
65
66 if (e.data.am_trigger) {
67 shortCodeString += ' trigger=' + e.data.am_trigger
68 }
69
70 if (e.data.am_trigger && e.data.am_trigger_type) {
71 shortCodeString += ' trigger_type=' + e.data.am_trigger_type
72 }
73
74 if (e.data.am_trigger && e.data.am_in_dialog) {
75 shortCodeString += ' in_dialog=1'
76 }
77
78 if (e.data.am_ivy && !e.data.am_trigger) {
79 shortCodeString += ' ivy=' + e.data.am_ivy
80 }
81
82 return shortCodeString
83 }
84
85 let syncTriggerFields = function (hasTrigger) {
86 if (!win) {
87 return
88 }
89
90 let triggerType = win.find('#am_trigger_type')
91 let inDialog = win.find('#am_in_dialog')
92 let ivy = win.find('#am_ivy')
93
94 if (triggerType) {
95 triggerType.parent().visible(!!hasTrigger)
96 }
97 if (inDialog) {
98 inDialog.parent().visible(!!hasTrigger)
99 }
100 if (ivy) {
101 ivy.parent().visible(!hasTrigger)
102 }
103 }
104
105 let setAndOpenEditor = function (view) {
106 editor.windowManager.close()
107
108 let viewBody = [{
109 type: 'listbox',
110 name: 'am_view_type',
111 label: wpAmeliaLabels.select_view,
112 values: [
113 {value: 'stepbooking', text: 'Step Booking', classes: 'am-booking-shortcode'},
114 {value: 'catalogbooking', text: 'Catalog Booking', classes: 'am-booking-shortcode'},
115 {value: 'eventslistbooking', text: 'Events List Booking', classes: 'am-booking-shortcode'},
116 {value: 'eventscalendarbooking', text: 'Events Calendar Booking', classes: 'am-booking-shortcode'},
117 {value: 'customer_panel', text: 'Customer Panel', classes: 'am-booking-shortcode'},
118 {value: 'employee_panel', text: 'Employee Panel', classes: 'am-booking-shortcode'},
119 // {value: 'booking', text: 'Booking', classes: 'am-booking-shortcode am-outdated-booking-shortcode'},
120 // {value: 'search', text: 'Search', classes: 'am-booking-shortcode am-outdated-booking-shortcode'},
121 // {value: 'catalog', text: 'Catalog', classes: 'am-booking-shortcode am-outdated-booking-shortcode'},
122 // {value: 'events', text: 'Events', classes: 'am-booking-shortcode am-outdated-booking-shortcode'},
123 ],
124 value: view,
125 onSelect: function () {
126 setAndOpenEditor(this.value())
127 }
128 },
129 ]
130
131 let filterItems = null
132
133 // set view
134 switch (view) {
135 case ('booking'):
136 case ('stepbooking'):
137
138 // Filter
139 filterItems = []
140
141 if (categories.length > 1) {
142 filterItems.push({
143 type: 'listbox',
144 name: 'am_booking_category',
145 label: wpAmeliaLabels.select_category,
146 classes: 'am-booking-categories',
147 values: [{
148 value: 0,
149 text: wpAmeliaLabels.show_all_categories
150 }].concat(categories),
151 })
152 }
153
154 if (services.length > 1) {
155 filterItems.push({
156 type: 'listbox',
157 name: 'am_booking_service',
158 label: wpAmeliaLabels.select_service,
159 classes: 'am-booking-services',
160 values: [{
161 value: 0,
162 text: wpAmeliaLabels.show_all_services
163 }].concat(services),
164 })
165 }
166
167 if (employees.length > 1) {
168 filterItems.push({
169 type: 'listbox',
170 name: 'am_booking_employee',
171 label: wpAmeliaLabels.select_employee,
172 classes: 'am-booking-employees',
173 values: [{
174 value: 0,
175 text: wpAmeliaLabels.show_all_employees
176 }].concat(employees),
177 })
178 }
179
180 if (locations.length > 1) {
181 filterItems.push({
182 type: 'listbox',
183 name: 'am_booking_location',
184 label: wpAmeliaLabels.select_location,
185 classes: 'am-booking-locations',
186 values: [{
187 value: 0,
188 text: wpAmeliaLabels.show_all_locations
189 }].concat(locations),
190 })
191 }
192
193 if (packages.length) {
194 if (view === 'stepbooking') {
195 filterItems.push({
196 type: 'listbox',
197 name: 'am_booking_package',
198 label: wpAmeliaLabels.select_package,
199 classes: 'am-booking-packages',
200 values: [{
201 value: 0,
202 text: wpAmeliaLabels.show_all_packages
203 }].concat(packages),
204 })
205 }
206
207 viewBody.push({
208 type: 'listbox',
209 name: 'am_show',
210 values: [
211 {value: '', text: wpAmeliaLabels.show_all},
212 {value: 'services', text: wpAmeliaLabels.services},
213 {value: 'packages', text: wpAmeliaLabels.packages}
214 ],
215 classes: 'am-show',
216 })
217 }
218
219 viewBody.push({
220 type: 'checkbox',
221 name: 'am_booking_filter',
222 label: wpAmeliaLabels.filter,
223 classes: 'am-booking-filter',
224 onChange: function () {
225 let filterForm = win.find('#am_booking_panel')
226 filterForm.visible(!filterForm.visible())
227 }
228 })
229
230 viewBody.push({
231 type: 'form',
232 name: 'am_booking_panel',
233 classes: 'am-booking-panel',
234 items: filterItems,
235 visible: false,
236 })
237
238 if (view === 'stepbooking') {
239 // Layout version selector
240 viewBody.push({
241 type: 'listbox',
242 label: wpAmeliaLabels.layout_select_label,
243 name: 'am_layout',
244 values: [
245 {value: '1', text: wpAmeliaLabels.layout_dropdown},
246 {value: '2', text: wpAmeliaLabels.layout_list}
247 ],
248 classes: 'am-booking-layout',
249 })
250
251 setSharedShortcodeElements(viewBody, {ivy: ivy})
252 }
253
254 break
255 case ('search'):
256 // Filter
257 viewBody.push({
258 type: 'checkbox',
259 name: 'am_search_date',
260 label: wpAmeliaLabels.search_date,
261 classes: 'am-search-date',
262 })
263
264 if (packages.length) {
265 viewBody.push({
266 type: 'listbox',
267 name: 'am_show',
268 values: [
269 {value: '', text: wpAmeliaLabels.show_all},
270 {value: 'services', text: wpAmeliaLabels.services},
271 {value: 'packages', text: wpAmeliaLabels.packages}
272 ],
273 classes: 'am-show',
274 })
275 }
276
277 break
278 case ('catalog'):
279 case ('catalogbooking'):
280 var catalogOptions = [
281 {value: 'catalog', text: wpAmeliaLabels.show_catalog},
282 {value: 'category', text: wpAmeliaLabels.show_category},
283 {value: 'service', text: wpAmeliaLabels.show_service}
284 ]
285
286 if (packages.length) {
287 catalogOptions.push({value: 'package', text: wpAmeliaLabels.show_package})
288 }
289
290 viewBody.push({
291 type: 'listbox',
292 name: 'am_catalog_view_type',
293 label: wpAmeliaLabels.select_catalog_view,
294 values: catalogOptions,
295 classes: 'am-catalog-view-type',
296 onSelect: function () {
297 catalogView = this.value()
298
299 let categoryElement = win.find('#am_category')
300 let serviceElement = win.find('#am_service')
301 let packageElement = win.find('#am_package')
302 let showElement = win.find('#am_show')
303
304 if (catalogView === 'category') {
305 categoryElement.visible(true)
306 serviceElement.visible(false)
307 packageElement.visible(false)
308 showElement.visible(true)
309 } else if (catalogView === 'service') {
310 categoryElement.visible(false)
311 serviceElement.visible(true)
312 packageElement.visible(false)
313 showElement.visible(view !== 'catalog')
314 } else if (catalogView === 'package') {
315 categoryElement.visible(false)
316 serviceElement.visible(false)
317 packageElement.visible(true)
318 showElement.visible(false)
319 } else {
320 categoryElement.visible(false)
321 serviceElement.visible(false)
322 packageElement.visible(false)
323 showElement.visible(true)
324 }
325 },
326 })
327
328 // Category
329 viewBody.push({
330 type: 'listbox',
331 name: 'am_category',
332 values: categories,
333 classes: 'am-categories',
334 })
335
336 // Service
337 viewBody.push({
338 type: 'listbox',
339 name: 'am_service',
340 values: services,
341 classes: 'am-services',
342 })
343
344 if (packages.length) {
345 // Package
346 viewBody.push({
347 type: 'listbox',
348 name: 'am_package',
349 values: packages,
350 classes: 'am-packages',
351 })
352
353 // Service
354 viewBody.push({
355 type: 'listbox',
356 name: 'am_show',
357 values: [
358 {value: '', text: wpAmeliaLabels.show_all},
359 {value: 'services', text: wpAmeliaLabels.services},
360 {value: 'packages', text: wpAmeliaLabels.packages}
361 ],
362 classes: 'am-show',
363 })
364 }
365
366 // Filter
367 filterItems = []
368
369 if (employees.length > 1) {
370 filterItems.push({
371 type: 'listbox',
372 name: 'am_booking_employee',
373 label: wpAmeliaLabels.select_employee,
374 classes: 'am-booking-employees',
375 values: [{
376 value: 0,
377 text: wpAmeliaLabels.show_all_employees
378 }].concat(employees),
379 })
380 }
381
382 if (locations.length > 1) {
383 filterItems.push({
384 type: 'listbox',
385 name: 'am_booking_location',
386 label: wpAmeliaLabels.select_location,
387 classes: 'am-booking-locations',
388 values: [{
389 value: 0,
390 text: wpAmeliaLabels.show_all_locations
391 }].concat(locations),
392 })
393 }
394
395 if (view === 'catalogbooking') {
396 filterItems.push({
397 type: 'checkbox',
398 name: 'am_booking_skip_categories',
399 label: wpAmeliaLabels.skip_categories,
400 classes: 'am-booking-skip-categories',
401 })
402 }
403
404 viewBody.push({
405 type: 'checkbox',
406 name: 'am_booking_filter',
407 label: wpAmeliaLabels.filter,
408 classes: 'am-booking-filter',
409 style: '',
410 onChange: function () {
411 let filterForm = win.find('#am_booking_panel')
412 filterForm.visible(!filterForm.visible())
413 }
414 })
415
416 viewBody.push({
417 type: 'form',
418 name: 'am_booking_panel',
419 classes: 'am-booking-panel',
420 items: filterItems,
421 visible: false,
422 })
423
424 setSharedShortcodeElements(viewBody, {ivy: ivy})
425
426 break
427
428 case ('events'):
429 case ('eventslistbooking'):
430 case ('eventscalendarbooking'):
431 // Filter
432 filterItems = [
433 {
434 type: 'listbox',
435 name: 'am_booking_event',
436 label: wpAmeliaLabels.select_event,
437 classes: 'am-booking-events',
438 values: [{
439 value: 0,
440 text: wpAmeliaLabels.show_all_events
441 }].concat(events),
442 },
443 {
444 type: 'checkbox',
445 name: 'am_booking_event_recurring',
446 label: wpAmeliaLabels.recurring_event,
447 classes: 'am-recurring-event',
448 },
449 {
450 type: 'listbox',
451 name: 'am_booking_location',
452 label: wpAmeliaLabels.select_location,
453 classes: 'am-booking-locations',
454 values: [{
455 value: 0,
456 text: wpAmeliaLabels.show_all_locations
457 }].concat(locations),
458 },
459 {
460 type: 'listbox',
461 name: 'am_booking_tag',
462 label: wpAmeliaLabels.select_tag,
463 classes: 'am-booking-tags',
464 values: [{
465 value: 0,
466 text: wpAmeliaLabels.show_all_tags
467 }].concat(tags),
468 }
469 ]
470
471 viewBody.push({
472 type: 'checkbox',
473 name: 'am_booking_filter',
474 label: wpAmeliaLabels.filter,
475 classes: 'am-booking-filter',
476 onChange: function () {
477 let filterForm = win.find('#am_booking_panel')
478 filterForm.visible(!filterForm.visible())
479 }
480 })
481
482 viewBody.push({
483 type: 'form',
484 name: 'am_booking_panel',
485 classes: 'am-booking-panel',
486 items: filterItems,
487 visible: false,
488 })
489
490 if (view === 'events' && !parseInt(wpAmeliaLabels.isLite)) {
491 viewBody.push({
492 type: 'listbox',
493 name: 'am_booking_event_view_type',
494 label: wpAmeliaLabels.show_event_view_type,
495 values: [
496 {value: 'list', text: wpAmeliaLabels.show_event_view_list},
497 {value: 'calendar', text: wpAmeliaLabels.show_event_view_calendar}
498 ],
499 classes: 'am-booking-events-view',
500 })
501 }
502
503 setSharedShortcodeElements(viewBody, {ivy: ivy})
504
505 break
506
507 case ('customer_panel'):
508 case ('employee_panel'):
509
510 viewBody.push({
511 type: 'checkbox',
512 name: 'am_cabinet_appointments',
513 label: wpAmeliaLabels.appointments,
514 classes: 'am_cabinet_appointments',
515 })
516
517 viewBody.push({
518 type: 'checkbox',
519 name: 'am_cabinet_events',
520 label: wpAmeliaLabels.events,
521 classes: 'am_cabinet_events',
522 })
523
524 if (view === 'employee_panel') {
525 viewBody.push({
526 type: 'checkbox',
527 name: 'am_cabinet_profile',
528 label: wpAmeliaLabels.profile,
529 classes: 'am_cabinet_profile',
530 })
531 }
532
533 break
534 }
535
536 // open editor
537 win = editor.windowManager.open({
538 title: 'Amelia Booking',
539 width: 500,
540 height: 435,
541 body: viewBody,
542 onSubmit: function (e) {
543 let shortCodeString = ''
544
545 switch (view) {
546 case ('booking'):
547 case ('stepbooking'):
548 shortCodeString += getSharedShortcodeString(e)
549
550 if (e.data.am_booking_service) {
551 shortCodeString += ' service=' + e.data.am_booking_service
552 } else if (e.data.am_booking_category) {
553 shortCodeString += ' category=' + e.data.am_booking_category
554 } else if (e.data.am_booking_package) {
555 shortCodeString += ' package=' + e.data.am_booking_package
556 }
557
558 if (e.data.am_booking_employee) {
559 shortCodeString += ' employee=' + e.data.am_booking_employee
560 }
561
562 if (e.data.am_booking_location) {
563 shortCodeString += ' location=' + e.data.am_booking_location
564 }
565
566 if (e.data.am_show) {
567 shortCodeString += ' show=' + e.data.am_show
568 }
569
570 if (view === 'stepbooking' && e.data.am_layout) {
571 shortCodeString += ' layout=' + e.data.am_layout
572 }
573
574 editor.insertContent((view === 'stepbooking' ? '[ameliastepbooking' : '[ameliabooking') + shortCodeString + ']')
575
576 break
577
578 case ('search'):
579 if (e.data.am_search_date) {
580 shortCodeString += ' today=1'
581 }
582
583 if (e.data.am_trigger) {
584 shortCodeString += ' trigger=' + e.data.am_trigger
585 }
586
587 if (e.data.am_show) {
588 shortCodeString += ' show=' + e.data.am_show
589 }
590
591 editor.insertContent('[ameliasearch' + shortCodeString + ']')
592
593 break
594
595 case ('catalog'):
596 shortCodeString += getSharedShortcodeString(e)
597
598 if (e.data.am_booking_employee) {
599 shortCodeString += ' employee=' + e.data.am_booking_employee
600 }
601
602 if (e.data.am_booking_location) {
603 shortCodeString += ' location=' + e.data.am_booking_location
604 }
605
606 if (e.data.am_show && catalogView !== 'service' && catalogView !== 'package') {
607 shortCodeString += ' show=' + e.data.am_show
608 }
609
610 if (catalogView === 'category') {
611 editor.insertContent('[ameliacatalog category=' + e.data.am_category + shortCodeString + ']')
612 } else if (catalogView === 'service') {
613 editor.insertContent('[ameliacatalog service=' + e.data.am_service + shortCodeString + ']')
614 } else if (catalogView === 'package') {
615 editor.insertContent('[ameliacatalog package=' + e.data.am_package + shortCodeString + ']')
616 } else {
617 editor.insertContent('[ameliacatalog' + shortCodeString + ']')
618 }
619
620 break
621
622 case ('catalogbooking'):
623 shortCodeString += getSharedShortcodeString(e)
624
625 if (e.data.am_booking_employee) {
626 shortCodeString += ' employee=' + e.data.am_booking_employee
627 }
628
629 if (e.data.am_booking_location) {
630 shortCodeString += ' location=' + e.data.am_booking_location
631 }
632
633 if (e.data.am_booking_skip_categories) {
634 shortCodeString += ' categories_hidden=1'
635 }
636
637 if (catalogView === 'category') {
638 if (e.data.am_show) {
639 shortCodeString += ' show=' + e.data.am_show
640 }
641 editor.insertContent('[ameliacatalogbooking category=' + e.data.am_category + shortCodeString + ']')
642 } else if (catalogView === 'service') {
643 if (e.data.am_show && e.data.am_show !== 'packages') {
644 shortCodeString += ' show=' + e.data.am_show
645 }
646 editor.insertContent('[ameliacatalogbooking service=' + e.data.am_service + shortCodeString + ']')
647 } else if (catalogView === 'package') {
648 editor.insertContent('[ameliacatalogbooking package=' + e.data.am_package + shortCodeString + ']')
649 } else {
650 if (e.data.am_show) {
651 shortCodeString += ' show=' + e.data.am_show
652 }
653 editor.insertContent('[ameliacatalogbooking' + shortCodeString + ']')
654 }
655
656 break
657
658 case ('events'):
659 case ('eventslistbooking'):
660 case ('eventscalendarbooking'):
661 shortCodeString += getSharedShortcodeString(e)
662
663 if (e.data.am_booking_event) {
664 shortCodeString += ' event=' + e.data.am_booking_event
665
666 if (e.data.am_booking_event_recurring) {
667 shortCodeString += ' recurring=1'
668 }
669 }
670
671 if (view === 'events' && e.data.am_booking_event_view_type) {
672 shortCodeString += ' type=' + "'" + e.data.am_booking_event_view_type + "'"
673 }
674
675 if (e.data.am_booking_tag) {
676 shortCodeString += ` tag="${e.data.am_booking_tag}"`
677 }
678
679 if (e.data.am_booking_location) {
680 shortCodeString += ' location=' + e.data.am_booking_location
681 }
682
683 if (view === 'eventslistbooking') {
684 editor.insertContent('[ameliaeventslistbooking' + shortCodeString + ']')
685 } else if (view === 'eventscalendarbooking') {
686 editor.insertContent('[ameliaeventscalendarbooking' + shortCodeString + ']')
687 } else {
688 editor.insertContent('[ameliaevents' + shortCodeString + ']')
689 }
690
691 break
692
693 case ('customer_panel'):
694 case ('employee_panel'):
695 if (e.data.am_cabinet_appointments) {
696 shortCodeString += ' appointments=1'
697 }
698
699 if (e.data.am_cabinet_events) {
700 shortCodeString += ' events=1'
701 }
702
703 if (e.data.am_cabinet_profile && view !== 'customer_panel') {
704 shortCodeString += ' profile-hidden=1'
705 }
706
707 if (e.data.am_trigger) {
708 shortCodeString += ' trigger=' + e.data.am_trigger
709 }
710
711 editor.insertContent(view === 'customer_panel' ? '[ameliacustomerpanel' + shortCodeString + ']' : '[ameliaemployeepanel' + shortCodeString + ']')
712
713 break
714 }
715 },
716 onOpen: function () {
717 categoryElement = win.find('#am_category')
718 serviceElement = win.find('#am_service')
719 packageElement = win.find('#am_package')
720
721 categoryElement.visible(false)
722 serviceElement.visible(false)
723 packageElement.visible(false)
724
725 if (view === 'stepbooking' || view === 'catalog' || view === 'catalogbooking' || view === 'events' || view === 'eventslistbooking' || view === 'eventscalendarbooking') {
726 let trigger = win.find('#am_trigger')[0]
727 let hasTrigger = trigger ? !!trigger.value() : false
728
729 syncTriggerFields(hasTrigger)
730 }
731 },
732 })
733 }
734
735 // Add new button
736 editor.addButton('ameliaButton', {
737 title: wpAmeliaLabels.insert_amelia_shortcode,
738 cmd: 'ameliaButtonCommand',
739 image: window.wpAmeliaPluginURL + 'public/img/amelia-logo-admin-icon.svg'
740 })
741
742 // Button functionality
743 editor.addCommand('ameliaButtonCommand', function () {
744 jQuery.ajax({
745 url: ajaxurl + '?action=wpamelia_api&call=/entities&types[]=categories&types[]=employees&types[]=locations&types[]=events&types[]=tags&types[]=packages&types[]=ivy',
746 dataType: 'json',
747 success: function (response) {
748 entities = response.data
749 categories = []
750 services = []
751 employees = []
752 locations = []
753 packages = []
754 servicesList = []
755 events = []
756 tags = []
757 ivy = []
758
759 for (let i = 0; i < response.data.categories.length; i++) {
760 categories.push({
761 value: response.data.categories[i].id,
762 text: response.data.categories[i].name + ' (id: ' + response.data.categories[i].id + ')'
763 })
764 }
765
766 // Add all services to one array
767 response.data.categories.map(category => category.serviceList).forEach(function (serviceList) {
768 servicesList = servicesList.concat(serviceList)
769 })
770
771 // Create array of services objects
772 for (let i = 0; i < servicesList.length; i++) {
773 if (servicesList[i].show) {
774 services.push({
775 value: servicesList[i].id,
776 text: servicesList[i].name + ' (id: ' + servicesList[i].id + ')'
777 })
778 }
779 }
780
781 // Create array of packages objects
782 for (let i = 0; i < response.data.categories.length; i++) {
783 if (response.data.categories[i].show) {
784 packages.push({
785 value: response.data.categories[i].id,
786 text: response.data.categories[i].name + ' (id: ' + response.data.categories[i].id + ')'
787 })
788 }
789 }
790
791 // Create array of employees objects
792 for (let i = 0; i < response.data.employees.length; i++) {
793 if (response.data.employees[i].show) {
794 employees.push({
795 value: response.data.employees[i].id,
796 text: response.data.employees[i].firstName + ' ' + response.data.employees[i].lastName + ' (id: ' + response.data.employees[i].id + ')'
797 })
798 }
799 }
800
801 // Create array of locations objects
802 for (let i = 0; i < response.data.locations.length; i++) {
803 locations.push({
804 value: response.data.locations[i].id,
805 text: response.data.locations[i].name + ' (id: ' + response.data.locations[i].id + ')'
806 })
807 }
808
809 // Create array of packages objects
810 for (let i = 0; i < response.data.packages.length; i++) {
811 packages.push({
812 value: response.data.packages[i].id,
813 text: response.data.packages[i].name + ' (id: ' + response.data.packages[i].id + ')'
814 })
815 }
816
817 for (let i = 0; i < response.data.events.length; i++) {
818 events.push({
819 value: response.data.events[i].id,
820 text: response.data.events[i].name + ' (id: ' + response.data.events[i].id + ') - ' + response.data.events[i].formattedPeriodStart
821 })
822 }
823
824 for (let i = 0; i < response.data.tags.length; i++) {
825 tags.push({
826 value: response.data.tags[i].name,
827 text: response.data.tags[i].name
828 })
829 }
830
831 for (let i = 0; i < (response.data.ivy || []).length; i++) {
832 ivy.push({
833 value: response.data.ivy[i].value,
834 text: response.data.ivy[i].label
835 })
836 }
837
838 // set and open editor
839 setAndOpenEditor('stepbooking')
840 }
841 })
842 })
843 }
844 })
845
846 tinymce.PluginManager.add('ameliaBookingPlugin', tinymce.plugins.ameliaBookingPlugin)
847 })()
848