@tulipnpm/timekit_project_selector 2.0.5 → 2.0.8-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +154 -109
- package/dist/timekit_project_selector.js +33 -15
- package/dist/timekit_project_selector.min.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Tulip Appointments Web Widget
|
|
2
2
|
|
|
3
|
-
The
|
|
3
|
+
The Tulip Appointments Web Widget is a library that extends the functionality of [TimeKit's Booking Widget](https://developers.timekit.io/docs/booking-widget-v2). This library allows users to set up selectors based on project metadata, which will filter down a list of TimeKit projects for a customer to book with. The library has a default UI that embeds on an e-commerce site that can either be customized or overwritten.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -12,7 +12,7 @@ The TimeKit Project Selector is a library that extends the functionality of [Tim
|
|
|
12
12
|
|
|
13
13
|
## Initialization
|
|
14
14
|
|
|
15
|
-
To initialize the
|
|
15
|
+
To initialize the Tulip Appointments Web Widget on your site, you first need to import all required libraries onto your webpage (see above). After the library is installed, set up is as easy as running a single function:
|
|
16
16
|
|
|
17
17
|
```js
|
|
18
18
|
timekit_project_selector.init({
|
|
@@ -29,20 +29,90 @@ This will connect to TimeKit's API and load in all the required data. Once the i
|
|
|
29
29
|
|
|
30
30
|
## Configurations
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
Tulip Appointments Web Widget has many configuration options:
|
|
33
33
|
|
|
34
34
|
| Option | Optional? | Default value | Description |
|
|
35
35
|
|--------|-----------|---------------|-------------|
|
|
36
36
|
| app_key | No | | Token required to connect to TimeKit API. Can be found at **https://admin.timekit.io/a/apps/<app_slug>/apisettings/keys** |
|
|
37
|
-
| api_base_url | Yes | https://api.timekit.io | Timekit API url pointing to production environment. For staging
|
|
38
|
-
| defaultUI | Yes | true | When true, will create the default user interface for the project selector.
|
|
39
|
-
| embed | Yes | false | When true, the user interface will
|
|
37
|
+
| api_base_url | Yes | https://api.timekit.io | Timekit API url pointing to production environment. For staging environments point to `https://api-staging.timekit.io`.
|
|
38
|
+
| defaultUI | Yes | true | When true, will create the default user interface for the project selector. See [Widget Modes](#widget-modes) below |
|
|
39
|
+
| embed | Yes | false | When true, the user interface will be configured for Page Mode. It will be placed inside of a specified div. See [Widget Modes](#widget-modes) below |
|
|
40
40
|
| includePrivateAppointments | Yes | false | When true, private appointment types will be fetched from the TimeKit API |
|
|
41
41
|
| region | Yes | | Initial filter applied when getting default list of projects. Any project that does not have the same **t_region** metadata value will not be shown on initialization |
|
|
42
42
|
| selectorOptions | No | | See below for details |
|
|
43
43
|
| widgetImageUrl | Yes | Tulip Appointments Icon | When using the default widget UI, change this value to your desired image URL to replace widget image |
|
|
44
44
|
| duplicateCustomerCheck | Yes | false | When a new booking is created, a call is made to check for potential duplicate Timekit customers. Requires the following webhook to be configured via Timekit: **/api/customers/timekit_webhook_connect_client**|
|
|
45
45
|
|
|
46
|
+
### Widget Modes
|
|
47
|
+
|
|
48
|
+
There are three modes of UI the Tulip Appointments Web Widget:
|
|
49
|
+
|
|
50
|
+
- Popup Mode
|
|
51
|
+
- Automatically creates a button that will open the widget in a popup
|
|
52
|
+
- Page Mode
|
|
53
|
+
- Injects itself onto the page given a destination HTML element
|
|
54
|
+
- Custom UI
|
|
55
|
+
- No UI is created, you have to create UI for all steps up to the calendar view
|
|
56
|
+
|
|
57
|
+
Whichever mode you choose is determined by the `defaultUI` and `embed` properties. Refer to the matrix below to see which mode is configured for each possible value of `defaultUI ` and `embed`.
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
| | embed=true | embed=false |
|
|
61
|
+
|-|-|-|
|
|
62
|
+
| defaultUI=true | Page Mode | Popup Mode |
|
|
63
|
+
| defaultUI=false| Custom UI | Custom UI |
|
|
64
|
+
|
|
65
|
+
#### Popup Mode Widget
|
|
66
|
+
|
|
67
|
+

|
|
68
|
+
|
|
69
|
+
When enabled on initialization of the library the default user interface will be built on the web page as a widget. To disable the default UI from appearing, simply set the **defaultUI** configuration to `false`.
|
|
70
|
+
|
|
71
|
+
NOTE: If you are using the widget view, you cannot have a div with ID **timekit-project-selector-container** on your DOM.
|
|
72
|
+
|
|
73
|
+
```js
|
|
74
|
+
timekit_project_selector.init({
|
|
75
|
+
app_key: <timekit_app_key>,
|
|
76
|
+
defaultUI: true,
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
#### Page Mode Widget
|
|
81
|
+
|
|
82
|
+

|
|
83
|
+
|
|
84
|
+
To use the Page Mode Widget, change the **embed** configuration to `true`. This will build the widget into a container div with the id **timekit-project-selector-container**. This allows you control of the positioning, size and style of the interface.
|
|
85
|
+
|
|
86
|
+
```html
|
|
87
|
+
<div id="timekit-project-selector-container"></div>
|
|
88
|
+
<script>
|
|
89
|
+
timekit_project_selector.init({
|
|
90
|
+
app_key: <timekit_app_key>,
|
|
91
|
+
defaultUI: true,
|
|
92
|
+
embed: true,
|
|
93
|
+
});
|
|
94
|
+
</script>
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
#### Custom UI
|
|
98
|
+
|
|
99
|
+
If you do not want to use the Page Mode or Popup Mode widget and want to create your own UI, change the **defaultUI** configuration to `false`. This will not show the Popup or Page Widget UIs. When the store and appointment type is selected, a calendar UI will be populated in the HTML element with id `bookingjs`.
|
|
100
|
+
|
|
101
|
+
For a more in-depth example, see [Example Custom UI](#example-custom-ui)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
```html
|
|
105
|
+
<!-- Container div for the calendar to display-->
|
|
106
|
+
<div id="bookingjs"></div>
|
|
107
|
+
<script>
|
|
108
|
+
timekit_project_selector.init({
|
|
109
|
+
app_key: <timekit_app_key>,
|
|
110
|
+
defaultUI: false,
|
|
111
|
+
});
|
|
112
|
+
</script>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
|
|
46
116
|
### Selector Options
|
|
47
117
|
|
|
48
118
|
The selector options are how you can set the metadata fields that you want the user to select from. The order that the keys are placed in the object is the order the customer will see the selector options. If you are using the default UI, you will also need to specify the selector option copyright fields for each option. If you are not using the default UI, simply assign the keys to have value `true`.
|
|
@@ -67,7 +137,7 @@ When using the default UI, you must set the selector display values for each sel
|
|
|
67
137
|
|
|
68
138
|
#### Selector Option Strategy (Optional)
|
|
69
139
|
|
|
70
|
-
This parameter is used for defining the logic of rendering projects. The **strategy** field is used for rendering either Stores having Appointment Types belonging to them, or Appointment Types having Stores belonging to them. By default, strategy is set to `store_project` (Appointment Type > Store)
|
|
140
|
+
This parameter is used for defining the logic of rendering projects. The **strategy** field is used for rendering either Stores having Appointment Types belonging to them, or Appointment Types having Stores belonging to them. By default, strategy is set to `store_project` (Appointment Type > Store)
|
|
71
141
|
|
|
72
142
|
```
|
|
73
143
|
strategy: 'store_project',
|
|
@@ -75,7 +145,7 @@ strategy: 'store_project',
|
|
|
75
145
|
|
|
76
146
|
#### Selector Option Search Bar
|
|
77
147
|
|
|
78
|
-
In addition to allowing for customization of the text on the widget, the
|
|
148
|
+
In addition to allowing for customization of the text on the widget, the Tulip Appointments Web Widget also allows for the addition of a search bar to allow a user to search for certain text inside of a card.
|
|
79
149
|
|
|
80
150
|
To enable this search bar, you can include the following inside of a Selector Option.
|
|
81
151
|
|
|
@@ -86,7 +156,7 @@ search_bar: {
|
|
|
86
156
|
}
|
|
87
157
|
```
|
|
88
158
|
|
|
89
|
-
By default, the search bar feature is not enabled if this configuration is missing from a selector option. If this configuration is present, then the **enabled** field is required. The **enabled** field must either be `true` or `false`, where `true` indicates that the search bar will show up in the default UI, and `false` indicates that it will not be present.
|
|
159
|
+
By default, the search bar feature is not enabled if this configuration is missing from a selector option. If this configuration is present, then the **enabled** field is required. The **enabled** field must either be `true` or `false`, where `true` indicates that the search bar will show up in the default UI, and `false` indicates that it will not be present.
|
|
90
160
|
|
|
91
161
|
The **placeholder** field is optional and is not required for the search bar. If this field is missing, the placeholder text inside the search bar will default to `Please enter your search term`. Otherwise, the text can be replaced following the specifications below.
|
|
92
162
|
|
|
@@ -164,42 +234,7 @@ timekit_project_selector.init({
|
|
|
164
234
|
});
|
|
165
235
|
```
|
|
166
236
|
|
|
167
|
-
### Default UI
|
|
168
|
-
|
|
169
|
-
When enabled on initialization of the library the default user interface will be built on the web page as a widget. To disable the default UI from appearing, simply set the **defaultUI** configuration to `false`.
|
|
170
237
|
|
|
171
|
-
NOTE: If you are using the widget view, you cannot have a div with ID **timekit-project-selector-container** on your DOM.
|
|
172
|
-
|
|
173
|
-
```js
|
|
174
|
-
timekit_project_selector.init({
|
|
175
|
-
app_key: <timekit_app_key>,
|
|
176
|
-
defaultUI: true,
|
|
177
|
-
});
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
### Embedding UI
|
|
181
|
-
|
|
182
|
-
With the default UI there are two options: Widget Mode and Embedded Mode. By default, the UI will build a widget. To use the embedded mode, change the **embed** configuration to `true`. This will not build the widget, but will build in interface into a container div with the id **timekit-project-selector-container**. This allows you control of the positioning, size and style of the interface.
|
|
183
|
-
|
|
184
|
-
```js
|
|
185
|
-
// Requires a div with ID 'timekit-project-selector-container'. This is where the UI will render.
|
|
186
|
-
timekit_project_selector.init({
|
|
187
|
-
app_key: <timekit_app_key>,
|
|
188
|
-
defaultUI: true,
|
|
189
|
-
embed: true,
|
|
190
|
-
});
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
### Custom UI
|
|
194
|
-
|
|
195
|
-
If you do not want to use the default UI and want to create your own UI, change the **defaultUI** configuration to `false`. This will not show the widget or embedded UI.
|
|
196
|
-
|
|
197
|
-
```js
|
|
198
|
-
timekit_project_selector.init({
|
|
199
|
-
app_key: <timekit_app_key>,
|
|
200
|
-
defaultUI: false,
|
|
201
|
-
});
|
|
202
|
-
```
|
|
203
238
|
|
|
204
239
|
### Including Private Appointment Types (Optional)
|
|
205
240
|
|
|
@@ -250,11 +285,11 @@ See below for how to use the exposed methods.
|
|
|
250
285
|
|
|
251
286
|
## Exposed Methods
|
|
252
287
|
|
|
253
|
-
The
|
|
288
|
+
The Tulip Appointments Web Widget library exposes the methods that are used to create our default user interface. This gives you the tools to build custom interfaces that are branded for your company to have customers select the correct TimeKit project to book with.
|
|
254
289
|
|
|
255
290
|
### init
|
|
256
291
|
|
|
257
|
-
Asynchronous method that initiate the
|
|
292
|
+
Asynchronous method that initiate the Tulip Appointments Web Widget.
|
|
258
293
|
|
|
259
294
|
```js
|
|
260
295
|
timekit_project_selector.init({
|
|
@@ -381,27 +416,30 @@ timekit_project_selector.selectProject(timekitProject);
|
|
|
381
416
|
```
|
|
382
417
|
|
|
383
418
|
## Example Custom UI
|
|
419
|
+
|
|
384
420
|
```html
|
|
385
421
|
<!DOCTYPE html>
|
|
422
|
+
|
|
386
423
|
<html lang="en">
|
|
387
424
|
|
|
388
425
|
<head>
|
|
389
426
|
<meta charset="UTF-8">
|
|
390
427
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
391
|
-
<title>Custom UI -
|
|
428
|
+
<title>Custom UI - Tulip Appointments Web Widget Example</title>
|
|
392
429
|
|
|
393
430
|
<!-- Booking.js minified dependency -->
|
|
394
431
|
<link rel="stylesheet" href="https://cdn.timekit.io/booking-js/v3/booking.min.css" />
|
|
395
|
-
<script type="text/javascript" src="
|
|
432
|
+
<script type="text/javascript" src="https://cdn.timekit.io/booking-js/v3/booking.min.js"></script>
|
|
433
|
+
|
|
396
434
|
<!-- Tulip Project selector -->
|
|
397
|
-
<script src="
|
|
435
|
+
<script src="https://cdn.jsdelivr.net/npm/@tulipnpm/timekit_project_selector@latest/dist/timekit_project_selector.min.js"></script>
|
|
398
436
|
</head>
|
|
399
437
|
|
|
400
438
|
<body>
|
|
401
|
-
<h1>Custom UI -
|
|
439
|
+
<h1>Custom UI - Tulip Appointments Web Widget Example</h1>
|
|
402
440
|
|
|
403
441
|
<!-- Placeholder div for TK Projects of t_project_type = service_project -->
|
|
404
|
-
<ul class="
|
|
442
|
+
<ul class="services"></ul>
|
|
405
443
|
|
|
406
444
|
<!-- Placeholder div for TK Projects of t_project_type = store_project -->
|
|
407
445
|
<ul class="stores"></ul>
|
|
@@ -410,79 +448,86 @@ timekit_project_selector.selectProject(timekitProject);
|
|
|
410
448
|
<div id="bookingjs"></div>
|
|
411
449
|
|
|
412
450
|
<script>
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
451
|
+
const tps = timekit_project_selector;
|
|
452
|
+
|
|
453
|
+
tps.init({
|
|
454
|
+
// Insert widget key provided via TK admin panel
|
|
455
|
+
app_key: 'live_widget_key_xj4RMO93SIXSS9EbZiw286Fs0epKDnN6',
|
|
456
|
+
api_base_url: 'https://api-staging.timekit.io',
|
|
457
|
+
// If you need to filter by country
|
|
458
|
+
// region: 'USA',
|
|
459
|
+
// Set defaultUI to false as we are using a custom UI
|
|
460
|
+
defaultUI: false,
|
|
461
|
+
// Selector options still prvided but values are set to true
|
|
462
|
+
selectorOptions: {
|
|
463
|
+
// Step 1: Is to select the service_project
|
|
464
|
+
service_project: true,
|
|
465
|
+
// Step 2: Is to select the store project
|
|
466
|
+
store_project: true,
|
|
467
|
+
}
|
|
468
|
+
}).then(async () => {
|
|
469
|
+
let serviceHtml = '';
|
|
470
|
+
let locationHtml = '';
|
|
471
|
+
|
|
472
|
+
// You could use simple array instead of using the steps factor.
|
|
473
|
+
// This factory makes it simple to track which TK project uuids were selected
|
|
474
|
+
let stepsFactory = tps.getStepsFactory();
|
|
475
|
+
|
|
476
|
+
// Fetch the service_project
|
|
477
|
+
let globalProjects = await tps.getStrategy('service_project').getProjects({ t_private: 0, t_disabled: 0 });
|
|
478
|
+
|
|
479
|
+
// Render out links for each service_project
|
|
480
|
+
globalProjects.forEach((globalProject) => {
|
|
481
|
+
serviceHtml += "<a href=\"#\" class=\"service\" id=\"" + globalProject.id + "\"> <li>" + globalProject.name + "</li></a>";
|
|
482
|
+
})
|
|
483
|
+
|
|
484
|
+
document.querySelector('.services').innerHTML = serviceHtml;
|
|
439
485
|
|
|
440
|
-
|
|
441
|
-
globalProjects.forEach((globalProject) => {
|
|
442
|
-
let link = "<a href=\"#\" class=\"global_appointment\" id=\"" + globalProject.id + "\"> <li>'" + globalProject.name + "'</li></a>";
|
|
443
|
-
$('.global_projects').append(link);
|
|
444
|
-
})
|
|
486
|
+
var services = document.querySelectorAll('a.service'), i;
|
|
445
487
|
|
|
488
|
+
for (i = 0; i < services.length; ++i) {
|
|
446
489
|
// Register an event listener on the newly generated link
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
service_project_id
|
|
453
|
-
t_disabled: 0,
|
|
454
|
-
t_private: 0
|
|
490
|
+
services[i].addEventListener("click", async function (event) {
|
|
491
|
+
|
|
492
|
+
let service_project_id = event.target.parentNode.id;
|
|
493
|
+
let storeProjects = await tps.getStrategy('store_project').getProjects({
|
|
494
|
+
// t_private: 0, t_disabled: 0,
|
|
495
|
+
service_project_id: service_project_id
|
|
455
496
|
});
|
|
456
|
-
|
|
497
|
+
|
|
457
498
|
// Render out links for each store_project
|
|
458
499
|
storeProjects.forEach((project) => {
|
|
459
|
-
|
|
460
|
-
$('.stores').append(link);
|
|
500
|
+
locationHtml += "<a href=\"#\" class=\"store_project\" id=\"" + project.id + "\"> <li>" + project.name + "</li></a>";
|
|
461
501
|
})
|
|
462
502
|
|
|
463
|
-
|
|
464
|
-
$("a.store_project").click(function (event) {
|
|
503
|
+
document.querySelector('.stores').innerHTML = locationHtml;
|
|
465
504
|
|
|
466
|
-
|
|
505
|
+
var locations = document.querySelectorAll('a.store_project'), j;
|
|
467
506
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
});
|
|
507
|
+
for (j = 0; j < locations.length; ++j) {
|
|
508
|
+
// Register an event listener on the newly generated store link
|
|
509
|
+
locations[j].addEventListener("click", async function (e) {
|
|
510
|
+
let store_project_id = e.target.parentNode.id;
|
|
473
511
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
512
|
+
const projects = await tps.getStrategy().getProjects({
|
|
513
|
+
store_project_id: store_project_id,
|
|
514
|
+
service_project_id: service_project_id
|
|
515
|
+
});
|
|
478
516
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
517
|
+
const selectedProject = projects.find(project => project.meta?.t_service_id === service_project_id);
|
|
518
|
+
// Render Booking.js
|
|
519
|
+
tps.selectProject(selectedProject);
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
}
|
|
482
524
|
|
|
525
|
+
}).catch((error) => {
|
|
526
|
+
console.log(error.message);
|
|
483
527
|
});
|
|
484
528
|
</script>
|
|
485
529
|
</body>
|
|
486
530
|
|
|
487
531
|
</html>
|
|
532
|
+
|
|
488
533
|
```
|
|
@@ -20564,9 +20564,11 @@ var TimekitApiClient = /*#__PURE__*/function () {
|
|
|
20564
20564
|
function TimekitApiClient() {
|
|
20565
20565
|
var appKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
20566
20566
|
var baseURL = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
20567
|
+
var region = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
|
|
20567
20568
|
_classCallCheck(this, TimekitApiClient);
|
|
20568
20569
|
this.appKey = appKey;
|
|
20569
20570
|
this.appBaseURL = baseURL;
|
|
20571
|
+
this.regionFilter = region;
|
|
20570
20572
|
this.cachedItems = new CacheItems();
|
|
20571
20573
|
this.instance = axios_default().create({
|
|
20572
20574
|
baseURL: this.appBaseURL + '/v2'
|
|
@@ -20574,9 +20576,10 @@ var TimekitApiClient = /*#__PURE__*/function () {
|
|
|
20574
20576
|
}
|
|
20575
20577
|
_createClass(TimekitApiClient, [{
|
|
20576
20578
|
key: "setAppKey",
|
|
20577
|
-
value: function setAppKey(appKey, appUrl) {
|
|
20579
|
+
value: function setAppKey(appKey, appUrl, region) {
|
|
20578
20580
|
this.appKey = appKey;
|
|
20579
20581
|
this.appBaseURL = appUrl;
|
|
20582
|
+
this.regionFilter = region;
|
|
20580
20583
|
this.instance = axios_default().create({
|
|
20581
20584
|
baseURL: this.appBaseURL + '/v2'
|
|
20582
20585
|
});
|
|
@@ -20819,16 +20822,22 @@ var TimekitApiClient = /*#__PURE__*/function () {
|
|
|
20819
20822
|
value: function () {
|
|
20820
20823
|
var _getLocations = _asyncToGenerator( /*#__PURE__*/regenerator_default().mark(function _callee6() {
|
|
20821
20824
|
var filters,
|
|
20825
|
+
query,
|
|
20822
20826
|
_args6 = arguments;
|
|
20823
20827
|
return regenerator_default().wrap(function _callee6$(_context6) {
|
|
20824
20828
|
while (1) switch (_context6.prev = _context6.next) {
|
|
20825
20829
|
case 0:
|
|
20826
20830
|
filters = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : [];
|
|
20827
|
-
|
|
20828
|
-
|
|
20829
|
-
|
|
20831
|
+
// Add region to query
|
|
20832
|
+
query = this.getMetaQueryForLocations();
|
|
20833
|
+
if (this.regionFilter != '') {
|
|
20834
|
+
query += ";meta.t_store_country:".concat(this.regionFilter);
|
|
20835
|
+
}
|
|
20836
|
+
_context6.next = 5;
|
|
20837
|
+
return this.getLocationsByMetaQuery(this.filtersToQuery(query, filters));
|
|
20838
|
+
case 5:
|
|
20830
20839
|
return _context6.abrupt("return", _context6.sent);
|
|
20831
|
-
case
|
|
20840
|
+
case 6:
|
|
20832
20841
|
case "end":
|
|
20833
20842
|
return _context6.stop();
|
|
20834
20843
|
}
|
|
@@ -21166,7 +21175,7 @@ var ProjectsStore = /*#__PURE__*/function () {
|
|
|
21166
21175
|
_createClass(ProjectsStore, [{
|
|
21167
21176
|
key: "init",
|
|
21168
21177
|
value: function init(configManager) {
|
|
21169
|
-
this.apiClient.setAppKey(configManager.app_key, configManager.api_base_url);
|
|
21178
|
+
this.apiClient.setAppKey(configManager.app_key, configManager.api_base_url, configManager.region);
|
|
21170
21179
|
}
|
|
21171
21180
|
}, {
|
|
21172
21181
|
key: "getApiClient",
|
|
@@ -21332,12 +21341,13 @@ var Step = /*#__PURE__*/function () {
|
|
|
21332
21341
|
_createClass(Step, [{
|
|
21333
21342
|
key: "init",
|
|
21334
21343
|
value: function init() {
|
|
21335
|
-
var _data$filters, _data$strategy;
|
|
21344
|
+
var _data$filters, _data$strategy, _data$stepFilters;
|
|
21336
21345
|
var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
21337
21346
|
this.options = new StepOptions(data);
|
|
21338
21347
|
this.dataOptions = new StepDataOptions(data);
|
|
21339
21348
|
this.defaultFilters = (_data$filters = data['filters']) !== null && _data$filters !== void 0 ? _data$filters : [];
|
|
21340
21349
|
this.strategy = (_data$strategy = data['strategy']) !== null && _data$strategy !== void 0 ? _data$strategy : null;
|
|
21350
|
+
this.stepFilters = (_data$stepFilters = data['stepFilters']) !== null && _data$stepFilters !== void 0 ? _data$stepFilters : [];
|
|
21341
21351
|
}
|
|
21342
21352
|
}, {
|
|
21343
21353
|
key: "setProjectType",
|
|
@@ -21346,7 +21356,7 @@ var Step = /*#__PURE__*/function () {
|
|
|
21346
21356
|
if (!this.strategy) {
|
|
21347
21357
|
this.strategy = projectType;
|
|
21348
21358
|
}
|
|
21349
|
-
if (projectType === 'global_appointment_type_project') {
|
|
21359
|
+
if (projectType === 'store_appointment_type_project' || projectType === 'global_appointment_type_project') {
|
|
21350
21360
|
this.strategy = 'service_project';
|
|
21351
21361
|
this.projectType = 'service_project';
|
|
21352
21362
|
}
|
|
@@ -21511,6 +21521,11 @@ var ConfigurationManager = /*#__PURE__*/function () {
|
|
|
21511
21521
|
value: function isEmbedded() {
|
|
21512
21522
|
return this.embed;
|
|
21513
21523
|
}
|
|
21524
|
+
}, {
|
|
21525
|
+
key: "getRegion",
|
|
21526
|
+
value: function getRegion() {
|
|
21527
|
+
return this.region;
|
|
21528
|
+
}
|
|
21514
21529
|
}, {
|
|
21515
21530
|
key: "getSelectorOptions",
|
|
21516
21531
|
value: function getSelectorOptions() {
|
|
@@ -21558,6 +21573,7 @@ var StoreProjectsStrategy = /*#__PURE__*/function () {
|
|
|
21558
21573
|
var _this = this;
|
|
21559
21574
|
var filters,
|
|
21560
21575
|
mainFilters,
|
|
21576
|
+
newFilters,
|
|
21561
21577
|
locations,
|
|
21562
21578
|
storeIds,
|
|
21563
21579
|
defaultFilters,
|
|
@@ -21567,25 +21583,26 @@ var StoreProjectsStrategy = /*#__PURE__*/function () {
|
|
|
21567
21583
|
case 0:
|
|
21568
21584
|
filters = _args.length > 0 && _args[0] !== undefined ? _args[0] : [];
|
|
21569
21585
|
mainFilters = _args.length > 1 && _args[1] !== undefined ? _args[1] : [];
|
|
21570
|
-
|
|
21571
|
-
|
|
21572
|
-
|
|
21586
|
+
newFilters = structuredClone(filters);
|
|
21587
|
+
if (newFilters !== null && newFilters !== void 0 && newFilters.service_project_id) {
|
|
21588
|
+
mainFilters['services.uuid'] = newFilters === null || newFilters === void 0 ? void 0 : newFilters.service_project_id;
|
|
21589
|
+
Reflect.deleteProperty(newFilters, 'service_project_id');
|
|
21573
21590
|
}
|
|
21574
|
-
_context.next =
|
|
21591
|
+
_context.next = 6;
|
|
21575
21592
|
return this.store.getApiClient().getLocations(mainFilters).then(function (projects) {
|
|
21576
21593
|
return _this.store.setProjects(projects);
|
|
21577
21594
|
});
|
|
21578
|
-
case
|
|
21595
|
+
case 6:
|
|
21579
21596
|
locations = _context.sent;
|
|
21580
21597
|
storeIds = [];
|
|
21581
21598
|
defaultFilters = StepsFactory_instance.currentStep() ? StepsFactory_instance.currentStep().getDefaultFilters() : [];
|
|
21582
21599
|
locations.forEach(function (project) {
|
|
21583
21600
|
storeIds.push(project.meta[_this.storeProjectIdKey]);
|
|
21584
21601
|
});
|
|
21585
|
-
return _context.abrupt("return", this.store.getProjects(LocationsStrategy_objectSpread(LocationsStrategy_objectSpread({},
|
|
21602
|
+
return _context.abrupt("return", this.store.getProjects(LocationsStrategy_objectSpread(LocationsStrategy_objectSpread({}, newFilters), defaultFilters)).filter(function (project) {
|
|
21586
21603
|
return storeIds.includes(project.meta[_this.storeProjectIdKey]);
|
|
21587
21604
|
}));
|
|
21588
|
-
case
|
|
21605
|
+
case 11:
|
|
21589
21606
|
case "end":
|
|
21590
21607
|
return _context.stop();
|
|
21591
21608
|
}
|
|
@@ -22616,6 +22633,7 @@ var UI = /*#__PURE__*/function () {
|
|
|
22616
22633
|
this.is_embedded = is_embedded;
|
|
22617
22634
|
this.userSelectionArray = [];
|
|
22618
22635
|
this.navigator.setCount(this.cm.getSelectorOptionsCount() + 1); // Account for 1 extra dot for bookingJS
|
|
22636
|
+
this.region = this.cm.getRegion();
|
|
22619
22637
|
}
|
|
22620
22638
|
_createClass(UI, [{
|
|
22621
22639
|
key: "setup",
|