@projectcaluma/ember-form 14.11.0 → 14.12.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,10 +1,11 @@
1
- import { getOwner } from "@ember/application";
2
1
  import { action } from "@ember/object";
3
2
  import { inject as service } from "@ember/service";
4
3
  import Component from "@glimmer/component";
5
4
  import { tracked } from "@glimmer/tracking";
6
5
  import { DateTime } from "luxon";
7
6
 
7
+ import getConfig from "@projectcaluma/ember-core/utils/get-config";
8
+
8
9
  export default class CfFieldInputDateComponent extends Component {
9
10
  @service intl;
10
11
 
@@ -14,21 +15,13 @@ export default class CfFieldInputDateComponent extends Component {
14
15
  return this.intl.primaryLocale.split("-")[0];
15
16
  }
16
17
 
17
- get config() {
18
- return getOwner(this).resolveRegistration("config:environment");
19
- }
20
-
21
18
  get dateFormat() {
22
- const {
23
- FLATPICKR_DATE_FORMAT = {
24
- de: "d.m.Y",
25
- fr: "d.m.Y",
26
- en: "m/d/Y",
27
- },
28
- FLATPICKR_DATE_FORMAT_DEFAULT = "m/d/Y",
29
- } = this.config["ember-caluma"] || {};
19
+ const config = getConfig(this);
30
20
 
31
- return FLATPICKR_DATE_FORMAT[this.locale] ?? FLATPICKR_DATE_FORMAT_DEFAULT;
21
+ return (
22
+ config.FLATPICKR_DATE_FORMAT[this.locale] ??
23
+ config.FLATPICKR_DATE_FORMAT_DEFAULT
24
+ );
32
25
  }
33
26
 
34
27
  @action
@@ -1,7 +1,8 @@
1
- import { getOwner } from "@ember/application";
2
1
  import { action } from "@ember/object";
3
2
  import Component from "@glimmer/component";
4
3
 
4
+ import getConfig from "@projectcaluma/ember-core/utils/get-config";
5
+
5
6
  export default class CfFieldInputFloatComponent extends Component {
6
7
  get disabled() {
7
8
  return this.args.disabled || this.args.field?.question.isCalculated;
@@ -12,9 +13,7 @@ export default class CfFieldInputFloatComponent extends Component {
12
13
  return this.args.field.question.raw.floatStep;
13
14
  }
14
15
 
15
- const config = getOwner(this).resolveRegistration("config:environment");
16
- const { floatStep = 0.001 } = config["ember-caluma"] || {};
17
- return floatStep;
16
+ return getConfig(this).floatStep;
18
17
  }
19
18
 
20
19
  /**
@@ -1,4 +1,3 @@
1
- import { getOwner } from "@ember/application";
2
1
  import { action } from "@ember/object";
3
2
  import { inject as service } from "@ember/service";
4
3
  import { ensureSafeComponent } from "@embroider/util";
@@ -6,6 +5,8 @@ import Component from "@glimmer/component";
6
5
  import PowerSelectComponent from "ember-power-select/components/power-select";
7
6
  import PowerSelectMultipleComponent from "ember-power-select/components/power-select-multiple";
8
7
 
8
+ import getConfig from "@projectcaluma/ember-core/utils/get-config";
9
+
9
10
  /**
10
11
  * Dropdown component for the single and multiple choice question type
11
12
  *
@@ -39,10 +40,10 @@ export default class CfFieldInputPowerselectComponent extends Component {
39
40
  }
40
41
 
41
42
  get searchEnabled() {
42
- const config = getOwner(this).resolveRegistration("config:environment");
43
- const { powerSelectEnableSearchLimit = 10 } = config["ember-caluma"] || {};
44
-
45
- return this.args.field?.options?.length > powerSelectEnableSearchLimit;
43
+ return (
44
+ this.args.field?.options?.length >
45
+ getConfig(this).powerSelectEnableSearchLimit
46
+ );
46
47
  }
47
48
 
48
49
  get placeholder() {
@@ -1,7 +1,7 @@
1
1
  import { action } from "@ember/object";
2
2
  import Component from "@glimmer/component";
3
3
 
4
- export default class CfFieldInpuRadio extends Component {
4
+ export default class CfFieldInputRadio extends Component {
5
5
  isAnswerRemoved = (option) => {
6
6
  return (
7
7
  this.args.compare &&
@@ -1,20 +1,16 @@
1
- import { getOwner } from "@ember/application";
2
1
  import Component from "@glimmer/component";
3
2
 
3
+ import getConfig from "@projectcaluma/ember-core/utils/get-config";
4
+
4
5
  /**
5
6
  * Label component of the CfField
6
7
  *
7
8
  * @class CfFieldLabelComponent
8
9
  */
9
10
  export default class CfFieldLabelComponent extends Component {
10
- get config() {
11
- return getOwner(this).resolveRegistration("config:environment");
12
- }
13
-
14
11
  get useMandatoryAsterisk() {
15
- const { USE_MANDATORY_ASTERISK = false } =
16
- this.config["ember-caluma"] || {};
17
-
18
- return this.args.useMandatoryAsterisk ?? USE_MANDATORY_ASTERISK;
12
+ return (
13
+ this.args.useMandatoryAsterisk ?? getConfig(this).USE_MANDATORY_ASTERISK
14
+ );
19
15
  }
20
16
  }
@@ -1,5 +1,6 @@
1
1
  fragment CaseFormAndWorkflow on Case {
2
2
  id
3
+ meta
3
4
  workflow {
4
5
  id
5
6
  slug
@@ -13,6 +14,7 @@ fragment CaseFormAndWorkflow on Case {
13
14
  }
14
15
  family {
15
16
  id
17
+ meta
16
18
  workflow {
17
19
  id
18
20
  slug
@@ -12,6 +12,10 @@ query DocumentAnswers($id: ID!) {
12
12
  }
13
13
  workItem {
14
14
  id
15
+ meta
16
+ task {
17
+ slug
18
+ }
15
19
  case {
16
20
  ...CaseFormAndWorkflow
17
21
  }
@@ -232,7 +232,9 @@ export default class Document extends Base {
232
232
  * @property {Object} jexlContext
233
233
  */
234
234
  get jexlContext() {
235
- const _case = this.raw.workItem?.case ?? this.raw.case;
235
+ const workItem = this.raw.workItem;
236
+ const _case = workItem?.case ?? this.raw.case;
237
+
236
238
  return (
237
239
  this.parentDocument?.jexlContext ?? {
238
240
  // JEXL interprets null in an expression as variable instead of a
@@ -244,14 +246,24 @@ export default class Document extends Base {
244
246
  form: this.rootForm.slug,
245
247
  formMeta: this.rootForm.raw.meta,
246
248
  },
247
- case: {
248
- form: _case?.document?.form.slug,
249
- workflow: _case?.workflow.slug,
250
- root: {
251
- form: _case?.family.document?.form.slug,
252
- workflow: _case?.family.workflow.slug,
253
- },
254
- },
249
+ case: _case
250
+ ? {
251
+ form: _case.document?.form.slug,
252
+ workflow: _case.workflow.slug,
253
+ meta: _case.meta,
254
+ root: {
255
+ form: _case.family.document?.form.slug,
256
+ workflow: _case.family.workflow.slug,
257
+ meta: _case.family.meta,
258
+ },
259
+ }
260
+ : null,
261
+ workItem: workItem
262
+ ? {
263
+ task: workItem.task.slug,
264
+ meta: workItem.meta,
265
+ }
266
+ : null,
255
267
  },
256
268
  }
257
269
  );
@@ -554,13 +554,17 @@ export default class Field extends Base {
554
554
  * - `info.formMeta`: The meta of the form this question is attached to.
555
555
  * - `info.parent.form`: The parent form if applicable.
556
556
  * - `info.parent.formMeta`: The parent form meta if applicable.
557
- * - `info.parent.question`: The parent field question if applicable.
557
+ * - `info.parent.question`: The parent question (table or form question)
558
558
  * - `info.root.form`: The new property for the root form.
559
559
  * - `info.root.formMeta`: The new property for the root form meta.
560
560
  * - `info.case.form`: The cases' form (works for task forms and case forms).
561
561
  * - `info.case.workflow`: The cases' workflow (works for task forms and case forms).
562
+ * - `info.case.meta`: The cases' meta (works for task forms and case forms).
562
563
  * - `info.case.root.form`: The _root_ cases' form (works for task forms and case forms).
563
564
  * - `info.case.root.workflow`: The _root_ cases' workflow (works for task forms and case forms).
565
+ * - `info.case.root.meta`: The _root_ cases' meta (works for task forms and case forms).
566
+ * - `info.workItem.task`: The task slug of the work item
567
+ * - `info.workItem.meta`: The meta of the work item
564
568
  *
565
569
  * @property {Object} jexlContext
566
570
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@projectcaluma/ember-form",
3
- "version": "14.11.0",
3
+ "version": "14.12.0",
4
4
  "description": "Ember addon for rendering Caluma forms.",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -39,7 +39,7 @@
39
39
  "luxon": "^3.5.0",
40
40
  "reactiveweb": "^1.3.0",
41
41
  "tracked-toolbox": "^2.0.0",
42
- "@projectcaluma/ember-core": "^14.11.0"
42
+ "@projectcaluma/ember-core": "^14.12.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@ember/optional-features": "2.3.0",
@@ -74,12 +74,12 @@
74
74
  "uikit": "3.25.6",
75
75
  "uuid": "13.0.0",
76
76
  "webpack": "5.104.1",
77
- "@projectcaluma/ember-workflow": "14.11.0",
78
- "@projectcaluma/ember-testing": "14.11.0"
77
+ "@projectcaluma/ember-testing": "14.12.0",
78
+ "@projectcaluma/ember-workflow": "14.12.0"
79
79
  },
80
80
  "peerDependencies": {
81
81
  "ember-source": ">= 4.0.0",
82
- "@projectcaluma/ember-workflow": "^14.11.0"
82
+ "@projectcaluma/ember-workflow": "^14.12.0"
83
83
  },
84
84
  "dependenciesMeta": {
85
85
  "@projectcaluma/ember-core": {