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