@projectcaluma/ember-form 14.3.2 → 14.4.1

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.
@@ -24,5 +24,7 @@
24
24
  @onChange={{this.onChange}}
25
25
  @onReady={{this.onReady}}
26
26
  @onClose={{this.onClose}}
27
+ @minDate={{@minDate}}
28
+ @maxDate={{@maxDate}}
27
29
  />
28
30
  </div>
@@ -19,7 +19,6 @@ fragment SimpleQuestion on Question {
19
19
  node {
20
20
  slug
21
21
  regex
22
- errorMsg
23
22
  }
24
23
  }
25
24
  }
@@ -38,7 +37,6 @@ fragment SimpleQuestion on Question {
38
37
  node {
39
38
  slug
40
39
  regex
41
- errorMsg
42
40
  }
43
41
  }
44
42
  }
@@ -3,7 +3,6 @@ import { assert } from "@ember/debug";
3
3
  import { associateDestroyableChild } from "@ember/destroyable";
4
4
  import { inject as service } from "@ember/service";
5
5
  import { camelize } from "@ember/string";
6
- import { isEmpty } from "@ember/utils";
7
6
  import { tracked } from "@glimmer/tracking";
8
7
  import { queryManager } from "ember-apollo-client";
9
8
  import { dropTask, lastValue, restartableTask } from "ember-concurrency";
@@ -609,25 +608,45 @@ export default class Field extends Base {
609
608
  input.dataSourceContext = JSON.stringify(this.document.dataSourceContext);
610
609
  }
611
610
 
612
- const response = yield this.apollo.mutate(
613
- {
614
- mutation: MUTATION_MAP[type],
615
- variables: { input },
616
- },
617
- `saveDocument${type}.answer`,
618
- );
611
+ try {
612
+ const response = yield this.apollo.mutate(
613
+ {
614
+ mutation: MUTATION_MAP[type],
615
+ variables: { input },
616
+ },
617
+ `saveDocument${type}.answer`,
618
+ );
619
619
 
620
- const wasNew = this.isNew;
620
+ const wasNew = this.isNew;
621
621
 
622
- Object.entries(response).forEach(([key, value]) => {
623
- this.answer.raw[key] = value;
624
- });
622
+ Object.entries(response).forEach(([key, value]) => {
623
+ this.answer.raw[key] = value;
624
+ });
625
625
 
626
- if (wasNew) {
627
- this.answer.pushIntoStore();
628
- }
626
+ if (wasNew) {
627
+ this.answer.pushIntoStore();
628
+ }
629
629
 
630
- return response;
630
+ return response;
631
+ } catch (e) {
632
+ const validationError = e.errors.find(
633
+ (err) => err.extensions?.code === "format_validation_failed",
634
+ );
635
+
636
+ if (validationError) {
637
+ this._errors = [
638
+ ...this._errors,
639
+ {
640
+ type: "format",
641
+ context: { errorMsg: validationError.message },
642
+ value,
643
+ },
644
+ ];
645
+ } else {
646
+ this._errors = [];
647
+ throw e;
648
+ }
649
+ }
631
650
  }
632
651
 
633
652
  /**
@@ -704,35 +723,6 @@ export default class Field extends Base {
704
723
  }
705
724
  }
706
725
 
707
- /**
708
- * Validate the value against the regexes of the given format validators.
709
- *
710
- * @method _validateFormatValidators
711
- * @return {Array<Boolean|Object>} An array of error objects or `true`
712
- * @private
713
- */
714
- _validateFormatValidators() {
715
- const validators =
716
- this.question.raw.formatValidators?.edges.map((edge) => edge.node) ?? [];
717
- const value = this.answer.value;
718
-
719
- if (isEmpty(value)) {
720
- // empty values should not be validated since they are handled by the
721
- // requiredness validation
722
- return validators.map(() => true);
723
- }
724
-
725
- return validators.map((validator) => {
726
- return (
727
- new RegExp(validator.regex).test(value) || {
728
- type: "format",
729
- context: { errorMsg: validator.errorMsg },
730
- value,
731
- }
732
- );
733
- });
734
- }
735
-
736
726
  /**
737
727
  * Method to validate if a question is required or not.
738
728
  *
@@ -757,7 +747,6 @@ export default class Field extends Base {
757
747
  */
