@projectcaluma/ember-form-builder 10.0.2 → 11.0.0-beta.10

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +1152 -0
  2. package/addon/components/cfb-code-editor.hbs +2 -1
  3. package/addon/components/cfb-code-editor.js +53 -8
  4. package/addon/components/cfb-form-editor/general.hbs +81 -90
  5. package/addon/components/cfb-form-editor/general.js +15 -11
  6. package/addon/components/cfb-form-editor/question/default.js +11 -12
  7. package/addon/components/cfb-form-editor/question/options.hbs +1 -1
  8. package/addon/components/cfb-form-editor/question/validation.hbs +3 -2
  9. package/addon/components/cfb-form-editor/question/validation.js +17 -13
  10. package/addon/components/cfb-form-editor/question-list/item.hbs +8 -8
  11. package/addon/components/cfb-form-editor/question-list/item.js +2 -2
  12. package/addon/components/cfb-form-editor/question-list.hbs +8 -8
  13. package/addon/components/cfb-form-editor/question-list.js +13 -8
  14. package/addon/components/cfb-form-editor/question.hbs +23 -15
  15. package/addon/components/cfb-form-editor/question.js +22 -20
  16. package/addon/components/cfb-form-editor.hbs +5 -5
  17. package/addon/components/cfb-form-list/item.hbs +1 -1
  18. package/addon/components/cfb-form-list.hbs +69 -72
  19. package/addon/components/cfb-form-list.js +49 -39
  20. package/addon/components/cfb-navigation.hbs +1 -1
  21. package/addon/components/cfb-toggle-switch.hbs +2 -2
  22. package/addon/controllers/index.js +6 -0
  23. package/addon/engine.js +8 -11
  24. package/addon/gql/fragments/field.graphql +23 -1
  25. package/addon/gql/fragments/form-info.graphql +1 -0
  26. package/addon/gql/fragments/question-info.graphql +1 -0
  27. package/addon/gql/mutations/add-form-question.graphql +2 -0
  28. package/addon/gql/mutations/remove-form-question.graphql +2 -0
  29. package/addon/gql/mutations/reorder-form-questions.graphql +2 -0
  30. package/addon/gql/mutations/save-action-button-question.graphql +1 -0
  31. package/addon/gql/mutations/save-calculated-float-question.graphql +1 -0
  32. package/addon/gql/mutations/save-choice-question.graphql +2 -0
  33. package/addon/gql/mutations/save-date-question.graphql +1 -0
  34. package/addon/gql/mutations/save-dynamic-choice-question.graphql +1 -0
  35. package/addon/gql/mutations/save-dynamic-multiple-choice-question.graphql +1 -0
  36. package/addon/gql/mutations/save-file-question.graphql +1 -0
  37. package/addon/gql/mutations/save-float-question.graphql +1 -0
  38. package/addon/gql/mutations/save-form-question.graphql +2 -0
  39. package/addon/gql/mutations/save-form.graphql +1 -0
  40. package/addon/gql/mutations/save-integer-question.graphql +1 -0
  41. package/addon/gql/mutations/save-multiple-choice-question.graphql +2 -0
  42. package/addon/gql/mutations/save-option.graphql +1 -0
  43. package/addon/gql/mutations/save-static-question.graphql +1 -0
  44. package/addon/gql/mutations/save-table-question.graphql +2 -0
  45. package/addon/gql/mutations/save-text-question.graphql +1 -0
  46. package/addon/gql/mutations/save-textarea-question.graphql +1 -0
  47. package/addon/gql/queries/all-format-validators.graphql +10 -0
  48. package/addon/gql/queries/check-form-slug.graphql +1 -0
  49. package/addon/gql/queries/check-question-slug.graphql +1 -0
  50. package/addon/gql/queries/form-editor-general.graphql +1 -0
  51. package/addon/gql/queries/form-editor-question.graphql +21 -0
  52. package/addon/gql/queries/form-list.graphql +1 -0
  53. package/addon/gql/queries/search-form-question.graphql +4 -0
  54. package/addon/gql/queries/search-question.graphql +3 -0
  55. package/addon/instance-initializers/form-builder-widget-overrides.js +15 -0
  56. package/addon/modifiers/pikaday.js +2 -0
  57. package/addon/routes/edit/questions/edit.js +1 -1
  58. package/addon/routes/edit.js +1 -1
  59. package/addon/templates/edit/questions/edit.hbs +1 -1
  60. package/addon/templates/edit/questions/new.hbs +1 -4
  61. package/addon/templates/edit.hbs +5 -5
  62. package/addon/templates/index.hbs +8 -1
  63. package/addon/templates/new.hbs +1 -1
  64. package/addon/utils/and.js +47 -0
  65. package/addon/utils/or.js +40 -0
  66. package/addon/validations/option.js +1 -1
  67. package/addon/validations/question.js +2 -2
  68. package/addon/validators/slug.js +1 -1
  69. package/app/instance-initializers/form-builder-widget-overrides.js +4 -0
  70. package/app/styles/@projectcaluma/ember-form-builder.scss +1 -1
  71. package/app/utils/and.js +1 -0
  72. package/app/utils/or.js +1 -0
  73. package/index.js +6 -4
  74. package/package.json +37 -30
  75. package/translations/de.yaml +5 -5
  76. package/translations/en.yaml +2 -2
  77. package/translations/fr.yaml +154 -1
