@projectcaluma/ember-form-builder 10.0.3 → 11.0.0-beta.4
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/CHANGELOG.md +1089 -0
- package/addon/components/cfb-form-editor/general.hbs +83 -90
- package/addon/components/cfb-form-editor/general.js +11 -6
- package/addon/components/cfb-form-editor/question/default.js +11 -12
- package/addon/components/cfb-form-editor/question/options.hbs +1 -1
- package/addon/components/cfb-form-editor/question/validation.hbs +1 -0
- package/addon/components/cfb-form-editor/question-list/item.hbs +4 -4
- package/addon/components/cfb-form-editor/question-list/item.js +2 -2
- package/addon/components/cfb-form-editor/question-list.hbs +6 -6
- package/addon/components/cfb-form-editor/question-list.js +5 -6
- package/addon/components/cfb-form-editor/question.hbs +3 -2
- package/addon/components/cfb-form-editor/question.js +4 -3
- package/addon/components/cfb-form-editor.hbs +5 -5
- package/addon/components/cfb-form-list/item.hbs +1 -1
- package/addon/components/cfb-form-list.hbs +69 -72
- package/addon/components/cfb-form-list.js +10 -33
- package/addon/components/cfb-toggle-switch.hbs +1 -1
- package/addon/engine.js +7 -10
- package/addon/routes/edit/questions/edit.js +1 -1
- package/addon/routes/edit.js +1 -1
- package/addon/templates/edit/questions/edit.hbs +1 -1
- package/addon/templates/edit/questions/new.hbs +1 -4
- package/addon/templates/edit.hbs +5 -5
- package/addon/templates/index.hbs +1 -1
- package/addon/templates/new.hbs +1 -1
- package/addon/utils/and.js +47 -0
- package/addon/utils/or.js +40 -0
- package/addon/validations/option.js +1 -1
- package/addon/validations/question.js +2 -2
- package/addon/validators/slug.js +1 -1
- package/app/utils/and.js +1 -0
- package/app/utils/or.js +1 -0
- package/index.js +6 -4
- package/package.json +28 -23
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { action } from "@ember/object";
|
|
2
1
|
import Component from "@glimmer/component";
|
|
3
2
|
import { tracked } from "@glimmer/tracking";
|
|
4
|
-
import {
|
|
5
|
-
import { timeout } from "ember-concurrency";
|
|
6
|
-
import { restartableTask } from "ember-concurrency-decorators";
|
|
3
|
+
import { timeout, restartableTask } from "ember-concurrency";
|
|
7
4
|
|
|
8
|
-
import
|
|
5
|
+
import { useCalumaQuery } from "@projectcaluma/ember-core/caluma-query";
|
|
9
6
|
import { allForms } from "@projectcaluma/ember-core/caluma-query/queries";
|
|
10
7
|
|
|
11
8
|
export default class ComponentsCfbFormListComponent extends Component {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
formsQuery = useCalumaQuery(this, allForms, () => ({
|
|
10
|
+
options: { pageSize: 20 },
|
|
11
|
+
filter: this.filter,
|
|
12
|
+
order: [{ attribute: "NAME", direction: "ASC" }],
|
|
13
|
+
}));
|
|
15
14
|
|
|
16
15
|
@tracked category = "active";
|
|
17
16
|
@tracked search = "";
|
|
@@ -29,33 +28,11 @@ export default class ComponentsCfbFormListComponent extends Component {
|
|
|
29
28
|
return [isArchived, search].filter(Boolean) || null;
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
@action
|
|
33
|
-
setFilter(name, eventOrValue) {
|
|
34
|
-
this[name] =
|
|
35
|
-
eventOrValue instanceof Event ? eventOrValue.target.value : eventOrValue;
|
|
36
|
-
|
|
37
|
-
this.fetchForms.perform();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@action
|
|
41
|
-
submit(event) {
|
|
42
|
-
event.preventDefault();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
@action
|
|
46
|
-
loadMoreForms(e) {
|
|
47
|
-
e.preventDefault();
|
|
48
|
-
|
|
49
|
-
this.formsQuery.fetchMore();
|
|
50
|
-
}
|
|
51
|
-
|
|
52
31
|
@restartableTask
|
|
53
|
-
*
|
|
32
|
+
*setFilter(name, eventOrValue) {
|
|
54
33
|
yield timeout(500);
|
|
55
34
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
order: [{ attribute: "NAME", direction: "ASC" }],
|
|
59
|
-
});
|
|
35
|
+
this[name] =
|
|
36
|
+
eventOrValue instanceof Event ? eventOrValue.target.value : eventOrValue;
|
|
60
37
|
}
|
|
61
38
|
}
|
package/addon/engine.js
CHANGED
|
@@ -6,16 +6,13 @@ import config from "./config/environment";
|
|
|
6
6
|
|
|
7
7
|
const { modulePrefix } = config;
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Resolver,
|
|
9
|
+
export default class FormBuilderEngine extends Engine {
|
|
10
|
+
modulePrefix = modulePrefix;
|
|
11
|
+
Resolver = Resolver;
|
|
13
12
|
|
|
14
|
-
dependencies
|
|
13
|
+
dependencies = {
|
|
15
14
|
services: ["apollo", "notification", "intl", "caluma-options", "validator"],
|
|
16
|
-
}
|
|
17
|
-
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
18
17
|
|
|
19
|
-
loadInitializers(
|
|
20
|
-
|
|
21
|
-
export default Eng;
|
|
18
|
+
loadInitializers(FormBuilderEngine, modulePrefix);
|
|
@@ -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 { lastValue, dropTask } from "ember-concurrency";
|
|
5
5
|
import { gql } from "graphql-tag";
|
|
6
6
|
|
|
7
7
|
import { navigationTitle } from "@projectcaluma/ember-form-builder/decorators";
|
package/addon/routes/edit.js
CHANGED
|
@@ -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 { lastValue, dropTask } from "ember-concurrency";
|
|
5
5
|
import { gql } from "graphql-tag";
|
|
6
6
|
|
|
7
7
|
import { navigationTitle } from "@projectcaluma/ember-form-builder/decorators";
|
package/addon/templates/edit.hbs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<CfbFormEditor
|
|
2
2
|
@slug={{@model}}
|
|
3
|
-
@
|
|
4
|
-
@
|
|
5
|
-
@
|
|
6
|
-
@
|
|
7
|
-
@
|
|
3
|
+
@onEditQuestion={{this.editQuestion}}
|
|
4
|
+
@onCreateQuestion={{this.createQuestion}}
|
|
5
|
+
@onAfterAddQuestion={{this.editQuestion}}
|
|
6
|
+
@onAfterRemoveQuestion={{this.afterRemoveQuestion}}
|
|
7
|
+
@onClickForm={{this.clickForm}}
|
|
8
8
|
>
|
|
9
9
|
{{outlet}}
|
|
10
10
|
</CfbFormEditor>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<CfbFormList @
|
|
1
|
+
<CfbFormList @onNewForm={{this.newForm}} @onEditForm={{this.editForm}} />
|
package/addon/templates/new.hbs
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { typeOf } from "@ember/utils";
|
|
2
|
+
import { isPromise } from "validated-changeset";
|
|
3
|
+
|
|
4
|
+
function notTrue(value) {
|
|
5
|
+
return typeOf(value) !== "boolean" || !value;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function handleResult(result) {
|
|
9
|
+
if (notTrue(result)) throw result;
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Accepts an array of ember-changeset-validations validation functions.
|
|
15
|
+
*
|
|
16
|
+
* Copied and updated from nucleartide/ember-changeset-hofs
|
|
17
|
+
* @module and
|
|
18
|
+
*/
|
|
19
|
+
export default function and(...validators) {
|
|
20
|
+
return (key, newValue, oldValue, changes, object) => {
|
|
21
|
+
for (let i = 0; i < validators.length; i++) {
|
|
22
|
+
const validation = validators[i](
|
|
23
|
+
key,
|
|
24
|
+
newValue,
|
|
25
|
+
oldValue,
|
|
26
|
+
changes,
|
|
27
|
+
object
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
if (isPromise(validation)) {
|
|
31
|
+
let promise = validation.then(handleResult);
|
|
32
|
+
|
|
33
|
+
for (let j = i + 1; j < validators.length; j++) {
|
|
34
|
+
promise = promise
|
|
35
|
+
.then(() => validators[j](key, newValue, oldValue, changes, object))
|
|
36
|
+
.then(handleResult);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return promise.catch((err) => err);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (notTrue(validation)) return validation;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return true;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { isPromise } from "validated-changeset";
|
|
2
|
+
|
|
3
|
+
function isTrue(value) {
|
|
4
|
+
return value === true;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function handleResult(result) {
|
|
8
|
+
if (isTrue(result)) throw true;
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Copied and updated from nucleartide/ember-changeset-hofs
|
|
14
|
+
* @module or
|
|
15
|
+
*/
|
|
16
|
+
export default function or(...validators) {
|
|
17
|
+
return (key, newValue, oldValue, changes, object) => {
|
|
18
|
+
let validation;
|
|
19
|
+
|
|
20
|
+
for (let i = 0; i < validators.length; i++) {
|
|
21
|
+
validation = validators[i](key, newValue, oldValue, changes, object);
|
|
22
|
+
|
|
23
|
+
if (isPromise(validation)) {
|
|
24
|
+
let promise = validation.then(handleResult);
|
|
25
|
+
|
|
26
|
+
for (let j = i + 1; j < validators.length; j++) {
|
|
27
|
+
promise = promise
|
|
28
|
+
.then(() => validators[j](key, newValue, oldValue, changes, object))
|
|
29
|
+
.then(handleResult);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return promise.catch((err) => err);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (isTrue(validation)) return true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return validation;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
validateLength,
|
|
4
4
|
} from "ember-changeset-validations/validators";
|
|
5
5
|
|
|
6
|
-
import and from "@projectcaluma/ember-
|
|
6
|
+
import and from "@projectcaluma/ember-form-builder/utils/and";
|
|
7
7
|
import validateSlug from "@projectcaluma/ember-form-builder/validators/slug";
|
|
8
8
|
|
|
9
9
|
export default {
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
import validateGtLt from "../validators/gt-lt";
|
|
8
8
|
import validateOptions from "../validators/options";
|
|
9
9
|
|
|
10
|
-
import and from "@projectcaluma/ember-
|
|
11
|
-
import or from "@projectcaluma/ember-
|
|
10
|
+
import and from "@projectcaluma/ember-form-builder/utils/and";
|
|
11
|
+
import or from "@projectcaluma/ember-form-builder/utils/or";
|
|
12
12
|
import validateSlug from "@projectcaluma/ember-form-builder/validators/slug";
|
|
13
13
|
import validateType from "@projectcaluma/ember-form-builder/validators/type";
|
|
14
14
|
|
package/addon/validators/slug.js
CHANGED
package/app/utils/and.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "@projectcaluma/ember-form-builder/utils/and";
|
package/app/utils/or.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "@projectcaluma/ember-form-builder/utils/or";
|
package/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
// eslint-disable-next-line node/no-unpublished-require
|
|
4
|
-
const
|
|
4
|
+
const { buildEngine } = require("ember-engines/lib/engine-addon");
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
module.exports = EngineAddon.extend({
|
|
6
|
+
module.exports = buildEngine({
|
|
8
7
|
name: require("./package.json").name,
|
|
9
|
-
|
|
8
|
+
|
|
9
|
+
lazyLoading: {
|
|
10
|
+
enabled: false,
|
|
11
|
+
},
|
|
10
12
|
|
|
11
13
|
included(...args) {
|
|
12
14
|
this._super.included.apply(this, args);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@projectcaluma/ember-form-builder",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0-beta.4",
|
|
4
4
|
"description": "Ember engine for building Caluma forms.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon",
|
|
@@ -14,50 +14,55 @@
|
|
|
14
14
|
"test:ember": "ember test",
|
|
15
15
|
"test:ember-compatibility": "ember try:each"
|
|
16
16
|
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"ember-engines": ">= 0.8"
|
|
19
|
+
},
|
|
17
20
|
"dependencies": {
|
|
18
|
-
"@ember/render-modifiers": "^2.0.
|
|
21
|
+
"@ember/render-modifiers": "^2.0.3",
|
|
19
22
|
"@glimmer/component": "^1.0.4",
|
|
20
23
|
"@glimmer/tracking": "^1.0.4",
|
|
21
|
-
"@projectcaluma/ember-core": "^
|
|
22
|
-
"@projectcaluma/ember-form": "^
|
|
24
|
+
"@projectcaluma/ember-core": "^11.0.0-beta.2",
|
|
25
|
+
"@projectcaluma/ember-form": "^11.0.0-beta.4",
|
|
23
26
|
"codejar": "^3.5.0",
|
|
24
27
|
"ember-apollo-client": "^3.2.0",
|
|
25
|
-
"ember-auto-import": "^2.
|
|
26
|
-
"ember-changeset": "^
|
|
27
|
-
"ember-changeset-validations": "^
|
|
28
|
-
"ember-cli-babel": "^7.26.
|
|
28
|
+
"ember-auto-import": "^2.4.0",
|
|
29
|
+
"ember-changeset": "^4.0.0-beta.2",
|
|
30
|
+
"ember-changeset-validations": "^4.0.0-beta.2",
|
|
31
|
+
"ember-cli-babel": "^7.26.11",
|
|
29
32
|
"ember-cli-htmlbars": "^6.0.1",
|
|
30
|
-
"ember-composable-helpers": "^
|
|
33
|
+
"ember-composable-helpers": "^5.0.0",
|
|
31
34
|
"ember-concurrency": "^2.2.0",
|
|
32
|
-
"ember-concurrency-decorators": "^2.0.3",
|
|
33
35
|
"ember-engines-router-service": "^0.3.0",
|
|
34
|
-
"ember-fetch": "^8.
|
|
35
|
-
"ember-math-helpers": "^2.18.
|
|
36
|
+
"ember-fetch": "^8.1.1",
|
|
37
|
+
"ember-math-helpers": "^2.18.1",
|
|
36
38
|
"ember-pikaday": "^3.0.0",
|
|
37
39
|
"ember-power-select": "^5.0.3",
|
|
40
|
+
"ember-resources": "^4.2.0",
|
|
38
41
|
"ember-test-selectors": "^6.0.0",
|
|
39
|
-
"ember-uikit": "^
|
|
40
|
-
"ember-validated-form": "^5.
|
|
41
|
-
"graphql": "^15.
|
|
42
|
+
"ember-uikit": "^5.0.0-beta.9",
|
|
43
|
+
"ember-validated-form": "^5.1.1",
|
|
44
|
+
"graphql": "^15.8.0",
|
|
42
45
|
"graphql-tag": "^2.12.6",
|
|
43
46
|
"jexl": "^2.3.0",
|
|
44
47
|
"moment": "^2.29.1",
|
|
45
|
-
"prismjs": "^1.
|
|
48
|
+
"prismjs": "^1.26.0"
|
|
46
49
|
},
|
|
50
|
+
"//": "TODO: remove ember-data when https://github.com/ember-engines/ember-engines/pull/794 is released",
|
|
47
51
|
"devDependencies": {
|
|
48
52
|
"@ember/optional-features": "2.0.0",
|
|
49
53
|
"@ember/test-helpers": "2.6.0",
|
|
50
|
-
"@embroider/test-setup": "0.
|
|
51
|
-
"@
|
|
54
|
+
"@embroider/test-setup": "1.0.0",
|
|
55
|
+
"@faker-js/faker": "6.0.0-alpha.5",
|
|
56
|
+
"@projectcaluma/ember-testing": "10.2.0-beta.2",
|
|
52
57
|
"broccoli-asset-rev": "3.0.0",
|
|
53
|
-
"ember-cli": "3.28.
|
|
58
|
+
"ember-cli": "3.28.5",
|
|
54
59
|
"ember-cli-code-coverage": "1.0.3",
|
|
55
60
|
"ember-cli-dependency-checker": "3.2.0",
|
|
56
61
|
"ember-cli-inject-live-reload": "2.1.0",
|
|
57
|
-
"ember-cli-mirage": "2.
|
|
62
|
+
"ember-cli-mirage": "2.4.0",
|
|
58
63
|
"ember-cli-sri": "2.1.1",
|
|
59
64
|
"ember-cli-terser": "4.0.2",
|
|
60
|
-
"ember-data": "3.28.
|
|
65
|
+
"ember-data": "3.28.7",
|
|
61
66
|
"ember-disable-prototype-extensions": "1.1.3",
|
|
62
67
|
"ember-engines": "0.8.20",
|
|
63
68
|
"ember-export-application-global": "2.0.1",
|
|
@@ -68,12 +73,12 @@
|
|
|
68
73
|
"ember-source": "3.28.8",
|
|
69
74
|
"ember-source-channel-url": "3.0.0",
|
|
70
75
|
"ember-try": "2.0.0",
|
|
71
|
-
"faker": "5.5.3",
|
|
72
76
|
"loader.js": "4.7.0",
|
|
77
|
+
"miragejs": "0.1.43",
|
|
73
78
|
"npm-run-all": "4.1.5",
|
|
74
79
|
"qunit": "2.17.2",
|
|
75
80
|
"qunit-dom": "2.0.0",
|
|
76
|
-
"webpack": "5.
|
|
81
|
+
"webpack": "5.68.0"
|
|
77
82
|
},
|
|
78
83
|
"engines": {
|
|
79
84
|
"node": "12.* || 14.* || >= 16"
|