@projectcaluma/ember-form-builder 14.0.0 → 14.1.1

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.
@@ -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 { node };
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
- <li class="cfb-option-row" data-test-row={{concat "option-" (add i 1)}}>
12
- <ValidatedForm @model={{row}} as |f|>
13
- <div
14
- uk-grid
15
- class="uk-grid-small uk-flex uk-flex-top"
16
- id={{row.slug}}
17
- >
18
- <div class="uk-width-auto uk-flex uk-flex-middle">
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
@@ -64,6 +64,7 @@ export default class CfbFormEditorQuestionOptions extends Component {
64
64
  slug: "",
65
65
  label: "",
66
66
  isArchived: false,
67
+ isHidden: "false",
67
68
  slugUnlinked: false,
68
69
  question: this.args.model.slug,
69
70
  },
@@ -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>
@@ -0,0 +1,6 @@
1
+ import Component from "@glimmer/component";
2
+ import { tracked } from "@glimmer/tracking";
3
+
4
+ export default class CfbFormEditorQuestionOption extends Component {
5
+ @tracked showJexl = false;
6
+ }
@@ -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
  },
@@ -4,6 +4,7 @@ mutation SaveOption($input: SaveOptionInput!) {
4
4
  id
5
5
  label
6
6
  slug
7
+ isHidden
7
8
  }
8
9
  }
9
10
  }
@@ -77,6 +77,7 @@ query FormEditorQuestion($slug: String!) {
77
77
  label
78
78
  slug
79
79
  isArchived
80
+ isHidden
80
81
  }
81
82
  }
82
83
  }
@@ -94,6 +95,7 @@ query FormEditorQuestion($slug: String!) {
94
95
  label
95
96
  slug
96
97
  isArchived
98
+ isHidden
97
99
  }
98
100
  }
99
101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectcaluma/ember-form-builder",
3
- "version": "14.0.0",
3
+ "version": "14.1.1",
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.0.0",
52
- "@projectcaluma/ember-form": "^14.0.0"
51
+ "@projectcaluma/ember-core": "^14.1.1",
52
+ "@projectcaluma/ember-form": "^14.1.1"
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.3.0",
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.0.0"
88
+ "@projectcaluma/ember-testing": "14.1.1"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "ember-engines": "^0.11.0",
@@ -145,6 +145,7 @@ caluma:
145
145
  delete: "Option löschen"
146
146
  archive: "Option archivieren (verstecken)"
147
147
  restore: "Option wiederherstellen"
148
+ show-jexl: "JEXL anzeigen"
148
149
 
149
150
  notification:
150
151
  form:
@@ -145,6 +145,7 @@ caluma:
145
145
  delete: "Delete option"
146
146
  archive: "Archive (hide) option"
147
147
  restore: "Restore option"
148
+ show-jexl: "Show JEXL"
148
149
 
149
150
  notification:
150
151
  form:
@@ -145,6 +145,7 @@ caluma:
145
145
  delete: "Supprimer l'option"
146
146
  archive: "Archiver (masquer) l'option"
147
147
  restore: "Restaurer l'option"
148
+ show-jexl: "Afficher JEXL"
148
149
 
149
150
  notification:
150
151
  form:
@@ -145,6 +145,7 @@ caluma:
145
145
  delete: "Elimina opzione"
146
146
  archive: "Archivia (nascondi) opzione"
147
147
  restore: "Ripristina opzione"
148
+ show-jexl: "Mostra JEXL"
148
149
 
149
150
  notification:
150
151
  form: