@projectcaluma/ember-form-builder 10.0.2 → 11.0.0-beta.3

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.
Files changed (65) hide show
  1. package/CHANGELOG.md +1082 -0
  2. package/addon/components/cfb-form-editor/general.hbs +83 -90
  3. package/addon/components/cfb-form-editor/general.js +11 -6
  4. package/addon/components/cfb-form-editor/question/default.js +11 -12
  5. package/addon/components/cfb-form-editor/question/options.hbs +1 -1
  6. package/addon/components/cfb-form-editor/question/validation.hbs +1 -0
  7. package/addon/components/cfb-form-editor/question-list/item.hbs +8 -8
  8. package/addon/components/cfb-form-editor/question-list/item.js +2 -2
  9. package/addon/components/cfb-form-editor/question-list.hbs +8 -8
  10. package/addon/components/cfb-form-editor/question-list.js +5 -6
  11. package/addon/components/cfb-form-editor/question.hbs +3 -2
  12. package/addon/components/cfb-form-editor/question.js +1 -2
  13. package/addon/components/cfb-form-editor.hbs +5 -5
  14. package/addon/components/cfb-form-list/item.hbs +1 -1
  15. package/addon/components/cfb-form-list.hbs +69 -72
  16. package/addon/components/cfb-form-list.js +10 -33
  17. package/addon/components/cfb-navigation.hbs +1 -1
  18. package/addon/components/cfb-toggle-switch.hbs +2 -2
  19. package/addon/engine.js +7 -10
  20. package/addon/gql/fragments/field.graphql +23 -1
  21. package/addon/gql/fragments/form-info.graphql +1 -0
  22. package/addon/gql/fragments/question-info.graphql +1 -0
  23. package/addon/gql/mutations/add-form-question.graphql +2 -0
  24. package/addon/gql/mutations/remove-form-question.graphql +2 -0
  25. package/addon/gql/mutations/reorder-form-questions.graphql +2 -0
  26. package/addon/gql/mutations/save-action-button-question.graphql +1 -0
  27. package/addon/gql/mutations/save-calculated-float-question.graphql +1 -0
  28. package/addon/gql/mutations/save-choice-question.graphql +2 -0
  29. package/addon/gql/mutations/save-date-question.graphql +1 -0
  30. package/addon/gql/mutations/save-dynamic-choice-question.graphql +1 -0
  31. package/addon/gql/mutations/save-dynamic-multiple-choice-question.graphql +1 -0
  32. package/addon/gql/mutations/save-file-question.graphql +1 -0
  33. package/addon/gql/mutations/save-float-question.graphql +1 -0
  34. package/addon/gql/mutations/save-form-question.graphql +2 -0
  35. package/addon/gql/mutations/save-form.graphql +1 -0
  36. package/addon/gql/mutations/save-integer-question.graphql +1 -0
  37. package/addon/gql/mutations/save-multiple-choice-question.graphql +2 -0
  38. package/addon/gql/mutations/save-option.graphql +1 -0
  39. package/addon/gql/mutations/save-static-question.graphql +1 -0
  40. package/addon/gql/mutations/save-table-question.graphql +2 -0
  41. package/addon/gql/mutations/save-text-question.graphql +1 -0
  42. package/addon/gql/mutations/save-textarea-question.graphql +1 -0
  43. package/addon/gql/queries/check-form-slug.graphql +1 -0
  44. package/addon/gql/queries/check-question-slug.graphql +1 -0
  45. package/addon/gql/queries/form-editor-general.graphql +1 -0
  46. package/addon/gql/queries/form-editor-question.graphql +7 -0
  47. package/addon/gql/queries/form-list.graphql +1 -0
  48. package/addon/gql/queries/search-form-question.graphql +4 -0
  49. package/addon/gql/queries/search-question.graphql +3 -0
  50. package/addon/routes/edit/questions/edit.js +1 -1
  51. package/addon/routes/edit.js +1 -1
  52. package/addon/templates/edit/questions/edit.hbs +1 -1
  53. package/addon/templates/edit/questions/new.hbs +1 -4
  54. package/addon/templates/edit.hbs +5 -5
  55. package/addon/templates/index.hbs +1 -1
  56. package/addon/templates/new.hbs +1 -1
  57. package/addon/utils/and.js +47 -0
  58. package/addon/utils/or.js +40 -0
  59. package/addon/validations/option.js +1 -1
  60. package/addon/validations/question.js +2 -2
  61. package/addon/validators/slug.js +1 -1
  62. package/app/utils/and.js +1 -0
  63. package/app/utils/or.js +1 -0
  64. package/index.js +6 -4
  65. package/package.json +28 -25
@@ -1,10 +1,10 @@
1
1
  <CfbFormEditor
2
2
  @slug={{@model}}
3
- @on-edit-question={{this.editQuestion}}
4
- @on-create-question={{this.createQuestion}}
5
- @on-after-add-question={{this.editQuestion}}
6
- @on-after-remove-question={{this.afterRemoveQuestion}}
7
- @on-click-form={{this.clickForm}}
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 @on-new-form={{this.newForm}} @on-edit-form={{this.editForm}} />
1
+ <CfbFormList @onNewForm={{this.newForm}} @onEditForm={{this.editForm}} />
@@ -1,6 +1,6 @@
1
1
  <CfbFormEditor @slug={{@model}}>
2
2
  <CfbFormEditor::General
