@projectcaluma/ember-form-builder 12.12.0 → 12.14.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/cfb-advanced-settings.hbs +1 -1
- package/addon/components/cfb-form-editor/cfb-advanced-settings.js +15 -1
- package/addon/components/cfb-form-editor/question-list/item.hbs +10 -2
- package/addon/components/cfb-form-editor/question-list/item.js +11 -0
- package/addon/components/cfb-form-editor/question.hbs +7 -5
- package/addon/components/cfb-form-editor/question.js +28 -0
- package/addon/templates/edit/questions/edit.hbs +0 -1
- package/package.json +7 -7
- package/addon/controllers/edit/questions/edit.js +0 -12
|
@@ -1,6 +1,20 @@
|
|
|
1
|
+
import { action } from "@ember/object";
|
|
1
2
|
import Component from "@glimmer/component";
|
|
2
3
|
import { tracked } from "@glimmer/tracking";
|
|
3
|
-
|
|
4
4
|
export default class CfbFormEditorCfbAdvancedSettings extends Component {
|
|
5
5
|
@tracked showAdvanced = false;
|
|
6
|
+
|
|
7
|
+
constructor(owner, args) {
|
|
8
|
+
super(owner, args);
|
|
9
|
+
|
|
10
|
+
this.showAdvanced =
|
|
11
|
+
JSON.parse(localStorage.getItem("showAdvanced")) ?? false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@action
|
|
15
|
+
toggleAdvanced() {
|
|
16
|
+
this.showAdvanced = !this.showAdvanced;
|
|
17
|
+
|
|
18
|
+
localStorage.setItem("showAdvanced", this.showAdvanced);
|
|
19
|
+
}
|
|
6
20
|
}
|
|
@@ -41,7 +41,11 @@
|
|
|
41
41
|
<a
|
|
42
42
|
data-test-edit-question
|
|
43
43
|
href="#"
|
|
44
|
-
class=
|
|
44
|
+
class={{if
|
|
45
|
+
this.isActive
|
|
46
|
+
"uk-width-auto uk-margin-small-right uk-text-bold"
|
|
47
|
+
"uk-width-auto uk-margin-small-right"
|
|
48
|
+
}}
|
|
45
49
|
{{on "click" (fn this.editQuestion @question)}}
|
|
46
50
|
>
|
|
47
51
|
{{@question.slug}}
|
|
@@ -51,7 +55,11 @@
|
|
|
51
55
|
</a>
|
|
52
56
|
{{else}}
|
|
53
57
|
<span
|
|
54
|
-
class=
|
|
58
|
+
class={{if
|
|
59
|
+
this.isActive
|
|
60
|
+
"uk-width-auto uk-margin-small-right uk-text-bold"
|
|
61
|
+
"uk-width-auto uk-margin-small-right"
|
|
62
|
+
}}
|
|
55
63
|
>{{@question.slug}}</span>
|
|
56
64
|
{{/if}}
|
|
57
65
|
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { action } from "@ember/object";
|
|
2
2
|
import { guidFor } from "@ember/object/internals";
|
|
3
|
+
import { service } from "@ember/service";
|
|
3
4
|
import Component from "@glimmer/component";
|
|
4
5
|
import jexl from "jexl";
|
|
5
6
|
|
|
6
7
|
import { hasQuestionType } from "@projectcaluma/ember-core/helpers/has-question-type";
|
|
7
8
|
|
|
8
9
|
export default class CfbFormEditorQuestionListItem extends Component {
|
|
10
|
+
@service router;
|
|
11
|
+
|
|
9
12
|
get elementId() {
|
|
10
13
|
return guidFor(this);
|
|
11
14
|
}
|
|
@@ -48,6 +51,14 @@ export default class CfbFormEditorQuestionListItem extends Component {
|
|
|
48
51
|
);
|
|
49
52
|
}
|
|
50
53
|
|
|
54
|
+
get isActive() {
|
|
55
|
+
// we can't access this.router.applicationRouter.currentRoute.queryParams
|
|
56
|
+
// because it is non-reactive
|
|
57
|
+
return this.router.currentURL?.endsWith(
|
|
58
|
+
`/questions/${this.args.question.slug}`,
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
51
62
|
@action
|
|
52
63
|
editQuestion(question, e) {
|
|
53
64
|
e.preventDefault();
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
@name="__typename"
|
|
36
36
|
@required={{true}}
|
|
37
37
|
@disabled={{not (is-empty @slug)}}
|
|
38
|
-
@on-update={{
|
|
38
|
+
@on-update={{this.updateType}}
|
|
39
39
|
/>
|
|
40
40
|
|
|
41
41
|
<f.input
|
|
@@ -428,10 +428,12 @@
|
|
|
428
428
|
</CfbFormEditor::CfbAdvancedSettings>
|
|
429
429
|
|
|
430
430
|
<div class="uk-flex uk-flex-between uk-flex-middle uk-flex-row-reverse">
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
431
|
+
{{#unless this.isNew}}
|
|
432
|
+
<CfbFormEditor::QuestionUsage
|
|
433
|
+
@slug={{changeset-get f.model "slug"}}
|
|
434
|
+
class="uk-flex-last"
|
|
435
|
+
/>
|
|
436
|
+
{{/unless}}
|
|
435
437
|
|
|
436
438
|
<f.submit
|
|
437
439
|
@disabled={{f.loading}}
|
|
@@ -195,6 +195,10 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
195
195
|
return this.data.lastSuccessful?.value?.[0]?.node;
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
+
get isNew() {
|
|
199
|
+
return !this.changeset.get("id");
|
|
200
|
+
}
|
|
201
|
+
|
|
198
202
|
get prefix() {
|
|
199
203
|
return this.calumaOptions.namespace
|
|
200
204
|
? `${this.calumaOptions.namespace}-`
|
|
@@ -497,6 +501,30 @@ export default class CfbFormEditorQuestion extends Component {
|
|
|
497
501
|
}
|
|
498
502
|
}
|
|
499
503
|
|
|
504
|
+
@action
|
|
505
|
+
updateType(value, changeset) {
|
|
506
|
+
changeset.set("__typename", value);
|
|
507
|
+
|
|
508
|
+
const defaultWidget = "cf-field/input/number-separator";
|
|
509
|
+
const currentWidget = changeset.get("meta.widgetOverride");
|
|
510
|
+
const isViableType = [
|
|
511
|
+
"IntegerQuestion",
|
|
512
|
+
"FloatQuestion",
|
|
513
|
+
"CalculatedFloatQuestion",
|
|
514
|
+
].includes(value);
|
|
515
|
+
|
|
516
|
+
if (this.calumaOptions.useNumberSeparatorWidgetAsDefault) {
|
|
517
|
+
if (isViableType && !currentWidget) {
|
|
518
|
+
// Set the default widget as override if the question type is viable for
|
|
519
|
+
// it and there is no widget selected yet
|
|
520
|
+
changeset.set("meta.widgetOverride", defaultWidget);
|
|
521
|
+
} else if (!isViableType && currentWidget === defaultWidget) {
|
|
522
|
+
// Remove default widget for non viable question types
|
|
523
|
+
changeset.set("meta.widgetOverride", undefined);
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
500
528
|
@action
|
|
501
529
|
updateSubForm(value, changeset) {
|
|
502
530
|
changeset.set("subForm.slug", value.slug);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectcaluma/ember-form-builder",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.14.0",
|
|
4
4
|
"description": "Ember engine for building Caluma forms.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
"highlightjs-jexl": "^0.0.5",
|
|
43
43
|
"jexl": "^2.3.0",
|
|
44
44
|
"lodash.isequal": "^4.5.0",
|
|
45
|
-
"reactiveweb": "^1.2.
|
|
45
|
+
"reactiveweb": "^1.2.3",
|
|
46
46
|
"uikit": "^3.19.2",
|
|
47
|
-
"@projectcaluma/ember-core": "^12.
|
|
48
|
-
"@projectcaluma/ember-form": "^12.
|
|
47
|
+
"@projectcaluma/ember-core": "^12.14.0",
|
|
48
|
+
"@projectcaluma/ember-form": "^12.14.0"
|
|
49
49
|
},
|
|
50
50
|
"//": [
|
|
51
51
|
"TODO: remove obsolete dependency to `ember-data` which is only necessary",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@ember/optional-features": "2.1.0",
|
|
58
58
|
"@ember/test-helpers": "3.3.0",
|
|
59
|
-
"@embroider/test-setup": "
|
|
59
|
+
"@embroider/test-setup": "4.0.0",
|
|
60
60
|
"@faker-js/faker": "8.4.1",
|
|
61
61
|
"broccoli-asset-rev": "3.0.0",
|
|
62
62
|
"ember-autoresize-modifier": "0.7.0",
|
|
@@ -79,9 +79,9 @@
|
|
|
79
79
|
"loader.js": "4.7.0",
|
|
80
80
|
"miragejs": "0.1.48",
|
|
81
81
|
"qunit": "2.20.1",
|
|
82
|
-
"qunit-dom": "3.
|
|
82
|
+
"qunit-dom": "3.1.2",
|
|
83
83
|
"webpack": "5.91.0",
|
|
84
|
-
"@projectcaluma/ember-testing": "12.
|
|
84
|
+
"@projectcaluma/ember-testing": "12.14.0"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
87
|
"ember-engines": "^0.9.0",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import Controller from "@ember/controller";
|
|
2
|
-
import { action } from "@ember/object";
|
|
3
|
-
import { inject as service } from "@ember/service";
|
|
4
|
-
|
|
5
|
-
export default class EditQuestionsEditController extends Controller {
|
|
6
|
-
@service router;
|
|
7
|
-
|
|
8
|
-
@action
|
|
9
|
-
afterSubmit() {
|
|
10
|
-
this.router.transitionTo("edit");
|
|
11
|
-
}
|
|
12
|
-
}
|