@@ -11,7 +11,6 @@
11
11
  >
12
12
  {{#if (and f.model.isDirty @slug)}}
13
13
  <div class="uk-alert-warning uk-animation-fade" uk-alert>
14
- <a href="#" class="uk-alert-close" uk-close></a>
15
14
  <div uk-grid class="uk-grid-small">
16
15
  <div class="uk-width-auto uk-flex uk-flex-middle">
17
16
  <UkIcon @icon="warning" @ratio={{1.2}} />
@@ -141,6 +140,7 @@
141
140
  @label={{t "caluma.form-builder.question.confirmationText"}}
142
141
  @name="infoText"
143
142
  @type="textarea"
143
+ {{autoresize mode="height"}}
144
144
  />
145
145
  {{else}}
146
146
  <div class="uk-margin">
@@ -208,13 +208,13 @@
208
208
  />
209
209
 
210
210
  <f.input
211
- @name="meta.formatValidators"
211
+ @name="formatValidators"
212
212
  @label={{t "caluma.form-builder.question.formatValidators"}}
213
- @placeholder={{t "caluma.form-builder.question.choose"}}
213
+ @placeholder={{t "caluma.form-builder.question.no-selection"}}
214
214
  @required={{false}}
215
215
  @renderComponent={{component "cfb-form-editor/question/validation"}}
216
- @on-update={{changeset-set f.model "meta.formatValidators"}}
217
- @value={{changeset-get f.model "meta.formatValidators"}}
216
+ @on-update={{changeset-set f.model "formatValidators"}}
217
+ @value={{changeset-get f.model "formatValidators"}}
218
218
  />
219
219
  {{/if}}
220
220
 
@@ -296,10 +296,10 @@
296
296
  @type="select"
297
297
  @required={{true}}
298
298
  @label={{t "caluma.form-builder.question.dataSource"}}
299
- @options={{or this.availableDataSources.lastSuccessful.value array}}
299
+ @options={{or this.availableDataSources.lastSuccessful.value (array)}}
300
300
  @optionTargetPath="name"
301
301
  @optionLabelPath="info"
302
- @includeBlank={{t "caluma.form-builder.question.choose"}}
302
+ @prompt={{t "caluma.form-builder.question.no-selection"}}
303
303
  />
304
304
  {{/if}}
305
305
 
@@ -329,9 +329,9 @@
329
329
  as |fi|
330
330
  >
331
331
  <PowerSelect
332
- @options={{or this.availableForms.lastSuccessful.value array}}
332
+ @options={{or this.availableForms.lastSuccessful.value (array)}}
333
333
  @selected={{fi.value}}
334
- @placeholder={{t "caluma.form-builder.question.choose"}}
334
+ @placeholder={{t "caluma.form-builder.question.no-selection"}}
335
335
  @onBlur={{fi.setDirty}}
336
336
  @onChange={{fi.update}}
337
337
  @searchField="slug"
@@ -342,6 +342,7 @@
342
342
  @noMatchesMessage={{t
343
343
  "caluma.form-builder.question.search-empty"
344
344
  }}
345
+ @renderInPlace={{true}}
345
346
  as |form|
346
347
  >
347
348
  <span
@@ -403,9 +404,9 @@
403
404
  as |fi|
404
405
  >
405
406
  <PowerSelect
406
- @options={{or this.availableForms.lastSuccessful.value array}}
407
+ @options={{or this.availableForms.lastSuccessful.value (array)}}
407
408
  @selected={{fi.value}}
408
- @placeholder={{t "caluma.form-builder.question.choose"}}
409
+ @placeholder={{t "caluma.form-builder.question.no-selection"}}
409
410
  @onBlur={{fi.setDirty}}
410
411
  @onChange={{fi.update}}
411
412
  @searchField="slug"
@@ -414,6 +415,7 @@
414
415
  "caluma.form-builder.question.search-placeholder"
415
416
  }}
