case-editor-tools 1.0.0-beta.9 → 1.0.2
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/constants/key-definitions.d.ts +3 -0
- package/constants/key-definitions.js +7 -1
- package/constants/key-definitions.js.map +1 -1
- package/exporter/index.d.ts +2 -0
- package/exporter/index.js +128 -0
- package/exporter/index.js.map +1 -0
- package/expression-utils/expressionGen.d.ts +1 -1
- package/expression-utils/studyEngineExpressions.d.ts +94 -13
- package/expression-utils/studyEngineExpressions.js +215 -19
- package/expression-utils/studyEngineExpressions.js.map +1 -1
- package/{item-editor-cb5ebc1a.js → item-editor-59f51ecc.js} +67 -46
- package/item-editor-59f51ecc.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/package.json +5 -5
- package/surveys/index.d.ts +1 -0
- package/surveys/index.js +9 -1
- package/surveys/index.js.map +1 -1
- package/surveys/responseTypeGenerators/likertGroupComponents.d.ts +27 -0
- package/surveys/responseTypeGenerators/likertGroupComponents.js +350 -0
- package/surveys/responseTypeGenerators/likertGroupComponents.js.map +1 -0
- package/surveys/responseTypeGenerators/matrixGroupComponent.d.ts +49 -0
- package/surveys/responseTypeGenerators/matrixGroupComponent.js +100 -0
- package/surveys/responseTypeGenerators/matrixGroupComponent.js.map +1 -0
- package/surveys/responseTypeGenerators/optionGroupComponents.d.ts +7 -0
- package/surveys/responseTypeGenerators/optionGroupComponents.js +129 -0
- package/surveys/responseTypeGenerators/optionGroupComponents.js.map +1 -0
- package/surveys/survey-editor/component-editor.d.ts +1 -1
- package/surveys/survey-editor/data-types.d.ts +1 -1
- package/surveys/survey-editor/item-editor.d.ts +2 -1
- package/surveys/survey-editor/item-editor.js +2 -1
- package/surveys/survey-editor/item-editor.js.map +1 -1
- package/surveys/survey-editor/survey-editor.d.ts +6 -1
- package/surveys/survey-editor/survey-editor.js +13 -6
- package/surveys/survey-editor/survey-editor.js.map +1 -1
- package/surveys/survey-engine-expressions.d.ts +12 -2
- package/surveys/survey-engine-expressions.js +43 -2
- package/surveys/survey-engine-expressions.js.map +1 -1
- package/surveys/survey-items.d.ts +33 -227
- package/surveys/survey-items.js +215 -780
- package/surveys/survey-items.js.map +1 -1
- package/surveys/types/group.d.ts +1 -1
- package/surveys/types/group.js +2 -1
- package/surveys/types/group.js.map +1 -1
- package/surveys/types/index.js +3 -1
- package/surveys/types/index.js.map +1 -1
- package/surveys/types/item-properties.d.ts +206 -2
- package/surveys/types/item-properties.js +7 -0
- package/surveys/types/item-properties.js.map +1 -1
- package/surveys/types/item.d.ts +1 -1
- package/surveys/types/survey-definition.d.ts +7 -3
- package/surveys/types/survey-definition.js +11 -2
- package/surveys/types/survey-definition.js.map +1 -1
- package/surveys/utils/componentGenerators.d.ts +2 -13
- package/surveys/utils/componentGenerators.js +1 -34
- package/surveys/utils/componentGenerators.js.map +1 -1
- package/surveys/utils/optionDefGenerators.d.ts +84 -0
- package/surveys/utils/optionDefGenerators.js +211 -0
- package/surveys/utils/optionDefGenerators.js.map +1 -0
- package/surveys/utils/simple-generators.d.ts +4 -3
- package/surveys/utils/simple-generators.js +29 -0
- package/surveys/utils/simple-generators.js.map +1 -1
- package/surveys/utils/simple-question-editor.d.ts +5 -5
- package/surveys/utils/simple-question-editor.js +5 -2
- package/surveys/utils/simple-question-editor.js.map +1 -1
- package/types/expression.d.ts +1 -1
- package/types/messageConfig.d.ts +49 -0
- package/types/messageConfig.js +23 -0
- package/types/messageConfig.js.map +1 -0
- package/types/study.d.ts +3 -1
- package/types/studyRules.d.ts +3 -2
- package/types/studyRules.js +5 -1
- package/types/studyRules.js.map +1 -1
- package/item-editor-cb5ebc1a.js.map +0 -1
|
@@ -0,0 +1,129 @@
|
|
|
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('../types/item-properties.js');
|
|
8
|
+
require('../utils/randomKeyGenerator.js');
|
|
9
|
+
|
|
10
|
+
const optionDefToItemComponent = (optionDef) => {
|
|
11
|
+
const isGroup = optionDef.items && optionDef.items.length > 0;
|
|
12
|
+
const optEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
13
|
+
key: optionDef.key,
|
|
14
|
+
role: optionDef.role,
|
|
15
|
+
isGroup: isGroup
|
|
16
|
+
});
|
|
17
|
+
if (isGroup) {
|
|
18
|
+
optEditor.setOrder({
|
|
19
|
+
name: 'sequential'
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (optionDef.content) {
|
|
23
|
+
optEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(optionDef.content));
|
|
24
|
+
}
|
|
25
|
+
if (optionDef.description) {
|
|
26
|
+
optEditor.setDescription(surveys_utils_simpleGenerators.generateLocStrings(optionDef.description));
|
|
27
|
+
}
|
|
28
|
+
switch (optionDef.role) {
|
|
29
|
+
case 'date':
|
|
30
|
+
optEditor.setDType('date');
|
|
31
|
+
break;
|
|
32
|
+
case 'numberInput':
|
|
33
|
+
optEditor.setDType('number');
|
|
34
|
+
break;
|
|
35
|
+
case 'timeInput':
|
|
36
|
+
optEditor.setDType('number');
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
if (optionDef.displayCondition) {
|
|
40
|
+
optEditor.setDisplayCondition(optionDef.displayCondition);
|
|
41
|
+
}
|
|
42
|
+
if (optionDef.disabled) {
|
|
43
|
+
optEditor.setDisabled(optionDef.disabled);
|
|
44
|
+
}
|
|
45
|
+
if (optionDef.style) {
|
|
46
|
+
optEditor.setStyles(optionDef.style);
|
|
47
|
+
}
|
|
48
|
+
if (optionDef.optionProps) {
|
|
49
|
+
if (typeof (optionDef.optionProps.min) === 'number') {
|
|
50
|
+
optionDef.optionProps.min = { dtype: 'num', num: optionDef.optionProps.min };
|
|
51
|
+
}
|
|
52
|
+
if (typeof (optionDef.optionProps.max) === 'number') {
|
|
53
|
+
optionDef.optionProps.max = { dtype: 'num', num: optionDef.optionProps.max };
|
|
54
|
+
}
|
|
55
|
+
if (typeof (optionDef.optionProps.stepSize) === 'number') {
|
|
56
|
+
optionDef.optionProps.stepSize = { dtype: 'num', num: optionDef.optionProps.stepSize };
|
|
57
|
+
}
|
|
58
|
+
optEditor.setProperties(optionDef.optionProps);
|
|
59
|
+
}
|
|
60
|
+
if (optionDef.items) {
|
|
61
|
+
if (optionDef.role === 'text') {
|
|
62
|
+
optionDef.items.forEach((item, index) => {
|
|
63
|
+
const textItem = item;
|
|
64
|
+
optEditor.addItemComponent({
|
|
65
|
+
key: index.toFixed(),
|
|
66
|
+
role: 'text',
|
|
67
|
+
content: surveys_utils_simpleGenerators.generateLocStrings(textItem.content),
|
|
68
|
+
style: textItem.className ? [{ key: 'className', value: textItem.className }] : undefined
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
optionDef.items.forEach((item) => {
|
|
74
|
+
const clozeItem = item;
|
|
75
|
+
const comp = optionDefToItemComponent(clozeItem);
|
|
76
|
+
optEditor.addItemComponent(comp);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return optEditor.getComponent();
|
|
81
|
+
};
|
|
82
|
+
const initResponseGroup = (type, key, optionItems, order, groupDisabled, groupContent, groupDescription) => {
|
|
83
|
+
// init group
|
|
84
|
+
const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
85
|
+
key: key,
|
|
86
|
+
isGroup: true,
|
|
87
|
+
role: type,
|
|
88
|
+
});
|
|
89
|
+
groupEdit.setOrder(order ? order : {
|
|
90
|
+
name: 'sequential'
|
|
91
|
+
});
|
|
92
|
+
if (groupDisabled) {
|
|
93
|
+
groupEdit.setDisabled(groupDisabled);
|
|
94
|
+
}
|
|
95
|
+
if (groupContent) {
|
|
96
|
+
groupEdit.setContent(groupContent);
|
|
97
|
+
}
|
|
98
|
+
if (groupDescription) {
|
|
99
|
+
groupEdit.setDescription(groupDescription);
|
|
100
|
+
}
|
|
101
|
+
// add option items
|
|
102
|
+
optionItems.forEach(optionDef => {
|
|
103
|
+
groupEdit.addItemComponent(optionDefToItemComponent(optionDef));
|
|
104
|
+
});
|
|
105
|
+
return groupEdit.getComponent();
|
|
106
|
+
};
|
|
107
|
+
const initSingleChoiceGroup = (key, optionItems, order) => {
|
|
108
|
+
// init group
|
|
109
|
+
return initResponseGroup('singleChoiceGroup', key, optionItems, order);
|
|
110
|
+
};
|
|
111
|
+
const initMultipleChoiceGroup = (key, optionItems, order) => {
|
|
112
|
+
// init group
|
|
113
|
+
return initResponseGroup('multipleChoiceGroup', key, optionItems, order);
|
|
114
|
+
};
|
|
115
|
+
const initDropdownGroup = (key, optionItems, order, groupDisabled, groupContent, groupDescription) => {
|
|
116
|
+
// init group
|
|
117
|
+
return initResponseGroup('dropDownGroup', key, optionItems, order, groupDisabled, groupContent ? surveys_utils_simpleGenerators.generateLocStrings(groupContent) : undefined, groupDescription ? surveys_utils_simpleGenerators.generateLocStrings(groupDescription) : undefined);
|
|
118
|
+
};
|
|
119
|
+
const initSliderCategoricalGroup = (key, optionItems, order, groupDisabled) => {
|
|
120
|
+
// init group
|
|
121
|
+
return initResponseGroup('sliderCategorical', key, optionItems, order, groupDisabled);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
exports.initDropdownGroup = initDropdownGroup;
|
|
125
|
+
exports.initMultipleChoiceGroup = initMultipleChoiceGroup;
|
|
126
|
+
exports.initSingleChoiceGroup = initSingleChoiceGroup;
|
|
127
|
+
exports.initSliderCategoricalGroup = initSliderCategoricalGroup;
|
|
128
|
+
exports.optionDefToItemComponent = optionDefToItemComponent;
|
|
129
|
+
//# 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;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SurveyItem, SurveyItemTypes, Expression, Validation, ItemComponent, ItemGroupComponent } from "survey-engine/
|
|
1
|
+
import { SurveyItem, SurveyItemTypes, Expression, Validation, ItemComponent, ItemGroupComponent, ConfidentialMode } from "survey-engine/data_types";
|
|
2
2
|
import { NewItemProps, NewComponentProps } from "./data-types";
|
|
3
3
|
interface ItemEditorInt {
|
|
4
4
|
getItem: () => SurveyItem;
|
|
@@ -36,6 +36,7 @@ export declare class ItemEditor implements ItemEditorInt {
|
|
|
36
36
|
getItem(): SurveyItem;
|
|
37
37
|
getItemJSON(pretty?: boolean): string;
|
|
38
38
|
setKey(newKey: string): void;
|
|
39
|
+
setConfidentialMode(confidentialMode?: ConfidentialMode): void;
|
|
39
40
|
addToFollows(key: string): void;
|
|
40
41
|
removeFromFollows(key: string): void;
|
|
41
42
|
clearFollows(): void;
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var surveys_surveyEditor_itemEditor = require('../../item-editor-
|
|
5
|
+
var surveys_surveyEditor_itemEditor = require('../../item-editor-59f51ecc.js');
|
|
6
6
|
require('./component-editor.js');
|
|
7
7
|
require('../utils/randomKeyGenerator.js');
|
|
8
|
+
require('../../logger/logger.js');
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
|
|
@@ -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 surveys_surveyEditor_itemEditor = require('../../item-editor-
|
|
5
|
+
var surveys_surveyEditor_itemEditor = require('../../item-editor-59f51ecc.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,7 +70,7 @@ 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
76
|
const item = (new surveys_surveyEditor_itemEditor.ItemEditor(undefined, newItem)).getItem();
|
|
@@ -82,7 +89,7 @@ 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
95
|
const item = (new surveys_surveyEditor_itemEditor.ItemEditor(undefined, newItem)).getItem();
|
|
@@ -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 (!surveys_surveyEditor_itemEditor.
|
|
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 (surveys_surveyEditor_itemEditor.
|
|
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;
|
|
@@ -63,6 +64,9 @@ export declare const SurveyEngine: {
|
|
|
63
64
|
getNumValue: (itemKey: string, optionKey: string) => Expression;
|
|
64
65
|
regexCheck: (itemKey: string, optionKey: string, pattern: string) => Expression;
|
|
65
66
|
};
|
|
67
|
+
consentQuestion: {
|
|
68
|
+
accepted: (itemKey: string) => Expression;
|
|
69
|
+
};
|
|
66
70
|
textInput: {
|
|
67
71
|
regexCheck: (itemKey: string, pattern: string) => Expression;
|
|
68
72
|
};
|
|
@@ -72,7 +76,12 @@ export declare const SurveyEngine: {
|
|
|
72
76
|
datePicker: {
|
|
73
77
|
get: (itemKey: string) => Expression;
|
|
74
78
|
};
|
|
75
|
-
|
|
79
|
+
participantFlags: {
|
|
80
|
+
hasKey: (key: string) => Expression;
|
|
81
|
+
hasKeyAndValue: (key: string, value: string) => Expression;
|
|
82
|
+
getAsNum: (key: string) => Expression;
|
|
83
|
+
};
|
|
84
|
+
isLoggedIn: () => Expression;
|
|
76
85
|
getters: {
|
|
77
86
|
getContext: () => Expression;
|
|
78
87
|
getResponses: () => Expression;
|
|
@@ -94,6 +103,7 @@ export declare const SurveyEngine: {
|
|
|
94
103
|
isDefined: (arg: Expression) => Expression;
|
|
95
104
|
hasResponse: (itemKey: string, responseKey: string) => Expression;
|
|
96
105
|
getResponseItem: (itemKey: string, responseKey: string) => Expression;
|
|
106
|
+
parseValueAsNum: (valueRef: Expression) => Expression;
|
|
97
107
|
getResponseValueAsNum: (itemKey: string, responseKey: string) => Expression;
|
|
98
108
|
getResponseValueAsStr: (itemKey: string, responseKey: string) => Expression;
|
|
99
109
|
checkResponseValueWithRegex: (itemKey: string, responseKey: string, regexPattern: string) => 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,38 @@ 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
|
+
/**
|
|
323
|
+
* Check if the participant is logged in currently.
|
|
324
|
+
* @returns true if context variable isLoggedIn is set and true
|
|
325
|
+
*/
|
|
326
|
+
const isLoggedIn = () => {
|
|
327
|
+
return and(isDefined(getAttribute(getContext(), 'isLoggedIn')), getAttribute(getContext(), 'isLoggedIn'));
|
|
328
|
+
};
|
|
298
329
|
/**
|
|
299
330
|
* Counts the number of selected options in a multiple choice question
|
|
300
331
|
* @param itemKey full key of the survey item (e.g. SURVEY.GROUP.QUESTIONKEY)
|
|
@@ -329,6 +360,9 @@ const textInputRegexCheck = (itemKey, pattern) => {
|
|
|
329
360
|
const multilineTextInputRegexCheck = (itemKey, pattern) => {
|
|
330
361
|
return checkResponseValueWithRegex(itemKey, [constants_keyDefinitions.responseGroupKey, constants_keyDefinitions.inputKey].join('.'), pattern);
|
|
331
362
|
};
|
|
363
|
+
const consentAcceptedCondition = (itemKey) => {
|
|
364
|
+
return hasResponse(itemKey, [constants_keyDefinitions.responseGroupKey, constants_keyDefinitions.consentKey].join('.'));
|
|
365
|
+
};
|
|
332
366
|
const NativeSurveyEngineExpressions = {
|
|
333
367
|
getters: {
|
|
334
368
|
// root data reference:
|
|
@@ -355,6 +389,7 @@ const NativeSurveyEngineExpressions = {
|
|
|
355
389
|
isDefined,
|
|
356
390
|
hasResponse,
|
|
357
391
|
getResponseItem,
|
|
392
|
+
parseValueAsNum,
|
|
358
393
|
getResponseValueAsNum,
|
|
359
394
|
getResponseValueAsStr,
|
|
360
395
|
checkResponseValueWithRegex,
|
|
@@ -394,13 +429,19 @@ const SurveyEngine = Object.assign(Object.assign({}, NativeSurveyEngineExpressio
|
|
|
394
429
|
getDateValue: multipleChoiceGetNumOptionValue,
|
|
395
430
|
getNumValue: multipleChoiceGetNumOptionValue,
|
|
396
431
|
regexCheck: mulitpleChoiceTextInputRegexCheck,
|
|
432
|
+
}, consentQuestion: {
|
|
433
|
+
accepted: consentAcceptedCondition,
|
|
397
434
|
}, textInput: {
|
|
398
435
|
regexCheck: textInputRegexCheck,
|
|
399
436
|
}, multilineTextInput: {
|
|
400
437
|
regexCheck: multilineTextInputRegexCheck,
|
|
401
438
|
}, datePicker: {
|
|
402
439
|
get: getDatePickerResponseValue,
|
|
403
|
-
},
|
|
440
|
+
}, participantFlags: {
|
|
441
|
+
hasKey: hasParticipantFlagKey,
|
|
442
|
+
hasKeyAndValue: hasParticipantFlagKeyAndValue,
|
|
443
|
+
getAsNum: parseParticipantFlagAsNum,
|
|
444
|
+
}, isLoggedIn });
|
|
404
445
|
|
|
405
446
|
exports.NativeSurveyEngineExpressions = NativeSurveyEngineExpressions;
|
|
406
447
|
exports.SurveyEngine = SurveyEngine;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"survey-engine-expressions.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"survey-engine-expressions.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|