@projectcaluma/ember-form 11.0.0-beta.18 → 11.0.0-beta.20
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +20 -0
- package/addon/components/cf-content.js +2 -2
- package/addon/components/cf-field/input/checkbox.hbs +1 -1
- package/addon/components/cf-field/input/radio.hbs +1 -1
- package/addon/components/cf-field/input/table.hbs +1 -0
- package/addon/components/cf-field/label.hbs +4 -2
- package/addon/components/cf-field.js +6 -3
- package/addon/lib/field.js +23 -24
- package/addon/lib/question.js +2 -2
- package/package.json +23 -23
- package/translations/de.yaml +1 -1
- package/translations/en.yaml +1 -1
- package/translations/fr.yaml +1 -1
- package/addon/components/cf-field/label.js +0 -11
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
# [@projectcaluma/ember-form-v11.0.0-beta.20](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.19...@projectcaluma/ember-form-v11.0.0-beta.20) (2022-06-09)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* **form:** improve validation of choice and multiple choice fields ([e828fad](https://github.com/projectcaluma/ember-caluma/commit/e828fad9557fd521ca9eec63af74f8cee12e3910))
|
7
|
+
* **form:** pass context to table row form ([af1031a](https://github.com/projectcaluma/ember-caluma/commit/af1031ae9e8138a404cd043199709025092da882))
|
8
|
+
|
9
|
+
|
10
|
+
### Features
|
11
|
+
|
12
|
+
* **form:** add option to bypass the timeout when saving a field ([a2ba306](https://github.com/projectcaluma/ember-caluma/commit/a2ba306306f90a2d2279b34550507241f0987961))
|
13
|
+
|
14
|
+
# [@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)
|
15
|
+
|
16
|
+
|
17
|
+
### Bug Fixes
|
18
|
+
|
19
|
+
* **resources:** fix deprecations of ember-resources ([7a84c5c](https://github.com/projectcaluma/ember-caluma/commit/7a84c5c78d5b28f7b5393c64722907728dd5f42b))
|
20
|
+
|
1
21
|
# [@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)
|
2
22
|
|
3
23
|
|
@@ -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 {
|
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 =
|
128
|
+
data = trackedTask(this, this.fetchData, () => [this.args.documentId]);
|
129
129
|
|
130
130
|
@dropTask
|
131
131
|
*fetchData() {
|
@@ -10,7 +10,7 @@
|
|
10
10
|
name={{@field.pk}}
|
11
11
|
value={{option.slug}}
|
12
12
|
checked={{eq option.slug @field.answer.value}}
|
13
|
-
disabled={{@disabled}}
|
13
|
+
disabled={{or option.disabled @disabled}}
|
14
14
|
{{on "change" (fn @onSave option.slug)}}
|
15
15
|
/>
|
16
16
|
{{#if (and option.disabled (not @disabled))}}
|
@@ -1,11 +1,13 @@
|
|
1
|
-
<label class="uk-form-label" for={{@field.pk}}>
|
1
|
+
<label class="uk-form-label" for={{@field.pk}} ...attributes>
|
2
2
|
<span class="uk-text-bold">
|
3
3
|
{{@field.question.raw.label}}
|
4
4
|
</span>
|
5
5
|
|
6
|
-
{{#if
|
6
|
+
{{#if (and (not @field.question.isCalculated) @field.optional)}}
|
7
7
|
<span
|
8
8
|
class="uk-margin-small-left uk-text-muted uk-text-lowercase uk-text-normal"
|
9
9
|
>({{t "caluma.form.optional"}})</span>
|
10
10
|
{{/if}}
|
11
|
+
|
12
|
+
{{yield}}
|
11
13
|
</label>
|
@@ -65,15 +65,18 @@ export default class CfFieldComponent extends Component {
|
|
65
65
|
* reduce the amount of saved values when changed rapidly.
|
66
66
|
*
|
67
67
|
* @method save
|
68
|
-
* @param {String|Number|String[]} value
|
68
|
+
* @param {String|Number|String[]} value The new value to save to the field
|
69
|
+
* @param {Boolean} bypassTimeout Whether to bypass the timeout
|
69
70
|
*/
|
70
71
|
@restartableTask
|
71
|
-
*save(value) {
|
72
|
+
*save(value, bypassTimeout = false) {
|
72
73
|
/* istanbul ignore next */
|
73
74
|
if (macroCondition(isTesting())) {
|
74
75
|
// no timeout
|
75
76
|
} else {
|
76
|
-
|
77
|
+
if (!bypassTimeout) {
|
78
|
+
yield timeout(500);
|
79
|
+
}
|
77
80
|
}
|
78
81
|
|
79
82
|
if (this.args.field.answer) {
|
package/addon/lib/field.js
CHANGED
@@ -582,10 +582,10 @@ export default class Field extends Base {
|
|
582
582
|
@cached
|
583
583
|
get errors() {
|
584
584
|
return this._errors.map(({ type, context, value }) => {
|
585
|
-
return this.intl.t(
|
586
|
-
|
587
|
-
|
588
|
-
);
|
585
|
+
return this.intl.t(`caluma.form.validation.${type}`, {
|
586
|
+
...context,
|
587
|
+
value,
|
588
|
+
});
|
589
589
|
});
|
590
590
|
}
|
591
591
|
|
@@ -742,10 +742,7 @@ export default class Field extends Base {
|
|
742
742
|
* @private
|
743
743
|
*/
|
744
744
|
_validateChoiceQuestion() {
|
745
|
-
return
|
746
|
-
allowBlank: true,
|
747
|
-
in: (this.options || []).map(({ slug }) => slug),
|
748
|
-
});
|
745
|
+
return this._validateOption(this.answer.value, true);
|
749
746
|
}
|
750
747
|
|
751
748
|
/**
|
@@ -757,15 +754,9 @@ export default class Field extends Base {
|
|
757
754
|
* @private
|
758
755
|
*/
|
759
756
|
_validateMultipleChoiceQuestion() {
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
}
|
764
|
-
return value.map((value) =>
|
765
|
-
validate("inclusion", value, {
|
766
|
-
in: (this.options || []).map(({ slug }) => slug),
|
767
|
-
})
|
768
|
-
);
|
757
|
+
return this.answer.value
|
758
|
+
? this.answer.value.map((value) => this._validateOption(value))
|
759
|
+
: true;
|
769
760
|
}
|
770
761
|
|
771
762
|
/**
|
@@ -779,9 +770,7 @@ export default class Field extends Base {
|
|
779
770
|
async _validateDynamicChoiceQuestion() {
|
780
771
|
await this.question.dynamicOptions;
|
781
772
|
|
782
|
-
return
|
783
|
-
in: (this.options || []).map(({ slug }) => slug),
|
784
|
-
});
|
773
|
+
return this._validateOption(this.answer.value);
|
785
774
|
}
|
786
775
|
|
787
776
|
/**
|
@@ -801,10 +790,20 @@ export default class Field extends Base {
|
|
801
790
|
|
802
791
|
await this.question.dynamicOptions;
|
803
792
|
|
804
|
-
return value.map((value) =>
|
805
|
-
|
806
|
-
|
807
|
-
|
793
|
+
return value.map((value) => this._validateOption(value));
|
794
|
+
}
|
795
|
+
|
796
|
+
_validateOption(value, allowBlank = false) {
|
797
|
+
const label = Array.isArray(this.selected)
|
798
|
+
? this.selected.find((selected) => selected.slug === value)?.label
|
799
|
+
: this.selected?.label;
|
800
|
+
|
801
|
+
return validate("inclusion", value, {
|
802
|
+
in: (this.options || [])
|
803
|
+
.filter((option) => !option.disabled)
|
804
|
+
.map(({ slug }) => slug),
|
805
|
+
allowBlank,
|
806
|
+
label: label ?? value,
|
808
807
|
});
|
809
808
|
}
|
810
809
|
|
package/addon/lib/question.js
CHANGED
@@ -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 {
|
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 =
|
80
|
+
dynamicOptions = trackedTask(this, this.loadDynamicOptions, () => []);
|
81
81
|
|
82
82
|
get dynamicChoiceOptions() {
|
83
83
|
return this.dynamicOptions.value ?? [];
|
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.20",
|
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.
|
19
|
-
"@embroider/util": "^1.
|
20
|
-
"@glimmer/component": "^1.1.
|
21
|
-
"@glimmer/tracking": "^1.1.
|
22
|
-
"@projectcaluma/ember-core": "^11.0.0-beta.
|
18
|
+
"@embroider/macros": "^1.7.1",
|
19
|
+
"@embroider/util": "^1.7.1",
|
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.
|
24
|
+
"ember-auto-import": "^2.4.2",
|
25
25
|
"ember-autoresize-modifier": "^0.5.0",
|
26
26
|
"ember-cli-babel": "^7.26.11",
|
27
27
|
"ember-cli-htmlbars": "^6.0.1",
|
@@ -31,31 +31,31 @@
|
|
31
31
|
"ember-fetch": "^8.1.1",
|
32
32
|
"ember-in-viewport": "^4.0.2",
|
33
33
|
"ember-intl": "^5.7.2",
|
34
|
-
"ember-math-helpers": "^2.18.
|
34
|
+
"ember-math-helpers": "^2.18.2",
|
35
35
|
"ember-pikaday": "^4.0.0",
|
36
36
|
"ember-power-select": "^5.0.4",
|
37
|
-
"ember-resources": "^4.
|
38
|
-
"ember-uikit": "^5.1.
|
37
|
+
"ember-resources": "^4.8.2",
|
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.
|
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.
|
49
|
-
"@embroider/test-setup": "1.
|
50
|
-
"@faker-js/faker": "
|
51
|
-
"@projectcaluma/ember-testing": "11.0.0-beta.
|
52
|
-
"@projectcaluma/ember-workflow": "11.0.0-beta.
|
48
|
+
"@ember/test-helpers": "2.8.1",
|
49
|
+
"@embroider/test-setup": "1.7.1",
|
50
|
+
"@faker-js/faker": "7.2.0",
|
51
|
+
"@projectcaluma/ember-testing": "11.0.0-beta.8",
|
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.
|
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.
|
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.
|
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
|
-
"miragejs": "0.1.
|
71
|
+
"miragejs": "0.1.45",
|
72
72
|
"npm-run-all": "4.1.5",
|
73
|
-
"qunit": "2.
|
73
|
+
"qunit": "2.19.1",
|
74
74
|
"qunit-dom": "2.0.0",
|
75
75
|
"uuid": "8.3.2",
|
76
|
-
"webpack": "5.
|
76
|
+
"webpack": "5.73.0"
|
77
77
|
},
|
78
78
|
"peerDependencies": {
|
79
|
-
"@projectcaluma/ember-workflow": "^11.0.0-beta.
|
79
|
+
"@projectcaluma/ember-workflow": "^11.0.0-beta.7"
|
80
80
|
},
|
81
81
|
"peerDependenciesMeta": {
|
82
82
|
"@projectcaluma/ember-workflow": {
|
package/translations/de.yaml
CHANGED
@@ -46,7 +46,7 @@ caluma:
|
|
46
46
|
greaterThanOrEqualTo: "Die Eingabe in diesem Feld darf nicht kleiner als {gte} sein"
|
47
47
|
lessThanOrEqualTo: "Die Eingabe in diesem Feld darf nicht grösser als {lte} sein"
|
48
48
|
notAnInteger: "Bitte geben Sie eine ganze Zahl ein"
|
49
|
-
inclusion: "
|
49
|
+
inclusion: '"{label}" ist kein gültiger Wert für dieses Feld'
|
50
50
|
deleteFailed: "Beim Löschen ist ein Fehler aufgetreten."
|
51
51
|
uploadFailed: "Beim Hochladen ist ein Fehler aufgetreten."
|
52
52
|
format: "{errorMsg}"
|
package/translations/en.yaml
CHANGED
@@ -46,7 +46,7 @@ caluma:
|
|
46
46
|
greaterThanOrEqualTo: "The value of this field must be greater than or equal to {gte}"
|
47
47
|
lessThanOrEqualTo: "The value of this field must be less than or equal to {lte}"
|
48
48
|
notAnInteger: "The value of this field must be an integer"
|
49
|
-
inclusion: "
|
49
|
+
inclusion: '"{label}" is not a valid value for this field'
|
50
50
|
deleteFailed: "An error occured during deletion."
|
51
51
|
uploadFailed: "An error occured during upload."
|
52
52
|
format: "{errorMsg}"
|
package/translations/fr.yaml
CHANGED
@@ -46,7 +46,7 @@ caluma:
|
|
46
46
|
greaterThanOrEqualTo: "La valeur indiquée dans ce champ ne doit pas être inférieure à {gte} "
|
47
47
|
lessThanOrEqualTo: "L'entrée dans ce champ ne doit pas être supérieure à {lte} "
|
48
48
|
notAnInteger: "Veuillez entrer un nombre entier"
|
49
|
-
inclusion: "
|
49
|
+
inclusion: '"{label}" n''est pas une valeur valide pour ce champ'
|
50
50
|
deleteFailed: "Une erreur est survenue lors de la suppression."
|
51
51
|
uploadFailed: "Une erreur s'est produite pendant le téléchargement."
|
52
52
|
format: "{errorMsg}"
|