@projectcaluma/ember-core 9.1.0 → 10.0.2

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.
@@ -7,7 +7,6 @@ export default {
7
7
  "WorkItem",
8
8
  "Flow",
9
9
  "DynamicOption",
10
- "CalculatedFloatQuestion",
11
10
  "Option",
12
11
  "TextQuestion",
13
12
  "StringAnswer",
@@ -30,13 +29,14 @@ export default {
30
29
  "StaticQuestion",
31
30
  "FileAnswer",
32
31
  "File",
32
+ "CalculatedFloatQuestion",
33
+ "ActionButtonQuestion",
33
34
  "SimpleTask",
34
35
  "CompleteWorkflowFormTask",
35
36
  "CompleteTaskFormTask",
36
37
  ],
37
38
  Task: ["SimpleTask", "CompleteWorkflowFormTask", "CompleteTaskFormTask"],
38
39
  Question: [
39
- "CalculatedFloatQuestion",
40
40
  "TextQuestion",
41
41
  "ChoiceQuestion",
42
42
  "MultipleChoiceQuestion",
@@ -50,6 +50,8 @@ export default {
50
50
  "FormQuestion",
51
51
  "FileQuestion",
52
52
  "StaticQuestion",
53
+ "CalculatedFloatQuestion",
54
+ "ActionButtonQuestion",
53
55
  ],
54
56
  Answer: [
55
57
  "StringAnswer",
@@ -60,4 +62,5 @@ export default {
60
62
  "TableAnswer",
61
63
  "FileAnswer",
62
64
  ],
65
+ DynamicQuestion: ["DynamicChoiceQuestion", "DynamicMultipleChoiceQuestion"],
63
66
  };
@@ -2,18 +2,19 @@ import { getOwner, setOwner } from "@ember/application";
2
2
  import { assert } from "@ember/debug";
3
3
  import { tracked } from "@glimmer/tracking";
4
4
  import { queryManager } from "ember-apollo-client";
5
- import gql from "graphql-tag";
5
+ import {
6
+ enqueueTask,
7
+ lastValue,
8
+ restartableTask,
9
+ task,
10
+ } from "ember-concurrency-decorators";
11
+ import { gql } from "graphql-tag";
6
12
 
7
13
  export default class BaseQuery {
8
14
  @queryManager apollo;
9
15
 
10
16
  @tracked items = [];
11
17
 
12
- @tracked totalCount = 0;
13
- @tracked hasNextPage = true;
14
-
15
- @tracked isLoading = true;
16
-
17
18
  constructor({
18
19
  pageSize = null,
19
20
  processNew = async (items) => items,
@@ -21,17 +22,13 @@ export default class BaseQuery {
21
22
  queryOptions = {},
22
23
  }) {
23
24
  this.pageSize = pageSize;
24
- this.cursor = null;
25
-
26
25
  this.processNew = processNew;
27
26
  this.processAll = processAll;
28
27
  this.queryOptions = queryOptions;
29
28
  }
30
29
 
31
30
  get query() {
32
- assert("`query` must be implemented on the model");
33
-
34
- return "";
31
+ return assert("`query` must be implemented on the model");
35
32
  }
36
33
 
37
34
  get pagination() {
@@ -52,51 +49,20 @@ export default class BaseQuery {
52
49
  return factory.class;
53
50
  }
54
51
 
55
- fetch({ filter = [], order = [], queryOptions = {} } = {}) {
56
- this.items = [];
57
- this.totalCount = 0;
58
- this.hasNextPage = true;
59
- this.cursor = null;
52
+ get isLoading() {
53
+ return this._fetch.isRunning || this._fetchMore.isRunning;
54
+ }
60
55
 
61
- this.filter = filter;
62
- this.order = order;
63
- this.queryOptions = { ...(this.queryOptions ?? {}), ...queryOptions };
56
+ get totalCount() {
57
+ return this._data?.[this.dataKey].totalCount;
58
+ }
64
59
 
65
- return this.fetchMore();
60
+ get hasNextPage() {
61
+ return this._data?.[this.dataKey].pageInfo.hasNextPage;
66
62
  }
67
63
 
68
- async fetchMore() {
69
- if (this.hasNextPage) {
70
- this.isLoading = true;
71
-
72
- const data = await this.apollo.query({
73
- query: gql`
74
- ${this.query}
75
- `,
76
- variables: {
77
- filter: this.filter,
78
- order: this.order,
79
- pageSize: this.pageSize,
80
- cursor: this.cursor,
81
- },
82
- fetchPolicy: "network-only",
83
- ...this.queryOptions,
84
- });
85
-
86
- this.cursor = data[this.dataKey].pageInfo.endCursor;
87
-
88
- this.hasNextPage = data[this.dataKey].pageInfo.hasNextPage;
89
- this.totalCount = data[this.dataKey].totalCount;
90
-
91
- const rawItems = data[this.dataKey].edges.map(({ node }) => node);
92
-
93
- this.items = await this.processAll([
94
- ...this.items,
95
- ...(await this.processNew(rawItems)),
96
- ]);
97
-
98
- this.isLoading = false;
99
- }
64
+ get cursor() {
65
+ return this._data?.[this.dataKey].pageInfo.endCursor;
100
66
  }
101
67
 
102
68
  get value() {
@@ -112,4 +78,59 @@ export default class BaseQuery {
112
78
  return instance;
113
79
  });
114
80
  }
81
+
82
+ fetch(...args) {
83
+ return this._fetch.perform(...args);
84
+ }
85
+
86
+ fetchMore(...args) {
87
+ return this._fetchMore.perform(...args);
88
+ }
89
+
90
+ @restartableTask
91
+ *_fetch({ filter = [], order = [], queryOptions = {} } = {}) {
92
+ yield this._fetchPage.cancelAll({ resetState: true });
93
+
94
+ this.items = [];
95
+
96
+ this.filter = filter;
97
+ this.order = order;
98
+ this.queryOptions = { ...(this.queryOptions ?? {}), ...queryOptions };
99
+
100
+ return yield this._fetchPage.linked().perform();
101
+ }
102
+
103
+ @enqueueTask
104
+ *_fetchMore() {
105
+ if (!this._data) return;
106
+
107
+ return yield this._fetchPage.linked().perform();
108
+ }
109
+
110
+ @lastValue("_fetchPage") _data;
111
+ @task
112
+ *_fetchPage() {
113
+ const data = yield this.apollo.query({
114
+ query: gql`
115
+ ${this.query}
116
+ `,
117
+ variables: {
118
+ filter: this.filter,
119
+ order: this.order,
120
+ pageSize: this.pageSize,
121
+ cursor: this.cursor,
122
+ },
123
+ fetchPolicy: "network-only",
124
+ ...this.queryOptions,
125
+ });
126
+
127
+ this.items = yield this.processAll([
128
+ ...this.items,
129
+ ...(yield this.processNew(
130
+ data[this.dataKey].edges.map(({ node }) => node)
131
+ )),
132
+ ]);
133
+
134
+ return data;
135
+ }
115
136
  }
@@ -20,6 +20,8 @@ export default class PrivateResolver extends Helper {
20
20
  ? identifiers[0]
21
21
  : identifiers;
22
22
 
23
+ if (!identifier) return null;
24
+
23
25
  // The parameter for the helper changed so we need to recompute and store
24
26
  // the new parameter to remember it at the next computation
25
27
  if (identifier !== this._identifier) {
@@ -2,6 +2,7 @@ import { assert } from "@ember/debug";
2
2
  import { once } from "@ember/runloop";
3
3
  import Service, { inject as service } from "@ember/service";
4
4
  import { camelize } from "@ember/string";
5
+ import { task } from "ember-concurrency";
5
6
  import { pluralize } from "ember-inflector";
6
7
 
7
8
  /**
@@ -9,23 +10,24 @@ import { pluralize } from "ember-inflector";
9
10
  *
10
11
  * @function typeResolver
11
12
  * @param {"group"|"user"} type The type of the objects to resolve
12
- * @returns {Function} The decorator function that returns a method descriptor to resolve the requested objects
13
+ * @returns {Function} The decorator function that returns an enqueued task to resolve the requested objects
13
14
  */
14
15
  function typeResolver(type) {
15
- return function () {
16
- return {
17
- async value() {
18
- const methodName = camelize(`resolve-${pluralize(type)}`);
19
- const result = await this.calumaOptions[methodName]?.([
20
- ...this[type].identifiers,
21
- ]);
16
+ return task(function* () {
17
+ const identifiers = [...this[type].identifiers];
18
+ const callbacks = [...this[type].callbacks];
22
19
 
23
- this[type].callbacks.forEach((callback) => callback(result));
20
+ this[type] = undefined;
24
21
 
25
- this[type] = undefined;
26
- },
27
- };
28
- };
22
+ if (!identifiers.length) return;
23
+
24
+ const methodName = camelize(`resolve-${pluralize(type)}`);
25
+ const result = yield this.calumaOptions[methodName]?.(identifiers);
26
+
27
+ yield Promise.all(callbacks.map((callback) => callback(result)));
28
+
29
+ return result;
30
+ }).enqueue();
29
31
  }
30
32
 
31
33
  export default class PrivateSchedulerService extends Service {
@@ -72,6 +74,6 @@ export default class PrivateSchedulerService extends Service {
72
74
  typeResolverName in this
73
75
  );
74
76
 
75
- once(this, typeResolverName);
77
+ once(this[typeResolverName], "perform");
76
78
  }
77
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectcaluma/ember-core",
3
- "version": "9.1.0",
3
+ "version": "10.0.2",
4
4
  "description": "Ember core addon for working with Caluma.",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -15,6 +15,7 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@apollo/client": "^3.4.16",
18
+ "@glimmer/tracking": "^1.0.4",
18
19
  "ember-apollo-client": "^3.2.0",
19
20
  "ember-auto-import": "^2.2.3",
20
21
  "ember-changeset-validations": "^3.16.0",
@@ -25,21 +26,23 @@
25
26
  "ember-fetch": "^8.0.4",
26
27
  "ember-intl": "^5.7.0",
27
28
  "graphql": "^15.6.1",
28
- "graphql-tag": "^2.12.5",
29
+ "graphql-tag": "^2.12.6",
29
30
  "intersection-observer": "^0.12.0",
30
31
  "jexl": "^2.3.0",
31
32
  "lodash.clonedeep": "^4.5.0",
32
33
  "moment": "^2.29.1",
33
34
  "proxy-polyfill": "^0.3.2",
34
- "slugify": "^1.6.1"
35
+ "slugify": "^1.6.2"
35
36
  },
36
37
  "devDependencies": {
37
38
  "@ember/optional-features": "2.0.0",
39
+ "@ember/render-modifiers": "2.0.0",
38
40
  "@ember/test-helpers": "2.6.0",
39
- "@embroider/test-setup": "0.47.1",
40
- "@projectcaluma/ember-testing": "9.0.0",
41
+ "@embroider/test-setup": "0.47.2",
42
+ "@glimmer/component": "1.0.4",
43
+ "@projectcaluma/ember-testing": "10.0.0",
41
44
  "broccoli-asset-rev": "3.0.0",
42
- "ember-cli": "3.28.3",
45
+ "ember-cli": "3.28.4",
43
46
  "ember-cli-code-coverage": "1.0.3",
44
47
  "ember-cli-dependency-checker": "3.2.0",
45
48
  "ember-cli-inject-live-reload": "2.1.0",
@@ -54,16 +57,16 @@
54
57
  "ember-resolver": "8.0.3",
55
58
  "ember-source": "3.28.6",
56
59
  "ember-source-channel-url": "3.0.0",
57
- "ember-try": "1.4.0",
60
+ "ember-try": "2.0.0",
58
61
  "faker": "5.5.3",
59
62
  "loader.js": "4.7.0",
60
63
  "npm-run-all": "4.1.5",
61
64
  "qunit": "2.17.2",
62
65
  "qunit-dom": "2.0.0",
63
- "webpack": "5.61.0"
66
+ "webpack": "5.64.1"
64
67
  },
65
68
  "engines": {
66
- "node": "10.* || >= 12"
69
+ "node": "12.* || 14.* || >= 16"
67
70
  },
68
71
  "ember": {
69
72
  "edition": "octane"
@@ -6,9 +6,10 @@ caluma:
6
6
  COMPLETED: "Erledigt"
7
7
  CANCELED: "Abgebrochen"
8
8
  SKIPPED: "Übersprungen"
9
-
9
+ SUSPENDED: "Pausiert"
10
10
  case:
11
11
  status:
12
12
  RUNNING: "In Bearbeitung"
13
13
  COMPLETED: "Abgeschlossen"
14
14
  CANCELED: "Abgebrochen"
15
+ SUSPENDED: "Pausiert"
@@ -6,8 +6,10 @@ caluma:
6
6
  COMPLETED: "Completed"
7
7
  CANCELED: "Canceled"
8
8
  SKIPPED: "Skipped"
9
+ SUSPENDED: "Suspended"
9
10
  case:
10
11
  status:
11
12
  RUNNING: "Pending"
12
13
  COMPLETED: "Completed"
13
14
  CANCELED: "Canceled"
15
+ SUSPENDED: "Suspended"
@@ -6,9 +6,10 @@ caluma:
6
6
  COMPLETED: "Terminé"
7
7
  CANCELED: "Annulé"
8
8
  SKIPPED: "Sauté"
9
-
9
+ SUSPENDED: "En pause"
10
10
  case:
11
11
  status:
12
12
  RUNNING: "En cours"
13
13
  COMPLETED: "Terminé"
14
14
  CANCELED: "Annulé"
15
+ SUSPENDED: "En pause"