@projectcaluma/ember-form 11.0.0-beta.16 → 11.0.0-beta.17
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +23 -0
- package/addon/components/cf-field/hint.hbs +5 -0
- package/addon/components/cf-field.hbs +23 -1
- package/addon/components/cf-field.js +10 -7
- package/addon/gql/fragments/field.graphql +12 -0
- package/addon/helpers/format-graphql-error.js +21 -0
- package/app/components/cf-field/hint.js +1 -0
- package/app/helpers/format-graphql-error.js +1 -0
- package/package.json +12 -12
- package/translations/de.yaml +4 -0
- package/translations/en.yaml +4 -0
- package/translations/fr.yaml +4 -0
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
# [@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)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* **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)
|
7
|
+
|
8
|
+
|
9
|
+
### Features
|
10
|
+
|
11
|
+
* **cf-field:** add optional hints for form fields ([d847fbf](https://github.com/projectcaluma/ember-caluma/commit/d847fbffa376ea60971fb9e91aff8bf54ce77d50))
|
12
|
+
* **form:** show technical details of backend errors in UI ([c34cda6](https://github.com/projectcaluma/ember-caluma/commit/c34cda691f78623f41da1f9d75a39efce7e0ff0f))
|
13
|
+
|
14
|
+
|
15
|
+
### BREAKING CHANGES
|
16
|
+
|
17
|
+
* **cf-field:** Question hints requires Caluma >= v7.15.0
|
18
|
+
|
19
|
+
Add option to create hints for certain question types. These
|
20
|
+
are displayed below the input field and can be used to provide
|
21
|
+
short, informative messages. Hints are available for all question
|
22
|
+
types except for form, static and action button questions.
|
23
|
+
|
1
24
|
# [@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
25
|
|
3
26
|
|
@@ -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
|
-
<
|
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
|
-
|
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.at(-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));
|
@@ -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.
|
3
|
+
"version": "11.0.0-beta.17",
|
4
4
|
"description": "Ember addon for rendering Caluma forms.",
|
5
5
|
"keywords": [
|
6
6
|
"ember-addon"
|
@@ -17,11 +17,11 @@
|
|
17
17
|
"@ember/string": "^3.0.0",
|
18
18
|
"@embroider/macros": "^1.5.0",
|
19
19
|
"@embroider/util": "^1.5.0",
|
20
|
-
"@glimmer/component": "^1.
|
21
|
-
"@glimmer/tracking": "^1.
|
20
|
+
"@glimmer/component": "^1.1.1",
|
21
|
+
"@glimmer/tracking": "^1.1.1",
|
22
22
|
"@projectcaluma/ember-core": "^11.0.0-beta.6",
|
23
23
|
"ember-apollo-client": "^4.0.2",
|
24
|
-
"ember-auto-import": "^2.4.
|
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,7 +29,7 @@
|
|
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.
|
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",
|
@@ -45,11 +45,11 @@
|
|
45
45
|
},
|
46
46
|
"devDependencies": {
|
47
47
|
"@ember/optional-features": "2.0.0",
|
48
|
-
"@ember/test-helpers": "2.
|
48
|
+
"@ember/test-helpers": "2.7.0",
|
49
49
|
"@embroider/test-setup": "1.5.0",
|
50
|
-
"@faker-js/faker": "6.
|
51
|
-
"@projectcaluma/ember-testing": "11.0.0-beta.
|
52
|
-
"@projectcaluma/ember-workflow": "11.0.0-beta.
|
50
|
+
"@faker-js/faker": "6.1.2",
|
51
|
+
"@projectcaluma/ember-testing": "11.0.0-beta.6",
|
52
|
+
"@projectcaluma/ember-workflow": "11.0.0-beta.6",
|
53
53
|
"broccoli-asset-rev": "3.0.0",
|
54
54
|
"ember-cli": "3.28.5",
|
55
55
|
"ember-cli-code-coverage": "1.0.3",
|
@@ -70,13 +70,13 @@
|
|
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.
|
73
|
+
"qunit": "2.18.1",
|
74
74
|
"qunit-dom": "2.0.0",
|
75
75
|
"uuid": "8.3.2",
|
76
|
-
"webpack": "5.
|
76
|
+
"webpack": "5.71.0"
|
77
77
|
},
|
78
78
|
"peerDependencies": {
|
79
|
-
"@projectcaluma/ember-workflow": "^11.0.0-beta.
|
79
|
+
"@projectcaluma/ember-workflow": "^11.0.0-beta.6"
|
80
80
|
},
|
81
81
|
"peerDependenciesMeta": {
|
82
82
|
"@projectcaluma/ember-workflow": {
|
package/translations/de.yaml
CHANGED
@@ -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"
|
package/translations/en.yaml
CHANGED
@@ -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"
|
package/translations/fr.yaml
CHANGED
@@ -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"
|