@projectcaluma/ember-form-builder 13.2.2 → 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.
@@ -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
+ }
@@ -212,6 +212,14 @@
212
212
  step="any"
213
213
  />
214
214
  </div>
215
+ <div>
216
+ <f.input
217
+ @type="number"
218
+ @name="floatStep"
219
+ @label={{t "caluma.form-builder.question.step"}}
220
+ step="any"
221
+ />
222
+ </div>
215
223
  </div>
216
224
  {{/if}}
217
225
 
@@ -97,6 +97,7 @@ export default class CfbFormEditorQuestion extends Component {
97
97
  integerMaxValue: null,
98
98
  floatMinValue: null,
99
99
  floatMaxValue: null,
100
+ floatStep: null,
100
101
  minLength: null,
101
102
  maxLength: null,
102
103
  defaultAnswer: null,
@@ -253,6 +254,7 @@ export default class CfbFormEditorQuestion extends Component {
253
254
  return {
254
255
  minValue: parseFloat(changeset.get("floatMinValue")),
255
256
  maxValue: parseFloat(changeset.get("floatMaxValue")),
257
+ step: parseFloat(changeset.get("floatStep")),
256
258
  placeholder: changeset.get("placeholder"),
257
259
  hintText: changeset.get("hintText"),
258
260
  };
@@ -363,11 +365,11 @@ export default class CfbFormEditorQuestion extends Component {
363
365
  (changeset.get("options") || [])
364
366
  .filter((option) => option.get("isDirty"))
365
367
  .map(async (option) => {
366
- const { label, slug, isArchived } = option;
368
+ const { label, slug, isArchived, isHidden } = option;
367
369
 
368
370
  await this.apollo.mutate({
369
371
  mutation: saveOptionMutation,
370
- variables: { input: { label, slug, isArchived } },
372
+ variables: { input: { label, slug, isArchived, isHidden } },
371
373
  });
372
374
  }),
373
375
  );
@@ -471,6 +473,7 @@ export default class CfbFormEditorQuestion extends Component {
471
473
  label: "",
472
474
  slug: "",
473
475
  isArchived: false,
476
+ isHidden: "false",
474
477
  slugUnlinked: false,
475
478
  question: this.model.slug,
476
479
  },
@@ -8,6 +8,7 @@ mutation SaveFloatQuestion($input: SaveFloatQuestionInput!) {
8
8
  ... on FloatQuestion {
9
9
  floatMinValue: minValue
10
10
  floatMaxValue: maxValue
11
+ floatStep: step
11
12
  hintText
12
13
  }
13
14
  }
@@ -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
  }
@@ -20,6 +20,7 @@ query FormEditorQuestion($slug: String!) {
20
20
  ... on FloatQuestion {
21
21
  floatMaxValue: maxValue
22
22
  floatMinValue: minValue
23
+ floatStep: step
23
24
  placeholder
24
25
  hintText
25
26
  defaultAnswer {
@@ -76,6 +77,7 @@ query FormEditorQuestion($slug: String!) {
76
77
  label
77
78
  slug
78
79
  isArchived
80
+ isHidden
79
81
  }
80
82
  }
81
83
  }
@@ -93,6 +95,7 @@ query FormEditorQuestion($slug: String!) {
93
95
  label
94
96
  slug
95
97
  isArchived
98
+ isHidden
96
99
  }
97
100
  }
98
101
  }
@@ -53,6 +53,10 @@ export default {
53
53
  validateGtLt({ gt: "floatMinValue", allowNone: true }),
54
54
  ),
55
55
  ),
56
+ floatStep: or(
57
+ validateType("FloatQuestion", false),
58
+ validateNumber({ gt: 0, allowBlank: true }),
59
+ ),
56
60
 
57
61
  minLength: or(
58
62
  and(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectcaluma/ember-form-builder",
3
- "version": "13.2.2",
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": "^13.2.2",
52
- "@projectcaluma/ember-form": "^13.2.2"
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.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": "13.2.2"
88
+ "@projectcaluma/ember-testing": "14.1.0"
89
89
  },
90
90
  "peerDependencies": {
91
91
  "ember-engines": "^0.11.0",
@@ -72,6 +72,7 @@ caluma:
72
72
  max-value: "Maximaler Wert"
73
73
  min-length: "Minimale Länge"
74
74
  max-length: "Maximale Länge"
75
+ step: "Schritte"
75
76
  rowForm: "Formular für Tabelleneinträge"
76
77
  subForm: "Formular für Einträge"
77
78
  no-selection: "Keine Auswahl"
@@ -144,6 +145,7 @@ caluma:
144
145
  delete: "Option löschen"
145
146
  archive: "Option archivieren (verstecken)"
146
147
  restore: "Option wiederherstellen"
148
+ show-jexl: "JEXL anzeigen"
147
149
 
148
150
  notification:
149
151
  form:
@@ -72,6 +72,7 @@ caluma:
72
72
  max-value: "Maximum value"
73
73
  min-length: "Minimum length"
74
74
  max-length: "Maximum length"
75
+ step: "Steps"
75
76
  rowForm: "Form to use for rows"
76
77
  subForm: "Form to use for entries"
77
78
  no-selection: "No selection"
@@ -144,6 +145,7 @@ caluma:
144
145
  delete: "Delete option"
145
146
  archive: "Archive (hide) option"
146
147
  restore: "Restore option"
148
+ show-jexl: "Show JEXL"
147
149
 
148
150
  notification:
149
151
  form:
@@ -72,6 +72,7 @@ caluma:
72
72
  max-value: "Valeur maximale"
73
73
  min-length: "Longueur minimale"
74
74
  max-length: "Longueur maximale"
75
+ step: "Étapes"
75
76
  rowForm: "Formulaire pour les entrées de tableau"
76
77
  subForm: "Formulaire pour les entrées"
77
78
  no-selection: "Aucune sélection"
@@ -144,6 +145,7 @@ caluma:
144
145
  delete: "Supprimer l'option"
145
146
  archive: "Archiver (masquer) l'option"
146
147
  restore: "Restaurer l'option"
148
+ show-jexl: "Afficher JEXL"
147
149
 
148
150
  notification:
149
151
  form:
@@ -72,6 +72,7 @@ caluma:
72
72
  max-value: "Valore massimo"
73
73
  min-length: "Lunghezza minima"
74
74
  max-length: "Lunghezza massima"
75
+ step: "Passi"
75
76
  rowForm: "Modulo per righe delle tabelle"
76
77
  subForm: "Modulo per voci"
77
78
  no-selection: "Nessuna selezione"
@@ -144,6 +145,7 @@ caluma:
144
145
  delete: "Elimina opzione"
145
146
  archive: "Archivia (nascondi) opzione"
146
147
  restore: "Ripristina opzione"
148
+ show-jexl: "Mostra JEXL"
147
149
 
148
150
  notification:
149
151
  form: