@projectcaluma/ember-form 14.5.0 → 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.
- package/README.md +82 -0
- package/addon/components/cf-field/input/files.js +7 -5
- package/addon/lib/base.js +25 -3
- package/addon/lib/field.js +11 -0
- package/addon/lib/fieldset.js +1 -3
- package/addon/services/caluma-store.js +8 -8
- package/package.json +9 -9
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# 
|
|
2
|
+
|
|
3
|
+
[](https://github.com/projectcaluma/ember-caluma/actions?query=workflow%3ATest)
|
|
4
|
+
[](https://automate.browserstack.com/public-build/RFNMT2hyTnRjNVZkUitkWUl2d3BWK21KbnU3MU1tTGpHS2tOVHVCU1RrZz0tLXJjZ1J5VEZ6ZmtJWVpFdHpDRnREcFE9PQ==--3034affde596526379b7a0a19798a7ba1f79154c)
|
|
5
|
+
[](https://codecov.io/gh/projectcaluma/ember-caluma)
|
|
6
|
+
[](https://github.com/prettier/prettier)
|
|
7
|
+
[](https://spdx.org/licenses/LGPL-3.0-or-later.html)
|
|
8
|
+
|
|
9
|
+
The Ember.js addons for [Caluma](https://caluma.io) - a collaborative form editing service.
|
|
10
|
+
|
|
11
|
+
## Browser support
|
|
12
|
+
|
|
13
|
+
|  |  |  |  |
|
|
14
|
+
| :-------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------: |
|
|
15
|
+
| last 2 versions | last 2 versions | last 2 versions | last 2 versions |
|
|
16
|
+
|
|
17
|
+
## Compatibility
|
|
18
|
+
|
|
19
|
+
`@projectcaluma/ember-*` packages are guaranteed to work with the following LTS versions of Ember.js:
|
|
20
|
+
|
|
21
|
+
- 5.4
|
|
22
|
+
- 4.12
|
|
23
|
+
|
|
24
|
+
## Documentation
|
|
25
|
+
|
|
26
|
+
You can find the interactive documentation [here](https://docs.caluma.io/ember-caluma).
|
|
27
|
+
|
|
28
|
+
## Contributing
|
|
29
|
+
|
|
30
|
+
### Installation
|
|
31
|
+
|
|
32
|
+
- `git clone git@github.com:projectcaluma/ember-caluma`
|
|
33
|
+
- `cd ember-caluma`
|
|
34
|
+
- `pnpm install`
|
|
35
|
+
|
|
36
|
+
### Linting
|
|
37
|
+
|
|
38
|
+
- `pnpm lint`
|
|
39
|
+
|
|
40
|
+
### Running tests
|
|
41
|
+
|
|
42
|
+
- `pnpm --filter @projectcaluma/ember-[package] exec ember test` – Runs the test suite on the current Ember version
|
|
43
|
+
- `pnpm --filter @projectcaluma/ember-[package] exec ember test --server` – Runs the test suite in "watch mode"
|
|
44
|
+
- `pnpm --filter @projectcaluma/ember-[package] exec ember try:each` – Runs the test suite against multiple Ember versions
|
|
45
|
+
|
|
46
|
+
Cross-browser testing provided by:
|
|
47
|
+
|
|
48
|
+
<a href="https://browserstack.com"><img alt="BrowserStack" src="https://user-images.githubusercontent.com/6150577/69328224-24f1d680-0c4f-11ea-8b02-5670334923a3.png" height="50"></a>
|
|
49
|
+
|
|
50
|
+
### Running the dummy application
|
|
51
|
+
|
|
52
|
+
#### With a mocked [Mirage.js](https://github.com/miragejs/ember-cli-mirage) backend
|
|
53
|
+
|
|
54
|
+
- `pnpm start`
|
|
55
|
+
- Visit the dummy application at [http://localhost:4200](http://localhost:4200).
|
|
56
|
+
|
|
57
|
+
#### With a dockerized [Caluma](https://github.com/projectcaluma/caluma) backend
|
|
58
|
+
|
|
59
|
+
- `docker compose up -d`
|
|
60
|
+
- `pnpm start-proxy`
|
|
61
|
+
- Visit the dummy application at [http://localhost:4200](http://localhost:4200).
|
|
62
|
+
|
|
63
|
+
### Updating the schema
|
|
64
|
+
|
|
65
|
+
The addon includes a mirage server for mocking Caluma's GraphQL API, which is generated from the GraphQL schema definition. If the upstream GraphQL schema changed you can update the addon by running
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
docker compose up -d
|
|
69
|
+
pnpm update-schema
|
|
70
|
+
pnpm update-possible-types
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Releasing
|
|
74
|
+
|
|
75
|
+
To release a new version, head over to [Actions](https://github.com/projectcaluma/ember-caluma/actions?query=workflow%3ARelease) and trigger a workflow run.
|
|
76
|
+
This will automatically check if a new version can be released, generate a changelog, draft a release and publish it on NPM.
|
|
77
|
+
|
|
78
|
+
## License
|
|
79
|
+
|
|
80
|
+
This project is licensed under the [LGPL-3.0-or-later license](LICENSE).
|
|
81
|
+
|
|
82
|
+
For further information on our license choice, you can read up on the [corresponding GitHub issue](https://github.com/projectcaluma/ember-caluma/issues/613).
|
|
@@ -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,11 +11,10 @@
|
|
|
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
|
-
"
|
|
17
|
-
"@glimmer/tracking": "^1.1.2",
|
|
18
|
-
"ember-apollo-client": "~4.0.2",
|
|
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",
|
|
21
20
|
"ember-basic-dropdown": "^8.4.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": {
|