@projectcaluma/ember-form 11.0.0-beta.12 → 11.0.0-beta.15
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +29 -0
- package/addon/components/cf-field/input/action-button.js +1 -11
- package/addon/components/cf-field/input/date.hbs +1 -0
- package/addon/components/cf-field/input/date.js +9 -0
- package/addon/components/cf-field/input/table.hbs +2 -2
- package/addon/components/cf-field/input/table.js +1 -11
- package/addon/components/cf-field.hbs +4 -1
- package/addon/components/cf-field.js +4 -5
- package/addon/components/cf-form-wrapper.hbs +3 -1
- package/addon/helpers/get-widget.js +16 -2
- package/addon/instance-initializers/form-widget-overrides.js +52 -0
- package/addon/lib/field.js +3 -9
- package/addon/lib/navigation.js +3 -1
- package/addon/lib/question.js +12 -4
- package/app/instance-initializers/form-widget-overrides.js +4 -0
- package/app/styles/@projectcaluma/ember-form.scss +5 -0
- package/package.json +13 -12
- package/translations/de.yaml +1 -1
- package/translations/en.yaml +1 -1
- package/translations/fr.yaml +1 -1
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,32 @@
|
|
1
|
+
# [@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)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* **form:** make sure dynamic options are loaded before validating ([2713b37](https://github.com/projectcaluma/ember-caluma/commit/2713b3718b64f9111ca3e7bec2a6c60fafcb183a))
|
7
|
+
|
8
|
+
# [@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)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* **form:** make sure table controls are always visible ([8cd97d2](https://github.com/projectcaluma/ember-caluma/commit/8cd97d204539f2e84b9baf9841591460bddf145a))
|
14
|
+
|
15
|
+
# [@projectcaluma/ember-form-v11.0.0-beta.13](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.12...@projectcaluma/ember-form-v11.0.0-beta.13) (2022-03-11)
|
16
|
+
|
17
|
+
|
18
|
+
### Bug Fixes
|
19
|
+
|
20
|
+
* **form:** don't refetch dynamic options on validation ([27061c6](https://github.com/projectcaluma/ember-caluma/commit/27061c67f0562508f558305247cb51d615fa36b0))
|
21
|
+
* **form:** fix input in date fields ([cf54bf5](https://github.com/projectcaluma/ember-caluma/commit/cf54bf5542e35fd7dbe293a9e22288afae6a517a))
|
22
|
+
* **navigation:** exclude static questions from visible fields ([6ebd085](https://github.com/projectcaluma/ember-caluma/commit/6ebd085098df71fab693dec5282ea4b81d5b9836))
|
23
|
+
* **workflow:** return case status on complete / skip work-item mutation ([524453c](https://github.com/projectcaluma/ember-caluma/commit/524453c1189b4375ca792fca7d35056b916696f8))
|
24
|
+
|
25
|
+
|
26
|
+
### Features
|
27
|
+
|
28
|
+
* **form:** support passing component override classes ([9409c7c](https://github.com/projectcaluma/ember-caluma/commit/9409c7cb5901dcdffec1c0294046da64b74b9922))
|
29
|
+
|
1
30
|
# [@projectcaluma/ember-form-v11.0.0-beta.12](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.11...@projectcaluma/ember-form-v11.0.0-beta.12) (2022-02-23)
|
2
31
|
|
3
32
|
|
@@ -1,17 +1,7 @@
|
|
1
1
|
import { assert } from "@ember/debug";
|
2
2
|
import { action } from "@ember/object";
|
3
3
|
import Component from "@glimmer/component";
|
4
|
-
import
|
5
|
-
|
6
|
-
async function confirm(text) {
|
7
|
-
try {
|
8
|
-
await UIkit.modal.confirm(text);
|
9
|
-
|
10
|
-
return true;
|
11
|
-
} catch (error) {
|
12
|
-
return false;
|
13
|
-
}
|
14
|
-
}
|
4
|
+
import { confirm } from "ember-uikit";
|
15
5
|
|
16
6
|
export default class CfFieldInputActionButtonComponent extends Component {
|
17
7
|
constructor(...args) {
|
@@ -16,6 +16,15 @@ export default class CfFieldInputDateComponent extends Component {
|
|
16
16
|
this.args.onSave(date ? DateTime.fromJSDate(date).toISODate() : null);
|
17
17
|
}
|
18
18
|
|
19
|
+
@action
|
20
|
+
parseDate(value) {
|
21
|
+
const date = DateTime.fromFormat(value, "D", {
|
22
|
+
locale: this.intl.primaryLocale,
|
23
|
+
});
|
24
|
+
|
25
|
+
return date.isValid ? date.toJSDate() : null;
|
26
|
+
}
|
27
|
+
|
19
28
|
@action
|
20
29
|
formatDate(date) {
|
21
30
|
return this.intl.formatDate(date, {
|
@@ -29,7 +29,7 @@
|
|
29
29
|
@color="link"
|
30
30
|
@onClick={{fn this.edit document}}
|
31
31
|
title={{t "caluma.form.edit"}}
|
32
|
-
class="uk-flex-inline uk-margin-small-left"
|
32
|
+
class="uk-flex-inline uk-margin-small-left table-controls"
|
33
33
|
data-test-edit-row
|
34
34
|
>
|
35
35
|
<UkIcon @icon="pencil" />
|
@@ -40,7 +40,7 @@
|
|
40
40
|
@color="link"
|
41
41
|
@onClick={{fn (perform this.delete) document}}
|
42
42
|
title={{t "caluma.form.delete"}}
|
43
|
-
class="uk-flex-inline uk-margin-small-left"
|
43
|
+
class="uk-flex-inline uk-margin-small-left table-controls"
|
44
44
|
data-test-delete-row
|
45
45
|
>
|
46
46
|
<UkIcon @icon="trash" />
|
@@ -5,22 +5,12 @@ import Component from "@glimmer/component";
|
|
5
5
|
import { tracked } from "@glimmer/tracking";
|
6
6
|
import { queryManager } from "ember-apollo-client";
|
7
7
|
import { dropTask } from "ember-concurrency";
|
8
|
-
import
|
8
|
+
import { confirm } from "ember-uikit";
|
9
9
|
|
10
10
|
import removeDocumentMutation from "@projectcaluma/ember-form/gql/mutations/remove-document.graphql";
|
11
11
|
import saveDocumentMutation from "@projectcaluma/ember-form/gql/mutations/save-document.graphql";
|
12
12
|
import { parseDocument } from "@projectcaluma/ember-form/lib/parsers";
|
13
13
|
|
14
|
-
async function confirm(text) {
|
15
|
-
try {
|
16
|
-
await UIkit.modal.confirm(text);
|
17
|
-
|
18
|
-
return true;
|
19
|
-
} catch (error) {
|
20
|
-
return false;
|
21
|
-
}
|
22
|
-
}
|
23
|
-
|
24
14
|
export default class CfFieldInputTableComponent extends Component {
|
25
15
|
@service notification;
|
26
16
|
@service intl;
|
@@ -14,7 +14,10 @@
|
|
14
14
|
|
15
15
|
<div class="uk-flex">
|
16
16
|
<div class="uk-width-expand">
|
17
|
-
{{#let
|
17
|
+
{{#let
|
18
|
+
(component (ensure-safe-component (get-widget @field.question)))
|
19
|
+
as |FieldComponent|
|
20
|
+
}}
|
18
21
|
<FieldComponent
|
19
22
|
@field={{@field}}
|
20
23
|
@disabled={{@disabled}}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { getOwner } from "@ember/application";
|
2
1
|
import { action } from "@ember/object";
|
2
|
+
import { macroCondition, isTesting } from "@embroider/macros";
|
3
3
|
import Component from "@glimmer/component";
|
4
4
|
import { timeout, restartableTask } from "ember-concurrency";
|
5
5
|
|
@@ -60,11 +60,10 @@ export default class CfFieldComponent extends Component {
|
|
60
60
|
*/
|
61
61
|
@restartableTask
|
62
62
|
*save(value) {
|
63
|
-
const { environment } =
|
64
|
-
getOwner(this).resolveRegistration("config:environment");
|
65
|
-
|
66
63
|
/* istanbul ignore next */
|
67
|
-
if (
|
64
|
+
if (macroCondition(isTesting())) {
|
65
|
+
// no timeout
|
66
|
+
} else {
|
68
67
|
yield timeout(500);
|
69
68
|
}
|
70
69
|
|
@@ -1,6 +1,15 @@
|
|
1
1
|
import Helper from "@ember/component/helper";
|
2
2
|
import { warn } from "@ember/debug";
|
3
3
|
import { inject as service } from "@ember/service";
|
4
|
+
import { ensureSafeComponent } from "@embroider/util";
|
5
|
+
|
6
|
+
import InputComponent from "@projectcaluma/ember-form/components/cf-field/input";
|
7
|
+
import FormComponent from "@projectcaluma/ember-form/components/cf-form";
|
8
|
+
|
9
|
+
const DEFAULT_WIDGETS = {
|
10
|
+
"cf-field/input": InputComponent,
|
11
|
+
"cf-form": FormComponent,
|
12
|
+
};
|
4
13
|
|
5
14
|
/**
|
6
15
|
* Helper for getting the right widget.
|
@@ -42,9 +51,14 @@ export default class GetWidgetHelper extends Helper {
|
|
42
51
|
{ id: "ember-caluma.unregistered-override" }
|
43
52
|
);
|
44
53
|
|
45
|
-
if (override)
|
54
|
+
if (override) {
|
55
|
+
return ensureSafeComponent(
|
56
|
+
override.componentClass ?? override.component,
|
57
|
+
this
|
58
|
+
);
|
59
|
+
}
|
46
60
|
}
|
47
61
|
|
48
|
-
return defaultWidget;
|
62
|
+
return ensureSafeComponent(DEFAULT_WIDGETS[defaultWidget], this);
|
49
63
|
}
|
50
64
|
}
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import { setOwner } from "@ember/application";
|
2
|
+
import { inject as service } from "@ember/service";
|
3
|
+
|
4
|
+
import HiddenComponent from "@projectcaluma/ember-form/components/cf-field/input/hidden";
|
5
|
+
import PowerSelectComponent from "@projectcaluma/ember-form/components/cf-field/input/powerselect";
|
6
|
+
|
7
|
+
class HiddenOverride {
|
8
|
+
@service intl;
|
9
|
+
|
10
|
+
get label() {
|
11
|
+
return this.intl.t("caluma.form-builder.question.widgetOverrides.hidden");
|
12
|
+
}
|
13
|
+
|
14
|
+
component = "cf-field/input/hidden";
|
15
|
+
componentClass = HiddenComponent;
|
16
|
+
}
|
17
|
+
|
18
|
+
class PowerSelectOverride {
|
19
|
+
@service intl;
|
20
|
+
|
21
|
+
get label() {
|
22
|
+
return this.intl.t(
|
23
|
+
"caluma.form-builder.question.widgetOverrides.powerselect"
|
24
|
+
);
|
25
|
+
}
|
26
|
+
|
27
|
+
component = "cf-field/input/powerselect";
|
28
|
+
componentClass = PowerSelectComponent;
|
29
|
+
types = [
|
30
|
+
"ChoiceQuestion",
|
31
|
+
"MultipleChoiceQuestion",
|
32
|
+
"DynamicChoiceQuestion",
|
33
|
+
"DynamicMultipleChoiceQuestion",
|
34
|
+
];
|
35
|
+
}
|
36
|
+
|
37
|
+
export function initialize(appInstance) {
|
38
|
+
const options = appInstance.lookup("service:caluma-options");
|
39
|
+
|
40
|
+
const hiddenOverride = new HiddenOverride();
|
41
|
+
const powerSelectOverride = new PowerSelectOverride();
|
42
|
+
|
43
|
+
setOwner(hiddenOverride, appInstance);
|
44
|
+
setOwner(powerSelectOverride, appInstance);
|
45
|
+
|
46
|
+
options.registerComponentOverride(hiddenOverride);
|
47
|
+
options.registerComponentOverride(powerSelectOverride);
|
48
|
+
}
|
49
|
+
|
50
|
+
export default {
|
51
|
+
initialize,
|
52
|
+
};
|
package/addon/lib/field.js
CHANGED
@@ -83,18 +83,12 @@ export default class Field extends Base {
|
|
83
83
|
_createQuestion() {
|
84
84
|
const owner = getOwner(this);
|
85
85
|
|
86
|
-
|
86
|
+
this.question =
|
87
87
|
this.calumaStore.find(`Question:${this.raw.question.slug}`) ||
|
88
88
|
new (owner.factoryFor("caluma-model:question").class)({
|
89
89
|
raw: this.raw.question,
|
90
90
|
owner,
|
91
91
|
});
|
92
|
-
|
93
|
-
if (question.isDynamic) {
|
94
|
-
question.loadDynamicOptions.perform();
|
95
|
-
}
|
96
|
-
|
97
|
-
this.question = question;
|
98
92
|
}
|
99
93
|
|
100
94
|
_createAnswer() {
|
@@ -783,7 +777,7 @@ export default class Field extends Base {
|
|
783
777
|
* @private
|
784
778
|
*/
|
785
779
|
async _validateDynamicChoiceQuestion() {
|
786
|
-
await this.question.
|
780
|
+
await this.question.dynamicOptions;
|
787
781
|
|
788
782
|
return validate("inclusion", this.answer.value, {
|
789
783
|
in: (this.options || []).map(({ slug }) => slug),
|
@@ -805,7 +799,7 @@ export default class Field extends Base {
|
|
805
799
|
return true;
|
806
800
|
}
|
807
801
|
|
808
|
-
await this.question.
|
802
|
+
await this.question.dynamicOptions;
|
809
803
|
|
810
804
|
return value.map((value) => {
|
811
805
|
return validate("inclusion", value, {
|
package/addon/lib/navigation.js
CHANGED
@@ -232,7 +232,9 @@ export class NavigationItem extends Base {
|
|
232
232
|
@cached
|
233
233
|
get visibleFields() {
|
234
234
|
return this.fieldset.fields.filter(
|
235
|
-
(f) =>
|
235
|
+
(f) =>
|
236
|
+
!["FormQuestion", "StaticQuestion"].includes(f.questionType) &&
|
237
|
+
!f.hidden
|
236
238
|
);
|
237
239
|
}
|
238
240
|
|
package/addon/lib/question.js
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
import { assert } from "@ember/debug";
|
2
2
|
import { camelize } from "@ember/string";
|
3
3
|
import { queryManager } from "ember-apollo-client";
|
4
|
-
import { dropTask
|
4
|
+
import { dropTask } from "ember-concurrency";
|
5
|
+
import { useTask } from "ember-resources";
|
5
6
|
import { cached } from "tracked-toolbox";
|
6
7
|
|
7
8
|
import getDynamicOptions from "@projectcaluma/ember-form/gql/queries/dynamic-options.graphql";
|
@@ -71,13 +72,20 @@ export default class Question extends Base {
|
|
71
72
|
);
|
72
73
|
|
73
74
|
return (
|
74
|
-
question.node.dynamicChoiceOptions
|
75
|
+
question.node.dynamicChoiceOptions ??
|
75
76
|
question.node.dynamicMultipleChoiceOptions
|
76
77
|
);
|
77
78
|
}
|
78
79
|
|
79
|
-
|
80
|
-
|
80
|
+
dynamicOptions = useTask(this, this.loadDynamicOptions, () => []);
|
81
|
+
|
82
|
+
get dynamicChoiceOptions() {
|
83
|
+
return this.dynamicOptions.value ?? [];
|
84
|
+
}
|
85
|
+
|
86
|
+
get dynamicMultipleChoiceOptions() {
|
87
|
+
return this.dynamicOptions.value ?? [];
|
88
|
+
}
|
81
89
|
|
82
90
|
/**
|
83
91
|
* Whether the question is a single choice question
|
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.15",
|
4
4
|
"description": "Ember addon for rendering Caluma forms.",
|
5
5
|
"keywords": [
|
6
6
|
"ember-addon"
|
@@ -14,10 +14,11 @@
|
|
14
14
|
"test:ember-compatibility": "ember try:each"
|
15
15
|
},
|
16
16
|
"dependencies": {
|
17
|
+
"@embroider/macros": "^1.5.0",
|
17
18
|
"@glimmer/component": "^1.0.4",
|
18
19
|
"@glimmer/tracking": "^1.0.4",
|
19
|
-
"@projectcaluma/ember-core": "^11.0.0-beta.
|
20
|
-
"ember-apollo-client": "^3.2.
|
20
|
+
"@projectcaluma/ember-core": "^11.0.0-beta.5",
|
21
|
+
"ember-apollo-client": "^3.2.1",
|
21
22
|
"ember-auto-import": "^2.4.0",
|
22
23
|
"ember-autoresize-modifier": "^0.5.0",
|
23
24
|
"ember-cli-babel": "^7.26.11",
|
@@ -31,28 +32,28 @@
|
|
31
32
|
"ember-math-helpers": "^2.18.1",
|
32
33
|
"ember-pikaday": "^4.0.0",
|
33
34
|
"ember-power-select": "^5.0.4",
|
34
|
-
"ember-resources": "^4.
|
35
|
-
"ember-uikit": "^5.
|
35
|
+
"ember-resources": "^4.4.0",
|
36
|
+
"ember-uikit": "^5.1.0",
|
36
37
|
"ember-validators": "^4.1.2",
|
37
38
|
"graphql": "^15.8.0",
|
38
39
|
"jexl": "^2.3.0",
|
39
40
|
"lodash.isequal": "^4.5.0",
|
40
|
-
"luxon": "^2.3.
|
41
|
+
"luxon": "^2.3.1",
|
41
42
|
"tracked-toolbox": "^1.2.3"
|
42
43
|
},
|
43
44
|
"devDependencies": {
|
44
45
|
"@ember/optional-features": "2.0.0",
|
45
46
|
"@ember/test-helpers": "2.6.0",
|
46
|
-
"@embroider/test-setup": "1.
|
47
|
-
"@faker-js/faker": "6.0.0-
|
48
|
-
"@projectcaluma/ember-testing": "11.0.0-beta.
|
49
|
-
"@projectcaluma/ember-workflow": "11.0.0-beta.
|
47
|
+
"@embroider/test-setup": "1.5.0",
|
48
|
+
"@faker-js/faker": "6.0.0-beta.0",
|
49
|
+
"@projectcaluma/ember-testing": "11.0.0-beta.4",
|
50
|
+
"@projectcaluma/ember-workflow": "11.0.0-beta.5",
|
50
51
|
"broccoli-asset-rev": "3.0.0",
|
51
52
|
"ember-cli": "3.28.5",
|
52
53
|
"ember-cli-code-coverage": "1.0.3",
|
53
54
|
"ember-cli-dependency-checker": "3.2.0",
|
54
55
|
"ember-cli-inject-live-reload": "2.1.0",
|
55
|
-
"ember-cli-mirage": "
|
56
|
+
"ember-cli-mirage": "3.0.0-alpha.2",
|
56
57
|
"ember-cli-sri": "2.1.1",
|
57
58
|
"ember-cli-terser": "4.0.2",
|
58
59
|
"ember-disable-prototype-extensions": "1.1.3",
|
@@ -70,7 +71,7 @@
|
|
70
71
|
"qunit": "2.18.0",
|
71
72
|
"qunit-dom": "2.0.0",
|
72
73
|
"uuid": "8.3.2",
|
73
|
-
"webpack": "5.
|
74
|
+
"webpack": "5.70.0"
|
74
75
|
},
|
75
76
|
"engines": {
|
76
77
|
"node": "12.* || 14.* || >= 16"
|
package/translations/de.yaml
CHANGED
@@ -34,7 +34,6 @@ caluma:
|
|
34
34
|
options-empty: "Keine Optionen vorhanden"
|
35
35
|
search-placeholder: "Hier tippen um zu suchen"
|
36
36
|
search-empty: "Keine Optionen gefunden"
|
37
|
-
null: "Keine Auswahl"
|
38
37
|
|
39
38
|
validation:
|
40
39
|
blank: "Dieses Feld darf nicht leer gelassen werden"
|
@@ -44,6 +43,7 @@ caluma:
|
|
44
43
|
lessThanOrEqualTo: "Die Eingabe in diesem Feld darf nicht grösser als {lte} sein"
|
45
44
|
notAnInteger: "Bitte geben Sie eine ganze Zahl ein"
|
46
45
|
inclusion: "'{value}' ist kein gültiger Wert für dieses Feld"
|
46
|
+
deleteFailed: "Beim Löschen ist ein Fehler aufgetreten."
|
47
47
|
uploadFailed: "Beim Hochladen ist ein Fehler aufgetreten."
|
48
48
|
format: "{errorMsg}"
|
49
49
|
table: "Mindestens eine Zeile der Tabelle wurde nicht korrekt ausgefüllt"
|
package/translations/en.yaml
CHANGED
@@ -34,7 +34,6 @@ caluma:
|
|
34
34
|
options-empty: "No options available"
|
35
35
|
search-placeholder: "Type here to search options"
|
36
36
|
search-empty: "Search didn't match any options"
|
37
|
-
null: "No selection"
|
38
37
|
|
39
38
|
validation:
|
40
39
|
blank: "This field can't be blank"
|
@@ -44,6 +43,7 @@ caluma:
|
|
44
43
|
lessThanOrEqualTo: "The value of this field must be less than or equal to {lte}"
|
45
44
|
notAnInteger: "The value of this field must be an integer"
|
46
45
|
inclusion: "'{value}' is not a valid value for this field"
|
46
|
+
deleteFailed: "An error occured during deletion."
|
47
47
|
uploadFailed: "An error occured during upload."
|
48
48
|
format: "{errorMsg}"
|
49
49
|
table: "At least one row of the table was not filled in correctly"
|
package/translations/fr.yaml
CHANGED
@@ -34,7 +34,6 @@ caluma:
|
|
34
34
|
options-empty: "Pas d'options disponibles"
|
35
35
|
search-placeholder: "Tapez ici pour rechercher"
|
36
36
|
search-empty: "Pas d'options trouvées"
|
37
|
-
null: "Aucune sélection"
|
38
37
|
|
39
38
|
validation:
|
40
39
|
blank: "Ce champ ne doit pas être laissé vide"
|
@@ -44,6 +43,7 @@ caluma:
|
|
44
43
|
lessThanOrEqualTo: "L'entrée dans ce champ ne doit pas être supérieure à {lte} "
|
45
44
|
notAnInteger: "Veuillez entrer un nombre entier"
|
46
45
|
inclusion: "'{value}' n'est pas une valeur valide pour ce champ"
|
46
|
+
deleteFailed: "Une erreur est survenue lors de la suppression."
|
47
47
|
uploadFailed: "Une erreur s'est produite pendant le téléchargement."
|
48
48
|
format: "{errorMsg}"
|
49
49
|
table: "Au moins une ligne du tableau n'a pas été remplie correctement"
|