@tulipnpm/timekit_project_selector 1.0.4 → 1.0.7
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/.idea/modules.xml +8 -0
- package/.idea/timekit-ecomm-widget.iml +8 -0
- package/.idea/vcs.xml +6 -0
- package/README.md +57 -9
- package/dist/229ef5cc3f6050f3239dc04035170b4d.svg +3 -0
- package/dist/timekit_project_selector.js +811 -123
- package/dist/timekit_project_selector.min.js +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/timekit-ecomm-widget.iml" filepath="$PROJECT_DIR$/.idea/timekit-ecomm-widget.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$" />
|
|
5
|
+
<orderEntry type="inheritedJdk" />
|
|
6
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
7
|
+
</component>
|
|
8
|
+
</module>
|
package/.idea/vcs.xml
ADDED
package/README.md
CHANGED
|
@@ -35,6 +35,7 @@ TimeKit Project Selector has many configuration options:
|
|
|
35
35
|
| app_key | No | | Token required to connect to TimeKit API. Can be found at **https://admin.timekit.io/a/apps/<app_slug>/apisettings/keys** |
|
|
36
36
|
| defaultUI | Yes | true | When true, will create the default user interface for the project selector. More details below |
|
|
37
37
|
| embed | Yes | false | When true, the user interface will not be shown in the widget, it will be placed inside of a specified div. More details below |
|
|
38
|
+
| includePrivateAppointments | Yes | false | When true, private appointment types will be fetched from the TimeKit API |
|
|
38
39
|
| 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 |
|
|
39
40
|
| selectorOptions | No | | See below for details |
|
|
40
41
|
| widgetImageUrl | Yes | Tulip Appointments Icon | When using the default widget UI, change this value to your desired image URL to replace widget image |
|
|
@@ -94,9 +95,21 @@ For each projects you can apply default filters by meta data. You can add many f
|
|
|
94
95
|
|
|
95
96
|
``` js
|
|
96
97
|
filters: {
|
|
97
|
-
't_disabled': false
|
|
98
|
+
't_disabled': false,
|
|
99
|
+
't_private': false
|
|
98
100
|
}
|
|
99
101
|
```
|
|
102
|
+
|
|
103
|
+
#### Geo Search Bar
|
|
104
|
+
Geo search bar is an alternative to the selector option bar and they shouldn't be used together.
|
|
105
|
+
When this option is specified, the user will be asked for their geolocation in the browser. If the user shares it, the list of the 5 closest stores will be displayed.
|
|
106
|
+
|
|
107
|
+
``` js
|
|
108
|
+
geo_search_bar: {
|
|
109
|
+
placeholder: 'Search for a city or postal code'
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
100
113
|
#### Standard Strings
|
|
101
114
|
|
|
102
115
|
Adding a string such as 'Select a Store' will display that hardcoded string in the place of the placeholder. This can also be used to display custom HTML elements like icons in the UI.
|
|
@@ -127,7 +140,8 @@ timekit_project_selector.init({
|
|
|
127
140
|
card_body: '[meta]t_appointment_type_description',
|
|
128
141
|
card_footer: '<i class="far fa-clock"></i> {{[project]availability.length}}',
|
|
129
142
|
filters: {
|
|
130
|
-
't_disabled': false
|
|
143
|
+
't_disabled': false,
|
|
144
|
+
't_private': false
|
|
131
145
|
}
|
|
132
146
|
},
|
|
133
147
|
store_project: {
|
|
@@ -183,6 +197,35 @@ timekit_project_selector.init({
|
|
|
183
197
|
});
|
|
184
198
|
```
|
|
185
199
|
|
|
200
|
+
### Including private appointment types (Optional)
|
|
201
|
+
|
|
202
|
+
By default widget fetches only public appointment types, in order to change that behavior and fetch the private appointment types, `includePrivateAppointments` configuration option can be specified to `true`.
|
|
203
|
+
|
|
204
|
+
```js
|
|
205
|
+
timekit_project_selector.init({
|
|
206
|
+
app_key: <timekit_app_key>,
|
|
207
|
+
...,
|
|
208
|
+
includePrivateAppointments: true,
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
In case if you use custom UI and you need to pull both private and public appointment types from TimeKit API, but want to display the private appointment types only when needed, filters can be used:
|
|
213
|
+
|
|
214
|
+
```js
|
|
215
|
+
timekit_project_selector.init({
|
|
216
|
+
app_key: <timekit_app_key>,
|
|
217
|
+
defaultUI: false,
|
|
218
|
+
includePrivateAppointments: true,
|
|
219
|
+
selectorOptions: {
|
|
220
|
+
global_appointment_type_project: true,
|
|
221
|
+
store_project: true,
|
|
222
|
+
}
|
|
223
|
+
}).then(() => {
|
|
224
|
+
// Add this filter whenever you want to surface only public appointment types
|
|
225
|
+
globalProjectFilters['t_private'] = 0;
|
|
226
|
+
});
|
|
227
|
+
```
|
|
228
|
+
|
|
186
229
|
See below for how to use the exposed methods.
|
|
187
230
|
|
|
188
231
|
---
|
|
@@ -270,7 +313,8 @@ timekit_project_selector.selectProject(timekitProject);
|
|
|
270
313
|
card_body: '[meta]t_appointment_type_description',
|
|
271
314
|
card_footer: '<i class="far fa-clock"></i> {{[project]availability.length}}',
|
|
272
315
|
filters: {
|
|
273
|
-
't_disabled': false
|
|
316
|
+
't_disabled': false,
|
|
317
|
+
't_private': false
|
|
274
318
|
}
|
|
275
319
|
},
|
|
276
320
|
store_project: {
|
|
@@ -311,7 +355,8 @@ timekit_project_selector.selectProject(timekitProject);
|
|
|
311
355
|
card_body: '[meta]t_appointment_type_description',
|
|
312
356
|
card_footer: '<i class="far fa-clock"></i> {{[project]availability.length}}',
|
|
313
357
|
filters: {
|
|
314
|
-
't_disabled': false
|
|
358
|
+
't_disabled': false,
|
|
359
|
+
't_private': false
|
|
315
360
|
}
|
|
316
361
|
}
|
|
317
362
|
}
|
|
@@ -369,9 +414,11 @@ timekit_project_selector.selectProject(timekitProject);
|
|
|
369
414
|
// This factory makes it simple to track which TK project uuids were selected
|
|
370
415
|
let stepsFactory = tps.getStepsFactory();
|
|
371
416
|
|
|
372
|
-
// We only want to surface active global appointment types
|
|
373
417
|
let globalProjectFilters = [];
|
|
418
|
+
// We only want to surface active global appointment types
|
|
374
419
|
globalProjectFilters['t_disabled'] = 0;
|
|
420
|
+
// We only want to surface public global appointment types
|
|
421
|
+
globalProjectFilters['t_private'] = 0;
|
|
375
422
|
|
|
376
423
|
// Fetch the global_appointment_type_project
|
|
377
424
|
let globalProjects = tps.getStrategy().getProjects('global_appointment_type_project', globalProjectFilters);
|
|
@@ -384,16 +431,17 @@ timekit_project_selector.selectProject(timekitProject);
|
|
|
384
431
|
|
|
385
432
|
// Register an event listener on the newly generated link
|
|
386
433
|
$("a.global_appointment").click(function (event) {
|
|
387
|
-
let
|
|
388
|
-
|
|
389
|
-
|
|
434
|
+
let storeProjectFilters = [];
|
|
435
|
+
storeProjectFilters['t_global_appointment_type_project_uuid'] = $(this).attr('id');
|
|
436
|
+
storeProjectFilters['t_disabled'] = 0;
|
|
437
|
+
storeProjectFilters['t_private'] = 0;
|
|
390
438
|
|
|
391
439
|
// We add the UUID of the selected global_appointment_type_project. This will be used at the end
|
|
392
440
|
// when we are selecting the store_appointment_type_project
|
|
393
441
|
stepsFactory.addFilterForLastStep('t_global_appointment_type_project_uuid', $(this).attr('id'));
|
|
394
442
|
stepsFactory.nextStep();
|
|
395
443
|
|
|
396
|
-
let storeProjects = tps.getStrategy('store_project').getProjects('store_project',
|
|
444
|
+
let storeProjects = tps.getStrategy('store_project').getProjects('store_project', storeProjectFilters);
|
|
397
445
|
|
|
398
446
|
// Render out links for each store_project
|
|
399
447
|
storeProjects.forEach((project) => {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="27" height="28" viewBox="0 0 27 28" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M14.4965 19.8023L17.6668 11.2512C17.8997 10.6235 17.2888 10.0126 16.661 10.2455L8.10653 13.4168C7.38541 13.6846 7.44166 14.7218 8.18753 14.9097L12.0418 15.8783L13.0037 19.7202C13.1915 20.4661 14.2299 20.5235 14.4965 19.8023V19.8023Z" stroke="#214DE6" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
3
|
+
</svg>
|