@tulipnpm/timekit_project_selector 3.0.0-rc.3 → 3.0.0-rc.5

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 CHANGED
@@ -5,9 +5,9 @@ The TimeKit Project Selector is a library that extends the functionality of [Tim
5
5
  ## Installation
6
6
 
7
7
  ```html
8
- <script src="https://cdn.jsdelivr.net/npm/@tulipnpm/timekit_project_selector@latest/dist/timekit_project_selector.min.js"></script>
9
8
  <link rel="stylesheet" href="https://cdn.timekit.io/booking-js/v3/booking.min.css" />
10
9
  <script type="text/javascript" src="//cdn.timekit.io/booking-js/v3/booking.min.js" defer></script>
10
+ <script src="https://cdn.jsdelivr.net/npm/@tulipnpm/timekit_project_selector@3.0.0-rc.4/dist/timekit_project_selector.min.js"></script>
11
11
  ```
12
12
 
13
13
  ## Initialization
@@ -51,11 +51,11 @@ timekit_project_selector.init({
51
51
  ...,
52
52
  selectorOptions: {
53
53
  store_project: true,
54
- store_appointment_type_project: true,
54
+ service_project: true,
55
55
  }
56
56
  });
57
57
  ```
58
- > You must use project type as key in the selectorOptions. Ex. global_appointment_type_project for render Global Appointment Type in step, store_appointment_type_project for render Store Appointment Type in step, store_project for render Stores in step
58
+ > You must use project type as key in the selectorOptions. Ex. service_project for render Global Appointment Type in step, store_appointment_type_project for render Store Appointment Type in step, store_project for render Stores in step
59
59
 
60
60
  ### Selector Option Copyright
61
61
 
@@ -133,12 +133,13 @@ Here is a sample of combined selectorOptions.
133
133
  timekit_project_selector.init({
134
134
  ...,
135
135
  selectorOptions: {
136
- global_appointment_type_project: {
136
+ service_project: {
137
+ strategy: 'service_project',
138
+ card_title: `{{[project]name}}`,
137
139
  title: 'Select an Appointment Type',
140
+ card_image: `{{[project]image_url}}`,
141
+ card_body: `{{[project]description}}`,
138
142
  description: 'Which appointment type would you like?',
139
- card_image: '[meta]t_appointment_type_image',
140
- card_title: '[meta]t_appointment_type_name',
141
- card_body: '[meta]t_appointment_type_description',
142
143
  card_footer: '<i class="far fa-clock"></i> {{[project]availability.length}}',
143
144
  filters: {
144
145
  't_disabled': 0,
@@ -147,15 +148,15 @@ timekit_project_selector.init({
147
148
  },
148
149
  store_project: {
149
150
  title: 'Select a Store',
150
- description: 'Choose a store from the following that you will be visiting for your appointment.',
151
+ strategy: 'store_project',
151
152
  card_title: '[meta]t_store_name',
152
- card_body: `{{[meta]t_store_address}}, {{[meta]t_store_city}}`,
153
153
  card_footer: '[meta]t_store_phone',
154
+ card_body: `{{[meta]t_store_address}}, {{[meta]t_store_city}}`,
155
+ description: 'Choose a store from the following that you will be visiting for your appointment.',
154
156
  search_bar: {
155
157
  enabled: true,
156
158
  placeholder: 'Search for a city or postal code'
157
159
  },
158
- strategy: 'store_project',
159
160
  },
160
161
  }
161
162
  });
@@ -218,7 +219,7 @@ timekit_project_selector.init({
218
219
  defaultUI: false,
219
220
  includePrivateAppointments: true,
220
221
  selectorOptions: {
221
- global_appointment_type_project: true,
222
+ service_project: true,
222
223
  store_project: true,
223
224
  }
224
225
  }).then(() => {
@@ -277,10 +278,7 @@ Optionally takes project type for return projects by project type only.(Filters
277
278
  Optionally takes filters for return filtered projects
278
279
 
279
280
  ```js
280
- let filters = [];
281
- filters['key'] = 'value';
282
-
283
- timekit_project_selector.getStrategy().getProjects('global_appointment_type', filters);
281
+ await timekit_project_selector.getStrategy('store_project').getProjects({ id: 'ef0cee8a-6096-453f-a634-1597b359cdfa'});
284
282
  ```
285
283
 
286
284
  ### getFilters
@@ -320,12 +318,13 @@ timekit_project_selector.selectProject(timekitProject);
320
318
  ### Global Appointment Type -> Store -> Booking.js
321
319
  ```js
322
320
  selectorOptions: {
323
- global_appointment_type_project: {
321
+ service_project: {
322
+ strategy: 'service_project',
323
+ card_title: `{{[project]name}}`,
324
324
  title: 'Select an Appointment Type',
325
+ card_image: `{{[project]image_url}}`,
326
+ card_body: `{{[project]description}}`,
325
327
  description: 'Which appointment type would you like?',
326
- card_image: '[meta]t_appointment_type_image',
327
- card_title: '[meta]t_appointment_type_name',
328
- card_body: '[meta]t_appointment_type_description',
329
328
  card_footer: '<i class="far fa-clock"></i> {{[project]availability.length}}',
330
329
  filters: {
331
330
  't_disabled': 0,
@@ -334,15 +333,15 @@ timekit_project_selector.selectProject(timekitProject);
334
333
  },
335
334
  store_project: {
336
335
  title: 'Select a Store',
337
- description: 'Choose a store from the following that you will be visiting for your appointment.',
336
+ strategy: 'store_project',
338
337
  card_title: '[meta]t_store_name',
339
- card_body: `{{[meta]t_store_address}}, {{[meta]t_store_city}}`,
340
338
  card_footer: '[meta]t_store_phone',
339
+ card_body: `{{[meta]t_store_address}}, {{[meta]t_store_city}}`,
340
+ description: 'Choose a store from the following that you will be visiting for your appointment.',
341
341
  search_bar: {
342
342
  enabled: true,
343
343
  placeholder: 'Search for a city or postal code'
344
344
  },
345
- strategy: 'store_project'
346
345
  }
347
346
  }
348
347
  ```
@@ -352,10 +351,11 @@ timekit_project_selector.selectProject(timekitProject);
352
351
  selectorOptions: {
353
352
  store_project: {
354
353
  title: 'Select a Store',
355
- description: 'Choose a store from the following that you will be visiting for your appointment.',
354
+ strategy: 'store_project',
356
355
  card_title: '[meta]t_store_name',
357
- card_body: `{{[meta]t_store_address}}, {{[meta]t_store_city}}`,
358
356
  card_footer: '[meta]t_store_phone',
357
+ card_body: `{{[meta]t_store_address}}, {{[meta]t_store_city}}`,
358
+ description: 'Choose a store from the following that you will be visiting for your appointment.',
359
359
  search_bar: {
360
360
  enabled: true,
361
361
  placeholder: 'Search for a city or postal code'
@@ -363,11 +363,12 @@ timekit_project_selector.selectProject(timekitProject);
363
363
  //strategy: 'store_project'
364
364
  },
365
365
  store_appointment_type_project: {
366
+ strategy: 'service_project',
367
+ card_title: `{{[project]name}}`,
366
368
  title: 'Select an Appointment Type',
369
+ card_image: `{{[project]image_url}}`,
370
+ card_body: `{{[project]description}}`,
367
371
  description: 'Which appointment type would you like?',
368
- card_image: '[meta]t_appointment_type_image',
369
- card_title: '[meta]t_appointment_type_name',
370
- card_body: '[meta]t_appointment_type_description',
371
372
  card_footer: '<i class="far fa-clock"></i> {{[project]availability.length}}',
372
373
  filters: {
373
374
  't_disabled': 0,
@@ -397,7 +398,7 @@ timekit_project_selector.selectProject(timekitProject);
397
398
  <body>
398
399
  <h1>Custom UI - TimeKit Project Selector Example</h1>
399
400
 
400
- <!-- Placeholder div for TK Projects of t_project_type = global_appointment_type_project -->
401
+ <!-- Placeholder div for TK Projects of t_project_type = service_project -->
401
402
  <ul class="global_projects"></ul>
402
403
 
403
404
  <!-- Placeholder div for TK Projects of t_project_type = store_project -->
@@ -418,26 +419,23 @@ timekit_project_selector.selectProject(timekitProject);
418
419
  defaultUI: false,
419
420
  // Selector options still prvided but values are set to true
420
421
  selectorOptions: {
421
- // Step 1: Is to select the global_appointment_type_project
422
- global_appointment_type_project: true,
422
+ // Step 1: Is to select the service_project
423
+ service_project: true,
423
424
  // Step 2: Is to select the store project
424
425
  store_project: true,
425
426
  }
426
- }).then(() => {
427
+ }).then(async () => {
427
428
  // You could use simple array instead of using the steps factor.
428
429
  // This factory makes it simple to track which TK project uuids were selected
429
430
  let stepsFactory = tps.getStepsFactory();
430
-
431
- let globalProjectFilters = [];
432
- // We only want to surface active global appointment types
433
- globalProjectFilters['t_disabled'] = 0;
434
- // We only want to surface public global appointment types
435
- globalProjectFilters['t_private'] = 0;
436
431
 
437
- // Fetch the global_appointment_type_project
438
- let globalProjects = tps.getStrategy().getProjects('global_appointment_type_project', globalProjectFilters);
432
+ // Fetch the service_project
433
+ let globalProjects = await tps.getStrategy('service_project').getProjects({
434
+ t_private: 0,
435
+ t_disabled: 0
436
+ });
439
437
 
440
- // Render out links for each global_appointment_type_project
438
+ // Render out links for each service_project
441
439
  globalProjects.forEach((globalProject) => {
442
440
  let link = "<a href=\"#\" class=\"global_appointment\" id=\"" + globalProject.id + "\"> <li>'" + globalProject.name + "'</li></a>";
443
441
  $('.global_projects').append(link);
@@ -445,18 +443,15 @@ timekit_project_selector.selectProject(timekitProject);
445
443
 
446
444
  // Register an event listener on the newly generated link
447
445
  $("a.global_appointment").click(function (event) {
448
- let storeProjectFilters = [];
449
- storeProjectFilters['t_global_appointment_type_project_uuid'] = $(this).attr('id');
450
- storeProjectFilters['t_disabled'] = 0;
451
- storeProjectFilters['t_private'] = 0;
452
-
453
- // We add the UUID of the selected global_appointment_type_project. This will be used at the end
454
- // when we are selecting the store_appointment_type_project
455
- stepsFactory.addFilterForLastStep('t_global_appointment_type_project_uuid', $(this).attr('id'));
456
446
  stepsFactory.nextStep();
457
447
 
458
- let storeProjects = tps.getStrategy('store_project').getProjects('store_project', storeProjectFilters);
459
-
448
+ const service_project_id = $(this).attr('id');
449
+ let storeProjects = await tps.getStrategy('store_project').getProjects({
450
+ service_project_id,
451
+ t_disabled: 0,
452
+ t_private: 0
453
+ });
454
+
460
455
  // Render out links for each store_project
461
456
  storeProjects.forEach((project) => {
462
457
  let link = "<a href=\"#\" class=\"store_project\" id=\"" + project.id + "\"> <li>'" + project.name + "'</li></a>";
@@ -466,17 +461,16 @@ timekit_project_selector.selectProject(timekitProject);
466
461
  // Register an event listener on the newly generated store link
467
462
  $("a.store_project").click(function (event) {
468
463
 
469
- // We add the UUID of the selected store_project. This will be used at the end
470
- // when we are selecting the store_appointment_type_project
471
- stepsFactory.addFilterForLastStep('t_store_project_uuid', $(this).attr('id'));
472
464
  stepsFactory.nextStep();
473
465
 
474
- // From the step factory get the filters we had applied throughout the process
475
- let filters = stepsFactory.currentStep().getFilters();
476
- let store_appointments = tps.getStrategy().getProjects('store_appointment_type_project', filters);
466
+ const store_project_id = $(this).attr('id');
467
+ const project = await tps.getStrategy().getProjects({
468
+ store_project_id,
469
+ service_project_id
470
+ });
477
471
 
478
472
  // Render Booking.js
479
- tps.selectProject(store_appointments[0]);
473
+ tps.selectProject(project);
480
474
  });
481
475
  });
482
476