@projectcaluma/ember-form-builder 14.7.0 → 14.7.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.
@@ -5,7 +5,7 @@ import { tracked } from "@glimmer/tracking";
5
5
  import { queryManager } from "ember-apollo-client";
6
6
  import { Changeset } from "ember-changeset";
7
7
  import lookupValidator from "ember-changeset-validations";
8
- import { dropTask } from "ember-concurrency";
8
+ import { task } from "ember-concurrency";
9
9
 
10
10
  import copyFormMutation from "@projectcaluma/ember-form-builder/gql/mutations/copy-form.graphql";
11
11
  import validations from "@projectcaluma/ember-form-builder/validations/form";
@@ -32,10 +32,9 @@ export default class CfbFormEditorCopyModal extends Component {
32
32
  this.visible = !this.visible;
33
33
  }
34
34
 
35
- @dropTask
36
- *submit(changeset) {
35
+ submit = task({ drop: true }, async (changeset) => {
37
36
  try {
38
- yield this.apollo.mutate(
37
+ await this.apollo.mutate(
39
38
  {
40
39
  mutation: copyFormMutation,
41
40
  variables: {
@@ -59,5 +58,5 @@ export default class CfbFormEditorCopyModal extends Component {
59
58
  this.intl.t("caluma.form-builder.notification.form.create.error"),
60
59
  );
61
60
  }
62
- }
61
+ });
63
62
  }
@@ -2,7 +2,7 @@ import { action } from "@ember/object";
2
2
  import { inject as service } from "@ember/service";
3
3
  import Component from "@glimmer/component";
4
4
  import { queryManager } from "ember-apollo-client";
5
- import { restartableTask, dropTask } from "ember-concurrency";
5
+ import { task } from "ember-concurrency";
6
6
  import { trackedTask } from "reactiveweb/ember-concurrency";
7
7
 
8
8
  import FormValidations from "../../validations/form";
@@ -23,10 +23,7 @@ export default class CfbFormEditorGeneral extends Component {
23
23
  return this._data.value?.[0]?.node;
24
24
  }
25
25
 
26
- _data = trackedTask(this, this.fetchData, () => [this.args.slug]);
27
-
28
- @restartableTask
29
- *fetchData() {
26
+ fetchData = task({ restartable: true }, async () => {
30
27
  if (!this.args.slug) {
31
28
  return [
32
29
  {
@@ -40,7 +37,7 @@ export default class CfbFormEditorGeneral extends Component {
40
37
  ];
41
38
  }
42
39
 
43
- return yield this.apollo.watchQuery(
40
+ return await this.apollo.watchQuery(
44
41
  {
45
42
  query: formEditorGeneralQuery,
46
43
  variables: { slug: this.args.slug },
@@ -48,7 +45,9 @@ export default class CfbFormEditorGeneral extends Component {
48
45
  },
49
46
  "allForms.edges",
50
47
  );
51
- }
48
+ });
49
+
50
+ _data = trackedTask(this, this.fetchData, () => [this.args.slug]);
52
51
 
53
52
  get prefix() {
54
53
  return this.calumaOptions.namespace
@@ -56,12 +55,11 @@ export default class CfbFormEditorGeneral extends Component {
56
55
  : "";
57
56
  }
58
57
 
59
- @dropTask
60
- *submit(changeset) {
58
+ submit = task({ drop: true }, async (changeset) => {
61
59
  const rawMeta = changeset.get("meta");
62
60
 
63
61
  try {
64
- const form = yield this.apollo.mutate(
62
+ const form = await this.apollo.mutate(
65
63
  {
66
64
  mutation: saveFormMutation,
67
65
  variables: {
@@ -96,7 +94,7 @@ export default class CfbFormEditorGeneral extends Component {
96
94
  ),
97
95
  );
98
96
  }
99
- }
97
+ });
100
98
 
101
99
  @action
102
100
  updateName(value, changeset) {
@@ -4,7 +4,7 @@ import Component from "@glimmer/component";
4
4
  import { queryManager } from "ember-apollo-client";
5
5
  import { Changeset } from "ember-changeset";
6
6
  import lookupValidator from "ember-changeset-validations";
7
- import { dropTask } from "ember-concurrency";
7
+ import { task } from "ember-concurrency";
8
8
 
9
9
  import slugify from "@projectcaluma/ember-core/utils/slugify";
10
10
  import saveChoiceQuestionMutation from "@projectcaluma/ember-form-builder/gql/mutations/save-choice-question.graphql";
@@ -26,10 +26,9 @@ export default class CfbFormEditorQuestionOptions extends Component {
26
26
  return this.args.value.every((row) => row.get("id") !== undefined);
27
27
  }
28
28
 
29
- @dropTask
30
- *reorderOptions(slugs) {
29
+ reorderOptions = task({ drop: true }, async (slugs) => {
31
30
  try {
32
- yield this.apollo.mutate({
31
+ await this.apollo.mutate({
33
32
  mutation: TYPES[this.args.model.__typename],
34
33
  variables: {
35
34
  input: {
@@ -52,7 +51,7 @@ export default class CfbFormEditorQuestionOptions extends Component {
52
51
  ),
53
52
  );
54
53
  }
55
- }
54
+ });
56
55
 
57
56
  @action
58
57
  addRow() {
@@ -2,7 +2,7 @@ import { action } from "@ember/object";
2
2
  import { underscore } from "@ember/string";
3
3
  import Component from "@glimmer/component";
4
4
  import { queryManager } from "ember-apollo-client";
5
- import { dropTask } from "ember-concurrency";
5
+ import { task } from "ember-concurrency";
6
6
  import { trackedTask } from "reactiveweb/ember-concurrency";
7
7
 
8
8
  import allFormatValidatorsQuery from "@projectcaluma/ember-form-builder/gql/queries/all-format-validators.graphql";
@@ -36,15 +36,14 @@ export default class CfbFormEditorQuestionValidation extends Component {
36
36
  );
37
37
  }
38
38
 
39
- _validators = trackedTask(this, this.fetchFormatValidators, () => []);
40
-
41
- @dropTask
42
- *fetchFormatValidators() {
43
- return yield this.apollo.watchQuery(
39
+ fetchFormatValidators = task({ drop: true }, async () => {
40
+ return await this.apollo.watchQuery(
44
41
  { query: allFormatValidatorsQuery, fetchPolicy: "cache-and-network" },
45
42
  "allFormatValidators.edges",
46
43
  );
47
- }
44
+ });
45
+
46
+ _validators = trackedTask(this, this.fetchFormatValidators, () => []);
48
47
 
49
48
  @action
50
49
  updateValidators(value) {
@@ -5,12 +5,7 @@ import { macroCondition, isTesting } from "@embroider/macros";
5
5
  import Component from "@glimmer/component";
6
6
  import { tracked } from "@glimmer/tracking";
7
7
  import { queryManager } from "ember-apollo-client";
8
- import {
9
- timeout,
10
- enqueueTask,
11
- lastValue,
12
- restartableTask,
13
- } from "ember-concurrency";
8
+ import { timeout, task } from "ember-concurrency";
14
9
  import UIkit from "uikit";
15
10
 
16
11
  import addFormQuestionMutation from "@projectcaluma/ember-form-builder/gql/mutations/add-form-question.graphql";
@@ -48,9 +43,11 @@ export default class ComponentsCfbFormEditorQuestionList extends Component {
48
43
  this.questionTask.perform();
49
44
  }
50
45
 
51
- @lastValue("questionTask") questionTaskValue = [];
52
- @restartableTask
53
- *questionTask(event) {
46
+ get questionTaskValue() {
47
+ return this.questionTask.lastSuccessful?.value ?? [];
48
+ }
49
+
50
+ questionTask = task({ restartable: true }, async (event) => {
54
51
  event?.preventDefault?.();
55
52
 
56
53
  const mode = this.mode;
@@ -61,12 +58,12 @@ export default class ComponentsCfbFormEditorQuestionList extends Component {
61
58
  // no timeout
62
59
  } else {
63
60
  if (search) {
64
- yield timeout(500);
61
+ await timeout(500);
65
62
  }
66
63
  }
67
64
 
68
65
  if (mode === "add" && this.hasNextPage) {
69
- const questions = yield this.apollo.watchQuery(
66
+ const questions = await this.apollo.watchQuery(
70
67
  {
71
68
  query: searchQuestionQuery,
72
69
  variables: {
@@ -88,7 +85,7 @@ export default class ComponentsCfbFormEditorQuestionList extends Component {
88
85
  return this.items;
89
86
  }
90
87
 
91
- return yield this.apollo.watchQuery(
88
+ return await this.apollo.watchQuery(
92
89
  {
93
90
  query: searchFormQuestionQuery,
94
91
  variables: {
@@ -99,12 +96,11 @@ export default class ComponentsCfbFormEditorQuestionList extends Component {
99
96
  },
100
97
  "allForms.edges",
101
98
  );
102
- }
99
+ });
103
100
 
104
- @restartableTask
105
- *reorderQuestions(slugs) {
101
+ reorderQuestions = task({ restartable: true }, async (slugs) => {
106
102
  try {
107
- yield this.apollo.mutate({
103
+ await this.apollo.mutate({
108
104
  mutation: reorderFormQuestionsMutation,
109
105
  variables: {
110
106
  input: {
@@ -127,12 +123,11 @@ export default class ComponentsCfbFormEditorQuestionList extends Component {
127
123
  ),
128
124
  );
129
125
  }
130
- }
126
+ });
131
127
 
132
- @enqueueTask
133
- *addQuestion(question) {
128
+ addQuestion = task({ enqueue: true }, async (question) => {
134
129
  try {
135
- yield this.apollo.mutate({
130
+ await this.apollo.mutate({
136
131
  mutation: addFormQuestionMutation,
137
132
  variables: {
138
133
  input: {
@@ -159,12 +154,11 @@ export default class ComponentsCfbFormEditorQuestionList extends Component {
159
154
  this.intl.t("caluma.form-builder.notification.form.add-question.error"),
160
155
  );
161
156
  }
162
- }
157
+ });
163
158
 
164
- @enqueueTask
165
- *removeQuestion(question) {
159
+ removeQuestion = task({ enqueue: true }, async (question) => {
166
160
  try {
167
- yield this.apollo.mutate({
161
+ await this.apollo.mutate({
168
162
  mutation: removeFormQuestionMutation,
169
163
  variables: {
170
164
  input: {
@@ -189,7 +183,7 @@ export default class ComponentsCfbFormEditorQuestionList extends Component {
189
183
  ),
190
184
  );
191
185
  }
192
- }
186
+ });
193
187
 
194
188
  _handleMoved({ detail: [sortable] }) {
195
189
  const children = [...sortable.$el.children];
@@ -7,7 +7,7 @@ import { tracked } from "@glimmer/tracking";
7
7
  import { queryManager } from "ember-apollo-client";
8
8
  import Changeset from "ember-changeset";
9
9
  import lookupValidator from "ember-changeset-validations";
10
- import { dropTask, restartableTask, task } from "ember-concurrency";
10
+ import { task } from "ember-concurrency";
11
11
 
12
12
  import { hasQuestionType } from "@projectcaluma/ember-core/helpers/has-question-type";
13
13
  import slugify from "@projectcaluma/ember-core/utils/slugify";
@@ -85,8 +85,7 @@ export default class CfbFormEditorQuestion extends Component {
85
85
 
86
86
  @tracked changeset;
87
87
 
88
- @restartableTask
89
- *data() {
88
+ data = task({ restartable: true }, async () => {
90
89
  if (!this.args.slug) {
91
90
  return A([
92
91
  {
@@ -122,7 +121,7 @@ export default class CfbFormEditorQuestion extends Component {
122
121
  ]);
123
122
  }
124
123
 
125
- return yield this.apollo.watchQuery(
124
+ return await this.apollo.watchQuery(
126
125
  {
127
126
  query: formEditorQuestionQuery,
128
127
  variables: { slug: this.args.slug },
@@ -130,11 +129,10 @@ export default class CfbFormEditorQuestion extends Component {
130
129
  },
131
130
  "allQuestions.edges",
132
131
  );
133
- }
132
+ });
134
133
 
135
- @restartableTask
136
- *availableForms() {
137
- const forms = yield this.apollo.watchQuery(
134
+ availableForms = task({ restartable: true }, async () => {
135
+ const forms = await this.apollo.watchQuery(
138
136
  {
139
137
  query: formListQuery,
140
138
  variables: {
@@ -151,11 +149,10 @@ export default class CfbFormEditorQuestion extends Component {
151
149
  return forms
152
150
  .filter((edge) => edge.node.slug !== this.args.form)
153
151
  .map((edge) => edge.node);
154
- }
152
+ });
155
153
 
156
- @restartableTask
157
- *availableDataSources() {
158
- const dataSources = yield this.apollo.watchQuery(
154
+ availableDataSources = task({ restartable: true }, async () => {
155
+ const dataSources = await this.apollo.watchQuery(
159
156
  { query: allDataSourcesQuery, fetchPolicy: "cache-and-network" },
160
157
  "allDataSources.edges",
161
158
  );
@@ -165,7 +162,7 @@ export default class CfbFormEditorQuestion extends Component {
165
162
  __typename: undefined,
166
163
  };
167
164
  });
168
- }
165
+ });
169
166
 
170
167
  get possibleTypes() {
171
168
  return Object.keys(TYPES).map((value) => ({
@@ -367,9 +364,8 @@ export default class CfbFormEditorQuestion extends Component {
367
364
  };
368
365
  }
369
366
 
370
- @task
371
- *saveOptions(changeset) {
372
- yield Promise.all(
367
+ saveOptions = task(async (changeset) => {
368
+ await Promise.all(
373
369
  (changeset.get("options") || [])
374
370
  .filter((option) => option.get("isDirty"))
375
371
  .map(async (option) => {
@@ -381,10 +377,9 @@ export default class CfbFormEditorQuestion extends Component {
381
377
  });
382
378
  }),
383
379
  );
384
- }
380
+ });
385
381
 
386
- @task
387
- *saveDefaultAnswer(question, changeset) {
382
+ saveDefaultAnswer = task(async (question, changeset) => {
388
383
  if (!changeset.get("defaultAnswer")) {
389
384
  return;
390
385
  }
@@ -413,17 +408,16 @@ export default class CfbFormEditorQuestion extends Component {
413
408
  input.value = value;
414
409
  }
415
410
 
416
- yield this.apollo.mutate({ mutation, variables: { input } });
417
- }
411
+ await this.apollo.mutate({ mutation, variables: { input } });
412
+ });
418
413
 
419
- @dropTask
420
- *submit(changeset) {
414
+ submit = task({ drop: true }, async (changeset) => {
421
415
  try {
422
- yield this.saveOptions.perform(changeset);
416
+ await this.saveOptions.perform(changeset);
423
417
 
424
418
  const typename = changeset.get("__typename");
425
419
  const input = this.getInput(changeset);
426
- const question = yield this.apollo.mutate(
420
+ const question = await this.apollo.mutate(
427
421
  {
428
422
  mutation: TYPES[typename],
429
423
  variables: { input },
@@ -431,11 +425,11 @@ export default class CfbFormEditorQuestion extends Component {
431
425
  `save${typename}.question`,
432
426
  );
433
427
 
434
- yield this.saveDefaultAnswer.perform(question, changeset);
428
+ await this.saveDefaultAnswer.perform(question, changeset);
435
429
 
436
430
  if (!this.args.slug) {
437
431
  // This is a new question which must be added to the form after creating it
438
- yield this.apollo.mutate({
432
+ await this.apollo.mutate({
439
433
  mutation: addFormQuestionMutation,
440
434
  variables: {
441
435
  input: {
@@ -458,7 +452,7 @@ export default class CfbFormEditorQuestion extends Component {
458
452
  this.intl.t("caluma.form-builder.notification.question.save.error"),
459
453
  );
460
454
  }
461
- }
455
+ });
462
456
 
463
457
  @action
464
458
  async fetchData() {
@@ -1,7 +1,7 @@
1
1
  import { inject as service } from "@ember/service";
2
2
  import { macroCondition, isTesting } from "@embroider/macros";
3
3
  import Component from "@glimmer/component";
4
- import { timeout, restartableTask } from "ember-concurrency";
4
+ import { timeout, task } from "ember-concurrency";
5
5
 
6
6
  import { useCalumaQuery } from "@projectcaluma/ember-core/caluma-query";
7
7
  import { allForms } from "@projectcaluma/ember-core/caluma-query/queries";
@@ -57,15 +57,14 @@ export default class ComponentsCfbFormListComponent extends Component {
57
57
  return [isArchived, isPublished, search].filter(Boolean) || null;
58
58
  }
59
59
 
60
- @restartableTask
61
- *search(event) {
60
+ search = task({ restartable: true }, async (event) => {
62
61
  /* istanbul ignore next */
63
62
  if (macroCondition(isTesting())) {
64
63
  // no timeout
65
64
  } else {
66
- yield timeout(500);
65
+ await timeout(500);
67
66
  }
68
67
 
69
68
  this.args.onUpdateSearch(event.target.value);
70
- }
69
+ });
71
70
  }
@@ -1,7 +1,7 @@
1
1
  import Route from "@ember/routing/route";
2
2
  import { inject as service } from "@ember/service";
3
3
  import { queryManager } from "ember-apollo-client";
4
- import { lastValue, dropTask } from "ember-concurrency";
4
+ import { task } from "ember-concurrency";
5
5
  import { gql } from "graphql-tag";
6
6
 
7
7
  import { navigationTitle } from "@projectcaluma/ember-form-builder/decorators";
@@ -11,12 +11,12 @@ export default class EditQuestionsEditRoute extends Route {
11
11
  @queryManager apollo;
12
12
 
13
13
  @navigationTitle
14
- @lastValue("fetchLabel")
15
- title;
14
+ get title() {
15
+ return this.fetchLabel.lastSuccessful?.value;
16
+ }
16
17
 
17
- @dropTask
18
- *fetchLabel(slug) {
19
- const [question] = yield this.apollo.query(
18
+ fetchLabel = task({ drop: true }, async (slug) => {
19
+ const [question] = await this.apollo.query(
20
20
  {
21
21
  query: gql`
22
22
  query QuestionLabel($slug: String!) {
@@ -36,7 +36,7 @@ export default class EditQuestionsEditRoute extends Route {
36
36
  );
37
37
 
38
38
  return question?.node.label;
39
- }
39
+ });
40
40
 
41
41
  beforeModel() {
42
42
  const { question_slug: slug } = this.paramsFor(this.routeName);
@@ -1,7 +1,7 @@
1
1
  import Route from "@ember/routing/route";
2
2
  import { inject as service } from "@ember/service";
3
3
  import { queryManager } from "ember-apollo-client";
4
- import { lastValue, dropTask } from "ember-concurrency";
4
+ import { task } from "ember-concurrency";
5
5
  import { gql } from "graphql-tag";
6
6
 
7
7
  import { navigationTitle } from "@projectcaluma/ember-form-builder/decorators";
@@ -11,12 +11,12 @@ export default class EditRoute extends Route {
11
11
  @queryManager apollo;
12
12
 
13
13
  @navigationTitle
14
- @lastValue("fetchName")
15
- title;
14
+ get title() {
15
+ return this.fetchName.lastSuccessful?.value;
16
+ }
16
17
 
17
- @dropTask
18
- *fetchName(slug) {
19
- const [form] = yield this.apollo.query(
18
+ fetchName = task({ drop: true }, async (slug) => {
19
+ const [form] = await this.apollo.query(
20
20
  {
21
21
  query: gql`
22
22
  query FormName($slug: String!) {
@@ -35,7 +35,7 @@ export default class EditRoute extends Route {
35
35
  );
36
36
 
37
37
  return form?.node.name;
38
- }
38
+ });
39
39
 
40
40
  beforeModel() {
41
41
  const { form_slug: slug } = this.paramsFor(this.routeName);
@@ -7,7 +7,7 @@ import {
7
7
  validateLength,
8
8
  validateFormat,
9
9
  } from "ember-changeset-validations/validators";
10
- import { timeout, restartableTask, didCancel } from "ember-concurrency";
10
+ import { timeout, task, didCancel } from "ember-concurrency";
11
11
 
12
12
  import checkFormSlugQuery from "@projectcaluma/ember-form-builder/gql/queries/check-form-slug.graphql";
13
13
  import checkOptionSlugQuery from "@projectcaluma/ember-form-builder/gql/queries/check-option-slug.graphql";
@@ -68,19 +68,18 @@ export class SlugUniquenessValidator {
68
68
  );
69
69
  }
70
70
 
71
- @restartableTask
72
- *_validate(slug, context) {
71
+ _validate = task({ restartable: true }, async (slug, context) => {
73
72
  /* istanbul ignore next */
74
73
  if (macroCondition(isTesting())) {
75
74
  // no timeout
76
75
  } else {
77
- yield timeout(500);
76
+ await timeout(500);
78
77
  }
79
78
 
80
79
  let count = Infinity;
81
80
 
82
81
  try {
83
- const response = yield this.apollo.query({
82
+ const response = await this.apollo.query({
84
83
  query: this.queries[this.type],
85
84
  variables:
86
85
  this.type === "option"
@@ -105,7 +104,7 @@ export class SlugUniquenessValidator {
105
104
  this.cache[this.type][slug] = isUnique;
106
105
 
107
106
  return isUnique;
108
- }
107
+ });
109
108
  }
110
109
 
111
110
  export default function slugValidation({ type, maxLength = 127 }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectcaluma/ember-form-builder",
3
- "version": "14.7.0",
3
+ "version": "14.7.1",
4
4
  "description": "Ember engine for building Caluma forms.",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -23,7 +23,7 @@
23
23
  "ember-cli-babel": "^8.2.0",
24
24
  "ember-cli-htmlbars": "^6.3.0",
25
25
  "ember-composable-helpers": "^5.0.0",
26
- "ember-concurrency": "^4.0.2",
26
+ "ember-concurrency": "^4.0.2 || ^5.1.0",
27
27
  "ember-engines-router-service": "^0.6.0",
28
28
  "ember-flatpickr": "^8.0.1",
29
29
  "ember-intl": "^7.1.1",
@@ -44,8 +44,8 @@
44
44
  "lodash.isequal": "^4.5.0",
45
45
  "reactiveweb": "^1.3.0",
46
46
  "uikit": "^3.22.0",
47
- "@projectcaluma/ember-core": "^14.7.0",
48
- "@projectcaluma/ember-form": "^14.7.0"
47
+ "@projectcaluma/ember-core": "^14.7.1",
48
+ "@projectcaluma/ember-form": "^14.7.1"
49
49
  },
50
50
  "//": [
51
51
  "TODO: remove obsolete dependency to `ember-data` which is only necessary",
@@ -83,7 +83,7 @@
83
83
  "qunit-dom": "3.5.0",
84
84
  "sinon": "21.0.1",
85
85
  "webpack": "5.104.1",
86
- "@projectcaluma/ember-testing": "14.7.0"
86
+ "@projectcaluma/ember-testing": "14.7.1"
87
87
  },
88
88
  "peerDependencies": {
89
89
  "ember-engines": "^0.11.0",