@recras/online-booking-js 2.0.3 → 2.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@recras/online-booking-js",
3
- "version": "2.0.3",
3
+ "version": "2.0.4",
4
4
  "description": "JS library for easy integration of Recras online booking and voucher sales",
5
5
  "main": "dist/onlinebooking.js",
6
6
  "scripts": {
@@ -31,22 +31,22 @@
31
31
  },
32
32
  "homepage": "https://github.com/Recras/online-booking-js#readme",
33
33
  "devDependencies": {
34
- "@babel/cli": "7.18.6",
35
- "@babel/core": "7.18.6",
34
+ "@babel/cli": "7.18.9",
35
+ "@babel/core": "7.18.9",
36
36
  "@babel/plugin-proposal-class-properties": "7.18.6",
37
37
  "@babel/plugin-transform-arrow-functions": "7.18.6",
38
38
  "@babel/plugin-transform-for-of": "7.18.8",
39
39
  "@babel/plugin-transform-object-assign": "7.18.6",
40
- "@babel/preset-env": "7.18.6",
40
+ "@babel/preset-env": "7.18.9",
41
41
  "babel-plugin-transform-es2017-object-entries": "0.0.5",
42
- "jasmine-core": "4.2.0",
42
+ "jasmine-core": "4.3.0",
43
43
  "jasmine-spec-reporter": "7.0.0",
44
- "jshint": "2.13.4",
45
- "karma": "6.3.19",
44
+ "jshint": "2.13.5",
45
+ "karma": "6.4.0",
46
46
  "karma-chrome-launcher": "3.1.0",
47
47
  "karma-firefox-launcher": "2.1.2",
48
- "karma-jasmine": "4.0.2",
48
+ "karma-jasmine": "5.1.0",
49
49
  "karma-spec-reporter": "0.0.34",
50
- "uglify-js": "3.15.4"
50
+ "uglify-js": "3.16.3"
51
51
  }
52
52
  }
package/src/booking.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*******************************
2
2
  * Recras integration library *
3
- * v 2.0.3 *
3
+ * v 2.0.4 *
4
4
  *******************************/
5
5
 
6
6
  class RecrasBooking {
@@ -457,24 +457,32 @@ class RecrasContactForm {
457
457
  );
458
458
  }
459
459
 
460
- showInlineErrors() {
460
+ showErrors() {
461
+ let errors = [];
461
462
  for (let el of this.getEmptyRequiredFields()) {
462
463
  const labelEl = el.parentNode.querySelector('label');
463
464
  const requiredText = this.languageHelper.translate('CONTACT_FORM_FIELD_REQUIRED', {
464
465
  FIELD_NAME: labelEl.innerText,
465
466
  });
466
- el.parentNode.insertAdjacentHTML(
467
- 'afterend',
468
- `<div class="booking-error">${ requiredText }</div>`
469
- );
467
+ errors.push(requiredText);
470
468
  }
471
469
  for (let el of this.getInvalidFields()) {
472
- const labelEl = el.parentNode.querySelector('label');
470
+ let parentEl = el.closest('div');
471
+ if (parentEl.classList.contains('radioGroup')) {
472
+ parentEl = parentEl.parentNode.closest('div');
473
+ }
474
+ const labelEl = parentEl.querySelector('label');
475
+ console.log(labelEl, parentEl.querySelectorAll('label'));
473
476
  const invalidText = this.languageHelper.translate('CONTACT_FORM_FIELD_INVALID', {
474
477
  FIELD_NAME: labelEl.innerText,
475
478
  });
476
- this.showInlineError(el, invalidText);
479
+ errors.push(invalidText);
477
480
  }
481
+ errors = [...new Set(errors)]; // Only unique text
482
+ this.findElement('button[type="submit"]').insertAdjacentHTML(
483
+ 'afterend',
484
+ `<div class="booking-error"><ul><li>${ errors.join('<li>') }</ul></div>`
485
+ );
478
486
  }
479
487
 
480
488
  showLabel(field, idx) {
@@ -502,7 +510,7 @@ class RecrasContactForm {
502
510
  );
503
511
  return false;
504
512
  } else if (this.hasEmptyRequiredFields() || !this.isValid()) {
505
- this.showInlineErrors();
513
+ this.showErrors();
506
514
  return false;
507
515
  }
508
516
 
package/src/vouchers.js CHANGED
@@ -184,7 +184,7 @@ class RecrasVoucher {
184
184
  let shouldDisable = false;
185
185
  this.contactForm.removeErrors();
186
186
  if (this.contactForm.hasEmptyRequiredFields() || !this.contactForm.isValid() || !this.contactForm.checkRequiredCheckboxes()) {
187
- this.contactForm.showInlineErrors();
187
+ this.contactForm.showErrors();
188
188
  shouldDisable = true;
189
189
  }
190
190