@projectcaluma/ember-form 14.0.0 → 14.1.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/addon/lib/field.js
CHANGED
@@ -339,7 +339,10 @@ export default class Field extends Base {
|
|
339
339
|
* - DynamicMultipleChoiceQuestion
|
340
340
|
*
|
341
341
|
* This will also return the disabled state of the option. An option can only
|
342
|
-
* be disabled
|
342
|
+
* be disabled in any of the following cases:
|
343
|
+
* - it is a dynamic option which is no longer available
|
344
|
+
* - the option has been removed from the form using the form builder
|
345
|
+
* - the option is no longer visible due to its JEXL
|
343
346
|
*
|
344
347
|
* @property {null|Object[]} options
|
345
348
|
*/
|
@@ -352,9 +355,39 @@ export default class Field extends Base {
|
|
352
355
|
const selected =
|
353
356
|
(this.question.isMultipleChoice ? this.value : [this.value]) || [];
|
354
357
|
|
355
|
-
const options = this.question.options
|
356
|
-
(option) => !option.disabled || selected.includes(option.slug)
|
357
|
-
|
358
|
+
const options = this.question.options
|
359
|
+
.filter((option) => !option.disabled || selected.includes(option.slug))
|
360
|
+
.map((option) => {
|
361
|
+
if (!option.isHidden) {
|
362
|
+
return option;
|
363
|
+
}
|
364
|
+
|
365
|
+
try {
|
366
|
+
const isHidden = this.document.jexl.evalSync(
|
367
|
+
option.isHidden,
|
368
|
+
this.jexlContext,
|
369
|
+
);
|
370
|
+
|
371
|
+
if (selected.includes(option.slug) && isHidden) {
|
372
|
+
return {
|
373
|
+
...option,
|
374
|
+
_isHidden: isHidden,
|
375
|
+
disabled: true,
|
376
|
+
};
|
377
|
+
}
|
378
|
+
return {
|
379
|
+
...option,
|
380
|
+
_isHidden: isHidden,
|
381
|
+
};
|
382
|
+
} catch (error) {
|
383
|
+
throw new Error(
|
384
|
+
`Error while evaluating \`isHidden\` expression on Option\`${option.slug}\`: ${error.message}`,
|
385
|
+
);
|
386
|
+
}
|
387
|
+
})
|
388
|
+
.filter(
|
389
|
+
({ _isHidden, disabled }) => !_isHidden || (_isHidden && disabled),
|
390
|
+
);
|
358
391
|
|
359
392
|
const hasUnknownValue = !selected.every((slug) =>
|
360
393
|
options.find((option) => option.slug === slug),
|
package/addon/lib/question.js
CHANGED
@@ -141,11 +141,14 @@ export default class Question extends Base {
|
|
141
141
|
const key = camelize(this.raw.__typename.replace(/Question$/, "Options"));
|
142
142
|
const raw = this.isDynamic ? this[key] : this.raw[key];
|
143
143
|
|
144
|
-
return (raw?.edges || []).map(
|
145
|
-
label,
|
146
|
-
|
147
|
-
|
148
|
-
|
144
|
+
return (raw?.edges || []).map(
|
145
|
+
({ node: { label, slug, isArchived, isHidden } }) => ({
|
146
|
+
label,
|
147
|
+
slug,
|
148
|
+
disabled: isArchived || false,
|
149
|
+
isHidden,
|
150
|
+
}),
|
151
|
+
);
|
149
152
|
}
|
150
153
|
|
151
154
|
/**
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@projectcaluma/ember-form",
|
3
|
-
"version": "14.
|
3
|
+
"version": "14.1.0",
|
4
4
|
"description": "Ember addon for rendering Caluma forms.",
|
5
5
|
"keywords": [
|
6
6
|
"ember-addon"
|
@@ -41,13 +41,13 @@
|
|
41
41
|
"luxon": "^3.5.0",
|
42
42
|
"reactiveweb": "^1.3.0",
|
43
43
|
"tracked-toolbox": "^2.0.0",
|
44
|
-
"@projectcaluma/ember-core": "^14.
|
44
|
+
"@projectcaluma/ember-core": "^14.1.0"
|
45
45
|
},
|
46
46
|
"devDependencies": {
|
47
47
|
"@ember/optional-features": "2.2.0",
|
48
48
|
"@ember/test-helpers": "4.0.4",
|
49
49
|
"@embroider/test-setup": "4.0.0",
|
50
|
-
"@faker-js/faker": "9.
|
50
|
+
"@faker-js/faker": "9.4.0",
|
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.22.0",
|
73
73
|
"uuid": "11.0.5",
|
74
74
|
"webpack": "5.97.1",
|
75
|
-
"@projectcaluma/ember-workflow": "14.
|
76
|
-
"@projectcaluma/ember-testing": "14.
|
75
|
+
"@projectcaluma/ember-workflow": "14.1.0",
|
76
|
+
"@projectcaluma/ember-testing": "14.1.0"
|
77
77
|
},
|
78
78
|
"peerDependencies": {
|
79
79
|
"ember-source": ">= 4.0.0",
|
80
|
-
"@projectcaluma/ember-workflow": "^14.
|
80
|
+
"@projectcaluma/ember-workflow": "^14.1.0"
|
81
81
|
},
|
82
82
|
"dependenciesMeta": {
|
83
83
|
"@projectcaluma/ember-core": {
|