758
748
  _validateTextQuestion() {
759
749
  return [
760
- ...this._validateFormatValidators(),
761
750
  validate("length", this.answer.value, {
762
751
  min: this.question.raw.textMinLength || 0,
763
752
  max: this.question.raw.textMaxLength || Number.POSITIVE_INFINITY,
@@ -775,7 +764,6 @@ export default class Field extends Base {
775
764
  */
776
765
  _validateTextareaQuestion() {
777
766
  return [
778
- ...this._validateFormatValidators(),
779
767
  validate("length", this.answer.value, {
780
768
  min: this.question.raw.textareaMinLength || 0,
781
769
  max: this.question.raw.textareaMaxLength || Number.POSITIVE_INFINITY,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectcaluma/ember-form",
3
- "version": "14.3.2",
3
+ "version": "14.4.1",
4
4
  "description": "Ember addon for rendering Caluma forms.",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -17,7 +17,7 @@
17
17
  "@glimmer/tracking": "^1.1.2",
18
18
  "ember-apollo-client": "~4.0.2",
19
19
  "ember-auto-import": "^2.10.0",
20
- "ember-autoresize-modifier": "^0.7.0",
20
+ "ember-autoresize-modifier": "^0.7.0 || ^0.8.0",
21
21
  "ember-basic-dropdown": "^8.4.0",
22
22
  "ember-cli-babel": "^8.2.0",
23
23
  "ember-cli-htmlbars": "^6.3.0",
@@ -28,7 +28,7 @@
28
28
  "ember-flatpickr": "^8.0.1",
29
29
  "ember-in-viewport": "^4.1.0",
30
30
  "ember-intl": "^7.1.1",
31
- "ember-math-helpers": "^4.2.1",
31
+ "ember-math-helpers": "^4.2.1 || ^5.0.0",
32
32
  "ember-power-select": "^8.6.2",
33
33
  "ember-template-imports": "^4.2.0",
34
34
  "ember-truth-helpers": "^4.0.3",
@@ -41,13 +41,13 @@
41
41
  "luxon": "^3.5.0",
42
42
  "reactiveweb": "^1.3.0",
43
43
  "tracked-toolbox": "^2.0.0",
44
- "@projectcaluma/ember-core": "^14.3.2"
44
+ "@projectcaluma/ember-core": "^14.4.1"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@ember/optional-features": "2.2.0",
48
48
  "@ember/test-helpers": "4.0.4",
49
49
  "@embroider/test-setup": "4.0.0",
50
- "@faker-js/faker": "9.7.0",
50
+ "@faker-js/faker": "10.0.0",
51
51
  "broccoli-asset-rev": "3.0.0",
52
52
  "ember-cli": "6.1.0",
53
53
  "ember-cli-clean-css": "3.0.0",
@@ -59,25 +59,25 @@
59
59
  "ember-cli-sri": "2.1.1",
60
60
  "ember-cli-terser": "4.0.2",
61
61
  "ember-load-initializers": "3.0.1",
62
- "ember-qunit": "9.0.2",
63
- "ember-resolver": "13.1.0",
62
+ "ember-qunit": "9.0.3",
63
+ "ember-resolver": "13.1.1",
64
64
  "ember-source": "6.1.0",
65
65
  "ember-source-channel-url": "3.0.0",
66
66
  "ember-try": "4.0.0",
67
67
  "loader.js": "4.7.0",
68
68
  "miragejs": "0.1.48",
69
69
  "qunit": "2.24.1",
70
- "qunit-dom": "3.4.0",
71
- "sass": "1.88.0",
72
- "uikit": "3.23.7",
73
- "uuid": "11.1.0",
74
- "webpack": "5.99.8",
75
- "@projectcaluma/ember-testing": "14.3.2",
76
- "@projectcaluma/ember-workflow": "14.3.2"
70
+ "qunit-dom": "3.5.0",
71
+ "sass": "1.92.1",
72
+ "uikit": "3.23.12",
73
+ "uuid": "12.0.0",
74
+ "webpack": "5.101.3",
75
+ "@projectcaluma/ember-workflow": "14.4.1",
76
+ "@projectcaluma/ember-testing": "14.4.1"
77
77
  },
78
78
  "peerDependencies": {
79
79
  "ember-source": ">= 4.0.0",
80
- "@projectcaluma/ember-workflow": "^14.3.2"
80
+ "@projectcaluma/ember-workflow": "^14.4.1"
81
81
  },
82
82
  "dependenciesMeta": {
83
83
  "@projectcaluma/ember-core": {