@projectcaluma/ember-form 11.0.0-beta.12 → 11.0.0-beta.13

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ # [@projectcaluma/ember-form-v11.0.0-beta.13](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.12...@projectcaluma/ember-form-v11.0.0-beta.13) (2022-03-11)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **form:** don't refetch dynamic options on validation ([27061c6](https://github.com/projectcaluma/ember-caluma/commit/27061c67f0562508f558305247cb51d615fa36b0))
7
+ * **form:** fix input in date fields ([cf54bf5](https://github.com/projectcaluma/ember-caluma/commit/cf54bf5542e35fd7dbe293a9e22288afae6a517a))
8
+ * **navigation:** exclude static questions from visible fields ([6ebd085](https://github.com/projectcaluma/ember-caluma/commit/6ebd085098df71fab693dec5282ea4b81d5b9836))
9
+ * **workflow:** return case status on complete / skip work-item mutation ([524453c](https://github.com/projectcaluma/ember-caluma/commit/524453c1189b4375ca792fca7d35056b916696f8))
10
+
11
+
12
+ ### Features
13
+
14
+ * **form:** support passing component override classes ([9409c7c](https://github.com/projectcaluma/ember-caluma/commit/9409c7cb5901dcdffec1c0294046da64b74b9922))
15
+
1
16
  # [@projectcaluma/ember-form-v11.0.0-beta.12](https://github.com/projectcaluma/ember-caluma/compare/@projectcaluma/ember-form-v11.0.0-beta.11...@projectcaluma/ember-form-v11.0.0-beta.12) (2022-02-23)
2
17
 
3
18
 
@@ -24,6 +24,7 @@
24
24
  i18n=this.pikadayTranslations
25
25
  value=@field.answer.value
26
26
  onSelect=this.onChange
27
+ parse=this.parseDate
27
28
  }}
28
29
  />
29
30
  {{/if}}
@@ -16,6 +16,15 @@ export default class CfFieldInputDateComponent extends Component {
16
16
  this.args.onSave(date ? DateTime.fromJSDate(date).toISODate() : null);
17
17
  }
18
18
 
19
+ @action
20
+ parseDate(value) {
21
+ const date = DateTime.fromFormat(value, "D", {
22
+ locale: this.intl.primaryLocale,
23
+ });
24
+
25
+ return date.isValid ? date.toJSDate() : null;
26
+ }
27
+
19
28
  @action
20
29
  formatDate(date) {
21
30
  return this.intl.formatDate(date, {
@@ -14,7 +14,10 @@
14
14
 
15
15
  <div class="uk-flex">
16
16
  <div class="uk-width-expand">
17
- {{#let (component (get-widget @field.question)) as |FieldComponent|}}
17
+ {{#let
18
+ (component (ensure-safe-component (get-widget @field.question)))
19
+ as |FieldComponent|
20
+ }}
18
21
  <FieldComponent
19
22
  @field={{@field}}
20
23
  @disabled={{@disabled}}
@@ -1,5 +1,5 @@
1
- import { getOwner } from "@ember/application";
2
1
  import { action } from "@ember/object";
2
+ import { macroCondition, isTesting } from "@embroider/macros";
3
3
  import Component from "@glimmer/component";
4
4
  import { timeout, restartableTask } from "ember-concurrency";
5
5
 
@@ -60,11 +60,10 @@ export default class CfFieldComponent extends Component {
60
60
  */
61
61
  @restartableTask
62
62
  *save(value) {
63
- const { environment } =
64
- getOwner(this).resolveRegistration("config:environment");
65
-
66
63
  /* istanbul ignore next */
67
- if (environment !== "test") {
64
+ if (macroCondition(isTesting())) {
65
+ // no timeout
66
+ } else {
68
67
  yield timeout(500);
69
68
  }
70
69
 
@@ -1,6 +1,8 @@
1
1
  {{#let
2
2
  (component
3
- (get-widget @fieldset.field.question @fieldset.form default="cf-form")
3
+ (ensure-safe-component
4
+ (get-widget @fieldset.field.question @fieldset.form default="cf-form")
5
+ )
4
6
  )
5
7
  as |FormComponent|
6
8
  }}
@@ -1,6 +1,15 @@
1
1
  import Helper from "@ember/component/helper";
2
2
  import { warn } from "@ember/debug";
3
3
  import { inject as service } from "@ember/service";
4
+ import { ensureSafeComponent } from "@embroider/util";
5
+
6
+ import InputComponent from "@projectcaluma/ember-form/components/cf-field/input";
7
+ import FormComponent from "@projectcaluma/ember-form/components/cf-form";
8
+
9
+ const DEFAULT_WIDGETS = {
10
+ "cf-field/input": InputComponent,
11
+ "cf-form": FormComponent,
12
+ };
4
13
 
5
14
  /**
6
15
  * Helper for getting the right widget.
@@ -42,9 +51,14 @@ export default class GetWidgetHelper extends Helper {
42
51
  { id: "ember-caluma.unregistered-override" }
43
52
  );
44
53
 
45
- if (override) return widget;
54
+ if (override) {
55
+ return ensureSafeComponent(
56
+ override.componentClass ?? override.component,
57
+ this
58
+ );
59
+ }
46
60
  }
47
61
 
48
- return defaultWidget;
62
+ return ensureSafeComponent(DEFAULT_WIDGETS[defaultWidget], this);
49
63
  }
50
64
  }
@@ -0,0 +1,52 @@
1
+ import { setOwner } from "@ember/application";
2
+ import { inject as service } from "@ember/service";
3
+
4
+ import HiddenComponent from "@projectcaluma/ember-form/components/cf-field/input/hidden";
5
+ import PowerSelectComponent from "@projectcaluma/ember-form/components/cf-field/input/powerselect";
6
+
7
+ class HiddenOverride {
8
+ @service intl;
9
+
10
+ get label() {
11
+ return this.intl.t("caluma.form-builder.question.widgetOverrides.hidden");
12
+ }
13
+
14
+ component = "cf-field/input/hidden";
15
+ componentClass = HiddenComponent;
16
+ }
17
+
18
+ class PowerSelectOverride {
19
+ @service intl;
20
+
21
+ get label() {
22
+ return this.intl.t(
23
+ "caluma.form-builder.question.widgetOverrides.powerselect"
24
+ );
25
+ }
26
+
27
+ component = "cf-field/input/powerselect";
28
+ componentClass = PowerSelectComponent;
29
+ types = [
30
+ "ChoiceQuestion",
31
+ "MultipleChoiceQuestion",
32
+ "DynamicChoiceQuestion",
33
+ "DynamicMultipleChoiceQuestion",
34
+ ];
35
+ }
36
+
37
+ export function initialize(appInstance) {
38
+ const options = appInstance.lookup("service:caluma-options");
39
+
40
+ const hiddenOverride = new HiddenOverride();
41
+ const powerSelectOverride = new PowerSelectOverride();
42
+
43
+ setOwner(hiddenOverride, appInstance);
44
+ setOwner(powerSelectOverride, appInstance);
45
+
46
+ options.registerComponentOverride(hiddenOverride);
47
+ options.registerComponentOverride(powerSelectOverride);
48
+ }
49
+
50
+ export default {
51
+ initialize,
52
+ };
@@ -83,18 +83,12 @@ export default class Field extends Base {
83
83
  _createQuestion() {
84
84
  const owner = getOwner(this);
85
85
 
86
- const question =
86
+ this.question =
87
87
  this.calumaStore.find(`Question:${this.raw.question.slug}`) ||
88
88
  new (owner.factoryFor("caluma-model:question").class)({
89
89
  raw: this.raw.question,
90
90
  owner,
91
91
  });
92
-
93
- if (question.isDynamic) {
94
- question.loadDynamicOptions.perform();
95
- }
96
-
97
- this.question = question;
98
92
  }
99
93
 
100
94
  _createAnswer() {
@@ -783,8 +777,6 @@ export default class Field extends Base {
783
777
  * @private
784
778
  */
785
779
  async _validateDynamicChoiceQuestion() {
786
- await this.question.loadDynamicOptions.perform();
787
-
788
780
  return validate("inclusion", this.answer.value, {
789
781
  in: (this.options || []).map(({ slug }) => slug),
790
782
  });
@@ -805,8 +797,6 @@ export default class Field extends Base {
805
797
  return true;
806
798
  }
807
799
 
808
- await this.question.loadDynamicOptions.perform();
809
-
810
800
  return value.map((value) => {
811
801
  return validate("inclusion", value, {
812
802
  in: (this.options || []).map(({ slug }) => slug),
@@ -232,7 +232,9 @@ export class NavigationItem extends Base {
232
232
  @cached
233
233
  get visibleFields() {
234
234
  return this.fieldset.fields.filter(
235
- (f) => f.questionType !== "FormQuestion" && !f.hidden
235
+ (f) =>
236
+ !["FormQuestion", "StaticQuestion"].includes(f.questionType) &&
237
+ !f.hidden
236
238
  );
237
239
  }
238
240
 
@@ -1,7 +1,8 @@
1
1
  import { assert } from "@ember/debug";
2
2
  import { camelize } from "@ember/string";
3
3
  import { queryManager } from "ember-apollo-client";
4
- import { dropTask, lastValue } from "ember-concurrency";
4
+ import { dropTask } from "ember-concurrency";
5
+ import { useTask } from "ember-resources";
5
6
  import { cached } from "tracked-toolbox";
6
7
 
7
8
  import getDynamicOptions from "@projectcaluma/ember-form/gql/queries/dynamic-options.graphql";
@@ -71,13 +72,20 @@ export default class Question extends Base {
71
72
  );
72
73
 
73
74
  return (
74
- question.node.dynamicChoiceOptions ||
75
+ question.node.dynamicChoiceOptions ??
75
76
  question.node.dynamicMultipleChoiceOptions
76
77
  );
77
78
  }
78
79
 
79
- @lastValue("loadDynamicOptions") dynamicChoiceOptions;
80
- @lastValue("loadDynamicOptions") dynamicMultipleChoiceOptions;
80
+ dynamicOptions = useTask(this, this.loadDynamicOptions, () => []);
81
+
82
+ get dynamicChoiceOptions() {
83
+ return this.dynamicOptions.value ?? [];
84
+ }
85
+
86
+ get dynamicMultipleChoiceOptions() {
87
+ return this.dynamicOptions.value ?? [];
88
+ }
81
89
 
82
90
  /**
83
91
  * Whether the question is a single choice question
@@ -0,0 +1,4 @@
1
+ export {
2
+ default,
3
+ initialize,
4
+ } from "@projectcaluma/ember-form/instance-initializers/form-widget-overrides";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectcaluma/ember-form",
3
- "version": "11.0.0-beta.12",
3
+ "version": "11.0.0-beta.13",
4
4
  "description": "Ember addon for rendering Caluma forms.",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -14,9 +14,10 @@
14
14
  "test:ember-compatibility": "ember try:each"
15
15
  },
16
16
  "dependencies": {
17
+ "@embroider/macros": "^1.5.0",
17
18
  "@glimmer/component": "^1.0.4",
18
19
  "@glimmer/tracking": "^1.0.4",
19
- "@projectcaluma/ember-core": "^11.0.0-beta.4",
20
+ "@projectcaluma/ember-core": "^11.0.0-beta.5",
20
21
  "ember-apollo-client": "^3.2.0",
21
22
  "ember-auto-import": "^2.4.0",
22
23
  "ember-autoresize-modifier": "^0.5.0",
@@ -31,28 +32,28 @@
31
32
  "ember-math-helpers": "^2.18.1",
32
33
  "ember-pikaday": "^4.0.0",
33
34
  "ember-power-select": "^5.0.4",
34
- "ember-resources": "^4.3.3",
35
+ "ember-resources": "^4.4.0",
35
36
  "ember-uikit": "^5.0.0",
36
37
  "ember-validators": "^4.1.2",
37
38
  "graphql": "^15.8.0",
38
39
  "jexl": "^2.3.0",
39
40
  "lodash.isequal": "^4.5.0",
40
- "luxon": "^2.3.0",
41
+ "luxon": "^2.3.1",
41
42
  "tracked-toolbox": "^1.2.3"
42
43
  },
43
44
  "devDependencies": {
44
45
  "@ember/optional-features": "2.0.0",
45
46
  "@ember/test-helpers": "2.6.0",
46
- "@embroider/test-setup": "1.2.0",
47
- "@faker-js/faker": "6.0.0-alpha.7",
48
- "@projectcaluma/ember-testing": "11.0.0-beta.3",
47
+ "@embroider/test-setup": "1.5.0",
48
+ "@faker-js/faker": "6.0.0-beta.0",
49
+ "@projectcaluma/ember-testing": "11.0.0-beta.4",
49
50
  "@projectcaluma/ember-workflow": "11.0.0-beta.4",
50
51
  "broccoli-asset-rev": "3.0.0",
51
52
  "ember-cli": "3.28.5",
52
53
  "ember-cli-code-coverage": "1.0.3",
53
54
  "ember-cli-dependency-checker": "3.2.0",
54
55
  "ember-cli-inject-live-reload": "2.1.0",
55
- "ember-cli-mirage": "2.4.0",
56
+ "ember-cli-mirage": "3.0.0-alpha.2",
56
57
  "ember-cli-sri": "2.1.1",
57
58
  "ember-cli-terser": "4.0.2",
58
59
  "ember-disable-prototype-extensions": "1.1.3",
@@ -70,7 +71,7 @@
70
71
  "qunit": "2.18.0",
71
72
  "qunit-dom": "2.0.0",
72
73
  "uuid": "8.3.2",
73
- "webpack": "5.69.1"
74
+ "webpack": "5.70.0"
74
75
  },
75
76
  "engines": {
76
77
  "node": "12.* || 14.* || >= 16"
@@ -34,7 +34,6 @@ caluma:
34
34
  options-empty: "Keine Optionen vorhanden"
35
35
  search-placeholder: "Hier tippen um zu suchen"
36
36
  search-empty: "Keine Optionen gefunden"
37
- null: "Keine Auswahl"
38
37
 
39
38
  validation:
40
39
  blank: "Dieses Feld darf nicht leer gelassen werden"
@@ -44,6 +43,7 @@ caluma:
44
43
  lessThanOrEqualTo: "Die Eingabe in diesem Feld darf nicht grösser als {lte} sein"
45
44
  notAnInteger: "Bitte geben Sie eine ganze Zahl ein"
46
45
  inclusion: "'{value}' ist kein gültiger Wert für dieses Feld"
46
+ deleteFailed: "Beim Löschen ist ein Fehler aufgetreten."
47
47
  uploadFailed: "Beim Hochladen ist ein Fehler aufgetreten."
48
48
  format: "{errorMsg}"
49
49
  table: "Mindestens eine Zeile der Tabelle wurde nicht korrekt ausgefüllt"
@@ -34,7 +34,6 @@ caluma:
34
34
  options-empty: "No options available"
35
35
  search-placeholder: "Type here to search options"
36
36
  search-empty: "Search didn't match any options"
37
- null: "No selection"
38
37
 
39
38
  validation:
40
39
  blank: "This field can't be blank"
@@ -44,6 +43,7 @@ caluma:
44
43
  lessThanOrEqualTo: "The value of this field must be less than or equal to {lte}"
45
44
  notAnInteger: "The value of this field must be an integer"
46
45
  inclusion: "'{value}' is not a valid value for this field"
46
+ deleteFailed: "An error occured during deletion."
47
47
  uploadFailed: "An error occured during upload."
48
48
  format: "{errorMsg}"
49
49
  table: "At least one row of the table was not filled in correctly"
@@ -34,7 +34,6 @@ caluma:
34
34
  options-empty: "Pas d'options disponibles"
35
35
  search-placeholder: "Tapez ici pour rechercher"
36
36
  search-empty: "Pas d'options trouvées"
37
- null: "Aucune sélection"
38
37
 
39
38
  validation:
40
39
  blank: "Ce champ ne doit pas être laissé vide"
@@ -44,6 +43,7 @@ caluma:
44
43
  lessThanOrEqualTo: "L'entrée dans ce champ ne doit pas être supérieure à {lte} "
45
44
  notAnInteger: "Veuillez entrer un nombre entier"
46
45
  inclusion: "'{value}' n'est pas une valeur valide pour ce champ"
46
+ deleteFailed: "Une erreur est survenue lors de la suppression."
47
47
  uploadFailed: "Une erreur s'est produite pendant le téléchargement."
48
48
  format: "{errorMsg}"
49
49
  table: "Au moins une ligne du tableau n'a pas été remplie correctement"