3
3
  @slug={{@model}}
4
- @on-after-submit={{this.afterSubmit}}
4
+ @onAfterSubmit={{this.afterSubmit}}
5
5
  />
6
6
  </CfbFormEditor>
@@ -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-core/utils/and";
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-core/utils/and";
11
- import or from "@projectcaluma/ember-core/utils/or";
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
 
@@ -4,7 +4,7 @@ import {
4
4
  validateFormat,
5
5
  } from "ember-changeset-validations/validators";
6
6
 
7
- import and from "@projectcaluma/ember-core/utils/and";
7
+ import and from "@projectcaluma/ember-form-builder/utils/and";
8
8
 
9
9
  const validateSlug = () =>
10
10
  and(
@@ -0,0 +1 @@
1
+ export { default } from "@projectcaluma/ember-form-builder/utils/and";
@@ -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 EngineAddon = require("ember-engines/lib/engine-addon");
4
+ const { buildEngine } = require("ember-engines/lib/engine-addon");
5
5
 
6
- /* eslint-disable ember/avoid-leaking-state-in-ember-objects */
7
- module.exports = EngineAddon.extend({
6
+ module.exports = buildEngine({
8
7
  name: require("./package.json").name,
9
- lazyLoading: false,
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": "10.0.2",
3
+ "version": "11.0.0-beta.3",
4
4
  "description": "Ember engine for building Caluma forms.",
5
5
  "keywords": [
6
6
  "ember-addon",
@@ -14,50 +14,53 @@
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.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": "^10.0.2",
22
- "@projectcaluma/ember-form": "^10.0.2",
24
+ "@projectcaluma/ember-core": "^11.0.0-beta.2",
25
+ "@projectcaluma/ember-form": "^11.0.0-beta.3",
23
26
  "codejar": "^3.5.0",
24
27
  "ember-apollo-client": "^3.2.0",
25
- "ember-auto-import": "^2.2.3",
26
- "ember-changeset": "^3.15.0",
27
- "ember-changeset-validations": "^3.16.0",
28
- "ember-cli-babel": "^7.26.6",
29
- "ember-cli-htmlbars": "^6.0.0",
30
- "ember-composable-helpers": "^4.5.0",
28
+ "ember-auto-import": "^2.4.0",
29
+ "ember-changeset": "^4.0.0-beta.1",
30
+ "ember-changeset-validations": "^4.0.0-beta.2",
31
+ "ember-cli-babel": "^7.26.11",
32
+ "ember-cli-htmlbars": "^6.0.1",
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.0.4",
36
+ "ember-fetch": "^8.1.1",
35
37
  "ember-math-helpers": "^2.18.0",
36
38
  "ember-pikaday": "^3.0.0",
37
- "ember-power-select": "^4.1.7",
39
+ "ember-power-select": "^5.0.3",
40
+ "ember-resources": "^4.1.3",
38
41
  "ember-test-selectors": "^6.0.0",
39
- "ember-uikit": "^4.0.0",
40
- "ember-validated-form": "^5.0.0",
41
- "graphql": "^15.6.1",
42
+ "ember-uikit": "^5.0.0-beta.3",
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.25.0"
48
+ "prismjs": "^1.26.0"
46
49
  },
47
50
  "devDependencies": {
48
51
  "@ember/optional-features": "2.0.0",
49
52
  "@ember/test-helpers": "2.6.0",
50
- "@embroider/test-setup": "0.47.2",
51
- "@projectcaluma/ember-testing": "10.0.0",
53
+ "@embroider/test-setup": "1.0.0",
54
+ "@faker-js/faker": "6.0.0-alpha.3",
55
+ "@projectcaluma/ember-testing": "10.2.0-beta.2",
52
56
  "broccoli-asset-rev": "3.0.0",
53
- "ember-cli": "3.28.4",
57
+ "ember-cli": "3.28.5",
54
58
  "ember-cli-code-coverage": "1.0.3",
55
59
  "ember-cli-dependency-checker": "3.2.0",
56
60
  "ember-cli-inject-live-reload": "2.1.0",
57
- "ember-cli-mirage": "2.2.0",
61
+ "ember-cli-mirage": "2.4.0",
58
62
  "ember-cli-sri": "2.1.1",
59
63
  "ember-cli-terser": "4.0.2",
60
- "ember-data": "3.28.3",
61
64
  "ember-disable-prototype-extensions": "1.1.3",
62
65
  "ember-engines": "0.8.20",
63
66
  "ember-export-application-global": "2.0.1",
@@ -65,15 +68,15 @@
65
68
  "ember-maybe-import-regenerator": "1.0.0",
66
69
  "ember-qunit": "5.1.5",
67
70
  "ember-resolver": "8.0.3",
68
- "ember-source": "3.28.6",
71
+ "ember-source": "3.28.8",
69
72
  "ember-source-channel-url": "3.0.0",
70
73
  "ember-try": "2.0.0",
71
- "faker": "5.5.3",
72
74
  "loader.js": "4.7.0",
75
+ "miragejs": "0.1.43",
73
76
  "npm-run-all": "4.1.5",
74
77
  "qunit": "2.17.2",
75
78
  "qunit-dom": "2.0.0",
76
- "webpack": "5.64.1"
79
+ "webpack": "5.67.0"
77
80
  },
78
81
  "engines": {
79
82
  "node": "12.* || 14.* || >= 16"