@projectcaluma/ember-form-builder 11.0.0-beta.2 → 11.0.0-beta.26
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 +154 -0
- package/addon/components/cfb-code-editor.hbs +2 -1
- package/addon/components/cfb-code-editor.js +59 -11
- package/addon/components/cfb-form-editor/general.hbs +2 -4
- package/addon/components/cfb-form-editor/general.js +7 -9
- package/addon/components/cfb-form-editor/question/options.hbs +1 -1
- 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-list/item.hbs +21 -13
- package/addon/components/cfb-form-editor/question-list/item.js +2 -2
- package/addon/components/cfb-form-editor/question-list.hbs +6 -6
- package/addon/components/cfb-form-editor/question-list.js +12 -7
- package/addon/components/cfb-form-editor/question.hbs +29 -15
- package/addon/components/cfb-form-editor/question.js +50 -24
- package/addon/components/cfb-form-editor.hbs +5 -5
- package/addon/components/cfb-form-list/item.hbs +1 -1
- package/addon/components/cfb-form-list.hbs +9 -9
- package/addon/components/cfb-form-list.js +44 -11
- package/addon/components/cfb-toggle-switch.hbs +1 -1
- package/addon/controllers/index.js +6 -0
- package/addon/engine.js +1 -1
- package/addon/gql/fragments/field.graphql +14 -2
- package/addon/gql/mutations/add-form-question.graphql +1 -1
- package/addon/gql/mutations/remove-form-question.graphql +1 -1
- package/addon/gql/mutations/reorder-form-questions.graphql +1 -1
- package/addon/gql/mutations/save-calculated-float-question.graphql +1 -0
- package/addon/gql/mutations/save-choice-question.graphql +1 -0
- package/addon/gql/mutations/save-date-question.graphql +3 -0
- package/addon/gql/mutations/save-dynamic-choice-question.graphql +1 -0
- package/addon/gql/mutations/save-dynamic-multiple-choice-question.graphql +1 -0
- package/addon/gql/mutations/save-files-question.graphql +14 -0
- package/addon/gql/mutations/save-float-question.graphql +1 -0
- package/addon/gql/mutations/save-integer-question.graphql +1 -0
- package/addon/gql/mutations/save-multiple-choice-question.graphql +1 -0
- package/addon/gql/mutations/save-table-question.graphql +1 -0
- package/addon/gql/mutations/save-text-question.graphql +1 -0
- package/addon/gql/mutations/save-textarea-question.graphql +1 -0
- package/addon/gql/queries/all-format-validators.graphql +10 -0
- package/addon/gql/queries/check-form-slug.graphql +1 -1
- package/addon/gql/queries/check-question-slug.graphql +1 -1
- package/addon/gql/queries/form-editor-general.graphql +1 -1
- package/addon/gql/queries/form-editor-question.graphql +29 -1
- package/addon/gql/queries/search-form-question.graphql +3 -3
- package/addon/instance-initializers/form-builder-widget-overrides.js +15 -0
- package/addon/modifiers/pikaday.js +2 -0
- package/addon/routes/edit/questions/edit.js +2 -1
- package/addon/routes/edit.js +1 -1
- package/addon/templates/edit/questions/edit.hbs +1 -1
- package/addon/templates/edit/questions/new.hbs +1 -4
- package/addon/templates/edit.hbs +5 -5
- package/addon/templates/index.hbs +8 -1
- package/addon/templates/new.hbs +1 -1
- package/addon/validations/question.js +6 -0
- package/app/instance-initializers/form-builder-widget-overrides.js +4 -0
- package/app/styles/@projectcaluma/ember-form-builder.scss +2 -2
- package/app/styles/_cfb-uikit-powerselect.scss +2 -0
- package/index.js +0 -6
- package/package.json +45 -34
- package/translations/de.yaml +7 -6
- package/translations/en.yaml +4 -3
- package/translations/fr.yaml +154 -1
- package/addon/gql/mutations/save-file-question.graphql +0 -11
- package/app/styles/_cfb-powerselect.scss +0 -31
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,157 @@
|
|
|
1
|
+
# [@projectcaluma/ember-form-builder-v11.0.0-beta.16](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-builder-v11.0.0-beta.15...@projectcaluma/ember-form-builder-v11.0.0-beta.16) (2022-08-05)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
* feat!: add multi file upload (#2040) ([c4fd004](https://github.com/projectcaluma/ember-caluma/commit/c4fd0049654b2d2e5ea62e5909a45d89cb888b40)), closes [#2040](https://github.com/projectcaluma/ember-caluma/issues/2040)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### BREAKING CHANGES
|
|
8
|
+
|
|
9
|
+
* This requires the caluma backend version v8.0.0-beta.12
|
|
10
|
+
or later.
|
|
11
|
+
|
|
12
|
+
# [@projectcaluma/ember-form-builder-v11.0.0-beta.15](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-builder-v11.0.0-beta.14...@projectcaluma/ember-form-builder-v11.0.0-beta.15) (2022-08-02)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* **analytics:** adds analytics module for caluma ([#1655](https://github.com/projectcaluma/ember-caluma/issues/1655)) ([9573abe](https://github.com/projectcaluma/ember-caluma/commit/9573abe95cd39cb1467113026f2ab7773c3c9143))
|
|
18
|
+
|
|
19
|
+
# [@projectcaluma/ember-form-builder-v11.0.0-beta.14](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-builder-v11.0.0-beta.13...@projectcaluma/ember-form-builder-v11.0.0-beta.14) (2022-06-09)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* **caluma:** use new filter syntax of caluma ([7a00c03](https://github.com/projectcaluma/ember-caluma/commit/7a00c03a103933d9e48dd88adb7382441a298742))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### BREAKING CHANGES
|
|
28
|
+
|
|
29
|
+
* **caluma:** `ember-caluma` now requires Caluma version >=
|
|
30
|
+
8.0.0-beta.6
|
|
31
|
+
|
|
32
|
+
# [@projectcaluma/ember-form-builder-v11.0.0-beta.13](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-builder-v11.0.0-beta.12...@projectcaluma/ember-form-builder-v11.0.0-beta.13) (2022-05-09)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Bug Fixes
|
|
36
|
+
|
|
37
|
+
* **deps:** update ember-engines ([5aa5300](https://github.com/projectcaluma/ember-caluma/commit/5aa530074ea7dc08267d8ccc411eb1538537a1b5))
|
|
38
|
+
* **resources:** fix deprecations of ember-resources ([7a84c5c](https://github.com/projectcaluma/ember-caluma/commit/7a84c5c78d5b28f7b5393c64722907728dd5f42b))
|
|
39
|
+
|
|
40
|
+
# [@projectcaluma/ember-form-builder-v11.0.0-beta.12](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-builder-v11.0.0-beta.11...@projectcaluma/ember-form-builder-v11.0.0-beta.12) (2022-04-07)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Bug Fixes
|
|
44
|
+
|
|
45
|
+
* **form-builder:** replace prismjs with highlight.js ([b92732c](https://github.com/projectcaluma/ember-caluma/commit/b92732c4586b2978dda80ad3643b6bd58c9605cb))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
### Features
|
|
49
|
+
|
|
50
|
+
* **cf-field:** add optional hints for form fields ([d847fbf](https://github.com/projectcaluma/ember-caluma/commit/d847fbffa376ea60971fb9e91aff8bf54ce77d50))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
### BREAKING CHANGES
|
|
54
|
+
|
|
55
|
+
* **cf-field:** Question hints requires Caluma >= v7.15.0
|
|
56
|
+
|
|
57
|
+
Add option to create hints for certain question types. These
|
|
58
|
+
are displayed below the input field and can be used to provide
|
|
59
|
+
short, informative messages. Hints are available for all question
|
|
60
|
+
types except for form, static and action button questions.
|
|
61
|
+
|
|
62
|
+
# [@projectcaluma/ember-form-builder-v11.0.0-beta.11](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-builder-v11.0.0-beta.10...@projectcaluma/ember-form-builder-v11.0.0-beta.11) (2022-03-23)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
### Bug Fixes
|
|
66
|
+
|
|
67
|
+
* **embroider:** add missing dependency on @ember/string ([3a6e6bb](https://github.com/projectcaluma/ember-caluma/commit/3a6e6bb39a8c1a40a2ae00b3d4ea00606a755e25))
|
|
68
|
+
|
|
69
|
+
# [@projectcaluma/ember-form-builder-v11.0.0-beta.10](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-builder-v11.0.0-beta.9...@projectcaluma/ember-form-builder-v11.0.0-beta.10) (2022-03-11)
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
### Bug Fixes
|
|
73
|
+
|
|
74
|
+
* **form-builder:** fix typo in class for code editor ([b00014c](https://github.com/projectcaluma/ember-caluma/commit/b00014c9c7fd737f15fe3592daf85ba2ab89ab23))
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
### Features
|
|
78
|
+
|
|
79
|
+
* **form-builder:** add field for editing meta ([9176862](https://github.com/projectcaluma/ember-caluma/commit/91768623f98cfa438ee9f758a951e01da72ceb5d))
|
|
80
|
+
* **form-builder:** add new categories published and unpublished ([52c1c1d](https://github.com/projectcaluma/ember-caluma/commit/52c1c1deaf15991e595e042f643889be64b425a0))
|
|
81
|
+
* **form:** support passing component override classes ([9409c7c](https://github.com/projectcaluma/ember-caluma/commit/9409c7cb5901dcdffec1c0294046da64b74b9922))
|
|
82
|
+
|
|
83
|
+
# [@projectcaluma/ember-form-builder-v11.0.0-beta.9](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-builder-v11.0.0-beta.8...@projectcaluma/ember-form-builder-v11.0.0-beta.9) (2022-02-23)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
### Features
|
|
87
|
+
|
|
88
|
+
* **form-builder:** autoresize textareas and code editor ([edf0871](https://github.com/projectcaluma/ember-caluma/commit/edf08710ebe0c7d372efa0d37bd0f3589c188dba))
|
|
89
|
+
|
|
90
|
+
# [@projectcaluma/ember-form-builder-v11.0.0-beta.8](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-builder-v11.0.0-beta.7...@projectcaluma/ember-form-builder-v11.0.0-beta.8) (2022-02-16)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
### Bug Fixes
|
|
94
|
+
|
|
95
|
+
* **pikaday:** add pikaday modifier reexport in engines ([c13d302](https://github.com/projectcaluma/ember-caluma/commit/c13d3021bb8fe82e1245a60182af01287c507697))
|
|
96
|
+
|
|
97
|
+
# [@projectcaluma/ember-form-builder-v11.0.0-beta.7](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-builder-v11.0.0-beta.6...@projectcaluma/ember-form-builder-v11.0.0-beta.7) (2022-02-07)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
### Bug Fixes
|
|
101
|
+
|
|
102
|
+
* **deps:** remove moment altogether and update ember-pikday ([b2f7fa2](https://github.com/projectcaluma/ember-caluma/commit/b2f7fa28fa076897addd36e5964c926c671508ff))
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
### BREAKING CHANGES
|
|
106
|
+
|
|
107
|
+
* **deps:** The host app now needs to opt-in to use the default
|
|
108
|
+
pikaday styles: https://github.com/adopted-ember-addons/ember-pikaday#styles
|
|
109
|
+
|
|
110
|
+
# [@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)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
### Bug Fixes
|
|
114
|
+
|
|
115
|
+
* **validation:** sync format validator validation with backend ([ee66968](https://github.com/projectcaluma/ember-caluma/commit/ee66968230b9f0e4c5a4df8bdb3f8e58b44b5b82))
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
### BREAKING CHANGES
|
|
119
|
+
|
|
120
|
+
* **validation:** Use the `formatValidators` property of the backend to store and read
|
|
121
|
+
format validators instead of the `meta.formatValidators` so the backend
|
|
122
|
+
validates as well. For more information on how to migrate check the
|
|
123
|
+
migration guide to v11.
|
|
124
|
+
|
|
125
|
+
# [@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)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
### Bug Fixes
|
|
129
|
+
|
|
130
|
+
* **form-builder:** fix active filter in form list ([87a1016](https://github.com/projectcaluma/ember-caluma/commit/87a1016eb646436f04f7e6e891502f329fd8e8a0))
|
|
131
|
+
|
|
132
|
+
# [@projectcaluma/ember-form-builder-v11.0.0-beta.4](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-builder-v11.0.0-beta.3...@projectcaluma/ember-form-builder-v11.0.0-beta.4) (2022-02-01)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
### Bug Fixes
|
|
136
|
+
|
|
137
|
+
* **form-builder:** omit isRequired property when saving action buttons ([27fb4ff](https://github.com/projectcaluma/ember-caluma/commit/27fb4ff9e394a4c9491c33374f1b088fd09274d3))
|
|
138
|
+
|
|
139
|
+
# [@projectcaluma/ember-form-builder-v11.0.0-beta.3](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-builder-v11.0.0-beta.2...@projectcaluma/ember-form-builder-v11.0.0-beta.3) (2022-01-24)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
### chore
|
|
143
|
+
|
|
144
|
+
* **deps:** update ember-uikit to v5 beta ([6568d39](https://github.com/projectcaluma/ember-caluma/commit/6568d398216d33b44da5b659830ca3c200dd7012))
|
|
145
|
+
* **form-builder:** rename actions from dasherized to camelized ([6a79484](https://github.com/projectcaluma/ember-caluma/commit/6a7948435f1e38e1f8b9cca82d1e091742afcc08))
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
### BREAKING CHANGES
|
|
149
|
+
|
|
150
|
+
* **form-builder:** All previously dasherized expected actions are now
|
|
151
|
+
camelized. E.g `@on-add-question` becomes `@onAddQuestion`.
|
|
152
|
+
* **deps:** All `@projectcaluma/ember-*` packages now require
|
|
153
|
+
`ember-uikit` v5+.
|
|
154
|
+
|
|
1
155
|
# [@projectcaluma/ember-form-builder-v11.0.0-beta.2](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-builder-v11.0.0-beta.1...@projectcaluma/ember-form-builder-v11.0.0-beta.2) (2022-01-18)
|
|
2
156
|
|
|
3
157
|
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
<div
|
|
4
4
|
name={{@name}}
|
|
5
|
-
class=
|
|
5
|
+
class="uk-textarea cfb-code-editor {{concat 'language-' @language}}"
|
|
6
6
|
{{did-insert this.didInsertNode}}
|
|
7
7
|
{{will-destroy this.willDestroyNode}}
|
|
8
|
+
{{autoresize mode="height"}}
|
|
8
9
|
></div>
|
|
9
10
|
|
|
10
11
|
{{component @hintComponent}}
|
|
@@ -1,25 +1,73 @@
|
|
|
1
1
|
import { action } from "@ember/object";
|
|
2
|
+
import { addObserver } from "@ember/object/observers";
|
|
2
3
|
import Component from "@glimmer/component";
|
|
3
|
-
import { tracked } from "@glimmer/tracking";
|
|
4
4
|
import { CodeJar } from "codejar";
|
|
5
|
-
import
|
|
6
|
-
import "
|
|
7
|
-
import "
|
|
5
|
+
import hljs from "highlight.js/lib/core";
|
|
6
|
+
import json from "highlight.js/lib/languages/json";
|
|
7
|
+
import markdown from "highlight.js/lib/languages/markdown";
|
|
8
|
+
import jexl from "highlightjs-jexl/src/languages/jexl";
|
|
9
|
+
|
|
10
|
+
hljs.registerLanguage("json", json);
|
|
11
|
+
hljs.registerLanguage("markdown", markdown);
|
|
12
|
+
hljs.registerLanguage("jexl", jexl);
|
|
8
13
|
|
|
9
14
|
export default class CfbCodeEditorComponent extends Component {
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
_editor = null;
|
|
16
|
+
_cursor = null;
|
|
17
|
+
_lastValue = null;
|
|
18
|
+
|
|
19
|
+
get value() {
|
|
20
|
+
const value = this.args.value;
|
|
21
|
+
|
|
22
|
+
if (this.args.language === "json" && typeof value === "object") {
|
|
23
|
+
return JSON.stringify(value?.unwrap?.() ?? value, null, 2);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return this.args.value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@action
|
|
30
|
+
onUpdate(value) {
|
|
31
|
+
if (this._lastValue === value) return;
|
|
32
|
+
|
|
33
|
+
this._cursor = this._editor.save();
|
|
34
|
+
|
|
35
|
+
if (this.args.language === "json") {
|
|
36
|
+
try {
|
|
37
|
+
value = JSON.parse(value);
|
|
38
|
+
} catch {
|
|
39
|
+
// update value directly
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this._lastValue = value;
|
|
44
|
+
this.args.update(value);
|
|
45
|
+
this.args.setDirty();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@action
|
|
49
|
+
updateCode() {
|
|
50
|
+
this._editor.updateCode(this.value);
|
|
51
|
+
|
|
52
|
+
if (this._cursor) {
|
|
53
|
+
this._editor.restore(this._cursor);
|
|
54
|
+
this._cursor = null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
12
57
|
|
|
13
58
|
@action
|
|
14
59
|
didInsertNode(element) {
|
|
15
|
-
|
|
16
|
-
this.
|
|
17
|
-
|
|
18
|
-
this.
|
|
60
|
+
this._editor = CodeJar(element, (editor) => hljs.highlightElement(editor));
|
|
61
|
+
this._editor.onUpdate(this.onUpdate);
|
|
62
|
+
|
|
63
|
+
this.updateCode();
|
|
64
|
+
|
|
65
|
+
// eslint-disable-next-line ember/no-observers
|
|
66
|
+
addObserver(this.args, "value", this, "updateCode");
|
|
19
67
|
}
|
|
20
68
|
|
|
21
69
|
@action
|
|
22
70
|
willDestroyNode() {
|
|
23
|
-
this.
|
|
71
|
+
this._editor.destroy();
|
|
24
72
|
}
|
|
25
73
|
}
|
|
@@ -55,11 +55,10 @@
|
|
|
55
55
|
@name="description"
|
|
56
56
|
@type="textarea"
|
|
57
57
|
@label={{t "caluma.form-builder.form.description"}}
|
|
58
|
-
|
|
58
|
+
{{autoresize mode="height"}}
|
|
59
59
|
/>
|
|
60
60
|
|
|
61
61
|
<f.input
|
|
62
|
-
class="uk-flex uk-flex-between uk-flex-column"
|
|
63
62
|
@name="isArchived"
|
|
64
63
|
@label={{t "caluma.form-builder.form.isArchived"}}
|
|
65
64
|
@required={{true}}
|
|
@@ -67,7 +66,6 @@
|
|
|
67
66
|
/>
|
|
68
67
|
|
|
69
68
|
<f.input
|
|
70
|
-
class="uk-flex uk-flex-between uk-flex-column"
|
|
71
69
|
@name="isPublished"
|
|
72
70
|
@label={{t "caluma.form-builder.form.isPublished"}}
|
|
73
71
|
@required={{true}}
|
|
@@ -85,7 +83,7 @@
|
|
|
85
83
|
<div
|
|
86
84
|
class="uk-text-center uk-text-muted uk-padding uk-padding-remove-horizontal"
|
|
87
85
|
>
|
|
88
|
-
|
|
86
|
+
<UkIcon @icon="bolt" @ratio={{5}} />
|
|
89
87
|
<p>{{t "caluma.form-builder.form.not-found" slug=@slug}}</p>
|
|
90
88
|
</div>
|
|
91
89
|
{{/if}}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { getOwner } from "@ember/application";
|
|
2
1
|
import { action } from "@ember/object";
|
|
3
2
|
import { inject as service } from "@ember/service";
|
|
3
|
+
import { macroCondition, isTesting } from "@embroider/macros";
|
|
4
4
|
import Component from "@glimmer/component";
|
|
5
5
|
import { queryManager } from "ember-apollo-client";
|
|
6
|
-
import { optional } from "ember-composable-helpers/helpers/optional";
|
|
7
6
|
import { timeout, restartableTask, dropTask } from "ember-concurrency";
|
|
8
|
-
import {
|
|
7
|
+
import { trackedTask } from "ember-resources/util/ember-concurrency";
|
|
9
8
|
|
|
10
9
|
import FormValidations from "../../validations/form";
|
|
11
10
|
|
|
@@ -26,7 +25,7 @@ export default class CfbFormEditorGeneral extends Component {
|
|
|
26
25
|
return this._data.value?.[0]?.node;
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
_data =
|
|
28
|
+
_data = trackedTask(this, this.fetchData, () => [this.args.slug]);
|
|
30
29
|
|
|
31
30
|
@restartableTask
|
|
32
31
|
*fetchData() {
|
|
@@ -89,7 +88,7 @@ export default class CfbFormEditorGeneral extends Component {
|
|
|
89
88
|
)
|
|
90
89
|
);
|
|
91
90
|
|
|
92
|
-
|
|
91
|
+
this.args.onAfterSubmit?.(form);
|
|
93
92
|
} catch (e) {
|
|
94
93
|
this.notification.danger(
|
|
95
94
|
this.intl.t(
|
|
@@ -104,10 +103,9 @@ export default class CfbFormEditorGeneral extends Component {
|
|
|
104
103
|
@restartableTask
|
|
105
104
|
*validateSlug(slug, changeset) {
|
|
106
105
|
/* istanbul ignore next */
|
|
107
|
-
if (
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
) {
|
|
106
|
+
if (macroCondition(isTesting())) {
|
|
107
|
+
// no timeout
|
|
108
|
+
} else {
|
|
111
109
|
yield timeout(500);
|
|
112
110
|
}
|
|
113
111
|
|
|
@@ -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 { trackedTask } from "ember-resources/util/ember-concurrency";
|
|
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 = trackedTask(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
|
}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
@question.isArchived
|
|
5
5
|
"cfb-form-editor__question-list__item__archived"
|
|
6
6
|
}}
|
|
7
|
-
{{did-insert (fn (optional @
|
|
8
|
-
{{will-destroy (fn (optional @
|
|
7
|
+
{{did-insert (fn (optional @onRegister) this.elementId @question.slug)}}
|
|
8
|
+
{{will-destroy (fn (optional @onUnregister) this.elementId @question.slug)}}
|
|
9
9
|
...attributes
|
|
10
10
|
>
|
|
11
11
|
<div class="uk-flex uk-flex-middle">
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
data-test-remove-item
|
|
25
25
|
uk-icon="minus"
|
|
26
26
|
class="cfb-pointer uk-text-danger"
|
|
27
|
-
{{on "click" (fn (optional @
|
|
27
|
+
{{on "click" (fn (optional @onRemoveQuestion) @question)}}
|
|
28
28
|
>
|
|
29
29
|
</i>
|
|
30
30
|
{{else if (eq @mode "add")}}
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
data-test-add-item
|
|
34
34
|
uk-icon="plus"
|
|
35
35
|
class="cfb-pointer uk-text-success"
|
|
36
|
-
{{on "click" (fn (optional @
|
|
36
|
+
{{on "click" (fn (optional @onAddQuestion) @question)}}
|
|
37
37
|
>
|
|
38
38
|
</i>
|
|
39
39
|
{{/if}}
|
|
@@ -80,12 +80,17 @@
|
|
|
80
80
|
|
|
81
81
|
<span class="uk-position-relative uk-width-auto">
|
|
82
82
|
<UkBadge
|
|
83
|
-
uk-tooltip
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
(
|
|
83
|
+
{{uk-tooltip
|
|
84
|
+
(if
|
|
85
|
+
this.hidden
|
|
86
|
+
(t
|
|
87
|
+
(concat
|
|
88
|
+
"caluma.form-builder.question-list.hidden." this.hiddenType
|
|
89
|
+
)
|
|
90
|
+
)
|
|
87
91
|
)
|
|
88
|
-
|
|
92
|
+
pos="left"
|
|
93
|
+
}}
|
|
89
94
|
class="cfb-form-editor__question-list__item__type
|
|
90
95
|
{{if
|
|
91
96
|
this.hidden
|
|
@@ -103,11 +108,14 @@
|
|
|
103
108
|
/>
|
|
104
109
|
{{#if this.required}}
|
|
105
110
|
<span
|
|
106
|
-
uk-tooltip
|
|
107
|
-
(
|
|
108
|
-
|
|
111
|
+
{{uk-tooltip
|
|
112
|
+
(t
|
|
113
|
+
(concat
|
|
114
|
+
"caluma.form-builder.question-list.required." this.requiredType
|
|
115
|
+
)
|
|
109
116
|
)
|
|
110
|
-
|
|
117
|
+
pos="top-left"
|
|
118
|
+
}}
|
|
111
119
|
title={{t
|
|
112
120
|
(concat
|
|
113
121
|
"caluma.form-builder.question-list.required." this.requiredType
|
|
@@ -51,12 +51,12 @@ export default class CfbFormEditorQuestionListItem extends Component {
|
|
|
51
51
|
@action
|
|
52
52
|
editQuestion(question, e) {
|
|
53
53
|
e.preventDefault();
|
|
54
|
-
this.args
|
|
54
|
+
this.args.onEditQuestion?.(question);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
@action
|
|
58
58
|
clickForm(form, e) {
|
|
59
59
|
e.preventDefault();
|
|
60
|
-
this.args
|
|
60
|
+
this.args.onClickForm?.(form);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -76,12 +76,12 @@
|
|
|
76
76
|
data-test-question-list-item={{item.node.slug}}
|
|
77
77
|
@mode={{this.mode}}
|
|
78
78
|
@question={{item.node}}
|
|
79
|
-
@
|
|
80
|
-
@
|
|
81
|
-
@
|
|
82
|
-
@
|
|
83
|
-
@
|
|
84
|
-
@
|
|
79
|
+
@onEditQuestion={{@onEditQuestion}}
|
|
80
|
+
@onRemoveQuestion={{perform this.removeQuestion}}
|
|
81
|
+
@onAddQuestion={{perform this.addQuestion}}
|
|
82
|
+
@onClickForm={{@onClickForm}}
|
|
83
|
+
@onRegister={{this.registerChild}}
|
|
84
|
+
@onUnregister={{this.unregisterChild}}
|
|
85
85
|
/>
|
|
86
86
|
{{else}}
|
|
87
87
|
<li
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { action } from "@ember/object";
|
|
2
2
|
import { run } from "@ember/runloop";
|
|
3
3
|
import { inject as service } from "@ember/service";
|
|
4
|
+
import { macroCondition, isTesting } from "@embroider/macros";
|
|
4
5
|
import Component from "@glimmer/component";
|
|
5
6
|
import { tracked } from "@glimmer/tracking";
|
|
6
7
|
import { queryManager } from "ember-apollo-client";
|
|
7
|
-
import { optional } from "ember-composable-helpers/helpers/optional";
|
|
8
8
|
import {
|
|
9
9
|
timeout,
|
|
10
10
|
enqueueTask,
|
|
@@ -35,7 +35,7 @@ export default class ComponentsCfbFormEditorQuestionList extends Component {
|
|
|
35
35
|
get questions() {
|
|
36
36
|
return this.mode === "add"
|
|
37
37
|
? this.questionTaskValue
|
|
38
|
-
: this.questionTaskValue
|
|
38
|
+
: this.questionTaskValue[0]?.node.questions.edges;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
// Use built in input component when it works instead of this getter and setter
|
|
@@ -56,8 +56,13 @@ export default class ComponentsCfbFormEditorQuestionList extends Component {
|
|
|
56
56
|
const mode = this.mode;
|
|
57
57
|
const search = mode !== "reorder" ? this.search : "";
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
/* istanbul ignore next */
|
|
60
|
+
if (macroCondition(isTesting())) {
|
|
61
|
+
// no timeout
|
|
62
|
+
} else {
|
|
63
|
+
if (search) {
|
|
64
|
+
yield timeout(500);
|
|
65
|
+
}
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
if (mode === "add" && this.hasNextPage) {
|
|
@@ -148,7 +153,7 @@ export default class ComponentsCfbFormEditorQuestionList extends Component {
|
|
|
148
153
|
|
|
149
154
|
this.questionTask.perform();
|
|
150
155
|
|
|
151
|
-
|
|
156
|
+
this.args.onAfterAddQuestion?.(question);
|
|
152
157
|
} catch (e) {
|
|
153
158
|
this.notification.danger(
|
|
154
159
|
this.intl.t("caluma.form-builder.notification.form.add-question.error")
|
|
@@ -176,7 +181,7 @@ export default class ComponentsCfbFormEditorQuestionList extends Component {
|
|
|
176
181
|
)
|
|
177
182
|
);
|
|
178
183
|
|
|
179
|
-
|
|
184
|
+
this.args.onAfterRemoveQuestion?.(question);
|
|
180
185
|
} catch (e) {
|
|
181
186
|
this.notification.danger(
|
|
182
187
|
this.intl.t(
|
|
@@ -238,7 +243,7 @@ export default class ComponentsCfbFormEditorQuestionList extends Component {
|
|
|
238
243
|
createNewQuestion(e) {
|
|
239
244
|
e.preventDefault();
|
|
240
245
|
|
|
241
|
-
this.args
|
|
246
|
+
this.args.onCreateQuestion?.();
|
|
242
247
|
this.setMode("reorder");
|
|
243
248
|
}
|
|
244
249
|
}
|