case-editor-tools 1.0.0-beta.3 → 1.0.0-beta.30
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/{build/constants → constants}/key-definitions.d.ts +1 -0
- package/{build/constants → constants}/key-definitions.js +3 -1
- package/{build/constants → constants}/key-definitions.js.map +1 -1
- package/exporter/index.d.ts +2 -0
- package/exporter/index.js +99 -0
- package/exporter/index.js.map +1 -0
- package/{build/expression-utils → expression-utils}/expressionGen.d.ts +1 -1
- package/{build/expression-utils → expression-utils}/expressionGen.js +0 -0
- package/{build/expression-utils → expression-utils}/expressionGen.js.map +0 -0
- package/{build/expression-utils → expression-utils}/studyEngineExpressions.d.ts +37 -7
- package/{build/expression-utils → expression-utils}/studyEngineExpressions.js +93 -4
- package/{build/expression-utils → expression-utils}/studyEngineExpressions.js.map +1 -1
- package/{build/index.d.ts → index.d.ts} +0 -0
- package/{build/index.js → index.js} +0 -0
- package/{build/index.js.map → index.js.map} +0 -0
- package/{build/item-editor-8fd24b61.js → item-editor-c6933791.js} +69 -51
- package/item-editor-c6933791.js.map +1 -0
- package/logger/index.d.ts +1 -0
- package/logger/index.js +10 -0
- package/logger/index.js.map +1 -0
- package/{build/logger → logger}/logger.d.ts +0 -0
- package/{build/logger → logger}/logger.js +0 -0
- package/{build/logger → logger}/logger.js.map +0 -0
- package/package.json +7 -8
- package/surveys/index.d.ts +3 -0
- package/surveys/index.js +28 -0
- package/surveys/index.js.map +1 -0
- package/surveys/responseTypeGenerators/likertGroupComponents.d.ts +27 -0
- package/surveys/responseTypeGenerators/likertGroupComponents.js +347 -0
- package/surveys/responseTypeGenerators/likertGroupComponents.js.map +1 -0
- package/surveys/responseTypeGenerators/matrixGroupComponent.d.ts +49 -0
- package/surveys/responseTypeGenerators/matrixGroupComponent.js +99 -0
- package/surveys/responseTypeGenerators/matrixGroupComponent.js.map +1 -0
- package/surveys/responseTypeGenerators/optionGroupComponents.d.ts +7 -0
- package/surveys/responseTypeGenerators/optionGroupComponents.js +125 -0
- package/surveys/responseTypeGenerators/optionGroupComponents.js.map +1 -0
- package/{build → surveys}/survey-editor/component-editor.d.ts +1 -1
- package/{build → surveys}/survey-editor/component-editor.js +0 -0
- package/{build → surveys}/survey-editor/component-editor.js.map +0 -0
- package/{build → surveys}/survey-editor/data-types.d.ts +1 -1
- package/{build → surveys}/survey-editor/data-types.js +0 -0
- package/{build → surveys}/survey-editor/data-types.js.map +0 -0
- package/{build → surveys}/survey-editor/item-editor.d.ts +1 -1
- package/{build → surveys}/survey-editor/item-editor.js +3 -2
- package/{build → surveys}/survey-editor/item-editor.js.map +1 -1
- package/{build → surveys}/survey-editor/survey-editor.d.ts +6 -1
- package/{build → surveys}/survey-editor/survey-editor.js +15 -8
- package/{build → surveys}/survey-editor/survey-editor.js.map +1 -1
- package/{build/expression-utils/surveyEngineExpressions.d.ts → surveys/survey-engine-expressions.d.ts} +9 -2
- package/{build/expression-utils/surveyEngineExpressions.js → surveys/survey-engine-expressions.js} +36 -4
- package/{build/expression-utils/surveyEngineExpressions.js.map → surveys/survey-engine-expressions.js.map} +1 -1
- package/surveys/survey-items.d.ts +66 -0
- package/surveys/survey-items.js +302 -0
- package/surveys/survey-items.js.map +1 -0
- package/{build → surveys}/types/group.d.ts +1 -1
- package/{build → surveys}/types/group.js +5 -5
- package/{build → surveys}/types/group.js.map +0 -0
- package/surveys/types/index.d.ts +4 -0
- package/surveys/types/index.js +20 -0
- package/surveys/types/index.js.map +1 -0
- package/surveys/types/item-properties.d.ts +189 -0
- package/surveys/types/item-properties.js +3 -0
- package/surveys/types/item-properties.js.map +1 -0
- package/{build → surveys}/types/item.d.ts +1 -1
- package/{build → surveys}/types/item.js +0 -0
- package/{build → surveys}/types/item.js.map +0 -0
- package/{build/types/surveyDefinition.d.ts → surveys/types/survey-definition.d.ts} +7 -3
- package/{build/types/surveyDefinition.js → surveys/types/survey-definition.js} +19 -11
- package/surveys/types/survey-definition.js.map +1 -0
- package/{build → surveys}/utils/componentGenerators.d.ts +2 -13
- package/surveys/utils/componentGenerators.js +58 -0
- package/{build → surveys}/utils/componentGenerators.js.map +1 -1
- package/surveys/utils/optionDefGenerators.d.ts +69 -0
- package/surveys/utils/optionDefGenerators.js +169 -0
- package/surveys/utils/optionDefGenerators.js.map +1 -0
- package/{build → surveys}/utils/randomKeyGenerator.d.ts +0 -0
- package/{build → surveys}/utils/randomKeyGenerator.js +0 -0
- package/{build → surveys}/utils/randomKeyGenerator.js.map +0 -0
- package/{build → surveys}/utils/simple-generators.d.ts +2 -2
- package/{build → surveys}/utils/simple-generators.js +5 -5
- package/{build → surveys}/utils/simple-generators.js.map +0 -0
- package/{build → surveys}/utils/simple-question-editor.d.ts +3 -3
- package/{build → surveys}/utils/simple-question-editor.js +7 -6
- package/{build → surveys}/utils/simple-question-editor.js.map +1 -1
- package/{build/types → types}/duration.d.ts +0 -0
- package/{build/types → types}/duration.js +0 -0
- package/{build/types → types}/duration.js.map +0 -0
- package/{build/types → types}/expression.d.ts +1 -1
- package/{build/types → types}/expression.js +0 -0
- package/{build/types → types}/expression.js.map +0 -0
- package/{build/types → types}/study.d.ts +2 -2
- package/{build/types → types}/study.js +0 -0
- package/{build/types → types}/study.js.map +0 -0
- package/{build/types → types}/studyRules.d.ts +1 -1
- package/{build/types → types}/studyRules.js +0 -0
- package/{build/types → types}/studyRules.js.map +0 -0
- package/.babelrc.js +0 -7
- package/.editorconfig +0 -13
- package/LICENSE +0 -202
- package/build/item-editor-8fd24b61.js.map +0 -1
- package/build/package.json +0 -26
- package/build/types/surveyDefinition.js.map +0 -1
- package/build/utils/componentGenerators.js +0 -92
- package/build/utils/question-type-generator.d.ts +0 -283
- package/build/utils/question-type-generator.js +0 -949
- package/build/utils/question-type-generator.js.map +0 -1
- package/rollup.config.js +0 -53
- package/src/constants/key-definitions.ts +0 -13
- package/src/expression-utils/expressionGen.ts +0 -28
- package/src/expression-utils/studyEngineExpressions.ts +0 -359
- package/src/expression-utils/surveyEngineExpressions.ts +0 -483
- package/src/index.ts +0 -1
- package/src/logger/logger.ts +0 -31
- package/src/survey-editor/component-editor.ts +0 -133
- package/src/survey-editor/data-types.ts +0 -18
- package/src/survey-editor/item-editor.ts +0 -528
- package/src/survey-editor/survey-editor.ts +0 -260
- package/src/types/duration.ts +0 -32
- package/src/types/expression.ts +0 -22
- package/src/types/group.ts +0 -73
- package/src/types/item.ts +0 -42
- package/src/types/study.ts +0 -17
- package/src/types/studyRules.ts +0 -39
- package/src/types/surveyDefinition.ts +0 -83
- package/src/utils/componentGenerators.ts +0 -122
- package/src/utils/question-type-generator.ts +0 -1516
- package/src/utils/randomKeyGenerator.ts +0 -11
- package/src/utils/simple-generators.ts +0 -106
- package/src/utils/simple-question-editor.ts +0 -52
- package/tsconfig.json +0 -100
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var surveys_surveyEditor_componentEditor = require('../survey-editor/component-editor.js');
|
|
6
|
+
var surveys_utils_simpleGenerators = require('../utils/simple-generators.js');
|
|
7
|
+
require('../utils/randomKeyGenerator.js');
|
|
8
|
+
|
|
9
|
+
const optionDefToItemComponent = (optionDef) => {
|
|
10
|
+
const isGroup = optionDef.items && optionDef.items.length > 0;
|
|
11
|
+
const optEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
12
|
+
key: optionDef.key,
|
|
13
|
+
role: optionDef.role,
|
|
14
|
+
isGroup: isGroup
|
|
15
|
+
});
|
|
16
|
+
if (isGroup) {
|
|
17
|
+
optEditor.setOrder({
|
|
18
|
+
name: 'sequential'
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
if (optionDef.content) {
|
|
22
|
+
optEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(optionDef.content));
|
|
23
|
+
}
|
|
24
|
+
if (optionDef.description) {
|
|
25
|
+
optEditor.setDescription(surveys_utils_simpleGenerators.generateLocStrings(optionDef.description));
|
|
26
|
+
}
|
|
27
|
+
switch (optionDef.role) {
|
|
28
|
+
case 'date':
|
|
29
|
+
optEditor.setDType('date');
|
|
30
|
+
break;
|
|
31
|
+
case 'numberInput':
|
|
32
|
+
optEditor.setDType('number');
|
|
33
|
+
break;
|
|
34
|
+
}
|
|
35
|
+
if (optionDef.displayCondition) {
|
|
36
|
+
optEditor.setDisplayCondition(optionDef.displayCondition);
|
|
37
|
+
}
|
|
38
|
+
if (optionDef.disabled) {
|
|
39
|
+
optEditor.setDisabled(optionDef.disabled);
|
|
40
|
+
}
|
|
41
|
+
if (optionDef.style) {
|
|
42
|
+
optEditor.setStyles(optionDef.style);
|
|
43
|
+
}
|
|
44
|
+
if (optionDef.optionProps) {
|
|
45
|
+
if (typeof (optionDef.optionProps.min) === 'number') {
|
|
46
|
+
optionDef.optionProps.min = { dtype: 'num', num: optionDef.optionProps.min };
|
|
47
|
+
}
|
|
48
|
+
if (typeof (optionDef.optionProps.max) === 'number') {
|
|
49
|
+
optionDef.optionProps.max = { dtype: 'num', num: optionDef.optionProps.max };
|
|
50
|
+
}
|
|
51
|
+
if (typeof (optionDef.optionProps.stepSize) === 'number') {
|
|
52
|
+
optionDef.optionProps.stepSize = { dtype: 'num', num: optionDef.optionProps.stepSize };
|
|
53
|
+
}
|
|
54
|
+
optEditor.setProperties(optionDef.optionProps);
|
|
55
|
+
}
|
|
56
|
+
if (optionDef.items) {
|
|
57
|
+
if (optionDef.role === 'text') {
|
|
58
|
+
optionDef.items.forEach((item, index) => {
|
|
59
|
+
const textItem = item;
|
|
60
|
+
optEditor.addItemComponent({
|
|
61
|
+
key: index.toFixed(),
|
|
62
|
+
role: 'text',
|
|
63
|
+
content: surveys_utils_simpleGenerators.generateLocStrings(textItem.content),
|
|
64
|
+
style: textItem.className ? [{ key: 'className', value: textItem.className }] : undefined
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
optionDef.items.forEach((item) => {
|
|
70
|
+
const clozeItem = item;
|
|
71
|
+
const comp = optionDefToItemComponent(clozeItem);
|
|
72
|
+
optEditor.addItemComponent(comp);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return optEditor.getComponent();
|
|
77
|
+
};
|
|
78
|
+
const initResponseGroup = (type, key, optionItems, order, groupDisabled, groupContent, groupDescription) => {
|
|
79
|
+
// init group
|
|
80
|
+
const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
81
|
+
key: key,
|
|
82
|
+
isGroup: true,
|
|
83
|
+
role: type,
|
|
84
|
+
});
|
|
85
|
+
groupEdit.setOrder(order ? order : {
|
|
86
|
+
name: 'sequential'
|
|
87
|
+
});
|
|
88
|
+
if (groupDisabled) {
|
|
89
|
+
groupEdit.setDisabled(groupDisabled);
|
|
90
|
+
}
|
|
91
|
+
if (groupContent) {
|
|
92
|
+
groupEdit.setContent(groupContent);
|
|
93
|
+
}
|
|
94
|
+
if (groupDescription) {
|
|
95
|
+
groupEdit.setDescription(groupDescription);
|
|
96
|
+
}
|
|
97
|
+
// add option items
|
|
98
|
+
optionItems.forEach(optionDef => {
|
|
99
|
+
groupEdit.addItemComponent(optionDefToItemComponent(optionDef));
|
|
100
|
+
});
|
|
101
|
+
return groupEdit.getComponent();
|
|
102
|
+
};
|
|
103
|
+
const initSingleChoiceGroup = (key, optionItems, order) => {
|
|
104
|
+
// init group
|
|
105
|
+
return initResponseGroup('singleChoiceGroup', key, optionItems, order);
|
|
106
|
+
};
|
|
107
|
+
const initMultipleChoiceGroup = (key, optionItems, order) => {
|
|
108
|
+
// init group
|
|
109
|
+
return initResponseGroup('multipleChoiceGroup', key, optionItems, order);
|
|
110
|
+
};
|
|
111
|
+
const initDropdownGroup = (key, optionItems, order, groupDisabled, groupContent, groupDescription) => {
|
|
112
|
+
// init group
|
|
113
|
+
return initResponseGroup('dropDownGroup', key, optionItems, order, groupDisabled, groupContent ? surveys_utils_simpleGenerators.generateLocStrings(groupContent) : undefined, groupDescription ? surveys_utils_simpleGenerators.generateLocStrings(groupDescription) : undefined);
|
|
114
|
+
};
|
|
115
|
+
const initSliderCategoricalGroup = (key, optionItems, order, groupDisabled) => {
|
|
116
|
+
// init group
|
|
117
|
+
return initResponseGroup('sliderCategorical', key, optionItems, order, groupDisabled);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
exports.initDropdownGroup = initDropdownGroup;
|
|
121
|
+
exports.initMultipleChoiceGroup = initMultipleChoiceGroup;
|
|
122
|
+
exports.initSingleChoiceGroup = initSingleChoiceGroup;
|
|
123
|
+
exports.initSliderCategoricalGroup = initSliderCategoricalGroup;
|
|
124
|
+
exports.optionDefToItemComponent = optionDefToItemComponent;
|
|
125
|
+
//# sourceMappingURL=optionGroupComponents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"optionGroupComponents.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ItemComponent, Expression, LocalizedObject, ComponentProperties } from "survey-engine/
|
|
1
|
+
import { ItemComponent, Expression, LocalizedObject, ComponentProperties } from "survey-engine/data_types";
|
|
2
2
|
import { NewComponentProps } from "./data-types";
|
|
3
3
|
interface ComponentEditorInt {
|
|
4
4
|
getComponent: () => ItemComponent;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SurveyItem, SurveyItemTypes, Expression, Validation, ItemComponent, ItemGroupComponent } from "survey-engine/
|
|
1
|
+
import { SurveyItem, SurveyItemTypes, Expression, Validation, ItemComponent, ItemGroupComponent } from "survey-engine/data_types";
|
|
2
2
|
import { NewItemProps, NewComponentProps } from "./data-types";
|
|
3
3
|
interface ItemEditorInt {
|
|
4
4
|
getItem: () => SurveyItem;
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var surveys_surveyEditor_itemEditor = require('../../item-editor-c6933791.js');
|
|
6
6
|
require('./component-editor.js');
|
|
7
7
|
require('../utils/randomKeyGenerator.js');
|
|
8
|
+
require('../../logger/logger.js');
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
exports.ItemEditor =
|
|
12
|
+
exports.ItemEditor = surveys_surveyEditor_itemEditor.ItemEditor;
|
|
12
13
|
//# sourceMappingURL=item-editor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item-editor.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"item-editor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Survey, LocalizedString, SurveyItem, SurveyContextDef, Expression } from "survey-engine/
|
|
1
|
+
import { Survey, LocalizedString, SurveyItem, SurveyContextDef, Expression } from "survey-engine/data_types";
|
|
2
|
+
import { SurveyAvailableFor } from "../types";
|
|
2
3
|
import { NewItemProps } from "./data-types";
|
|
3
4
|
interface SurveyEditorInt {
|
|
4
5
|
setSurveyName: (name: Array<LocalizedString>) => void;
|
|
@@ -6,6 +7,8 @@ interface SurveyEditorInt {
|
|
|
6
7
|
setSurveyDuration: (duration: Array<LocalizedString>) => void;
|
|
7
8
|
setSurveyContextRules: (contextRules: SurveyContextDef) => void;
|
|
8
9
|
setPrefillRules: (rules: Expression[]) => void;
|
|
10
|
+
setAvailableFor: (value?: SurveyAvailableFor) => void;
|
|
11
|
+
setRequireLoginBeforeSubmission: (value?: boolean) => void;
|
|
9
12
|
changeItemKey: (oldKey: string, newKey: string) => void;
|
|
10
13
|
addNewSurveyItem: (itemProps: NewItemProps, parentKey?: string, atPosition?: number) => SurveyItem | undefined;
|
|
11
14
|
updateSurveyItem: (item: SurveyItem) => void;
|
|
@@ -26,6 +29,8 @@ export declare class SurveyEditor implements SurveyEditorInt {
|
|
|
26
29
|
small: number;
|
|
27
30
|
large: number;
|
|
28
31
|
}): void;
|
|
32
|
+
setAvailableFor(value?: SurveyAvailableFor | undefined): void;
|
|
33
|
+
setRequireLoginBeforeSubmission(value?: boolean | undefined): void;
|
|
29
34
|
setSurveyContextRules(contextRules: SurveyContextDef): void;
|
|
30
35
|
setPrefillRules(rules: Expression[]): void;
|
|
31
36
|
addNewSurveyItem(newItem: NewItemProps, parentKey?: string, atPosition?: number): SurveyItem | undefined;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var surveys_surveyEditor_itemEditor = require('../../item-editor-c6933791.js');
|
|
6
|
+
var logger_logger = require('../../logger/logger.js');
|
|
6
7
|
require('./component-editor.js');
|
|
7
8
|
require('../utils/randomKeyGenerator.js');
|
|
8
9
|
|
|
@@ -51,6 +52,12 @@ class SurveyEditor {
|
|
|
51
52
|
setMaxItemPerPage(itemLimits) {
|
|
52
53
|
this.survey.maxItemsPerPage = itemLimits;
|
|
53
54
|
}
|
|
55
|
+
setAvailableFor(value) {
|
|
56
|
+
this.survey.availableFor = value;
|
|
57
|
+
}
|
|
58
|
+
setRequireLoginBeforeSubmission(value) {
|
|
59
|
+
this.survey.requireLoginBeforeSubmission = value;
|
|
60
|
+
}
|
|
54
61
|
setSurveyContextRules(contextRules) {
|
|
55
62
|
this.survey.contextRules = Object.assign({}, contextRules);
|
|
56
63
|
}
|
|
@@ -63,10 +70,10 @@ class SurveyEditor {
|
|
|
63
70
|
if (!parentKey) {
|
|
64
71
|
newItem.itemKey = this.surveyKey + '.' + newItem.itemKey;
|
|
65
72
|
if (this.survey.current.surveyDefinition.items.find(it => newItem.itemKey === it.key)) {
|
|
66
|
-
|
|
73
|
+
logger_logger.Logger.criticalError('Duplicate key in survey: ' + newItem.itemKey);
|
|
67
74
|
return undefined;
|
|
68
75
|
}
|
|
69
|
-
const item = (new
|
|
76
|
+
const item = (new surveys_surveyEditor_itemEditor.ItemEditor(undefined, newItem)).getItem();
|
|
70
77
|
if (atPosition !== undefined) {
|
|
71
78
|
this.survey.current.surveyDefinition.items.splice(atPosition, 0, item);
|
|
72
79
|
}
|
|
@@ -82,10 +89,10 @@ class SurveyEditor {
|
|
|
82
89
|
}
|
|
83
90
|
newItem.itemKey = parentKey + '.' + newItem.itemKey;
|
|
84
91
|
if (obj.items.find(it => newItem.itemKey === it.key)) {
|
|
85
|
-
|
|
92
|
+
logger_logger.Logger.criticalError('Duplicate key in survey: ' + newItem.itemKey);
|
|
86
93
|
return undefined;
|
|
87
94
|
}
|
|
88
|
-
const item = (new
|
|
95
|
+
const item = (new surveys_surveyEditor_itemEditor.ItemEditor(undefined, newItem)).getItem();
|
|
89
96
|
if (atPosition !== undefined) {
|
|
90
97
|
obj.items.splice(atPosition, 0, item);
|
|
91
98
|
}
|
|
@@ -101,7 +108,7 @@ class SurveyEditor {
|
|
|
101
108
|
return;
|
|
102
109
|
}
|
|
103
110
|
if (parent.items.find(it => surveyItem.key === it.key)) {
|
|
104
|
-
|
|
111
|
+
logger_logger.Logger.criticalError('Duplicate key in survey: ' + surveyItem.key);
|
|
105
112
|
return undefined;
|
|
106
113
|
}
|
|
107
114
|
if (atPosition !== undefined) {
|
|
@@ -175,7 +182,7 @@ class SurveyEditor {
|
|
|
175
182
|
obj = this.survey.current.surveyDefinition;
|
|
176
183
|
continue;
|
|
177
184
|
}
|
|
178
|
-
if (!
|
|
185
|
+
if (!surveys_surveyEditor_itemEditor.isSurveyGroupItem(obj)) {
|
|
179
186
|
console.warn('survey item is not a group: ', obj.key);
|
|
180
187
|
return;
|
|
181
188
|
}
|
|
@@ -215,7 +222,7 @@ class SurveyEditor {
|
|
|
215
222
|
}
|
|
216
223
|
changeItemKeyForSubtree(currentItem, newKey) {
|
|
217
224
|
currentItem = Object.assign({}, currentItem);
|
|
218
|
-
if (
|
|
225
|
+
if (surveys_surveyEditor_itemEditor.isSurveyGroupItem(currentItem)) {
|
|
219
226
|
currentItem.items = currentItem.items.map(item => {
|
|
220
227
|
const newSubkey = newKey + '.' + item.key.slice(item.key.lastIndexOf('.') + 1);
|
|
221
228
|
return this.changeItemKeyForSubtree(item, newSubkey);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"survey-editor.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"survey-editor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Expression } from "survey-engine/
|
|
1
|
+
import { Expression } from "survey-engine/data_types";
|
|
2
2
|
import { Duration } from "../types/duration";
|
|
3
3
|
export declare const NativeSurveyEngineExpressions: {
|
|
4
4
|
getters: {
|
|
@@ -22,6 +22,7 @@ export declare const NativeSurveyEngineExpressions: {
|
|
|
22
22
|
isDefined: (arg: Expression) => Expression;
|
|
23
23
|
hasResponse: (itemKey: string, responseKey: string) => Expression;
|
|
24
24
|
getResponseItem: (itemKey: string, responseKey: string) => Expression;
|
|
25
|
+
parseValueAsNum: (valueRef: Expression) => Expression;
|
|
25
26
|
getResponseValueAsNum: (itemKey: string, responseKey: string) => Expression;
|
|
26
27
|
getResponseValueAsStr: (itemKey: string, responseKey: string) => Expression;
|
|
27
28
|
checkResponseValueWithRegex: (itemKey: string, responseKey: string, regexPattern: string) => Expression;
|
|
@@ -72,7 +73,12 @@ export declare const SurveyEngine: {
|
|
|
72
73
|
datePicker: {
|
|
73
74
|
get: (itemKey: string) => Expression;
|
|
74
75
|
};
|
|
75
|
-
|
|
76
|
+
participantFlags: {
|
|
77
|
+
hasKey: (key: string) => Expression;
|
|
78
|
+
hasKeyAndValue: (key: string, value: string) => Expression;
|
|
79
|
+
getAsNum: (key: string) => Expression;
|
|
80
|
+
};
|
|
81
|
+
isLoggedIn: () => Expression;
|
|
76
82
|
getters: {
|
|
77
83
|
getContext: () => Expression;
|
|
78
84
|
getResponses: () => Expression;
|
|
@@ -94,6 +100,7 @@ export declare const SurveyEngine: {
|
|
|
94
100
|
isDefined: (arg: Expression) => Expression;
|
|
95
101
|
hasResponse: (itemKey: string, responseKey: string) => Expression;
|
|
96
102
|
getResponseItem: (itemKey: string, responseKey: string) => Expression;
|
|
103
|
+
parseValueAsNum: (valueRef: Expression) => Expression;
|
|
97
104
|
getResponseValueAsNum: (itemKey: string, responseKey: string) => Expression;
|
|
98
105
|
getResponseValueAsStr: (itemKey: string, responseKey: string) => Expression;
|
|
99
106
|
checkResponseValueWithRegex: (itemKey: string, responseKey: string, regexPattern: string) => Expression;
|
package/{build/expression-utils/surveyEngineExpressions.js → surveys/survey-engine-expressions.js}
RENAMED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var constants_keyDefinitions = require('../constants/key-definitions.js');
|
|
6
6
|
var types_duration = require('../types/duration.js');
|
|
7
|
-
var expressionUtils_expressionGen = require('
|
|
7
|
+
var expressionUtils_expressionGen = require('../expression-utils/expressionGen.js');
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Logical OR expression
|
|
@@ -61,6 +61,14 @@ const gte = (val1, val2) => expressionUtils_expressionGen.generateExpression('gt
|
|
|
61
61
|
* @returns
|
|
62
62
|
*/
|
|
63
63
|
const timestampWithOffset = (delta, reference) => expressionUtils_expressionGen.generateExpression('timestampWithOffset', undefined, types_duration.durationObjectToSeconds(delta), reference ? reference : undefined);
|
|
64
|
+
/**
|
|
65
|
+
* Parse the result of an expression as a number
|
|
66
|
+
* @param valueRef expression that returns a string with the value that should be parsed
|
|
67
|
+
* @returns expression that returns the value or undefined
|
|
68
|
+
*/
|
|
69
|
+
const parseValueAsNum = (valueRef) => {
|
|
70
|
+
return expressionUtils_expressionGen.generateExpression('parseValueAsNum', 'float', valueRef);
|
|
71
|
+
};
|
|
64
72
|
/**
|
|
65
73
|
* Extract value from a response if exits parsed as a number
|
|
66
74
|
* @param itemKey full key of the survey item (e.g. SURVEY.GROUP.QUESTIONKEY)
|
|
@@ -286,15 +294,34 @@ const getSurveyItemValidation = (itemKey, validationKey) => {
|
|
|
286
294
|
const dateResponseDiffFromNow = (itemKey, responseKey, unit, ignoreSign) => {
|
|
287
295
|
return expressionUtils_expressionGen.generateExpression('dateResponseDiffFromNow', undefined, itemKey, responseKey, unit, ignoreSign ? 1 : undefined);
|
|
288
296
|
};
|
|
297
|
+
/**
|
|
298
|
+
* Check participant flags object if contains the specified key value pair
|
|
299
|
+
* @param key retrieve participant flag's value for this key
|
|
300
|
+
* @returns
|
|
301
|
+
*/
|
|
302
|
+
const parseParticipantFlagAsNum = (key) => {
|
|
303
|
+
return parseValueAsNum(getAttribute(getAttribute(getContext(), 'participantFlags'), key));
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* Check participant flags object if contains the specified key value pair
|
|
307
|
+
* @param key retrieve participant flag's value for this key
|
|
308
|
+
* @returns
|
|
309
|
+
*/
|
|
310
|
+
const hasParticipantFlagKey = (key) => {
|
|
311
|
+
return isDefined(getAttribute(getAttribute(getContext(), 'participantFlags'), key));
|
|
312
|
+
};
|
|
289
313
|
/**
|
|
290
314
|
* Check participant flags object if contains the specified key value pair
|
|
291
315
|
* @param key retrieve participant flag's value for this key
|
|
292
316
|
* @param value string value to be checked for a match
|
|
293
317
|
* @returns
|
|
294
318
|
*/
|
|
295
|
-
const
|
|
319
|
+
const hasParticipantFlagKeyAndValue = (key, value) => {
|
|
296
320
|
return eq(getAttribute(getAttribute(getContext(), 'participantFlags'), key), value);
|
|
297
321
|
};
|
|
322
|
+
const isLoggedIn = () => {
|
|
323
|
+
return getAttribute(getContext(), 'isLoggedIn');
|
|
324
|
+
};
|
|
298
325
|
/**
|
|
299
326
|
* Counts the number of selected options in a multiple choice question
|
|
300
327
|
* @param itemKey full key of the survey item (e.g. SURVEY.GROUP.QUESTIONKEY)
|
|
@@ -355,6 +382,7 @@ const NativeSurveyEngineExpressions = {
|
|
|
355
382
|
isDefined,
|
|
356
383
|
hasResponse,
|
|
357
384
|
getResponseItem,
|
|
385
|
+
parseValueAsNum,
|
|
358
386
|
getResponseValueAsNum,
|
|
359
387
|
getResponseValueAsStr,
|
|
360
388
|
checkResponseValueWithRegex,
|
|
@@ -400,8 +428,12 @@ const SurveyEngine = Object.assign(Object.assign({}, NativeSurveyEngineExpressio
|
|
|
400
428
|
regexCheck: multilineTextInputRegexCheck,
|
|
401
429
|
}, datePicker: {
|
|
402
430
|
get: getDatePickerResponseValue,
|
|
403
|
-
},
|
|
431
|
+
}, participantFlags: {
|
|
432
|
+
hasKey: hasParticipantFlagKey,
|
|
433
|
+
hasKeyAndValue: hasParticipantFlagKeyAndValue,
|
|
434
|
+
getAsNum: parseParticipantFlagAsNum,
|
|
435
|
+
}, isLoggedIn });
|
|
404
436
|
|
|
405
437
|
exports.NativeSurveyEngineExpressions = NativeSurveyEngineExpressions;
|
|
406
438
|
exports.SurveyEngine = SurveyEngine;
|
|
407
|
-
//# sourceMappingURL=
|
|
439
|
+
//# sourceMappingURL=survey-engine-expressions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"survey-engine-expressions.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ItemGroupComponent, Expression, ItemComponent, SurveyItem, ExpressionArg, ResponseComponent } from "survey-engine/data_types";
|
|
2
|
+
import { ClozeQuestionProps, DateInputQuestionProps, GenericQuestionProps, MultiLineTextInput, NumericInputQuestionProps, OptionDef, ResponsiveBipolarLikertArrayQuestionProps, ResponsiveSingleChoiceArrayQuestionProps, TextInputQuestionProps } from "./types/item-properties";
|
|
3
|
+
import { LikertGroupRow } from "./responseTypeGenerators/likertGroupComponents";
|
|
4
|
+
interface OptionQuestionProps extends GenericQuestionProps {
|
|
5
|
+
responseOptions: Array<OptionDef>;
|
|
6
|
+
}
|
|
7
|
+
interface LikertGroupQuestionProps extends GenericQuestionProps {
|
|
8
|
+
rows: Array<LikertGroupRow>;
|
|
9
|
+
scaleOptions: Array<{
|
|
10
|
+
key: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
content: Map<string, string>;
|
|
13
|
+
}>;
|
|
14
|
+
stackOnSmallScreen?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface NumericSliderProps extends GenericQuestionProps {
|
|
17
|
+
sliderLabel: Map<string, string>;
|
|
18
|
+
noResponseLabel: Map<string, string>;
|
|
19
|
+
min?: number | ExpressionArg;
|
|
20
|
+
max?: number | ExpressionArg;
|
|
21
|
+
stepSize?: number | ExpressionArg;
|
|
22
|
+
}
|
|
23
|
+
interface CustomResponseItem extends ResponseComponent {
|
|
24
|
+
mapToRole?: 'singleChoiceGroup' | 'multipleChoiceGroup' | 'input';
|
|
25
|
+
items?: ItemComponent[];
|
|
26
|
+
}
|
|
27
|
+
interface CustomQuestionProps extends GenericQuestionProps {
|
|
28
|
+
responseItemDefs: CustomResponseItem[];
|
|
29
|
+
}
|
|
30
|
+
interface DisplayProps {
|
|
31
|
+
parentKey: string;
|
|
32
|
+
itemKey: string;
|
|
33
|
+
content: Array<ItemComponent>;
|
|
34
|
+
condition?: Expression;
|
|
35
|
+
}
|
|
36
|
+
interface EQ5DHealthSliderProps {
|
|
37
|
+
role: 'eq5d-health-indicator';
|
|
38
|
+
key: string;
|
|
39
|
+
displayCondition?: Expression;
|
|
40
|
+
disabled?: Expression;
|
|
41
|
+
instructionText: Map<string, string>;
|
|
42
|
+
valueBoxText: Map<string, string>;
|
|
43
|
+
maxHealthText: Map<string, string>;
|
|
44
|
+
minHealthText: Map<string, string>;
|
|
45
|
+
}
|
|
46
|
+
export declare const initEQ5DHealthIndicatorQuestion: (props: EQ5DHealthSliderProps) => ItemGroupComponent;
|
|
47
|
+
export declare const SurveyItems: {
|
|
48
|
+
singleChoice: (props: OptionQuestionProps) => SurveyItem;
|
|
49
|
+
responsiveSingleChoiceArray: (props: ResponsiveSingleChoiceArrayQuestionProps) => SurveyItem;
|
|
50
|
+
responsiveBipolarLikertArray: (props: ResponsiveBipolarLikertArrayQuestionProps) => SurveyItem;
|
|
51
|
+
multipleChoice: (props: OptionQuestionProps) => SurveyItem;
|
|
52
|
+
dateInput: (props: DateInputQuestionProps) => SurveyItem;
|
|
53
|
+
textInput: (props: TextInputQuestionProps) => SurveyItem;
|
|
54
|
+
clozeQuestion: (props: ClozeQuestionProps) => SurveyItem;
|
|
55
|
+
numericInput: (props: NumericInputQuestionProps) => SurveyItem;
|
|
56
|
+
multilineTextInput: (props: MultiLineTextInput) => SurveyItem;
|
|
57
|
+
dropDown: (props: OptionQuestionProps) => SurveyItem;
|
|
58
|
+
numericSlider: (props: NumericSliderProps) => SurveyItem;
|
|
59
|
+
display: (props: DisplayProps) => SurveyItem;
|
|
60
|
+
surveyEnd: (parentKey: string, content: Map<string, string>, condition?: Expression | undefined) => SurveyItem;
|
|
61
|
+
customQuestion: (props: CustomQuestionProps) => SurveyItem;
|
|
62
|
+
old: {
|
|
63
|
+
simpleLikertGroup: (props: LikertGroupQuestionProps) => SurveyItem;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
export {};
|