@projectcaluma/ember-form-builder 11.0.0-beta.5 → 11.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/addon/components/cfb-form-editor/question/validation.hbs +2 -2
- package/addon/components/cfb-form-editor/question/validation.js +17 -13
- package/addon/components/cfb-form-editor/question.hbs +3 -3
- package/addon/components/cfb-form-editor/question.js +7 -0
- package/addon/engine.js +1 -1
- package/addon/gql/queries/all-format-validators.graphql +10 -0
- package/addon/gql/queries/form-editor-question.graphql +14 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
# [@projectcaluma/ember-form-builder-v11.0.0-beta.6](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-builder-v11.0.0-beta.5...@projectcaluma/ember-form-builder-v11.0.0-beta.6) (2022-02-03)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **validation:** sync format validator validation with backend ([ee66968](https://github.com/projectcaluma/ember-caluma/commit/ee66968230b9f0e4c5a4df8bdb3f8e58b44b5b82))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### BREAKING CHANGES
|
|
10
|
+
|
|
11
|
+
* **validation:** Use the `formatValidators` property of the backend to store and read
|
|
12
|
+
format validators instead of the `meta.formatValidators` so the backend
|
|
13
|
+
validates as well. For more information on how to migrate check the
|
|
14
|
+
migration guide to v11.
|
|
15
|
+
|
|
1
16
|
# [@projectcaluma/ember-form-builder-v11.0.0-beta.5](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-builder-v11.0.0-beta.4...@projectcaluma/ember-form-builder-v11.0.0-beta.5) (2022-02-02)
|
|
2
17
|
|
|
3
18
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<div class="uk-margin"
|
|
1
|
+
<div class="uk-margin">
|
|
2
2
|
{{component @labelComponent}}
|
|
3
3
|
|
|
4
4
|
<PowerSelectMultiple
|
|
5
5
|
@selected={{this.selected}}
|
|
6
|
-
@placeholder={{
|
|
6
|
+
@placeholder={{@placeholder}}
|
|
7
7
|
@options={{this.validators}}
|
|
8
8
|
@onChange={{this.updateValidators}}
|
|
9
9
|
@renderInPlace={{true}}
|
|
@@ -2,34 +2,38 @@ import { action } from "@ember/object";
|
|
|
2
2
|
import Component from "@glimmer/component";
|
|
3
3
|
import { queryManager } from "ember-apollo-client";
|
|
4
4
|
import { dropTask } from "ember-concurrency";
|
|
5
|
+
import { useTask } from "ember-resources";
|
|
5
6
|
|
|
6
|
-
import allFormatValidatorsQuery from "@projectcaluma/ember-
|
|
7
|
+
import allFormatValidatorsQuery from "@projectcaluma/ember-form-builder/gql/queries/all-format-validators.graphql";
|
|
7
8
|
|
|
8
9
|
export default class CfbFormEditorQuestionValidation extends Component {
|
|
9
10
|
@queryManager apollo;
|
|
10
11
|
|
|
11
|
-
@dropTask
|
|
12
|
-
*availableFormatValidators() {
|
|
13
|
-
const formatValidators = yield this.apollo.watchQuery(
|
|
14
|
-
{ query: allFormatValidatorsQuery, fetchPolicy: "cache-and-network" },
|
|
15
|
-
"allFormatValidators.edges"
|
|
16
|
-
);
|
|
17
|
-
return formatValidators.map((edge) => edge.node);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
12
|
get validators() {
|
|
21
|
-
return this.
|
|
13
|
+
return this._validators.value?.map((edge) => edge.node) ?? [];
|
|
22
14
|
}
|
|
23
15
|
|
|
24
16
|
get selected() {
|
|
25
17
|
return this.validators.filter((validator) =>
|
|
26
|
-
(this.args.value || []).includes(
|
|
18
|
+
(this.args.value?.edges.map((edge) => edge.node.slug) || []).includes(
|
|
19
|
+
validator.slug
|
|
20
|
+
)
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
_validators = useTask(this, this.fetchFormatValidators, () => []);
|
|
25
|
+
|
|
26
|
+
@dropTask
|
|
27
|
+
*fetchFormatValidators() {
|
|
28
|
+
return yield this.apollo.watchQuery(
|
|
29
|
+
{ query: allFormatValidatorsQuery, fetchPolicy: "cache-and-network" },
|
|
30
|
+
"allFormatValidators.edges"
|
|
27
31
|
);
|
|
28
32
|
}
|
|
29
33
|
|
|
30
34
|
@action
|
|
31
35
|
updateValidators(value) {
|
|
32
|
-
this.args.update(value.map((
|
|
36
|
+
this.args.update({ edges: value.map(({ slug }) => ({ node: { slug } })) });
|
|
33
37
|
this.args.setDirty();
|
|
34
38
|
}
|
|
35
39
|
}
|
|
@@ -207,13 +207,13 @@
|
|
|
207
207
|
/>
|
|
208
208
|
|
|
209
209
|
<f.input
|
|
210
|
-
@name="
|
|
210
|
+
@name="formatValidators"
|
|
211
211
|
@label={{t "caluma.form-builder.question.formatValidators"}}
|
|
212
212
|
@placeholder={{t "caluma.form-builder.question.choose"}}
|
|
213
213
|
@required={{false}}
|
|
214
214
|
@renderComponent={{component "cfb-form-editor/question/validation"}}
|
|
215
|
-
@on-update={{changeset-set f.model "
|
|
216
|
-
@value={{changeset-get f.model "
|
|
215
|
+
@on-update={{changeset-set f.model "formatValidators"}}
|
|
216
|
+
@value={{changeset-get f.model "formatValidators"}}
|
|
217
217
|
/>
|
|
218
218
|
{{/if}}
|
|
219
219
|
|
|
@@ -106,6 +106,7 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
106
106
|
subForm: {},
|
|
107
107
|
meta: {},
|
|
108
108
|
dataSource: "",
|
|
109
|
+
formatValidators: null,
|
|
109
110
|
// action button
|
|
110
111
|
action: ACTIONS[0],
|
|
111
112
|
color: COLORS[0],
|
|
@@ -258,6 +259,9 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
258
259
|
minLength: parseInt(changeset.get("minLength")),
|
|
259
260
|
maxLength: parseInt(changeset.get("maxLength")),
|
|
260
261
|
placeholder: changeset.get("placeholder"),
|
|
262
|
+
formatValidators: changeset
|
|
263
|
+
.get("formatValidators")
|
|
264
|
+
?.edges.map((edge) => edge.node.slug),
|
|
261
265
|
};
|
|
262
266
|
}
|
|
263
267
|
|
|
@@ -266,6 +270,9 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
266
270
|
minLength: parseInt(changeset.get("minLength")),
|
|
267
271
|
maxLength: parseInt(changeset.get("maxLength")),
|
|
268
272
|
placeholder: changeset.get("placeholder"),
|
|
273
|
+
formatValidators: changeset
|
|
274
|
+
.get("formatValidators")
|
|
275
|
+
?.edges.map((edge) => edge.node.slug),
|
|
269
276
|
};
|
|
270
277
|
}
|
|
271
278
|
|
package/addon/engine.js
CHANGED
|
@@ -11,7 +11,7 @@ export default class FormBuilderEngine extends Engine {
|
|
|
11
11
|
Resolver = Resolver;
|
|
12
12
|
|
|
13
13
|
dependencies = {
|
|
14
|
-
services: ["apollo", "notification", "intl", "caluma-options"
|
|
14
|
+
services: ["apollo", "notification", "intl", "caluma-options"],
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -33,11 +33,25 @@ query FormEditorQuestion($slug: String!) {
|
|
|
33
33
|
id
|
|
34
34
|
stringValue: value
|
|
35
35
|
}
|
|
36
|
+
formatValidators {
|
|
37
|
+
edges {
|
|
38
|
+
node {
|
|
39
|
+
slug
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
36
43
|
}
|
|
37
44
|
... on TextareaQuestion {
|
|
38
45
|
minLength
|
|
39
46
|
maxLength
|
|
40
47
|
placeholder
|
|
48
|
+
formatValidators {
|
|
49
|
+
edges {
|
|
50
|
+
node {
|
|
51
|
+
slug
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
41
55
|
defaultAnswer {
|
|
42
56
|
id
|
|
43
57
|
stringValue: value
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectcaluma/ember-form-builder",
|
|
3
|
-
"version": "11.0.0-beta.
|
|
3
|
+
"version": "11.0.0-beta.6",
|
|
4
4
|
"description": "Ember engine for building Caluma forms.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"@ember/render-modifiers": "^2.0.4",
|
|
22
22
|
"@glimmer/component": "^1.0.4",
|
|
23
23
|
"@glimmer/tracking": "^1.0.4",
|
|
24
|
-
"@projectcaluma/ember-core": "^11.0.0-beta.
|
|
25
|
-
"@projectcaluma/ember-form": "^11.0.0-beta.
|
|
24
|
+
"@projectcaluma/ember-core": "^11.0.0-beta.3",
|
|
25
|
+
"@projectcaluma/ember-form": "^11.0.0-beta.7",
|
|
26
26
|
"codejar": "^3.5.0",
|
|
27
27
|
"ember-apollo-client": "^3.2.0",
|
|
28
28
|
"ember-auto-import": "^2.4.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@ember/test-helpers": "2.6.0",
|
|
55
55
|
"@embroider/test-setup": "1.0.0",
|
|
56
56
|
"@faker-js/faker": "6.0.0-alpha.5",
|
|
57
|
-
"@projectcaluma/ember-testing": "
|
|
57
|
+
"@projectcaluma/ember-testing": "11.0.0-beta.1",
|
|
58
58
|
"broccoli-asset-rev": "3.0.0",
|
|
59
59
|
"ember-cli": "3.28.5",
|
|
60
60
|
"ember-cli-code-coverage": "1.0.3",
|