@projectcaluma/ember-core 14.5.1 → 14.7.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.
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
task,
|
|
10
10
|
} from "ember-concurrency";
|
|
11
11
|
import { gql } from "graphql-tag";
|
|
12
|
+
import { TrackedArray } from "tracked-built-ins";
|
|
12
13
|
|
|
13
14
|
export default class BaseQuery {
|
|
14
15
|
@queryManager apollo;
|
|
@@ -66,17 +67,7 @@ export default class BaseQuery {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
get value() {
|
|
69
|
-
|
|
70
|
-
`caluma-query-model:${this.modelName}`,
|
|
71
|
-
).class;
|
|
72
|
-
|
|
73
|
-
return this.items.map((item) => {
|
|
74
|
-
const instance = new Model(item);
|
|
75
|
-
|
|
76
|
-
setOwner(instance, getOwner(this));
|
|
77
|
-
|
|
78
|
-
return instance;
|
|
79
|
-
});
|
|
70
|
+
return this.items;
|
|
80
71
|
}
|
|
81
72
|
|
|
82
73
|
fetch(...args) {
|
|
@@ -98,7 +89,7 @@ export default class BaseQuery {
|
|
|
98
89
|
*_fetch({ filter = [], order = [], queryOptions = {} } = {}) {
|
|
99
90
|
yield this._fetchPage.cancelAll({ resetState: true });
|
|
100
91
|
|
|
101
|
-
this.items =
|
|
92
|
+
this.items = new TrackedArray();
|
|
102
93
|
|
|
103
94
|
this.filter = filter;
|
|
104
95
|
this.order = order;
|
|
@@ -131,13 +122,39 @@ export default class BaseQuery {
|
|
|
131
122
|
...this.queryOptions,
|
|
132
123
|
});
|
|
133
124
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
data[this.dataKey].edges.map(({ node }) => node),
|
|
138
|
-
)),
|
|
139
|
-
]);
|
|
125
|
+
const rawNewItems = data[this.dataKey].edges.map(({ node }) => node);
|
|
126
|
+
|
|
127
|
+
yield this.#parsePage(rawNewItems);
|
|
140
128
|
|
|
141
129
|
return data;
|
|
142
130
|
}
|
|
131
|
+
|
|
132
|
+
#createModel(item) {
|
|
133
|
+
const instance = new this.modelClass(item);
|
|
134
|
+
setOwner(instance, getOwner(this));
|
|
135
|
+
return instance;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async #parsePage(rawNewItems) {
|
|
139
|
+
const processedNewItems = await this.processNew(rawNewItems);
|
|
140
|
+
const rawExistingItems = this.items.map((model) => model.raw);
|
|
141
|
+
|
|
142
|
+
const allRawItems = [...processedNewItems, ...rawExistingItems];
|
|
143
|
+
const allProcessedItems = await this.processAll(allRawItems);
|
|
144
|
+
|
|
145
|
+
// Superficially check if `this.processAll` changed anything on the raw data
|
|
146
|
+
if (JSON.stringify(allRawItems) !== JSON.stringify(allProcessedItems)) {
|
|
147
|
+
// If so, we need to re-create the already existing models and reassign
|
|
148
|
+
// the `this.items` property in order to trigger a rerender for **all**
|
|
149
|
+
// items.
|
|
150
|
+
this.items = new TrackedArray(
|
|
151
|
+
allProcessedItems.map((i) => this.#createModel(i)),
|
|
152
|
+
);
|
|
153
|
+
} else {
|
|
154
|
+
// If not, only the newly added items need to be converted to models and
|
|
155
|
+
// added to the existing items in order to only trigger a partial rerender
|
|
156
|
+
// for the newly added items.
|
|
157
|
+
this.items.push(...processedNewItems.map((i) => this.#createModel(i)));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
143
160
|
}
|
|
@@ -51,7 +51,7 @@ export default class CalumaQueryResource extends Resource {
|
|
|
51
51
|
event.preventDefault();
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
this.query.fetchMore();
|
|
54
|
+
return this.query.fetchMore();
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
@action
|
|
@@ -60,7 +60,7 @@ export default class CalumaQueryResource extends Resource {
|
|
|
60
60
|
event.preventDefault();
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
this.query.refresh();
|
|
63
|
+
return this.query.refresh();
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
get value() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectcaluma/ember-core",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.7.0",
|
|
4
4
|
"description": "Ember core addon for working with Caluma.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -13,13 +13,11 @@
|
|
|
13
13
|
"@babel/core": "^7.26.0",
|
|
14
14
|
"@ember/string": "^3.1.1 || ^4.0.0",
|
|
15
15
|
"@embroider/macros": "^1.16.10",
|
|
16
|
-
"@glimmer/tracking": "^1.1.2",
|
|
17
16
|
"ember-apollo-client": "^5.0.0",
|
|
18
17
|
"ember-auto-import": "^2.10.0",
|
|
19
18
|
"ember-cli-babel": "^8.2.0",
|
|
20
19
|
"ember-cli-htmlbars": "^6.3.0",
|
|
21
20
|
"ember-concurrency": "^4.0.2",
|
|
22
|
-
"ember-fetch": "^8.1.2",
|
|
23
21
|
"ember-inflector": "^4.0.3 || ^5.0.1",
|
|
24
22
|
"ember-intl": "^7.1.1",
|
|
25
23
|
"ember-modify-based-class-resource": "^1.1.1",
|
|
@@ -29,16 +27,18 @@
|
|
|
29
27
|
"graphql-tag": "^2.12.6",
|
|
30
28
|
"jexl": "^2.3.0",
|
|
31
29
|
"lodash.clonedeep": "^4.5.0",
|
|
32
|
-
"slugify": "^1.6.6"
|
|
30
|
+
"slugify": "^1.6.6",
|
|
31
|
+
"tracked-built-ins": "^3.4.0 || ^4.0.0"
|
|
33
32
|
},
|
|
34
33
|
"devDependencies": {
|
|
35
|
-
"@ember/optional-features": "2.
|
|
34
|
+
"@ember/optional-features": "2.3.0",
|
|
36
35
|
"@ember/render-modifiers": "3.0.0",
|
|
37
36
|
"@ember/test-helpers": "4.0.4",
|
|
38
37
|
"@embroider/test-setup": "4.0.0",
|
|
39
|
-
"@embroider/util": "1.13.
|
|
40
|
-
"@faker-js/faker": "10.
|
|
38
|
+
"@embroider/util": "1.13.5",
|
|
39
|
+
"@faker-js/faker": "10.2.0",
|
|
41
40
|
"@glimmer/component": "1.1.2",
|
|
41
|
+
"@glimmer/tracking": "1.1.2",
|
|
42
42
|
"broccoli-asset-rev": "3.0.0",
|
|
43
43
|
"ember-cli": "6.1.0",
|
|
44
44
|
"ember-cli-clean-css": "3.0.0",
|
|
@@ -56,12 +56,12 @@
|
|
|
56
56
|
"ember-source-channel-url": "3.0.0",
|
|
57
57
|
"ember-try": "4.0.0",
|
|
58
58
|
"loader.js": "4.7.0",
|
|
59
|
-
"qunit": "2.
|
|
59
|
+
"qunit": "2.25.0",
|
|
60
60
|
"qunit-dom": "3.5.0",
|
|
61
|
-
"sinon": "21.0.
|
|
62
|
-
"uikit": "3.
|
|
63
|
-
"webpack": "5.
|
|
64
|
-
"@projectcaluma/ember-testing": "14.
|
|
61
|
+
"sinon": "21.0.1",
|
|
62
|
+
"uikit": "3.25.6",
|
|
63
|
+
"webpack": "5.104.1",
|
|
64
|
+
"@projectcaluma/ember-testing": "14.7.0"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"ember-data": "*",
|