@projectcaluma/ember-form-builder 12.7.0 → 12.9.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-code-editor.hbs +5 -2
- package/addon/components/cfb-code-editor.js +19 -17
- package/addon/components/cfb-form-editor/cfb-advanced-settings.hbs +16 -0
- package/addon/components/cfb-form-editor/cfb-advanced-settings.js +6 -0
- package/addon/components/cfb-form-editor/general.hbs +8 -0
- package/addon/components/cfb-form-editor/general.js +3 -0
- package/addon/components/cfb-form-editor/question-usage.hbs +50 -0
- package/addon/components/cfb-form-editor/question-usage.js +58 -0
- package/addon/components/cfb-form-editor/question.hbs +8 -16
- package/addon/gql/fragments/form-info.graphql +1 -0
- package/addon/gql/queries/all-forms-for-question.graphql +13 -0
- package/app/components/cfb-form-editor/cfb-advanced-settings.js +1 -0
- package/app/components/cfb-form-editor/question-usage.js +1 -0
- package/package.json +11 -9
- package/translations/de.yaml +5 -0
- package/translations/en.yaml +5 -0
- package/translations/fr.yaml +5 -0
|
@@ -4,11 +4,14 @@
|
|
|
4
4
|
<div class="uk-form-controls">
|
|
5
5
|
<div
|
|
6
6
|
name={{@name}}
|
|
7
|
-
class="uk-textarea cfb-code-editor
|
|
7
|
+
class="uk-textarea cfb-code-editor
|
|
8
|
+
{{concat 'language-' @language}}
|
|
9
|
+
{{if @isValid 'uk-form-success'}}
|
|
10
|
+
{{if @isInvalid 'uk-form-danger'}}"
|
|
8
11
|
{{did-insert this.didInsertNode}}
|
|
9
12
|
{{will-destroy this.willDestroyNode}}
|
|
10
13
|
{{autoresize mode="height"}}
|
|
11
|
-
{{on "blur"
|
|
14
|
+
{{on "blur" this.onBlur}}
|
|
12
15
|
></div>
|
|
13
16
|
</div>
|
|
14
17
|
|
|
@@ -6,6 +6,8 @@ import hljs from "highlight.js/lib/core";
|
|
|
6
6
|
import json from "highlight.js/lib/languages/json";
|
|
7
7
|
import markdown from "highlight.js/lib/languages/markdown";
|
|
8
8
|
import jexl from "highlightjs-jexl/src/languages/jexl";
|
|
9
|
+
import isEqual from "lodash.isequal";
|
|
10
|
+
import "highlight.js/styles/github.css";
|
|
9
11
|
|
|
10
12
|
hljs.configure({ ignoreUnescapedHTML: true });
|
|
11
13
|
|
|
@@ -15,14 +17,15 @@ hljs.registerLanguage("jexl", jexl);
|
|
|
15
17
|
|
|
16
18
|
export default class CfbCodeEditorComponent extends Component {
|
|
17
19
|
_editor = null;
|
|
18
|
-
_cursor = null;
|
|
19
20
|
_lastValue = this.args.value;
|
|
20
21
|
|
|
21
|
-
get
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
get stringValue() {
|
|
23
|
+
if (this.args.language === "json" && typeof this.args.value === "object") {
|
|
24
|
+
return JSON.stringify(
|
|
25
|
+
this.args.value?.unwrap?.() ?? this.args.value,
|
|
26
|
+
null,
|
|
27
|
+
2,
|
|
28
|
+
);
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
return this.args.value;
|
|
@@ -30,10 +33,6 @@ export default class CfbCodeEditorComponent extends Component {
|
|
|
30
33
|
|
|
31
34
|
@action
|
|
32
35
|
onUpdate(value) {
|
|
33
|
-
if (this._lastValue === value) return;
|
|
34
|
-
|
|
35
|
-
this._cursor = this._editor.save();
|
|
36
|
-
|
|
37
36
|
if (this.args.language === "json") {
|
|
38
37
|
try {
|
|
39
38
|
value = JSON.parse(value);
|
|
@@ -42,20 +41,23 @@ export default class CfbCodeEditorComponent extends Component {
|
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
|
|
44
|
+
if (isEqual(this._lastValue, value)) return;
|
|
45
|
+
|
|
45
46
|
this._lastValue = value;
|
|
46
47
|
this.args.update(value);
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
@action
|
|
50
51
|
updateCode() {
|
|
51
|
-
if (this._lastValue
|
|
52
|
+
if (isEqual(this._lastValue, this.args.value)) return;
|
|
52
53
|
|
|
53
|
-
this._editor.updateCode(this.
|
|
54
|
+
this._editor.updateCode(this.stringValue, false);
|
|
55
|
+
}
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
@action
|
|
58
|
+
onBlur() {
|
|
59
|
+
this._editor.updateCode(this.stringValue);
|
|
60
|
+
this.args.setDirty();
|
|
59
61
|
}
|
|
60
62
|
|
|
61
63
|
@action
|
|
@@ -66,7 +68,7 @@ export default class CfbCodeEditorComponent extends Component {
|
|
|
66
68
|
});
|
|
67
69
|
|
|
68
70
|
// set initial value
|
|
69
|
-
this._editor.updateCode(this.
|
|
71
|
+
this._editor.updateCode(this.stringValue);
|
|
70
72
|
|
|
71
73
|
// register update method
|
|
72
74
|
this._editor.onUpdate(this.onUpdate);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<UkButton
|
|
2
|
+
@color="link"
|
|
3
|
+
@onClick={{toggle-action "showAdvanced" this}}
|
|
4
|
+
class="uk-flex uk-flex-middle uk-margin"
|
|
5
|
+
>
|
|
6
|
+
{{#if this.showAdvanced}}
|
|
7
|
+
<UkIcon @icon="triangle-down" />
|
|
8
|
+
{{else}}
|
|
9
|
+
<UkIcon @icon="triangle-right" />
|
|
10
|
+
{{/if}}
|
|
11
|
+
{{t "caluma.form-builder.question.advancedSettings"}}
|
|
12
|
+
</UkButton>
|
|
13
|
+
|
|
14
|
+
{{#if this.showAdvanced}}
|
|
15
|
+
{{yield}}
|
|
16
|
+
{{/if}}
|
|
@@ -49,6 +49,14 @@
|
|
|
49
49
|
@renderComponent={{component "cfb-toggle-switch" size="small"}}
|
|
50
50
|
/>
|
|
51
51
|
|
|
52
|
+
<CfbFormEditor::CfbAdvancedSettings>
|
|
53
|
+
<f.input
|
|
54
|
+
@label={{t "caluma.form-builder.question.meta"}}
|
|
55
|
+
@name="meta"
|
|
56
|
+
@renderComponent={{component "cfb-code-editor" language="json"}}
|
|
57
|
+
/>
|
|
58
|
+
</CfbFormEditor::CfbAdvancedSettings>
|
|
59
|
+
|
|
52
60
|
<div class="uk-text-right">
|
|
53
61
|
<f.submit
|
|
54
62
|
@disabled={{f.loading}}
|
|
@@ -58,6 +58,8 @@ export default class CfbFormEditorGeneral extends Component {
|
|
|
58
58
|
|
|
59
59
|
@dropTask
|
|
60
60
|
*submit(changeset) {
|
|
61
|
+
const rawMeta = changeset.get("meta");
|
|
62
|
+
|
|
61
63
|
try {
|
|
62
64
|
const form = yield this.apollo.mutate(
|
|
63
65
|
{
|
|
@@ -69,6 +71,7 @@ export default class CfbFormEditorGeneral extends Component {
|
|
|
69
71
|
description: changeset.get("description"),
|
|
70
72
|
isArchived: changeset.get("isArchived"),
|
|
71
73
|
isPublished: changeset.get("isPublished"),
|
|
74
|
+
meta: JSON.stringify(rawMeta?.unwrap?.() ?? rawMeta),
|
|
72
75
|
},
|
|
73
76
|
},
|
|
74
77
|
},
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{{#if this.otherForms}}
|
|
2
|
+
<a
|
|
3
|
+
...attributes
|
|
4
|
+
href="#"
|
|
5
|
+
{{on "click" (fn (mut this.modalVisible) true)}}
|
|
6
|
+
data-test-show-question-usage-modal-link
|
|
7
|
+
>
|
|
8
|
+
{{this.title}}
|
|
9
|
+
</a>
|
|
10
|
+
{{/if}}
|
|
11
|
+
|
|
12
|
+
<UkModal
|
|
13
|
+
@visible={{this.modalVisible}}
|
|
14
|
+
@stack={{true}}
|
|
15
|
+
@onHide={{fn (mut this.modalVisible) false}}
|
|
16
|
+
data-test-question-usage-modal
|
|
17
|
+
as |modal|
|
|
18
|
+
>
|
|
19
|
+
<modal.header>
|
|
20
|
+
{{t "caluma.form-builder.question.usage.references-heading"}}
|
|
21
|
+
</modal.header>
|
|
22
|
+
<modal.body>
|
|
23
|
+
<ul class="uk-list uk-list-divider">
|
|
24
|
+
{{#each this.forms.value as |form|}}
|
|
25
|
+
<li data-test-question-form-item={{form.node.slug}}>
|
|
26
|
+
<div class="uk-flex uk-flex-middle">
|
|
27
|
+
<span class="uk-width-expand">
|
|
28
|
+
<LinkTo @route="edit" @model={{form.node.slug}}>
|
|
29
|
+
{{form.node.name}}
|
|
30
|
+
</LinkTo>
|
|
31
|
+
</span>
|
|
32
|
+
|
|
33
|
+
{{#if form.node.isArchived}}
|
|
34
|
+
<UkBadge>
|
|
35
|
+
{{t "caluma.form-builder.form.isArchived"}}
|
|
36
|
+
</UkBadge>
|
|
37
|
+
{{/if}}
|
|
38
|
+
|
|
39
|
+
{{#unless form.node.isPublished}}
|
|
40
|
+
<UkBadge class="uk-margin-small-left">
|
|
41
|
+
{{t "caluma.form-builder.question.usage.not-published"}}
|
|
42
|
+
</UkBadge>
|
|
43
|
+
{{/unless}}
|
|
44
|
+
</div>
|
|
45
|
+
<div class="uk-text-muted uk-text-small">{{form.node.slug}}</div>
|
|
46
|
+
</li>
|
|
47
|
+
{{/each}}
|
|
48
|
+
</ul>
|
|
49
|
+
</modal.body>
|
|
50
|
+
</UkModal>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { inject as service } from "@ember/service";
|
|
2
|
+
import Component from "@glimmer/component";
|
|
3
|
+
import { tracked } from "@glimmer/tracking";
|
|
4
|
+
import { queryManager } from "ember-apollo-client";
|
|
5
|
+
import { trackedFunction } from "ember-resources/util/function";
|
|
6
|
+
|
|
7
|
+
import allFormsForQuestionQuery from "@projectcaluma/ember-form-builder/gql/queries/all-forms-for-question.graphql";
|
|
8
|
+
|
|
9
|
+
export default class CfbFormEditorQuestionUsage extends Component {
|
|
10
|
+
@service intl;
|
|
11
|
+
@queryManager apollo;
|
|
12
|
+
|
|
13
|
+
@tracked modalVisible = false;
|
|
14
|
+
@tracked _forms = null;
|
|
15
|
+
|
|
16
|
+
get title() {
|
|
17
|
+
return this.intl.t("caluma.form-builder.question.usage.title", {
|
|
18
|
+
n: this.otherForms,
|
|
19
|
+
// for highlighting the number we use the <b> tag
|
|
20
|
+
htmlSafe: true,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
get otherForms() {
|
|
25
|
+
return this.forms.value?.length - 1 ?? 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
forms = trackedFunction(this, async () => {
|
|
29
|
+
if (!this.args.slug) {
|
|
30
|
+
// The shown question hasn't completely loaded yet
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
if (this._forms) {
|
|
34
|
+
// we have already fetched the forms previously
|
|
35
|
+
return this._forms;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
const forms = await this.apollo.query(
|
|
40
|
+
{
|
|
41
|
+
query: allFormsForQuestionQuery,
|
|
42
|
+
variables: {
|
|
43
|
+
slug: this.args.slug,
|
|
44
|
+
},
|
|
45
|
+
fetchPolicy: "no-cache",
|
|
46
|
+
},
|
|
47
|
+
"allForms.edges",
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
this._forms = forms; // cache the result
|
|
51
|
+
|
|
52
|
+
return forms;
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error(error);
|
|
55
|
+
return { value: [] };
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
@@ -384,20 +384,7 @@
|
|
|
384
384
|
@renderComponent={{component "cfb-toggle-switch" size="small"}}
|
|
385
385
|
/>
|
|
386
386
|
|
|
387
|
-
<
|
|
388
|
-
@color="link"
|
|
389
|
-
@onClick={{toggle-action "showAdvanced" this}}
|
|
390
|
-
class="uk-flex uk-flex-middle uk-margin"
|
|
391
|
-
>
|
|
392
|
-
{{#if this.showAdvanced}}
|
|
393
|
-
<UkIcon @icon="triangle-down" />
|
|
394
|
-
{{else}}
|
|
395
|
-
<UkIcon @icon="triangle-right" />
|
|
396
|
-
{{/if}}
|
|
397
|
-
{{t "caluma.form-builder.question.advancedSettings"}}
|
|
398
|
-
</UkButton>
|
|
399
|
-
|
|
400
|
-
{{#if this.showAdvanced}}
|
|
387
|
+
<CfbFormEditor::CfbAdvancedSettings>
|
|
401
388
|
{{#if (has-question-type f.model "action-button")}}
|
|
402
389
|
<f.input
|
|
403
390
|
@name="validateOnEnter"
|
|
@@ -438,9 +425,14 @@
|
|
|
438
425
|
@name="meta"
|
|
439
426
|
@renderComponent={{component "cfb-code-editor" language="json"}}
|
|
440
427
|
/>
|
|
441
|
-
|
|
428
|
+
</CfbFormEditor::CfbAdvancedSettings>
|
|
429
|
+
|
|
430
|
+
<div class="uk-flex uk-flex-between uk-flex-middle uk-flex-row-reverse">
|
|
431
|
+
<CfbFormEditor::QuestionUsage
|
|
432
|
+
@slug={{changeset-get f.model "slug"}}
|
|
433
|
+
class="uk-flex-last"
|
|
434
|
+
/>
|
|
442
435
|
|
|
443
|
-
<div class="uk-text-right">
|
|
444
436
|
<f.submit
|
|
445
437
|
@disabled={{f.loading}}
|
|
446
438
|
@label={{t "caluma.form-builder.global.save"}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "@projectcaluma/ember-form-builder/components/cfb-form-editor/cfb-advanced-settings";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "@projectcaluma/ember-form-builder/components/cfb-form-editor/question-usage";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectcaluma/ember-form-builder",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.9.0",
|
|
4
4
|
"description": "Ember engine for building Caluma forms.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -10,16 +10,16 @@
|
|
|
10
10
|
"homepage": "https://docs.caluma.io/ember-caluma",
|
|
11
11
|
"repository": "github:projectcaluma/ember-caluma",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@babel/core": "^7.23.
|
|
13
|
+
"@babel/core": "^7.23.7",
|
|
14
14
|
"@ember/legacy-built-in-components": "^0.5.0",
|
|
15
15
|
"@ember/render-modifiers": "^2.1.0",
|
|
16
16
|
"@ember/string": "^3.1.1",
|
|
17
|
-
"@embroider/macros": "^1.13.
|
|
17
|
+
"@embroider/macros": "^1.13.4",
|
|
18
18
|
"@glimmer/component": "^1.1.2",
|
|
19
19
|
"@glimmer/tracking": "^1.1.2",
|
|
20
20
|
"codejar": "^4.2.0",
|
|
21
21
|
"ember-apollo-client": "~4.0.2",
|
|
22
|
-
"ember-auto-import": "^2.7.
|
|
22
|
+
"ember-auto-import": "^2.7.2",
|
|
23
23
|
"ember-changeset": "^4.1.2",
|
|
24
24
|
"ember-changeset-validations": "^4.1.1",
|
|
25
25
|
"ember-cli-babel": "^8.2.0",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"ember-concurrency": "^3.1.1",
|
|
29
29
|
"ember-engines-router-service": "^0.5.0",
|
|
30
30
|
"ember-fetch": "^8.1.2",
|
|
31
|
-
"ember-flatpickr": "^
|
|
31
|
+
"ember-flatpickr": "^6.0.0",
|
|
32
32
|
"ember-intl": "^6.4.0",
|
|
33
33
|
"ember-math-helpers": "^4.0.0",
|
|
34
34
|
"ember-power-select": "^7.2.0",
|
|
@@ -36,14 +36,16 @@
|
|
|
36
36
|
"ember-test-selectors": "^6.0.0",
|
|
37
37
|
"ember-uikit": "^9.0.0",
|
|
38
38
|
"ember-validated-form": "^7.0.0",
|
|
39
|
+
"flatpickr": "^4.6.13",
|
|
39
40
|
"graphql": "^15.8.0",
|
|
40
41
|
"graphql-tag": "^2.12.6",
|
|
41
42
|
"highlight.js": "^11.9.0",
|
|
42
43
|
"highlightjs-jexl": "^0.0.5",
|
|
43
44
|
"jexl": "^2.3.0",
|
|
45
|
+
"lodash.isequal": "^4.5.0",
|
|
44
46
|
"uikit": "^3.17.11",
|
|
45
|
-
"@projectcaluma/ember-core": "^12.
|
|
46
|
-
"@projectcaluma/ember-form": "^12.
|
|
47
|
+
"@projectcaluma/ember-core": "^12.9.0",
|
|
48
|
+
"@projectcaluma/ember-form": "^12.9.0"
|
|
47
49
|
},
|
|
48
50
|
"//": [
|
|
49
51
|
"TODO: remove obsolete dependency to `ember-data` which is only necessary",
|
|
@@ -71,7 +73,7 @@
|
|
|
71
73
|
"ember-load-initializers": "2.1.2",
|
|
72
74
|
"ember-qunit": "8.0.2",
|
|
73
75
|
"ember-resolver": "11.0.1",
|
|
74
|
-
"ember-source": "5.
|
|
76
|
+
"ember-source": "5.6.0",
|
|
75
77
|
"ember-source-channel-url": "3.0.0",
|
|
76
78
|
"ember-try": "3.0.0",
|
|
77
79
|
"loader.js": "4.7.0",
|
|
@@ -79,7 +81,7 @@
|
|
|
79
81
|
"qunit": "2.20.0",
|
|
80
82
|
"qunit-dom": "3.0.0",
|
|
81
83
|
"webpack": "5.89.0",
|
|
82
|
-
"@projectcaluma/ember-testing": "12.
|
|
84
|
+
"@projectcaluma/ember-testing": "12.9.0"
|
|
83
85
|
},
|
|
84
86
|
"peerDependencies": {
|
|
85
87
|
"ember-engines": "^0.9.0",
|
package/translations/de.yaml
CHANGED
|
@@ -134,6 +134,11 @@ caluma:
|
|
|
134
134
|
|
|
135
135
|
hideLabel: "Label verstecken"
|
|
136
136
|
|
|
137
|
+
usage:
|
|
138
|
+
title: "Diese Frage wird in {n,plural, =1 {<b>einem</b> Formular} other {<b>#</b> Formularen}} verwendet."
|
|
139
|
+
references-heading: "Alle Verweise auf diese Frage"
|
|
140
|
+
not-published: "nicht publiziert"
|
|
141
|
+
|
|
137
142
|
options:
|
|
138
143
|
delete: "Option löschen"
|
|
139
144
|
archive: "Option archivieren (verstecken)"
|
package/translations/en.yaml
CHANGED
|
@@ -134,6 +134,11 @@ caluma:
|
|
|
134
134
|
|
|
135
135
|
hideLabel: "Hide label"
|
|
136
136
|
|
|
137
|
+
usage:
|
|
138
|
+
title: "This question is used in {n,plural, =1 {<b>another</b> form} other {<b>#</b> other forms}}"
|
|
139
|
+
references-heading: "All references of this question"
|
|
140
|
+
not-published: "not published"
|
|
141
|
+
|
|
137
142
|
options:
|
|
138
143
|
delete: "Delete option"
|
|
139
144
|
archive: "Archive (hide) option"
|
package/translations/fr.yaml
CHANGED
|
@@ -134,6 +134,11 @@ caluma:
|
|
|
134
134
|
|
|
135
135
|
hideLabel: "Cacher l'étiquette"
|
|
136
136
|
|
|
137
|
+
usage:
|
|
138
|
+
title: "Cette question est {n,plural, =1 {utilisé sous <b>une</b> forme} other {utilisé sous <b>#</b> formes}}."
|
|
139
|
+
references-heading: "Toutes les références à cette question"
|
|
140
|
+
not-published: "non publié"
|
|
141
|
+
|
|
137
142
|
options:
|
|
138
143
|
delete: "Supprimer l'option"
|
|
139
144
|
archive: "Archiver (masquer) l'option"
|