@projectcaluma/ember-form-builder 14.0.0 → 14.1.0
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/addon/components/cfb-form-editor/question/default.hbs +2 -0
- package/addon/components/cfb-form-editor/question/default.js +10 -1
- package/addon/components/cfb-form-editor/question/options.hbs +8 -74
- package/addon/components/cfb-form-editor/question/options.js +1 -0
- package/addon/components/cfb-form-editor/question-option.hbs +87 -0
- package/addon/components/cfb-form-editor/question-option.js +6 -0
- package/addon/components/cfb-form-editor/question.js +3 -2
- package/addon/gql/mutations/save-option.graphql +1 -0
- package/addon/gql/queries/form-editor-question.graphql +2 -0
- package/package.json +5 -5
- package/translations/de.yaml +1 -0
- package/translations/en.yaml +1 -0
- package/translations/fr.yaml +1 -0
- package/translations/it.yaml +1 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<div class="uk-margin">
|
|
2
2
|
<@labelComponent />
|
|
3
3
|
|
|
4
|
+
{{! Default values for ChoiceQuestions and MultipleChoiceQuestion options are not updated
|
|
5
|
+
when a new one is added because the object returned by `this.field` is too nested to track properly. }}
|
|
4
6
|
<div class="uk-form-controls">
|
|
5
7
|
{{component
|
|
6
8
|
(get-widget this.field.question)
|
|
@@ -45,7 +45,16 @@ export default class CfbFormEditorQuestionDefault extends Component {
|
|
|
45
45
|
// Format option changesets to match the raw format needed in lib.
|
|
46
46
|
raw[key] = {
|
|
47
47
|
edges: raw.options.map((node) => {
|
|
48
|
-
return {
|
|
48
|
+
return {
|
|
49
|
+
node: {
|
|
50
|
+
...node.get("data"),
|
|
51
|
+
...node.get("change"),
|
|
52
|
+
// While we want the real value of the option, the option should never
|
|
53
|
+
// be hidden in the form-builder. We need to set a value here as no
|
|
54
|
+
// value will lead to a Jexl error.
|
|
55
|
+
isHidden: "false",
|
|
56
|
+
},
|
|
57
|
+
};
|
|
49
58
|
}),
|
|
50
59
|
};
|
|
51
60
|
delete raw.options;
|
|
@@ -8,80 +8,14 @@
|
|
|
8
8
|
class="uk-list uk-list-divider uk-form-controls uk-margin-small-top"
|
|
9
9
|
>
|
|
10
10
|
{{#each @value as |row i|}}
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
{{#if this.canReorder}}
|
|
20
|
-
<span
|
|
21
|
-
data-test-sort-handle
|
|
22
|
-
uk-icon="menu"
|
|
23
|
-
class="uk-sortable-handle uk-margin-small-right"
|
|
24
|
-
role="button"
|
|
25
|
-
></span>
|
|
26
|
-
{{/if}}
|
|
27
|
-
{{#if (is-empty row.id)}}
|
|
28
|
-
<button
|
|
29
|
-
data-test-delete-row
|
|
30
|
-
type="button"
|
|
31
|
-
class="uk-icon-button"
|
|
32
|
-
uk-icon="trash"
|
|
33
|
-
title={{t "caluma.form-builder.options.delete"}}
|
|
34
|
-
{{on "click" (fn this.deleteRow row)}}
|
|
35
|
-
>
|
|
36
|
-
</button>
|
|
37
|
-
{{else}}
|
|
38
|
-
<button
|
|
39
|
-
data-test-archive-row
|
|
40
|
-
type="button"
|
|
41
|
-
class="uk-icon-button"
|
|
42
|
-
uk-icon={{if row.isArchived "refresh" "close"}}
|
|
43
|
-
title={{t
|
|
44
|
-
(concat
|
|
45
|
-
"caluma.form-builder.options."
|
|
46
|
-
(if row.isArchived "restore" "archive")
|
|
47
|
-
)
|
|
48
|
-
}}
|
|
49
|
-
{{on
|
|
50
|
-
"click"
|
|
51
|
-
(fn (changeset-set row "isArchived") (not row.isArchived))
|
|
52
|
-
}}
|
|
53
|
-
>
|
|
54
|
-
</button>
|
|
55
|
-
{{/if}}
|
|
56
|
-
</div>
|
|
57
|
-
<div class="uk-width-expand">
|
|
58
|
-
<f.input
|
|
59
|
-
@name="label"
|
|
60
|
-
@inputName={{concat "option-" (add i 1) "-label"}}
|
|
61
|
-
@required={{true}}
|
|
62
|
-
@disabled={{row.isArchived}}
|
|
63
|
-
@submitted={{@submitted}}
|
|
64
|
-
@on-update={{this.updateLabel}}
|
|
65
|
-
/>
|
|
66
|
-
</div>
|
|
67
|
-
<div class="uk-width-1-4">
|
|
68
|
-
<f.input
|
|
69
|
-
@name="slug"
|
|
70
|
-
@inputName={{concat "option-" (add i 1) "-slug"}}
|
|
71
|
-
@required={{true}}
|
|
72
|
-
@disabled={{not (is-empty row.id)}}
|
|
73
|
-
@submitted={{@submitted}}
|
|
74
|
-
@renderComponent={{component
|
|
75
|
-
"cfb-slug-input"
|
|
76
|
-
hidePrefix=true
|
|
77
|
-
prefix=@model.slug
|
|
78
|
-
onUnlink=(fn (mut row.slugUnlinked) true)
|
|
79
|
-
}}
|
|
80
|
-
/>
|
|
81
|
-
</div>
|
|
82
|
-
</div>
|
|
83
|
-
</ValidatedForm>
|
|
84
|
-
</li>
|
|
11
|
+
<CfbFormEditor::QuestionOption
|
|
12
|
+
@i={{i}}
|
|
13
|
+
@row={{row}}
|
|
14
|
+
@model={{@model}}
|
|
15
|
+
@canReorder={{this.canReorder}}
|
|
16
|
+
@deleteRow={{fn this.deleteRow row}}
|
|
17
|
+
@updateLabel={{this.updateLabel}}
|
|
18
|
+
/>
|
|
85
19
|
{{/each}}
|
|
86
20
|
<li class="uk-text-center">
|
|
87
21
|
<button
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<li class="cfb-option-row" data-test-row={{concat "option-" (add @i 1)}}>
|
|
2
|
+
<ValidatedForm @model={{@row}} as |f|>
|
|
3
|
+
<div uk-grid class="uk-grid-small uk-flex uk-flex-top" id={{@row.slug}}>
|
|
4
|
+
<div class="uk-width-auto uk-flex uk-flex-middle">
|
|
5
|
+
{{#if @canReorder}}
|
|
6
|
+
<span
|
|
7
|
+
data-test-sort-handle
|
|
8
|
+
uk-icon="menu"
|
|
9
|
+
class="uk-sortable-handle uk-margin-small-right"
|
|
10
|
+
role="button"
|
|
11
|
+
></span>
|
|
12
|
+
{{/if}}
|
|
13
|
+
{{#if (is-empty @row.id)}}
|
|
14
|
+
<button
|
|
15
|
+
data-test-delete-row
|
|
16
|
+
type="button"
|
|
17
|
+
class="uk-icon-button"
|
|
18
|
+
uk-icon="trash"
|
|
19
|
+
title={{t "caluma.form-builder.options.delete"}}
|
|
20
|
+
{{on "click" @deleteRow}}
|
|
21
|
+
>
|
|
22
|
+
</button>
|
|
23
|
+
{{else}}
|
|
24
|
+
<button
|
|
25
|
+
data-test-archive-row
|
|
26
|
+
type="button"
|
|
27
|
+
class="uk-icon-button"
|
|
28
|
+
uk-icon={{if @row.isArchived "refresh" "close"}}
|
|
29
|
+
title={{t
|
|
30
|
+
(concat
|
|
31
|
+
"caluma.form-builder.options."
|
|
32
|
+
(if @row.isArchived "restore" "archive")
|
|
33
|
+
)
|
|
34
|
+
}}
|
|
35
|
+
{{on
|
|
36
|
+
"click"
|
|
37
|
+
(fn (changeset-set @row "isArchived") (not @row.isArchived))
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
</button>
|
|
41
|
+
{{/if}}
|
|
42
|
+
</div>
|
|
43
|
+
<div class="uk-width-expand">
|
|
44
|
+
<f.input
|
|
45
|
+
@name="label"
|
|
46
|
+
@inputName={{concat "option-" (add @i 1) "-label"}}
|
|
47
|
+
@required={{true}}
|
|
48
|
+
@disabled={{@row.isArchived}}
|
|
49
|
+
@on-update={{@updateLabel}}
|
|
50
|
+
/>
|
|
51
|
+
</div>
|
|
52
|
+
<div class="uk-width-1-4">
|
|
53
|
+
<f.input
|
|
54
|
+
@name="slug"
|
|
55
|
+
@inputName={{concat "option-" (add @i 1) "-slug"}}
|
|
56
|
+
@required={{true}}
|
|
57
|
+
@disabled={{not (is-empty @row.id)}}
|
|
58
|
+
@renderComponent={{component
|
|
59
|
+
"cfb-slug-input"
|
|
60
|
+
hidePrefix=true
|
|
61
|
+
prefix=@model.slug
|
|
62
|
+
onUnlink=(fn (mut @row.slugUnlinked) true)
|
|
63
|
+
}}
|
|
64
|
+
/>
|
|
65
|
+
</div>
|
|
66
|
+
<div class="uk-width-auto">
|
|
67
|
+
<button
|
|
68
|
+
data-test-toggle-jexl
|
|
69
|
+
type="button"
|
|
70
|
+
class="uk-icon-button"
|
|
71
|
+
uk-icon={{if this.showJexl "triangle-up" "triangle-down"}}
|
|
72
|
+
title={{t "caluma.form-builder.options.show-jexl"}}
|
|
73
|
+
{{on "click" (fn (mut this.showJexl) (not this.showJexl))}}
|
|
74
|
+
/>
|
|
75
|
+
</div>
|
|
76
|
+
{{#if this.showJexl}}
|
|
77
|
+
<div class="uk-width-4-4">
|
|
78
|
+
<f.input
|
|
79
|
+
@label={{t "caluma.form-builder.question.isHidden"}}
|
|
80
|
+
@name="isHidden"
|
|
81
|
+
@renderComponent={{component "cfb-code-editor" language="jexl"}}
|
|
82
|
+
/>
|
|
83
|
+
</div>
|
|
84
|
+
{{/if}}
|
|
85
|
+
</div>
|
|
86
|
+
</ValidatedForm>
|
|
87
|
+
</li>
|
|
@@ -365,11 +365,11 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
365
365
|
(changeset.get("options") || [])
|
|
366
366
|
.filter((option) => option.get("isDirty"))
|
|
367
367
|
.map(async (option) => {
|
|
368
|
-
const { label, slug, isArchived } = option;
|
|
368
|
+
const { label, slug, isArchived, isHidden } = option;
|
|
369
369
|
|
|
370
370
|
await this.apollo.mutate({
|
|
371
371
|
mutation: saveOptionMutation,
|
|
372
|
-
variables: { input: { label, slug, isArchived } },
|
|
372
|
+
variables: { input: { label, slug, isArchived, isHidden } },
|
|
373
373
|
});
|
|
374
374
|
}),
|
|
375
375
|
);
|
|
@@ -473,6 +473,7 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
473
473
|
label: "",
|
|
474
474
|
slug: "",
|
|
475
475
|
isArchived: false,
|
|
476
|
+
isHidden: "false",
|
|
476
477
|
slugUnlinked: false,
|
|
477
478
|
question: this.model.slug,
|
|
478
479
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectcaluma/ember-form-builder",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.1.0",
|
|
4
4
|
"description": "Ember engine for building Caluma forms.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"lodash.isequal": "^4.5.0",
|
|
49
49
|
"reactiveweb": "^1.3.0",
|
|
50
50
|
"uikit": "^3.22.0",
|
|
51
|
-
"@projectcaluma/ember-core": "^14.
|
|
52
|
-
"@projectcaluma/ember-form": "^14.
|
|
51
|
+
"@projectcaluma/ember-core": "^14.1.0",
|
|
52
|
+
"@projectcaluma/ember-form": "^14.1.0"
|
|
53
53
|
},
|
|
54
54
|
"//": [
|
|
55
55
|
"TODO: remove obsolete dependency to `ember-data` which is only necessary",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@ember/optional-features": "2.2.0",
|
|
62
62
|
"@ember/test-helpers": "4.0.4",
|
|
63
63
|
"@embroider/test-setup": "4.0.0",
|
|
64
|
-
"@faker-js/faker": "9.
|
|
64
|
+
"@faker-js/faker": "9.4.0",
|
|
65
65
|
"broccoli-asset-rev": "3.0.0",
|
|
66
66
|
"ember-autoresize-modifier": "0.7.0",
|
|
67
67
|
"ember-cli": "6.1.0",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"qunit-dom": "3.4.0",
|
|
86
86
|
"sinon": "19.0.2",
|
|
87
87
|
"webpack": "5.97.1",
|
|
88
|
-
"@projectcaluma/ember-testing": "14.
|
|
88
|
+
"@projectcaluma/ember-testing": "14.1.0"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|
|
91
91
|
"ember-engines": "^0.11.0",
|
package/translations/de.yaml
CHANGED
package/translations/en.yaml
CHANGED
package/translations/fr.yaml
CHANGED