@projectcaluma/ember-form 11.0.0-beta.16 → 11.0.0-beta.19

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,40 @@
1
+ # [@projectcaluma/ember-form-v11.0.0-beta.19](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.18...@projectcaluma/ember-form-v11.0.0-beta.19) (2022-05-09)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **resources:** fix deprecations of ember-resources ([7a84c5c](https://github.com/projectcaluma/ember-caluma/commit/7a84c5c78d5b28f7b5393c64722907728dd5f42b))
7
+
8
+ # [@projectcaluma/ember-form-v11.0.0-beta.18](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.17...@projectcaluma/ember-form-v11.0.0-beta.18) (2022-04-13)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **form:** fix error formatting for older browsers ([9e34876](https://github.com/projectcaluma/ember-caluma/commit/9e3487625ccb73918b32fdf787054bab9114162f))
14
+
15
+ # [@projectcaluma/ember-form-v11.0.0-beta.17](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.16...@projectcaluma/ember-form-v11.0.0-beta.17) (2022-04-07)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **form:** fix error status indicator for backend errors ([03fc27e](https://github.com/projectcaluma/ember-caluma/commit/03fc27e0626edf3a6f774c41d25485158ee6a99d)), closes [#1877](https://github.com/projectcaluma/ember-caluma/issues/1877)
21
+
22
+
23
+ ### Features
24
+
25
+ * **cf-field:** add optional hints for form fields ([d847fbf](https://github.com/projectcaluma/ember-caluma/commit/d847fbffa376ea60971fb9e91aff8bf54ce77d50))
26
+ * **form:** show technical details of backend errors in UI ([c34cda6](https://github.com/projectcaluma/ember-caluma/commit/c34cda691f78623f41da1f9d75a39efce7e0ff0f))
27
+
28
+
29
+ ### BREAKING CHANGES
30
+
31
+ * **cf-field:** Question hints requires Caluma >= v7.15.0
32
+
33
+ Add option to create hints for certain question types. These
34
+ are displayed below the input field and can be used to provide
35
+ short, informative messages. Hints are available for all question
36
+ types except for form, static and action button questions.
37
+
1
38
  # [@projectcaluma/ember-form-v11.0.0-beta.16](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.15...@projectcaluma/ember-form-v11.0.0-beta.16) (2022-03-23)
2
39
 
3
40
 
@@ -4,7 +4,7 @@ import { inject as service } from "@ember/service";
4
4
  import Component from "@glimmer/component";
5
5
  import { queryManager } from "ember-apollo-client";
6
6
  import { dropTask } from "ember-concurrency";
7
- import { useTask } from "ember-resources";
7
+ import { trackedTask } from "ember-resources/util/ember-concurrency";
8
8
 
9
9
  import getDocumentAnswersQuery from "@projectcaluma/ember-form/gql/queries/document-answers.graphql";
10
10
  import getDocumentFormsQuery from "@projectcaluma/ember-form/gql/queries/document-forms.graphql";
@@ -125,7 +125,7 @@ export default class CfContentComponent extends Component {
125
125
  );
126
126
  }
127
127
 
128
- data = useTask(this, this.fetchData, () => [this.args.documentId]);
128
+ data = trackedTask(this, this.fetchData, () => [this.args.documentId]);
129
129
 
130
130
  @dropTask
131
131
  *fetchData() {
@@ -0,0 +1,5 @@
1
+ <div data-test-field-hint={{@field.pk}}>
2
+ <span class="uk-text-small uk-text-muted" ...attributes>
3
+ {{@field.question.raw.hintText}}
4
+ </span>
5
+ </div>
@@ -38,7 +38,25 @@
38
38
  {{#if this.save.isRunning}}
39
39
  <UkSpinner class="uk-animation-fade" />
40
40
  {{else if (or this.save.last.isError @field.isInvalid)}}
41
- <UkIcon @icon="warning" class="uk-animation-fade uk-text-danger" />
41
+ <div class="uk-flex-inline">
42
+ <UkIcon
43
+ @icon="warning"
44
+ class="uk-animation-fade uk-text-danger"
45
+ />
46
+ {{#if this.save.last.error}}
47
+ <div uk-dropdown="pos: bottom-left" class="uk-padding-small">
48
+ <div class="uk-alert uk-alert-danger uk-margin-small">
49
+ {{t "caluma.form.error.intro"}}
50
+ </div>
51
+ <p class="uk-text-meta uk-margin-small">
52
+ {{t "caluma.form.error.details"}}
53
+ </p>
54
+ <pre class="uk-margin-remove">
55
+ {{~format-graphql-error this.save.last.error~}}
56
+ </pre>
57
+ </div>
58
+ {{/if}}
59
+ </div>
42
60
  {{else if this.save.last.isSuccessful}}
43
61
  <UkIcon @icon="check" class="uk-animation-fade uk-text-success" />
44
62
  {{/if}}
@@ -46,6 +64,10 @@
46
64
  {{/if}}
47
65
  </div>
48
66
 
67
+ {{#if (and @field.question.raw.hintText this.hintTextVisible)}}
68
+ <CfField::hint @field={{@field}} />
69
+ {{/if}}
70
+
49
71
  {{#if @field.errors.length}}
50
72
  <CfField::errors @field={{@field}} />
51
73
  {{/if}}
@@ -46,6 +46,15 @@ export default class CfFieldComponent extends Component {
46
46
  return !hasQuestionType(this.args.field?.question, "action-button");
47
47
  }
48
48
 
49
+ get hintTextVisible() {
50
+ return !hasQuestionType(
51
+ this.args.field?.question,
52
+ "action-button",
53
+ "static",
54
+ "form"
55
+ );
56
+ }
57
+
49
58
  get saveIndicatorVisible() {
50
59
  return !hasQuestionType(this.args.field?.question, "action-button");
51
60
  }
@@ -73,12 +82,6 @@ export default class CfFieldComponent extends Component {
73
82
 
74
83
  yield this.args.field.validate.perform();
75
84
 
76
- try {
77
- // Save the new field value unlinked so the fields save task is not
78
- // aborted when this component is destroyed
79
- return yield this.args.field.save.unlinked().perform();
80
- } catch (e) {
81
- // The component was destroyed before the fields save task was finished
82
- }
85
+ return yield this.args.field.save.unlinked().perform();
83
86
  }
84
87
  }
@@ -28,6 +28,7 @@ fragment SimpleQuestion on Question {
28
28
  }
29
29
  }
30
30
  }
31
+ hintText
31
32
  }
32
33
  ... on TextareaQuestion {
33
34
  textareaMinLength: minLength
@@ -46,6 +47,7 @@ fragment SimpleQuestion on Question {
46
47
  }
47
48
  }
48
49
  }
50
+ hintText
49
51
  }
50
52
  ... on IntegerQuestion {
51
53
  integerMinValue: minValue
@@ -55,6 +57,7 @@ fragment SimpleQuestion on Question {
55
57
  value
56
58
  }
57
59
  placeholder
60
+ hintText
58
61
  }
59
62
  ... on FloatQuestion {
60
63
  floatMinValue: minValue
@@ -64,6 +67,7 @@ fragment SimpleQuestion on Question {
64
67
  value
65
68
  }
66
69
  placeholder
70
+ hintText
67
71
  }
68
72
  ... on ChoiceQuestion {
69
73
  choiceOptions: options {
@@ -80,6 +84,7 @@ fragment SimpleQuestion on Question {
80
84
  id
81
85
  value
82
86
  }
87
+ hintText
83
88
  }
84
89
  ... on MultipleChoiceQuestion {
85
90
  multipleChoiceOptions: options {
@@ -96,18 +101,24 @@ fragment SimpleQuestion on Question {
96
101
  id
97
102
  value
98
103
  }
104
+ hintText
99
105
  }
100
106
  ... on DateQuestion {
101
107
  dateDefaultAnswer: defaultAnswer {
102
108
  id
103
109
  value
104
110
  }
111
+ hintText
105
112
  }
106
113
  ... on StaticQuestion {
107
114
  staticContent
108
115
  }
109
116
  ... on CalculatedFloatQuestion {
110
117
  calcExpression
118
+ hintText
119
+ }
120
+ ... on FileQuestion {
121
+ hintText
111
122
  }
112
123
  ... on ActionButtonQuestion {
113
124
  action
@@ -130,6 +141,7 @@ fragment FieldTableQuestion on Question {
130
141
  }
131
142
  }
132
143
  }
144
+ hintText
133
145
  tableDefaultAnswer: defaultAnswer {
134
146
  id
135
147
  value {
@@ -0,0 +1,21 @@
1
+ import { helper } from "@ember/component/helper";
2
+
3
+ export function formatGraphqlErrorObject(error) {
4
+ try {
5
+ const path = error.path.join(".");
6
+ const { line, column } = error.locations[error.locations.length - 1];
7
+
8
+ return `${path}:${line}:${column}: ${error.message}`;
9
+ } catch (e) {
10
+ return null;
11
+ }
12
+ }
13
+
14
+ export function formatGraphqlError(error) {
15
+ return (
16
+ error?.errors?.map(formatGraphqlErrorObject).filter(Boolean).join("\n") ??
17
+ ""
18
+ );
19
+ }
20
+
21
+ export default helper(([error]) => formatGraphqlError(error));
@@ -2,7 +2,7 @@ import { assert } from "@ember/debug";
2
2
  import { camelize } from "@ember/string";
3
3
  import { queryManager } from "ember-apollo-client";
4
4
  import { dropTask } from "ember-concurrency";
5
- import { useTask } from "ember-resources";
5
+ import { trackedTask } from "ember-resources/util/ember-concurrency";
6
6
  import { cached } from "tracked-toolbox";
7
7
 
8
8
  import getDynamicOptions from "@projectcaluma/ember-form/gql/queries/dynamic-options.graphql";
@@ -77,7 +77,7 @@ export default class Question extends Base {
77
77
  );
78
78
  }
79
79
 
80
- dynamicOptions = useTask(this, this.loadDynamicOptions, () => []);
80
+ dynamicOptions = trackedTask(this, this.loadDynamicOptions, () => []);
81
81
 
82
82
  get dynamicChoiceOptions() {
83
83
  return this.dynamicOptions.value ?? [];
@@ -0,0 +1 @@
1
+ export { default } from "@projectcaluma/ember-form/components/cf-field/hint";
@@ -0,0 +1 @@
1
+ export { default } from "@projectcaluma/ember-form/helpers/format-graphql-error";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectcaluma/ember-form",
3
- "version": "11.0.0-beta.16",
3
+ "version": "11.0.0-beta.19",
4
4
  "description": "Ember addon for rendering Caluma forms.",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -15,13 +15,13 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@ember/string": "^3.0.0",
18
- "@embroider/macros": "^1.5.0",
19
- "@embroider/util": "^1.5.0",
20
- "@glimmer/component": "^1.0.4",
21
- "@glimmer/tracking": "^1.0.4",
22
- "@projectcaluma/ember-core": "^11.0.0-beta.6",
18
+ "@embroider/macros": "^1.6.0",
19
+ "@embroider/util": "^1.6.0",
20
+ "@glimmer/component": "^1.1.2",
21
+ "@glimmer/tracking": "^1.1.2",
22
+ "@projectcaluma/ember-core": "^11.0.0-beta.7",
23
23
  "ember-apollo-client": "^4.0.2",
24
- "ember-auto-import": "^2.4.0",
24
+ "ember-auto-import": "^2.4.1",
25
25
  "ember-autoresize-modifier": "^0.5.0",
26
26
  "ember-cli-babel": "^7.26.11",
27
27
  "ember-cli-htmlbars": "^6.0.1",
@@ -29,33 +29,33 @@
29
29
  "ember-composable-helpers": "^5.0.0",
30
30
  "ember-concurrency": "^2.2.1",
31
31
  "ember-fetch": "^8.1.1",
32
- "ember-in-viewport": "^4.0.0",
32
+ "ember-in-viewport": "^4.0.2",
33
33
  "ember-intl": "^5.7.2",
34
34
  "ember-math-helpers": "^2.18.1",
35
35
  "ember-pikaday": "^4.0.0",
36
36
  "ember-power-select": "^5.0.4",
37
- "ember-resources": "^4.4.0",
38
- "ember-uikit": "^5.1.1",
37
+ "ember-resources": "^4.7.1",
38
+ "ember-uikit": "^5.1.3",
39
39
  "ember-validators": "^4.1.2",
40
40
  "graphql": "^15.8.0",
41
41
  "jexl": "^2.3.0",
42
42
  "lodash.isequal": "^4.5.0",
43
- "luxon": "^2.3.1",
43
+ "luxon": "^2.4.0",
44
44
  "tracked-toolbox": "^1.2.3"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@ember/optional-features": "2.0.0",
48
- "@ember/test-helpers": "2.6.0",
49
- "@embroider/test-setup": "1.5.0",
50
- "@faker-js/faker": "6.0.0",
51
- "@projectcaluma/ember-testing": "11.0.0-beta.5",
52
- "@projectcaluma/ember-workflow": "11.0.0-beta.5",
48
+ "@ember/test-helpers": "2.7.0",
49
+ "@embroider/test-setup": "1.6.0",
50
+ "@faker-js/faker": "6.3.1",
51
+ "@projectcaluma/ember-testing": "11.0.0-beta.7",
52
+ "@projectcaluma/ember-workflow": "^11.0.0-beta.7",
53
53
  "broccoli-asset-rev": "3.0.0",
54
54
  "ember-cli": "3.28.5",
55
55
  "ember-cli-code-coverage": "1.0.3",
56
- "ember-cli-dependency-checker": "3.2.0",
56
+ "ember-cli-dependency-checker": "3.3.1",
57
57
  "ember-cli-inject-live-reload": "2.1.0",
58
- "ember-cli-mirage": "3.0.0-alpha.2",
58
+ "ember-cli-mirage": "3.0.0-alpha.3",
59
59
  "ember-cli-sri": "2.1.1",
60
60
  "ember-cli-terser": "4.0.2",
61
61
  "ember-disable-prototype-extensions": "1.1.3",
@@ -64,19 +64,19 @@
64
64
  "ember-maybe-import-regenerator": "1.0.0",
65
65
  "ember-qunit": "5.1.5",
66
66
  "ember-resolver": "8.0.3",
67
- "ember-source": "3.28.8",
67
+ "ember-source": "3.28.9",
68
68
  "ember-source-channel-url": "3.0.0",
69
69
  "ember-try": "2.0.0",
70
70
  "loader.js": "4.7.0",
71
71
  "miragejs": "0.1.43",
72
72
  "npm-run-all": "4.1.5",
73
- "qunit": "2.18.0",
73
+ "qunit": "2.19.1",
74
74
  "qunit-dom": "2.0.0",
75
75
  "uuid": "8.3.2",
76
- "webpack": "5.70.0"
76
+ "webpack": "5.72.0"
77
77
  },
78
78
  "peerDependencies": {
79
- "@projectcaluma/ember-workflow": "^11.0.0-beta.5"
79
+ "@projectcaluma/ember-workflow": "^11.0.0-beta.6"
80
80
  },
81
81
  "peerDependenciesMeta": {
82
82
  "@projectcaluma/ember-workflow": {
@@ -12,6 +12,10 @@ caluma:
12
12
  optionNotAvailable: "Diese Option ist nicht mehr verfügbar"
13
13
  info: "Mehr Informationen"
14
14
 
15
+ error:
16
+ intro: "Oh nein, auf unserer Seite ist etwas schief gelaufen. Ihre Antwort konnte nicht gespeichert werden."
17
+ details: "Technische Details:"
18
+
15
19
  navigation:
16
20
  next: "Weiter"
17
21
  previous: "Zurück"
@@ -12,6 +12,10 @@ caluma:
12
12
  optionNotAvailable: "This option is not available anymore"
13
13
  info: "More information"
14
14
 
15
+ error:
16
+ intro: "Oh no, something went wrong on our side. Your answer could not be saved."
17
+ details: "Technical details:"
18
+
15
19
  navigation:
16
20
  next: "Next"
17
21
  previous: "Previous"
@@ -12,6 +12,10 @@ caluma:
12
12
  optionNotAvailable: "Cette option n'est plus disponible"
13
13
  info: "Plus d'informations"
14
14
 
15
+ error:
16
+ intro: "Oh non, quelque chose a mal tourné de notre côté. Votre réponse n'a pas pu être sauvegardée."
17
+ details: "Détails techniques :"
18
+
15
19
  navigation:
16
20
  next: "suivante"
17
21
  previous: "précédente"