416
417
  @noMatchesMessage={{t "caluma.form-builder.question.search-empty"}}
418
+ @renderInPlace={{true}}
417
419
  as |form|
418
420
  >
419
421
  <span class="uk-width-auto uk-margin-small-right uk-text-truncate">
@@ -436,7 +438,7 @@
436
438
  @optionTargetPath="component"
437
439
  @optionLabelPath="label"
438
440
  @options={{this.availableOverrides}}
439
- class="uk-flex uk-flex-between uk-flex-column"
441
+ @prompt={{t "caluma.form-builder.question.no-selection"}}
440
442
  />
441
443
 
442
444
  <f.input
@@ -444,12 +446,11 @@
444
446
  @label={{t "caluma.form-builder.question.isArchived"}}
445
447
  @required={{true}}
446
448
  @renderComponent={{component "cfb-toggle-switch" size="small"}}
447
- class="uk-flex uk-flex-between uk-flex-column"
448
449
  />
449
450
 
450
451
  <UkButton
451
452
  @color="link"
452
- @on-click={{toggle-action "showAdvanced" this}}
453
+ @onClick={{toggle-action "showAdvanced" this}}
453
454
  class="uk-flex uk-flex-middle uk-margin"
454
455
  >
455
456
  {{#if this.showAdvanced}}
@@ -467,7 +468,6 @@
467
468
  @required={{true}}
468
469
  @label={{t "caluma.form-builder.question.validateOnEnter"}}
469
470
  @renderComponent={{component "cfb-toggle-switch" size="small"}}
470
- class="uk-flex uk-flex-between uk-flex-column"
471
471
  />
472
472
  {{/if}}
473
473
 
@@ -494,6 +494,14 @@
494
494
  />
495
495
  </div>
496
496
  {{/if}}
497
+
498
+ <div class="uk-margin">
499
+ <f.input
500
+ @label={{t "caluma.form-builder.question.meta"}}
501
+ @name="meta"
502
+ @renderComponent={{component "cfb-code-editor" language="json"}}
503
+ />
504
+ </div>
497
505
  {{/if}}
498
506
 
499
507
  <div class="uk-text-right">
@@ -1,16 +1,14 @@
1
- import { getOwner } from "@ember/application";
2
1
  import { A } from "@ember/array";
3
2
  import { action } from "@ember/object";
4
3
  import { inject as service } from "@ember/service";
5
4
  import { camelize } from "@ember/string";
5
+ import { macroCondition, isTesting } from "@embroider/macros";
6
6
  import Component from "@glimmer/component";
7
7
  import { tracked } from "@glimmer/tracking";
8
8
  import { queryManager } from "ember-apollo-client";
9
9
  import Changeset from "ember-changeset";
10
10
  import lookupValidator from "ember-changeset-validations";
11
- import { optional } from "ember-composable-helpers/helpers/optional";
12
11
  import { dropTask, restartableTask, task, timeout } from "ember-concurrency";
13
- import { all } from "rsvp";
14
12
 
15
13
  import { hasQuestionType } from "@projectcaluma/ember-core/helpers/has-question-type";
16
14
  import slugify from "@projectcaluma/ember-core/utils/slugify";
@@ -107,6 +105,7 @@ export default class CfbFormEditorQuestion extends Component {
107
105
  subForm: {},
108
106
  meta: {},
109
107
  dataSource: "",
108
+ formatValidators: null,
110
109
  // action button
111
110
  action: ACTIONS[0],
112
111
  color: COLORS[0],
@@ -183,16 +182,10 @@ export default class CfbFormEditorQuestion extends Component {
183
182
 
184
183
  get availableOverrides() {
185
184
  const type = this.changeset.get("__typename");
186
- const overrides = this.calumaOptions
187
- .getComponentOverrides()
188
- .filter((override) => {
189
- return !override.types || override.types.includes(type);
190
- });
191
185
 
192
- return [
193
- { label: this.intl.t("caluma.form.power-select.null"), component: "" },
194
- ...overrides,
195
- ];
186
+ return this.calumaOptions.getComponentOverrides().filter((override) => {
187
+ return !override.types || override.types.includes(type);
188
+ });
196
189
  }
197
190
 
198
191
  get model() {
@@ -213,16 +206,20 @@ export default class CfbFormEditorQuestion extends Component {
213
206
  const slug =
214
207
  ((!this.args.slug && this.prefix) || "") + changeset.get("slug");
215
208
 
209
+ const rawMeta = changeset.get("meta");
210
+
216
211
  const input = {
217
212
  slug,
218
213
  label: changeset.get("label"),
219
214
  isHidden: changeset.get("isHidden"),
220
215
  infoText: changeset.get("infoText"),
221
- meta: JSON.stringify(changeset.get("meta").unwrap()),
216
+ meta: JSON.stringify(rawMeta?.unwrap?.() ?? rawMeta),
222
217
  isArchived: changeset.get("isArchived"),
223
218
  };
224
219
 
225
- if (!hasQuestionType(changeset, "static", "calculated-float")) {
220
+ if (
221
+ !hasQuestionType(changeset, "static", "calculated-float", "action-button")
222
+ ) {
226
223
  Object.assign(input, {
227
224
  isRequired: changeset.get("isRequired"),
228
225
  });
@@ -257,6 +254,9 @@ export default class CfbFormEditorQuestion extends Component {
257
254
  minLength: parseInt(changeset.get("minLength")),
258
255
  maxLength: parseInt(changeset.get("maxLength")),
259
256
  placeholder: changeset.get("placeholder"),
257
+ formatValidators: changeset
258
+ .get("formatValidators")
259
+ ?.edges.map((edge) => edge.node.slug),
260
260
  };
261
261
  }
262
262
 
@@ -265,6 +265,9 @@ export default class CfbFormEditorQuestion extends Component {
265
265
  minLength: parseInt(changeset.get("minLength")),
266
266
  maxLength: parseInt(changeset.get("maxLength")),
267
267
  placeholder: changeset.get("placeholder"),
268
+ formatValidators: changeset
269
+ .get("formatValidators")
270
+ ?.edges.map((edge) => edge.node.slug),
268
271
  };
269
272
  }
270
273
 
@@ -326,7 +329,7 @@ export default class CfbFormEditorQuestion extends Component {
326
329
 
327
330
  @task
328
331
  *saveOptions(changeset) {
329
- yield all(
332
+ yield Promise.all(
330
333
  (changeset.get("options.edges") || []).map(async ({ node: option }) => {
331
334
  const { label, slug, isArchived } = option;
332
335
 
@@ -406,7 +409,7 @@ export default class CfbFormEditorQuestion extends Component {
406
409
  this.intl.t("caluma.form-builder.notification.question.save.success")
407
410
  );
408
411
 
409
- optional([this.args["on-after-submit"]])(question);
412
+ this.args.onAfterSubmit?.(question);
410
413
  } catch (e) {
411
414
  // eslint-disable-next-line no-console
412
415
  console.error(e);
@@ -419,10 +422,9 @@ export default class CfbFormEditorQuestion extends Component {
419
422
  @restartableTask
420
423
  *validateSlug(slug, changeset) {
421
424
  /* istanbul ignore next */
422
- if (
423
- getOwner(this).resolveRegistration("config:environment").environment !==
424
- "test"
425
- ) {
425
+ if (macroCondition(isTesting())) {
426
+ // no timeout
427
+ } else {
426
428
  yield timeout(500);
427
429
  }
428
430
 
@@ -12,11 +12,11 @@
12
12
  {{else}}
13
13
  <CfbFormEditor::QuestionList
14
14
  @form={{@slug}}
15
- @on-edit-question={{@on-edit-question}}
16
- @on-create-question={{@on-create-question}}
17
- @on-after-add-question={{@on-after-add-question}}
18
- @on-after-remove-question={{@on-after-remove-question}}
19
- @on-click-form={{@on-click-form}}
15
+ @onEditQuestion={{@onEditQuestion}}
16
+ @onCreateQuestion={{@onCreateQuestion}}
17
+ @onAfterAddQuestion={{@onAfterAddQuestion}}
18
+ @onAfterRemoveQuestion={{@onAfterRemoveQuestion}}
19
+ @onClickForm={{@onClickForm}}
20
20
  />
21
21
  {{/if}}
22
22
  </div>
@@ -12,7 +12,7 @@
12
12
  type="button"
13
13
  uk-icon="pencil"
14
14
  class="uk-icon-button"
15
- {{on "click" (fn (optional @on-edit-form) @item)}}
15
+ {{on "click" (fn (optional @onEditForm) @item)}}
16
16
  >
17
17
  </button>
18
18
  </span>
@@ -1,76 +1,73 @@
1
- <div
2
- ...attributes
3
- {{did-insert (perform this.fetchForms)}}
4
- {{did-update (perform this.fetchForms)}}
5
- >
6
- <div class="uk-flex uk-flex-between">
7
- <div class="uk-button-group">
8
- {{#each (array "active" "archived" "all") as |category|}}
9
- <UkButton
10
- data-test-filter={{category}}
11
- @on-click={{fn this.setFilter "category" category}}
12
- @label={{t (concat "caluma.form-builder.form." category)}}
13
- @class={{if (eq this.category category) "uk-button-primary" ""}}
14
- />
15
- {{/each}}
16
- </div>
17
- <div>
1
+ <div class="uk-flex uk-flex-between">
2
+ <div class="uk-button-group">
3
+ {{#each this.categories as |category|}}
18
4
  <UkButton
19
- data-test-new-form
20
- @on-click={{optional @on-new-form}}
21
- @label={{t "caluma.form-builder.form.new"}}
5
+ data-test-filter={{category.value}}
6
+ @onClick={{fn @onUpdateCategory category.value}}
7
+ @label={{category.label}}
8
+ @color={{if (eq @category category.value) "primary"}}
22
9
  />
23
- </div>
10
+ {{/each}}
24
11
  </div>
25
- <form
26
- class="uk-search uk-search-default uk-width-1-1 uk-margin-small-top"
27
- {{on "submit" this.submit}}
28
- >
29
- <span class="uk-search-icon-flip" uk-search-icon></span>
30
- <input
31
- data-test-form-search-input
32
- class="uk-search-input"
33
- type="search"
34
- placeholder="{{t "caluma.form-builder.global.search"}}..."
35
- aria-label="{{t "caluma.form-builder.global.search"}}"
36
- value={{this.search}}
37
- {{on "input" (fn this.setFilter "search")}}
12
+ <div>
13
+ <UkButton
14
+ data-test-new-form
15
+ @onClick={{optional @onNewForm}}
16
+ @label={{t "caluma.form-builder.form.new"}}
38
17
  />
39
- </form>
40
- {{#if this.formsQuery.isLoading}}
41
- <div class="uk-height-small uk-flex uk-flex-center uk-flex-middle">
42
- <UkSpinner ratio="2" />
43
- </div>
44
- {{else if this.formsQuery.value.length}}
45
- <ul data-test-form-list class="uk-list uk-list-divider uk-list-large">
46
- {{#each this.formsQuery.value key="id" as |item|}}
47
- <CfbFormList::Item
48
- data-test-form-list-item={{item.slug}}
49
- @item={{item}}
50
- @on-edit-form={{@on-edit-form}}
51
- />
52
- {{/each}}
53
- {{#if this.formsQuery.hasNextPage}}
54
- <li class="uk-text-center cfb-pointer">
55
- <a
56
- data-test-form-loader-button
57
- href="#"
58
- {{on "click" this.loadMoreForms}}
59
- >
60
- {{t "caluma.form-builder.form.loadMore"}}
61
- </a>
62
- </li>
63
- {{/if}}
64
- </ul>
65
- {{else}}
66
- <div
67
- data-test-form-list-empty
68
- class="uk-padding-large uk-padding-remove-horizontal uk-text-center"
69
- >
70
- <UkIcon @icon="search" @ratio={{10}} />
71
- <p class="uk-text-muted">
72
- {{t "caluma.form-builder.form.empty"}}
73
- </p>
74
- </div>
75
- {{/if}}
76
- </div>
18
+ </div>
19
+ </div>
20
+
21
+ <div class="uk-search uk-search-default uk-width-1-1 uk-margin-top">
22
+ <span class="uk-search-icon-flip" uk-search-icon></span>
23
+ <input
24
+ data-test-form-search-input
25
+ class="uk-search-input"
26
+ type="search"
27
+ placeholder="{{t 'caluma.form-builder.global.search'}}..."
28
+ aria-label="{{t 'caluma.form-builder.global.search'}}"
29
+ value={{@search}}
30
+ {{on "input" (perform this.search)}}
31
+ />
32
+ </div>
33
+
34
+ {{#if this.formsQuery.value.length}}
35
+ <ul data-test-form-list class="uk-list uk-list-divider uk-list-large">
36
+ {{#each this.formsQuery.value key="id" as |item|}}
37
+ <CfbFormList::Item
38
+ data-test-form-list-item={{item.slug}}
39
+ @item={{item}}
40
+ @onEditForm={{@onEditForm}}
41
+ />
42
+ {{/each}}
43
+ {{#if this.formsQuery.isLoading}}
44
+ <li class="uk-text-center">
45
+ <UkSpinner />
46
+ </li>
47
+ {{else if this.formsQuery.hasNextPage}}
48
+ <li class="uk-text-center cfb-pointer">
49
+ <a
50
+ data-test-form-loader-button
51
+ href="#"
52
+ {{on "click" this.formsQuery.fetchMore}}
53
+ >
54
+ {{t "caluma.form-builder.form.loadMore"}}
55
+ </a>
56
+ </li>
57
+ {{/if}}
58
+ </ul>
59
+ {{else if this.formsQuery.isLoading}}
60
+ <div class="uk-height-small uk-flex uk-flex-center uk-flex-middle">
61
+ <UkSpinner @ratio={{2}} />
62
+ </div>
63
+ {{else}}
64
+ <div
65
+ data-test-form-list-empty
66
+ class="uk-padding-large uk-padding-remove-horizontal uk-text-center"
67
+ >
68
+ <UkIcon @icon="search" @ratio={{10}} />
69
+ <p class="uk-text-muted">
70
+ {{t "caluma.form-builder.form.empty"}}
71
+ </p>
72
+ </div>
73
+ {{/if}}
@@ -1,61 +1,71 @@
1
- import { action } from "@ember/object";
1
+ import { inject as service } from "@ember/service";
2
+ import { macroCondition, isTesting } from "@embroider/macros";
2
3
  import Component from "@glimmer/component";
3
- import { tracked } from "@glimmer/tracking";
4
- import { queryManager } from "ember-apollo-client";
5
- import { timeout } from "ember-concurrency";
6
- import { restartableTask } from "ember-concurrency-decorators";
4
+ import { timeout, restartableTask } from "ember-concurrency";
7
5
 
8
- import calumaQuery from "@projectcaluma/ember-core/caluma-query";
6
+ import { useCalumaQuery } from "@projectcaluma/ember-core/caluma-query";
9
7
  import { allForms } from "@projectcaluma/ember-core/caluma-query/queries";
10
8
 
11
9
  export default class ComponentsCfbFormListComponent extends Component {
12
- @queryManager apollo;
10
+ @service intl;
13
11
 
14
- @calumaQuery({ query: allForms, options: { pageSize: 20 } }) formsQuery;
12
+ formsQuery = useCalumaQuery(this, allForms, () => ({
13
+ options: { pageSize: 20 },
14
+ filter: this.filter,
15
+ order: [{ attribute: "NAME", direction: "ASC" }],
16
+ }));
15
17
 
16
- @tracked category = "active";
17
- @tracked search = "";
18
+ get categories() {
19
+ return [
20
+ {
21
+ value: "active",
22
+ label: this.intl.t("caluma.form-builder.form.active"),
23
+ },
24
+ {
25
+ value: "archived",
26
+ label: this.intl.t("caluma.form-builder.form.isArchived"),
27
+ },
28
+ {
29
+ value: "published",
30
+ label: this.intl.t("caluma.form-builder.form.isPublished"),
31
+ },
32
+ {
33
+ value: "unpublished",
34
+ label: this.intl.t("caluma.form-builder.form.draft"),
35
+ },
36
+ { value: "all", label: this.intl.t("caluma.form-builder.form.all") },
37
+ ];
38
+ }
18
39
 
19
40
  get filter() {
20
41
  const isArchived =
21
- this.category === "active"
42
+ this.args.category === "active"
22
43
  ? { isArchived: false }
23
- : this.category === "archived"
44
+ : this.args.category === "archived"
24
45
  ? { isArchived: true }
25
46
  : null;
26
47
 
27
- const search = this.search ? { search: this.search } : null;
28
-
29
- return [isArchived, search].filter(Boolean) || null;
30
- }
48
+ const search = this.args.search ? { search: this.args.search } : null;
31
49
 
32
- @action
33
- setFilter(name, eventOrValue) {
34
- this[name] =
35
- eventOrValue instanceof Event ? eventOrValue.target.value : eventOrValue;
36
-
37
- this.fetchForms.perform();
38
- }
39
-
40
- @action
41
- submit(event) {
42
- event.preventDefault();
43
- }
44
-
45
- @action
46
- loadMoreForms(e) {
47
- e.preventDefault();
50
+ const isPublished =
51
+ this.args.category === "unpublished"
52
+ ? { isPublished: false }
53
+ : this.args.category === "published"
54
+ ? { isPublished: true }
55
+ : null;
48
56
 
49
- this.formsQuery.fetchMore();
57
+ return [isArchived, isPublished, search].filter(Boolean) || null;
50
58
  }
51
59
 
52
60
  @restartableTask
53
- *fetchForms() {
54
- yield timeout(500);
61
+ *search(event) {
62
+ /* istanbul ignore next */
63
+ if (macroCondition(isTesting())) {
64
+ // no timeout
65
+ } else {
66
+ yield timeout(500);
67
+ }
55
68
 
56
- yield this.formsQuery.fetch({
57
- filter: this.filter,
58
- order: [{ attribute: "NAME", direction: "ASC" }],
59
- });
69
+ this.args.onUpdateSearch(event.target.value);
60
70
  }
61
71
  }
@@ -4,7 +4,7 @@
4
4
  <LinkTo
5
5
  @route={{crumb.routeName}}
6
6
  class="uk-text-large uk-text-truncate cfb-navigation__item__link
7
- {{if crumb.disabled "uk-disabled"}}"
7
+ {{if crumb.disabled 'uk-disabled'}}"
8
8
  >
9
9
  {{crumb.title}}
10
10
  </LinkTo>
@@ -1,4 +1,4 @@
1
- <div class="uk-flex uk-flex-column {{unless @noMargin "uk-margin"}}">
1
+ <div class="uk-flex uk-flex-column {{unless @noMargin 'uk-margin'}}">
2
2
  <@labelComponent />
3
3
 
4
4
  <div class="uk-form-controls" ...attributes>
@@ -7,7 +7,7 @@
7
7
  @size={{@size}}
8
8
  @name={{@name}}
9
9
  @disabled={{@disabled}}
10
- @on-toggle={{@update}}
10
+ @onToggle={{@update}}
11
11
  />
12
12
  </div>
13
13
 
@@ -1,10 +1,16 @@
1
1
  import Controller from "@ember/controller";
2
2
  import { action } from "@ember/object";
3
3
  import { inject as service } from "@ember/service";
4
+ import { tracked } from "@glimmer/tracking";
4
5
 
5
6
  export default class IndexController extends Controller {
6
7
  @service router;
7
8
 
9
+ queryParams = ["search", "category"];
10
+
11
+ @tracked search = "";
12
+ @tracked category = "active";
13
+
8
14
  @action
9
15
  newForm() {
10
16
  this.router.transitionTo("new");
package/addon/engine.js CHANGED
@@ -6,16 +6,13 @@ import config from "./config/environment";
6
6
 
7
7
  const { modulePrefix } = config;
8
8
 
9
- /* eslint-disable ember/avoid-leaking-state-in-ember-objects */
10
- const Eng = Engine.extend({
11
- modulePrefix,
12
- Resolver,
9
+ export default class FormBuilderEngine extends Engine {
10
+ modulePrefix = modulePrefix;
11
+ Resolver = Resolver;
13
12
 
14
- dependencies: {
15
- services: ["apollo", "notification", "intl", "caluma-options", "validator"],
16
- },
17
- });
13
+ dependencies = {
14
+ services: ["apollo", "notification", "intl", "caluma-options"],
15
+ };
16
+ }
18
17
 
19
- loadInitializers(Eng, modulePrefix);
20
-
21
- export default Eng;
18
+ loadInitializers(FormBuilderEngine, modulePrefix);