@tulipnpm/timekit_project_selector 1.0.2 → 1.0.6
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 +48 -12
- package/dist/timekit_project_selector.js +17510 -17390
- package/dist/timekit_project_selector.min.js +2 -2
- package/package.json +2 -7
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 |
|
|
@@ -63,8 +64,7 @@ When using the default UI, you must set the selector display values for each sel
|
|
|
63
64
|
|
|
64
65
|
#### Selector Option Strategy (Optional)
|
|
65
66
|
|
|
66
|
-
This parameter
|
|
67
|
-
We use default strategy without this parameter
|
|
67
|
+
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)
|
|
68
68
|
|
|
69
69
|
```
|
|
70
70
|
strategy: 'store_project',
|
|
@@ -95,7 +95,8 @@ For each projects you can apply default filters by meta data. You can add many f
|
|
|
95
95
|
|
|
96
96
|
``` js
|
|
97
97
|
filters: {
|
|
98
|
-
't_disabled': false
|
|
98
|
+
't_disabled': false,
|
|
99
|
+
't_private': false
|
|
99
100
|
}
|
|
100
101
|
```
|
|
101
102
|
#### Standard Strings
|
|
@@ -128,7 +129,8 @@ timekit_project_selector.init({
|
|
|
128
129
|
card_body: '[meta]t_appointment_type_description',
|
|
129
130
|
card_footer: '<i class="far fa-clock"></i> {{[project]availability.length}}',
|
|
130
131
|
filters: {
|
|
131
|
-
't_disabled': false
|
|
132
|
+
't_disabled': false,
|
|
133
|
+
't_private': false
|
|
132
134
|
}
|
|
133
135
|
},
|
|
134
136
|
store_project: {
|
|
@@ -184,6 +186,35 @@ timekit_project_selector.init({
|
|
|
184
186
|
});
|
|
185
187
|
```
|
|
186
188
|
|
|
189
|
+
### Including private appointment types (Optional)
|
|
190
|
+
|
|
191
|
+
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`.
|
|
192
|
+
|
|
193
|
+
```js
|
|
194
|
+
timekit_project_selector.init({
|
|
195
|
+
app_key: <timekit_app_key>,
|
|
196
|
+
...,
|
|
197
|
+
includePrivateAppointments: true,
|
|
198
|
+
});
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
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:
|
|
202
|
+
|
|
203
|
+
```js
|
|
204
|
+
timekit_project_selector.init({
|
|
205
|
+
app_key: <timekit_app_key>,
|
|
206
|
+
defaultUI: false,
|
|
207
|
+
includePrivateAppointments: true,
|
|
208
|
+
selectorOptions: {
|
|
209
|
+
global_appointment_type_project: true,
|
|
210
|
+
store_project: true,
|
|
211
|
+
}
|
|
212
|
+
}).then(() => {
|
|
213
|
+
// Add this filter whenever you want to surface only public appointment types
|
|
214
|
+
globalProjectFilters['t_private'] = 0;
|
|
215
|
+
});
|
|
216
|
+
```
|
|
217
|
+
|
|
187
218
|
See below for how to use the exposed methods.
|
|
188
219
|
|
|
189
220
|
---
|
|
@@ -271,7 +302,8 @@ timekit_project_selector.selectProject(timekitProject);
|
|
|
271
302
|
card_body: '[meta]t_appointment_type_description',
|
|
272
303
|
card_footer: '<i class="far fa-clock"></i> {{[project]availability.length}}',
|
|
273
304
|
filters: {
|
|
274
|
-
't_disabled': false
|
|
305
|
+
't_disabled': false,
|
|
306
|
+
't_private': false
|
|
275
307
|
}
|
|
276
308
|
},
|
|
277
309
|
store_project: {
|
|
@@ -312,7 +344,8 @@ timekit_project_selector.selectProject(timekitProject);
|
|
|
312
344
|
card_body: '[meta]t_appointment_type_description',
|
|
313
345
|
card_footer: '<i class="far fa-clock"></i> {{[project]availability.length}}',
|
|
314
346
|
filters: {
|
|
315
|
-
't_disabled': false
|
|
347
|
+
't_disabled': false,
|
|
348
|
+
't_private': false
|
|
316
349
|
}
|
|
317
350
|
}
|
|
318
351
|
}
|
|
@@ -370,9 +403,11 @@ timekit_project_selector.selectProject(timekitProject);
|
|
|
370
403
|
// This factory makes it simple to track which TK project uuids were selected
|
|
371
404
|
let stepsFactory = tps.getStepsFactory();
|
|
372
405
|
|
|
373
|
-
// We only want to surface active global appointment types
|
|
374
406
|
let globalProjectFilters = [];
|
|
407
|
+
// We only want to surface active global appointment types
|
|
375
408
|
globalProjectFilters['t_disabled'] = 0;
|
|
409
|
+
// We only want to surface public global appointment types
|
|
410
|
+
globalProjectFilters['t_private'] = 0;
|
|
376
411
|
|
|
377
412
|
// Fetch the global_appointment_type_project
|
|
378
413
|
let globalProjects = tps.getStrategy().getProjects('global_appointment_type_project', globalProjectFilters);
|
|
@@ -385,16 +420,17 @@ timekit_project_selector.selectProject(timekitProject);
|
|
|
385
420
|
|
|
386
421
|
// Register an event listener on the newly generated link
|
|
387
422
|
$("a.global_appointment").click(function (event) {
|
|
388
|
-
let
|
|
389
|
-
|
|
390
|
-
|
|
423
|
+
let storeProjectFilters = [];
|
|
424
|
+
storeProjectFilters['t_global_appointment_type_project_uuid'] = $(this).attr('id');
|
|
425
|
+
storeProjectFilters['t_disabled'] = 0;
|
|
426
|
+
storeProjectFilters['t_private'] = 0;
|
|
391
427
|
|
|
392
428
|
// We add the UUID of the selected global_appointment_type_project. This will be used at the end
|
|
393
429
|
// when we are selecting the store_appointment_type_project
|
|
394
430
|
stepsFactory.addFilterForLastStep('t_global_appointment_type_project_uuid', $(this).attr('id'));
|
|
395
431
|
stepsFactory.nextStep();
|
|
396
432
|
|
|
397
|
-
let storeProjects = tps.getStrategy('store_project').getProjects('store_project',
|
|
433
|
+
let storeProjects = tps.getStrategy('store_project').getProjects('store_project', storeProjectFilters);
|
|
398
434
|
|
|
399
435
|
// Render out links for each store_project
|
|
400
436
|
storeProjects.forEach((project) => {
|
|
@@ -428,4 +464,4 @@ timekit_project_selector.selectProject(timekitProject);
|
|
|
428
464
|
</body>
|
|
429
465
|
|
|
430
466
|
</html>
|
|
431
|
-
```
|
|
467
|
+
```
|