@projectcaluma/ember-form 11.0.0-beta.14 → 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 +39 -0
- package/addon/components/cf-field/hint.hbs +5 -0
- package/addon/components/cf-field/input/action-button.hbs +23 -17
- package/addon/components/cf-field/input/action-button.js +72 -55
- package/addon/components/cf-field/input/checkbox.hbs +2 -3
- package/addon/components/cf-field/input/powerselect.hbs +27 -29
- package/addon/components/cf-field/input/powerselect.js +8 -2
- package/addon/components/cf-field/input/radio.hbs +1 -1
- package/addon/components/cf-field/input.hbs +8 -21
- package/addon/components/cf-field/input.js +32 -14
- 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/addon/lib/field.js +4 -0
- package/app/components/cf-field/hint.js +1 -0
- package/app/helpers/format-graphql-error.js +1 -0
- package/app/helpers/get-widget.js +1 -4
- package/app/styles/@projectcaluma/ember-form.scss +0 -17
- package/package.json +24 -14
- 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,42 @@
|
|
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
|
+
|
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)
|
25
|
+
|
26
|
+
|
27
|
+
### Bug Fixes
|
28
|
+
|
29
|
+
* **embroider:** add missing dependency on @ember/string ([3a6e6bb](https://github.com/projectcaluma/ember-caluma/commit/3a6e6bb39a8c1a40a2ae00b3d4ea00606a755e25))
|
30
|
+
* **embroider:** fix dynamic component usage ([1cf0f6e](https://github.com/projectcaluma/ember-caluma/commit/1cf0f6e2914651bbb0ec70d1f7485fd9db90c9b5))
|
31
|
+
* **embroider:** remove obsolete export for getWidget helper function ([94fb461](https://github.com/projectcaluma/ember-caluma/commit/94fb461aaa7cac6af9f5612b8f34ad047a2b67bb))
|
32
|
+
|
33
|
+
# [@projectcaluma/ember-form-v11.0.0-beta.15](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.14...@projectcaluma/ember-form-v11.0.0-beta.15) (2022-03-16)
|
34
|
+
|
35
|
+
|
36
|
+
### Bug Fixes
|
37
|
+
|
38
|
+
* **form:** make sure dynamic options are loaded before validating ([2713b37](https://github.com/projectcaluma/ember-caluma/commit/2713b3718b64f9111ca3e7bec2a6c60fafcb183a))
|
39
|
+
|
1
40
|
# [@projectcaluma/ember-form-v11.0.0-beta.14](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.13...@projectcaluma/ember-form-v11.0.0-beta.14) (2022-03-11)
|
2
41
|
|
3
42
|
|
@@ -1,17 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
<
|
7
|
-
@
|
8
|
-
@
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
1
|
+
{{#if
|
2
|
+
(macroCondition
|
3
|
+
(macroDependencySatisfies "@projectcaluma/ember-workflow" "*")
|
4
|
+
)
|
5
|
+
}}
|
6
|
+
<DocumentValidity
|
7
|
+
@document={{@field.document}}
|
8
|
+
@validateOnEnter={{this.validateOnEnter}}
|
9
|
+
as |isValid validate|
|
10
|
+
>
|
11
|
+
<WorkItemButton
|
12
|
+
@workItemId={{this.workItem}}
|
13
|
+
@mutation={{this.action}}
|
14
|
+
@label={{@field.question.raw.label}}
|
15
|
+
@disabled={{or (and (not-eq isValid null) (not isValid)) @disabled}}
|
16
|
+
@color={{this.color}}
|
17
|
+
@beforeMutate={{fn this.beforeMutate validate}}
|
18
|
+
@onSuccess={{this.onSuccess}}
|
19
|
+
@onError={{this.onError}}
|
20
|
+
class={{if @disabled "uk-hidden"}}
|
21
|
+
/>
|
22
|
+
</DocumentValidity>
|
23
|
+
{{/if}}
|
@@ -1,61 +1,78 @@
|
|
1
1
|
import { assert } from "@ember/debug";
|
2
2
|
import { action } from "@ember/object";
|
3
|
+
import { dependencySatisfies, macroCondition } from "@embroider/macros";
|
3
4
|
import Component from "@glimmer/component";
|
4
5
|
import { confirm } from "ember-uikit";
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
7
|
+
let CfFieldInputActionButtonComponent;
|
8
|
+
|
9
|
+
if (macroCondition(dependencySatisfies("@projectcaluma/ember-workflow", ""))) {
|
10
|
+
CfFieldInputActionButtonComponent = class extends Component {
|
11
|
+
constructor(...args) {
|
12
|
+
super(...args);
|
13
|
+
|
14
|
+
assert(
|
15
|
+
"The document must have a `workItemUuid` for `<CfField::Input::ActionButton />` to work.",
|
16
|
+
this.args.field.document.workItemUuid
|
17
|
+
);
|
18
|
+
}
|
19
|
+
|
20
|
+
get workItem() {
|
21
|
+
return (
|
22
|
+
this.args.context?.actionButtonWorkItemId ||
|
23
|
+
this.args.field.document.workItemUuid
|
24
|
+
);
|
25
|
+
}
|
26
|
+
|
27
|
+
get action() {
|
28
|
+
return this.args.field.question.raw.action.toLowerCase();
|
29
|
+
}
|
30
|
+
|
31
|
+
get color() {
|
32
|
+
return this.args.field.question.raw.color.toLowerCase();
|
33
|
+
}
|
34
|
+
|
35
|
+
get validateOnEnter() {
|
36
|
+
return (
|
37
|
+
this.args.field.question.raw.action === "COMPLETE" &&
|
38
|
+
this.args.field.question.raw.validateOnEnter
|
39
|
+
);
|
40
|
+
}
|
41
|
+
|
42
|
+
@action
|
43
|
+
async beforeMutate(validateFn) {
|
44
|
+
if (
|
45
|
+
this.args.field.question.raw.action === "COMPLETE" &&
|
46
|
+
!(await validateFn())
|
47
|
+
) {
|
48
|
+
return false;
|
49
|
+
}
|
50
|
+
|
51
|
+
const confirmText = this.args.field.question.raw.infoText;
|
52
|
+
|
53
|
+
return !confirmText || confirm(confirmText);
|
54
|
+
}
|
55
|
+
|
56
|
+
@action
|
57
|
+
onSuccess() {
|
58
|
+
return this.args.context?.actionButtonOnSuccess?.();
|
59
|
+
}
|
60
|
+
|
61
|
+
@action
|
62
|
+
onError(error) {
|
63
|
+
return this.args.context?.actionButtonOnError?.(error);
|
64
|
+
}
|
65
|
+
};
|
66
|
+
} else {
|
67
|
+
CfFieldInputActionButtonComponent = class extends Component {
|
68
|
+
constructor(...args) {
|
69
|
+
super(...args);
|
70
|
+
|
71
|
+
assert(
|
72
|
+
"@projectcaluma/ember-workflow must be installed to enable the usage of the action button questions"
|
73
|
+
);
|
74
|
+
}
|
75
|
+
};
|
61
76
|
}
|
77
|
+
|
78
|
+
export default CfFieldInputActionButtonComponent;
|
@@ -1,8 +1,7 @@
|
|
1
1
|
{{#each @field.options as |option i|}}
|
2
|
-
{{#if (gt i 0)}}<br />{{/if}}
|
2
|
+
{{#if (and (gt i 0) (not @field.raw.question.meta.vertical))}}<br />{{/if}}
|
3
3
|
<label
|
4
|
-
class="
|
5
|
-
{{if @field.isInvalid 'uk-form-danger'}}
|
4
|
+
class="{{if @field.isInvalid 'uk-form-danger'}}
|
6
5
|
{{if @field.raw.question.meta.vertical 'uk-margin-large-right'}}"
|
7
6
|
>
|
8
7
|
<input
|
@@ -1,29 +1,27 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
{{
|
26
|
-
|
27
|
-
|
28
|
-
</DynamicSelect>
|
29
|
-
{{/let}}
|
1
|
+
<this.selectComponent
|
2
|
+
@options={{@field.options}}
|
3
|
+
@selected={{@field.selected}}
|
4
|
+
@disabled={{@disabled}}
|
5
|
+
@allowClear={{true}}
|
6
|
+
@preventScroll={{true}}
|
7
|
+
@searchEnabled={{this.searchEnabled}}
|
8
|
+
@searchField="label"
|
9
|
+
@triggerId={{@field.pk}}
|
10
|
+
@renderInPlace={{true}}
|
11
|
+
@placeholder={{this.placeholder}}
|
12
|
+
@loadingMessage={{t "caluma.form.power-select.options-loading"}}
|
13
|
+
@searchMessage={{t "caluma.form.power-select.options-empty"}}
|
14
|
+
@searchPlaceholder={{t "caluma.form.power-select.search-placeholder"}}
|
15
|
+
@noMatchesMessage={{t "caluma.form.power-select.search-empty"}}
|
16
|
+
@onChange={{this.change}}
|
17
|
+
as |option|
|
18
|
+
>
|
19
|
+
{{#if (and option.disabled (not @disabled))}}
|
20
|
+
<del
|
21
|
+
class="uk-text-muted"
|
22
|
+
title={{t "caluma.form.optionNotAvailable"}}
|
23
|
+
>{{option.label}}</del>
|
24
|
+
{{else}}
|
25
|
+
{{option.label}}
|
26
|
+
{{/if}}
|
27
|
+
</this.selectComponent>
|
@@ -1,7 +1,10 @@
|
|
1
1
|
import { getOwner } from "@ember/application";
|
2
2
|
import { action } from "@ember/object";
|
3
3
|
import { inject as service } from "@ember/service";
|
4
|
+
import { ensureSafeComponent } from "@embroider/util";
|
4
5
|
import Component from "@glimmer/component";
|
6
|
+
import PowerSelectComponent from "ember-power-select/components/power-select";
|
7
|
+
import PowerSelectMultipleComponent from "ember-power-select/components/power-select-multiple";
|
5
8
|
|
6
9
|
/**
|
7
10
|
* Dropdown component for the single and multiple choice question type
|
@@ -16,8 +19,11 @@ export default class CfFieldInputPowerselectComponent extends Component {
|
|
16
19
|
return this.args.field?.question.isMultipleChoice;
|
17
20
|
}
|
18
21
|
|
19
|
-
get
|
20
|
-
return
|
22
|
+
get selectComponent() {
|
23
|
+
return ensureSafeComponent(
|
24
|
+
this.multiple ? PowerSelectMultipleComponent : PowerSelectComponent,
|
25
|
+
this
|
26
|
+
);
|
21
27
|
}
|
22
28
|
|
23
29
|
get searchEnabled() {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
{{#each @field.options as |option i|}}
|
2
|
-
{{#if (gt i 0)}}<br />{{/if}}
|
2
|
+
{{#if (and (gt i 0) (not @field.raw.question.meta.vertical))}}<br />{{/if}}
|
3
3
|
<label
|
4
4
|
class="{{if @field.isInvalid 'uk-form-danger'}}
|
5
5
|
{{if @field.raw.question.meta.vertical 'uk-margin-large-right'}}"
|
@@ -1,21 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
)
|
10
|
-
'uk-flex'
|
11
|
-
}}"
|
12
|
-
>
|
13
|
-
<InputComponent
|
14
|
-
@field={{@field}}
|
15
|
-
@disabled={{@disabled}}
|
16
|
-
@onSave={{@onSave}}
|
17
|
-
@context={{@context}}
|
18
|
-
/>
|
19
|
-
</div>
|
20
|
-
{{/let}}
|
21
|
-
{{/if}}
|
1
|
+
<div class="uk-form-controls">
|
2
|
+
<this.inputComponent
|
3
|
+
@field={{@field}}
|
4
|
+
@disabled={{@disabled}}
|
5
|
+
@onSave={{@onSave}}
|
6
|
+
@context={{@context}}
|
7
|
+
/>
|
8
|
+
</div>
|
@@ -1,12 +1,33 @@
|
|
1
|
-
import {
|
1
|
+
import { ensureSafeComponent } from "@embroider/util";
|
2
2
|
import Component from "@glimmer/component";
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
import ActionButtonComponent from "@projectcaluma/ember-form/components/cf-field/input/action-button";
|
5
|
+
import CheckboxComponent from "@projectcaluma/ember-form/components/cf-field/input/checkbox";
|
6
|
+
import DateComponent from "@projectcaluma/ember-form/components/cf-field/input/date";
|
7
|
+
import FileComponent from "@projectcaluma/ember-form/components/cf-field/input/file";
|
8
|
+
import FloatComponent from "@projectcaluma/ember-form/components/cf-field/input/float";
|
9
|
+
import IntegerComponent from "@projectcaluma/ember-form/components/cf-field/input/integer";
|
10
|
+
import RadioComponent from "@projectcaluma/ember-form/components/cf-field/input/radio";
|
11
|
+
import StaticComponent from "@projectcaluma/ember-form/components/cf-field/input/static";
|
12
|
+
import TableComponent from "@projectcaluma/ember-form/components/cf-field/input/table";
|
13
|
+
import TextComponent from "@projectcaluma/ember-form/components/cf-field/input/text";
|
14
|
+
import TextareaComponent from "@projectcaluma/ember-form/components/cf-field/input/textarea";
|
15
|
+
|
16
|
+
const COMPONENT_MAPPING = {
|
17
|
+
ActionButtonQuestion: ActionButtonComponent,
|
18
|
+
CalculatedFloatQuestion: FloatComponent,
|
19
|
+
ChoiceQuestion: RadioComponent,
|
20
|
+
DateQuestion: DateComponent,
|
21
|
+
DynamicChoiceQuestion: RadioComponent,
|
22
|
+
DynamicMultipleChoiceQuestion: CheckboxComponent,
|
23
|
+
FileQuestion: FileComponent,
|
24
|
+
FloatQuestion: FloatComponent,
|
25
|
+
IntegerQuestion: IntegerComponent,
|
26
|
+
MultipleChoiceQuestion: CheckboxComponent,
|
27
|
+
StaticQuestion: StaticComponent,
|
28
|
+
TableQuestion: TableComponent,
|
29
|
+
TextareaQuestion: TextareaComponent,
|
30
|
+
TextQuestion: TextComponent,
|
10
31
|
};
|
11
32
|
|
12
33
|
/**
|
@@ -16,17 +37,14 @@ const mapping = {
|
|
16
37
|
*/
|
17
38
|
export default class CfFieldInputComponent extends Component {
|
18
39
|
/**
|
19
|
-
* The input component
|
40
|
+
* The input component
|
20
41
|
*
|
21
|
-
* @property {
|
42
|
+
* @property {Component} inputComponent
|
22
43
|
* @accessor
|
23
44
|
*/
|
24
|
-
get
|
45
|
+
get inputComponent() {
|
25
46
|
const typename = this.args.field?.question.raw.__typename;
|
26
47
|
|
27
|
-
return (
|
28
|
-
typename &&
|
29
|
-
(mapping[typename] || dasherize(typename.replace(/Question$/, "")))
|
30
|
-
);
|
48
|
+
return ensureSafeComponent(COMPONENT_MAPPING[typename], this);
|
31
49
|
}
|
32
50
|
}
|
@@ -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));
|
package/addon/lib/field.js
CHANGED
@@ -777,6 +777,8 @@ export default class Field extends Base {
|
|
777
777
|
* @private
|
778
778
|
*/
|
779
779
|
async _validateDynamicChoiceQuestion() {
|
780
|
+
await this.question.dynamicOptions;
|
781
|
+
|
780
782
|
return validate("inclusion", this.answer.value, {
|
781
783
|
in: (this.options || []).map(({ slug }) => slug),
|
782
784
|
});
|
@@ -797,6 +799,8 @@ export default class Field extends Base {
|
|
797
799
|
return true;
|
798
800
|
}
|
799
801
|
|
802
|
+
await this.question.dynamicOptions;
|
803
|
+
|
800
804
|
return value.map((value) => {
|
801
805
|
return validate("inclusion", value, {
|
802
806
|
in: (this.options || []).map(({ slug }) => slug),
|
@@ -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";
|
@@ -9,20 +9,3 @@
|
|
9
9
|
min-height: 20px;
|
10
10
|
min-width: 20px;
|
11
11
|
}
|
12
|
-
|
13
|
-
.cf-checkbox_label {
|
14
|
-
display: block;
|
15
|
-
position: relative;
|
16
|
-
padding-left: 26px;
|
17
|
-
|
18
|
-
.uk-checkbox {
|
19
|
-
position: absolute;
|
20
|
-
top: 0.25em;
|
21
|
-
left: 0;
|
22
|
-
margin: 0;
|
23
|
-
}
|
24
|
-
|
25
|
-
& + br {
|
26
|
-
display: none;
|
27
|
-
}
|
28
|
-
}
|
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"
|
@@ -14,12 +14,14 @@
|
|
14
14
|
"test:ember-compatibility": "ember try:each"
|
15
15
|
},
|
16
16
|
"dependencies": {
|
17
|
+
"@ember/string": "^3.0.0",
|
17
18
|
"@embroider/macros": "^1.5.0",
|
18
|
-
"@
|
19
|
-
"@glimmer/
|
20
|
-
"@
|
21
|
-
"ember-
|
22
|
-
"ember-
|
19
|
+
"@embroider/util": "^1.5.0",
|
20
|
+
"@glimmer/component": "^1.1.1",
|
21
|
+
"@glimmer/tracking": "^1.1.1",
|
22
|
+
"@projectcaluma/ember-core": "^11.0.0-beta.6",
|
23
|
+
"ember-apollo-client": "^4.0.2",
|
24
|
+
"ember-auto-import": "^2.4.1",
|
23
25
|
"ember-autoresize-modifier": "^0.5.0",
|
24
26
|
"ember-cli-babel": "^7.26.11",
|
25
27
|
"ember-cli-htmlbars": "^6.0.1",
|
@@ -27,13 +29,13 @@
|
|
27
29
|
"ember-composable-helpers": "^5.0.0",
|
28
30
|
"ember-concurrency": "^2.2.1",
|
29
31
|
"ember-fetch": "^8.1.1",
|
30
|
-
"ember-in-viewport": "^4.0.
|
32
|
+
"ember-in-viewport": "^4.0.2",
|
31
33
|
"ember-intl": "^5.7.2",
|
32
34
|
"ember-math-helpers": "^2.18.1",
|
33
35
|
"ember-pikaday": "^4.0.0",
|
34
36
|
"ember-power-select": "^5.0.4",
|
35
37
|
"ember-resources": "^4.4.0",
|
36
|
-
"ember-uikit": "^5.1.
|
38
|
+
"ember-uikit": "^5.1.1",
|
37
39
|
"ember-validators": "^4.1.2",
|
38
40
|
"graphql": "^15.8.0",
|
39
41
|
"jexl": "^2.3.0",
|
@@ -43,11 +45,11 @@
|
|
43
45
|
},
|
44
46
|
"devDependencies": {
|
45
47
|
"@ember/optional-features": "2.0.0",
|
46
|
-
"@ember/test-helpers": "2.
|
48
|
+
"@ember/test-helpers": "2.7.0",
|
47
49
|
"@embroider/test-setup": "1.5.0",
|
48
|
-
"@faker-js/faker": "6.
|
49
|
-
"@projectcaluma/ember-testing": "11.0.0-beta.
|
50
|
-
"@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",
|
51
53
|
"broccoli-asset-rev": "3.0.0",
|
52
54
|
"ember-cli": "3.28.5",
|
53
55
|
"ember-cli-code-coverage": "1.0.3",
|
@@ -68,10 +70,18 @@
|
|
68
70
|
"loader.js": "4.7.0",
|
69
71
|
"miragejs": "0.1.43",
|
70
72
|
"npm-run-all": "4.1.5",
|
71
|
-
"qunit": "2.18.
|
73
|
+
"qunit": "2.18.1",
|
72
74
|
"qunit-dom": "2.0.0",
|
73
75
|
"uuid": "8.3.2",
|
74
|
-
"webpack": "5.
|
76
|
+
"webpack": "5.71.0"
|
77
|
+
},
|
78
|
+
"peerDependencies": {
|
79
|
+
"@projectcaluma/ember-workflow": "^11.0.0-beta.6"
|
80
|
+
},
|
81
|
+
"peerDependenciesMeta": {
|
82
|
+
"@projectcaluma/ember-workflow": {
|
83
|
+
"optional": true
|
84
|
+
}
|
75
85
|
},
|
76
86
|
"engines": {
|
77
87
|
"node": "12.* || 14.* || >= 16"
|
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"
|