@projectcaluma/ember-form 14.5.1 → 14.6.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,9 +1,9 @@
|
|
|
1
1
|
import { action } from "@ember/object";
|
|
2
2
|
import { inject as service } from "@ember/service";
|
|
3
|
+
import { waitForFetch } from "@ember/test-waiters";
|
|
3
4
|
import { macroCondition, isTesting } from "@embroider/macros";
|
|
4
5
|
import Component from "@glimmer/component";
|
|
5
6
|
import { queryManager } from "ember-apollo-client";
|
|
6
|
-
import fetch from "fetch";
|
|
7
7
|
|
|
8
8
|
import getFilesAnswerInfoQuery from "@projectcaluma/ember-form/gql/queries/filesanswer-info.graphql";
|
|
9
9
|
|
|
@@ -75,10 +75,12 @@ export default class CfFieldInputFilesComponent extends Component {
|
|
|
75
75
|
}));
|
|
76
76
|
|
|
77
77
|
const uploadFunction = async (file) => {
|
|
78
|
-
const response = await
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
const response = await waitForFetch(
|
|
79
|
+
fetch(file.uploadUrl, {
|
|
80
|
+
method: "PUT",
|
|
81
|
+
body: file.value,
|
|
82
|
+
}),
|
|
83
|
+
);
|
|
82
84
|
if (!response.ok) {
|
|
83
85
|
throw new Error();
|
|
84
86
|
}
|
package/addon/lib/base.js
CHANGED
|
@@ -2,6 +2,7 @@ import { setOwner } from "@ember/application";
|
|
|
2
2
|
import { assert } from "@ember/debug";
|
|
3
3
|
import { registerDestructor } from "@ember/destroyable";
|
|
4
4
|
import { inject as service } from "@ember/service";
|
|
5
|
+
import { cached } from "tracked-toolbox";
|
|
5
6
|
|
|
6
7
|
export default class Base {
|
|
7
8
|
@service calumaStore;
|
|
@@ -18,8 +19,8 @@ export default class Base {
|
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
registerDestructor(this, () => {
|
|
21
|
-
if (this.
|
|
22
|
-
this.calumaStore.delete(this.
|
|
22
|
+
if (this.storeKey) {
|
|
23
|
+
this.calumaStore.delete(this.storeKey);
|
|
23
24
|
}
|
|
24
25
|
});
|
|
25
26
|
}
|
|
@@ -31,13 +32,34 @@ export default class Base {
|
|
|
31
32
|
*/
|
|
32
33
|
raw = {};
|
|
33
34
|
|
|
35
|
+
/**
|
|
36
|
+
* The primary key of the lib class.
|
|
37
|
+
* Must be overridden in subclasses.
|
|
38
|
+
*
|
|
39
|
+
* @property {String} pk
|
|
40
|
+
*/
|
|
41
|
+
@cached
|
|
42
|
+
get pk() {
|
|
43
|
+
throw new Error("pk getter must be implemented in subclass");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The caluma store key of the answer.
|
|
48
|
+
*
|
|
49
|
+
* @property {String} storeKey
|
|
50
|
+
*/
|
|
51
|
+
@cached
|
|
52
|
+
get storeKey() {
|
|
53
|
+
return this.pk;
|
|
54
|
+
}
|
|
55
|
+
|
|
34
56
|
/**
|
|
35
57
|
* Push the object into the caluma store
|
|
36
58
|
*
|
|
37
59
|
* @method pushIntoStore
|
|
38
60
|
*/
|
|
39
61
|
pushIntoStore() {
|
|
40
|
-
if (this.
|
|
62
|
+
if (this.storeKey) {
|
|
41
63
|
this.calumaStore.push(this);
|
|
42
64
|
}
|
|
43
65
|
}
|
package/addon/lib/field.js
CHANGED
|
@@ -177,6 +177,17 @@ export default class Field extends Base {
|
|
|
177
177
|
return `${this.document.pk}:Question:${this.raw.question.slug}`;
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
+
/**
|
|
181
|
+
* The caluma store key of the field.
|
|
182
|
+
* The form primary key is added for re-used fields in different forms.
|
|
183
|
+
*
|
|
184
|
+
* @property {String} storeKey
|
|
185
|
+
*/
|
|
186
|
+
@cached
|
|
187
|
+
get storeKey() {
|
|
188
|
+
return `${this.fieldset.storeKey}:Question:${this.raw.question.slug}`;
|
|
189
|
+
}
|
|
190
|
+
|
|
180
191
|
/**
|
|
181
192
|
* The element ID used by the label component.
|
|
182
193
|
*
|
package/addon/lib/fieldset.js
CHANGED
|
@@ -52,9 +52,7 @@ export default class Fieldset extends Base {
|
|
|
52
52
|
const fields = this.raw.form.questions.map((question) => {
|
|
53
53
|
return associateDestroyableChild(
|
|
54
54
|
this,
|
|
55
|
-
this.calumaStore.find(
|
|
56
|
-
`${this.document.pk}:Question:${question.slug}`,
|
|
57
|
-
) ||
|
|
55
|
+
this.calumaStore.find(`${this.pk}:Question:${question.slug}`) ||
|
|
58
56
|
new (owner.factoryFor("caluma-model:field").class)({
|
|
59
57
|
raw: {
|
|
60
58
|
question,
|
|
@@ -13,14 +13,14 @@ export default class CalumaStoreService extends Service {
|
|
|
13
13
|
push(obj) {
|
|
14
14
|
assert(
|
|
15
15
|
`Object must have an \`pk\` in order to be pushed into the store`,
|
|
16
|
-
obj.
|
|
16
|
+
obj.storeKey,
|
|
17
17
|
);
|
|
18
18
|
|
|
19
|
-
const existing = this._store.get(obj.
|
|
19
|
+
const existing = this._store.get(obj.storeKey);
|
|
20
20
|
|
|
21
21
|
if (existing) {
|
|
22
22
|
debug(
|
|
23
|
-
`Object with the
|
|
23
|
+
`Object with the storeKey \`${obj.storeKey}\` already exists in the store. It will be updated.`,
|
|
24
24
|
);
|
|
25
25
|
|
|
26
26
|
set(existing, "raw", obj.raw);
|
|
@@ -28,17 +28,17 @@ export default class CalumaStoreService extends Service {
|
|
|
28
28
|
return existing;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
this._store.set(obj.
|
|
31
|
+
this._store.set(obj.storeKey, obj);
|
|
32
32
|
|
|
33
33
|
return obj;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
find(
|
|
37
|
-
return this._store.get(
|
|
36
|
+
find(storeKey) {
|
|
37
|
+
return this._store.get(storeKey) || null;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
delete(
|
|
41
|
-
this._store.delete(
|
|
40
|
+
delete(storeKey) {
|
|
41
|
+
this._store.delete(storeKey);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
clear() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectcaluma/ember-form",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.6.0",
|
|
4
4
|
"description": "Ember addon for rendering Caluma forms.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -11,10 +11,9 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@babel/core": "^7.26.0",
|
|
13
13
|
"@ember/string": "^3.1.1 || ^4.0.0",
|
|
14
|
+
"@ember/test-waiters": "^4.1.1",
|
|
14
15
|
"@embroider/macros": "^1.16.10",
|
|
15
16
|
"@embroider/util": "^1.13.2",
|
|
16
|
-
"@glimmer/component": "^1.1.2",
|
|
17
|
-
"@glimmer/tracking": "^1.1.2",
|
|
18
17
|
"ember-apollo-client": "^5.0.0",
|
|
19
18
|
"ember-auto-import": "^2.10.0",
|
|
20
19
|
"ember-autoresize-modifier": "^0.7.0 || ^0.8.0",
|
|
@@ -24,7 +23,6 @@
|
|
|
24
23
|
"ember-cli-showdown": "^9.0.1",
|
|
25
24
|
"ember-composable-helpers": "^5.0.0",
|
|
26
25
|
"ember-concurrency": "^4.0.2",
|
|
27
|
-
"ember-fetch": "^8.1.2",
|
|
28
26
|
"ember-flatpickr": "^8.0.1",
|
|
29
27
|
"ember-in-viewport": "^4.1.0",
|
|
30
28
|
"ember-intl": "^7.1.1",
|
|
@@ -41,13 +39,15 @@
|
|
|
41
39
|
"luxon": "^3.5.0",
|
|
42
40
|
"reactiveweb": "^1.3.0",
|
|
43
41
|
"tracked-toolbox": "^2.0.0",
|
|
44
|
-
"@projectcaluma/ember-core": "^14.
|
|
42
|
+
"@projectcaluma/ember-core": "^14.6.0"
|
|
45
43
|
},
|
|
46
44
|
"devDependencies": {
|
|
47
45
|
"@ember/optional-features": "2.2.0",
|
|
48
46
|
"@ember/test-helpers": "4.0.4",
|
|
49
47
|
"@embroider/test-setup": "4.0.0",
|
|
50
48
|
"@faker-js/faker": "10.0.0",
|
|
49
|
+
"@glimmer/component": "1.1.2",
|
|
50
|
+
"@glimmer/tracking": "1.1.2",
|
|
51
51
|
"broccoli-asset-rev": "3.0.0",
|
|
52
52
|
"ember-cli": "6.1.0",
|
|
53
53
|
"ember-cli-clean-css": "3.0.0",
|
|
@@ -72,12 +72,12 @@
|
|
|
72
72
|
"uikit": "3.23.13",
|
|
73
73
|
"uuid": "13.0.0",
|
|
74
74
|
"webpack": "5.101.3",
|
|
75
|
-
"@projectcaluma/ember-
|
|
76
|
-
"@projectcaluma/ember-
|
|
75
|
+
"@projectcaluma/ember-workflow": "14.6.0",
|
|
76
|
+
"@projectcaluma/ember-testing": "14.6.0"
|
|
77
77
|
},
|
|
78
78
|
"peerDependencies": {
|
|
79
79
|
"ember-source": ">= 4.0.0",
|
|
80
|
-
"@projectcaluma/ember-workflow": "^14.
|
|
80
|
+
"@projectcaluma/ember-workflow": "^14.6.0"
|
|
81
81
|
},
|
|
82
82
|
"dependenciesMeta": {
|
|
83
83
|
"@projectcaluma/ember-core": {
|