case-editor-tools 1.0.0-beta.3 → 1.0.0-beta.33
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 +75 -13
- package/{build/expression-utils → expression-utils}/studyEngineExpressions.js +165 -19
- 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 +349 -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} +40 -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 +191 -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 +3 -2
- package/{build/types → types}/studyRules.js +5 -1
- package/types/studyRules.js.map +1 -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/studyRules.js.map +0 -1
- 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
|
@@ -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,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)
|
|
@@ -355,6 +386,7 @@ const NativeSurveyEngineExpressions = {
|
|
|
355
386
|
isDefined,
|
|
356
387
|
hasResponse,
|
|
357
388
|
getResponseItem,
|
|
389
|
+
parseValueAsNum,
|
|
358
390
|
getResponseValueAsNum,
|
|
359
391
|
getResponseValueAsStr,
|
|
360
392
|
checkResponseValueWithRegex,
|
|
@@ -400,8 +432,12 @@ const SurveyEngine = Object.assign(Object.assign({}, NativeSurveyEngineExpressio
|
|
|
400
432
|
regexCheck: multilineTextInputRegexCheck,
|
|
401
433
|
}, datePicker: {
|
|
402
434
|
get: getDatePickerResponseValue,
|
|
403
|
-
},
|
|
435
|
+
}, participantFlags: {
|
|
436
|
+
hasKey: hasParticipantFlagKey,
|
|
437
|
+
hasKeyAndValue: hasParticipantFlagKeyAndValue,
|
|
438
|
+
getAsNum: parseParticipantFlagAsNum,
|
|
439
|
+
}, isLoggedIn });
|
|
404
440
|
|
|
405
441
|
exports.NativeSurveyEngineExpressions = NativeSurveyEngineExpressions;
|
|
406
442
|
exports.SurveyEngine = SurveyEngine;
|
|
407
|
-
//# sourceMappingURL=
|
|
443
|
+
//# 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 {};
|
|
@@ -0,0 +1,302 @@
|
|
|
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_surveyEditor_itemEditor = require('../item-editor-c6933791.js');
|
|
7
|
+
var surveys_utils_componentGenerators = require('./utils/componentGenerators.js');
|
|
8
|
+
var types_duration = require('../types/duration.js');
|
|
9
|
+
var constants_keyDefinitions = require('../constants/key-definitions.js');
|
|
10
|
+
var surveys_utils_simpleGenerators = require('./utils/simple-generators.js');
|
|
11
|
+
var surveys_utils_simpleQuestionEditor = require('./utils/simple-question-editor.js');
|
|
12
|
+
var surveys_surveyEngineExpressions = require('./survey-engine-expressions.js');
|
|
13
|
+
var surveys_responseTypeGenerators_optionGroupComponents = require('./responseTypeGenerators/optionGroupComponents.js');
|
|
14
|
+
var surveys_responseTypeGenerators_likertGroupComponents = require('./responseTypeGenerators/likertGroupComponents.js');
|
|
15
|
+
require('./utils/randomKeyGenerator.js');
|
|
16
|
+
require('../logger/logger.js');
|
|
17
|
+
require('../expression-utils/expressionGen.js');
|
|
18
|
+
|
|
19
|
+
const commonQuestionGenerator = (props, rg_inner) => {
|
|
20
|
+
const simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
|
|
21
|
+
// QUESTION TEXT
|
|
22
|
+
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
23
|
+
if (props.condition) {
|
|
24
|
+
simpleEditor.setCondition(props.condition);
|
|
25
|
+
}
|
|
26
|
+
if (props.helpGroupContent) {
|
|
27
|
+
simpleEditor.editor.setHelpGroupComponent(surveys_utils_simpleGenerators.generateHelpGroupComponent(props.helpGroupContent));
|
|
28
|
+
}
|
|
29
|
+
if (props.topDisplayCompoments) {
|
|
30
|
+
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
31
|
+
}
|
|
32
|
+
simpleEditor.setResponseGroupWithContent(rg_inner);
|
|
33
|
+
if (props.bottomDisplayCompoments) {
|
|
34
|
+
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
35
|
+
}
|
|
36
|
+
if (props.isRequired) {
|
|
37
|
+
simpleEditor.addHasResponseValidation();
|
|
38
|
+
}
|
|
39
|
+
if (props.customValidations) {
|
|
40
|
+
props.customValidations.forEach(v => simpleEditor.editor.addValidation(v));
|
|
41
|
+
}
|
|
42
|
+
if (props.footnoteText) {
|
|
43
|
+
simpleEditor.addDisplayComponent(surveys_utils_componentGenerators.ComponentGenerators.footnote({ content: props.footnoteText }));
|
|
44
|
+
}
|
|
45
|
+
return simpleEditor.getItem();
|
|
46
|
+
};
|
|
47
|
+
const generateNumericInputQuestion = (props) => {
|
|
48
|
+
var _a, _b, _c, _d;
|
|
49
|
+
const style = [];
|
|
50
|
+
if (props.inputMaxWidth) {
|
|
51
|
+
style.push({
|
|
52
|
+
key: 'inputMaxWidth', value: props.inputMaxWidth,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (props.labelBehindInput) {
|
|
56
|
+
style.push({ key: 'labelPlacement', value: 'after' });
|
|
57
|
+
}
|
|
58
|
+
const rg_inner = {
|
|
59
|
+
key: constants_keyDefinitions.numericInputKey,
|
|
60
|
+
role: 'numberInput',
|
|
61
|
+
properties: {
|
|
62
|
+
min: ((_a = props.componentProperties) === null || _a === void 0 ? void 0 : _a.min) !== undefined ? (typeof (props.componentProperties.min) === 'number' ? { dtype: 'num', num: props.componentProperties.min } : props.componentProperties.min) : undefined,
|
|
63
|
+
max: ((_b = props.componentProperties) === null || _b === void 0 ? void 0 : _b.max) !== undefined ? (typeof ((_c = props.componentProperties) === null || _c === void 0 ? void 0 : _c.max) === 'number' ? { dtype: 'num', num: props.componentProperties.max } : props.componentProperties.max) : undefined,
|
|
64
|
+
stepSize: ((_d = props.componentProperties) === null || _d === void 0 ? void 0 : _d.stepSize) ? (typeof (props.componentProperties.stepSize) === 'number' ? { dtype: 'num', num: props.componentProperties.stepSize } : props.componentProperties.stepSize) : undefined,
|
|
65
|
+
},
|
|
66
|
+
content: surveys_utils_simpleGenerators.generateLocStrings(props.inputLabel),
|
|
67
|
+
style: style.length > 0 ? style : undefined,
|
|
68
|
+
};
|
|
69
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
70
|
+
};
|
|
71
|
+
const generateSingleChoiceQuestion = (props) => {
|
|
72
|
+
const rg_inner = surveys_responseTypeGenerators_optionGroupComponents.initSingleChoiceGroup(constants_keyDefinitions.singleChoiceKey, props.responseOptions);
|
|
73
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
74
|
+
};
|
|
75
|
+
const generateDropDownQuestion = (props) => {
|
|
76
|
+
const rg_inner = surveys_responseTypeGenerators_optionGroupComponents.initDropdownGroup(constants_keyDefinitions.dropDownKey, props.responseOptions);
|
|
77
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
78
|
+
};
|
|
79
|
+
const generateMultipleChoiceQuestion = (props) => {
|
|
80
|
+
const rg_inner = surveys_responseTypeGenerators_optionGroupComponents.initMultipleChoiceGroup(constants_keyDefinitions.multipleChoiceKey, props.responseOptions);
|
|
81
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
82
|
+
};
|
|
83
|
+
const generateSimpleLikertGroupQuestion = (props) => {
|
|
84
|
+
var _a;
|
|
85
|
+
const rg_inner = surveys_responseTypeGenerators_likertGroupComponents.initLikertScaleGroup(constants_keyDefinitions.likertScaleGroupKey, props.rows, props.scaleOptions, props.stackOnSmallScreen);
|
|
86
|
+
// Add extra validation for likert
|
|
87
|
+
if (props.isRequired) {
|
|
88
|
+
if (!props.customValidations) {
|
|
89
|
+
props.customValidations = [];
|
|
90
|
+
}
|
|
91
|
+
(_a = props.customValidations) === null || _a === void 0 ? void 0 : _a.push({
|
|
92
|
+
key: 'r',
|
|
93
|
+
type: 'hard',
|
|
94
|
+
rule: surveys_utils_simpleGenerators.expWithArgs('and', ...props.rows.map(r => surveys_utils_simpleGenerators.expWithArgs('responseHasKeysAny', [props.parentKey, props.itemKey].join('.'), [constants_keyDefinitions.responseGroupKey, constants_keyDefinitions.likertScaleGroupKey, r.key].join('.'), ...props.scaleOptions.map(o => o.key))))
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
98
|
+
};
|
|
99
|
+
const generateResponsiveSingleChoiceArrayQuestion = (props) => {
|
|
100
|
+
var _a;
|
|
101
|
+
const rg_inner = surveys_responseTypeGenerators_likertGroupComponents.initResponsiveSingleChoiceArray(constants_keyDefinitions.responsiveSingleChoiceArrayKey, Object.assign({}, props));
|
|
102
|
+
// Add extra validation
|
|
103
|
+
if (props.isRequired) {
|
|
104
|
+
if (!props.customValidations) {
|
|
105
|
+
props.customValidations = [];
|
|
106
|
+
}
|
|
107
|
+
(_a = props.customValidations) === null || _a === void 0 ? void 0 : _a.push({
|
|
108
|
+
key: 'r',
|
|
109
|
+
type: 'hard',
|
|
110
|
+
rule: surveys_utils_simpleGenerators.expWithArgs('and', ...props.rows.map(r => surveys_utils_simpleGenerators.expWithArgs('responseHasKeysAny', [props.parentKey, props.itemKey].join('.'), [constants_keyDefinitions.responseGroupKey, constants_keyDefinitions.responsiveSingleChoiceArrayKey, r.key].join('.'), ...props.scaleOptions.map(o => o.key))))
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
114
|
+
};
|
|
115
|
+
const generateResponsiveBipolarLikertArray = (props) => {
|
|
116
|
+
var _a;
|
|
117
|
+
const rg_inner = surveys_responseTypeGenerators_likertGroupComponents.initResponsiveBipolarLikertArray(constants_keyDefinitions.responsiveBipolarLikertArrayKey, Object.assign({}, props));
|
|
118
|
+
// Add extra validation
|
|
119
|
+
if (props.isRequired) {
|
|
120
|
+
if (!props.customValidations) {
|
|
121
|
+
props.customValidations = [];
|
|
122
|
+
}
|
|
123
|
+
(_a = props.customValidations) === null || _a === void 0 ? void 0 : _a.push({
|
|
124
|
+
key: 'r',
|
|
125
|
+
type: 'hard',
|
|
126
|
+
rule: surveys_utils_simpleGenerators.expWithArgs('and', ...props.rows.map(r => surveys_utils_simpleGenerators.expWithArgs('responseHasKeysAny', [props.parentKey, props.itemKey].join('.'), [constants_keyDefinitions.responseGroupKey, constants_keyDefinitions.responsiveBipolarLikertArrayKey, r.key].join('.'), ...props.scaleOptions.map(o => o.key))))
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
130
|
+
};
|
|
131
|
+
const generateNumericSliderQuestion = (props) => {
|
|
132
|
+
const rg_inner = {
|
|
133
|
+
key: 'slider', role: 'sliderNumeric',
|
|
134
|
+
content: surveys_utils_simpleGenerators.generateLocStrings(props.sliderLabel),
|
|
135
|
+
description: surveys_utils_simpleGenerators.generateLocStrings(props.noResponseLabel),
|
|
136
|
+
properties: {
|
|
137
|
+
min: props.min !== undefined ? (typeof (props.min) === 'number' ? { dtype: 'num', num: props.min } : props.min) : undefined,
|
|
138
|
+
max: props.max !== undefined ? (typeof (props.max) === 'number' ? { dtype: 'num', num: props.max } : props.max) : undefined,
|
|
139
|
+
stepSize: props.stepSize ? (typeof (props.stepSize) === 'number' ? { dtype: 'num', num: props.stepSize } : props.stepSize) : undefined,
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
143
|
+
};
|
|
144
|
+
const generateDatePickerInput = (props) => {
|
|
145
|
+
const rg_inner = {
|
|
146
|
+
key: constants_keyDefinitions.datePickerKey, role: 'dateInput',
|
|
147
|
+
properties: {
|
|
148
|
+
dateInputMode: { str: props.dateInputMode },
|
|
149
|
+
min: props.minRelativeDate ? {
|
|
150
|
+
dtype: 'exp', exp: surveys_surveyEngineExpressions.SurveyEngine.timestampWithOffset(props.minRelativeDate.delta, props.minRelativeDate.reference)
|
|
151
|
+
} : undefined,
|
|
152
|
+
max: props.maxRelativeDate ? {
|
|
153
|
+
dtype: 'exp', exp: surveys_utils_simpleGenerators.expWithArgs('timestampWithOffset', types_duration.durationObjectToSeconds(props.maxRelativeDate.delta), props.maxRelativeDate.reference ? props.maxRelativeDate.reference : undefined)
|
|
154
|
+
} : undefined,
|
|
155
|
+
},
|
|
156
|
+
content: props.inputLabelText ? surveys_utils_simpleGenerators.generateLocStrings(props.inputLabelText) : undefined,
|
|
157
|
+
description: props.placeholderText ? surveys_utils_simpleGenerators.generateLocStrings(props.placeholderText) : undefined,
|
|
158
|
+
};
|
|
159
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
160
|
+
};
|
|
161
|
+
const generateTextInputQuestion = (props) => {
|
|
162
|
+
const style = [];
|
|
163
|
+
if (props.maxLength !== undefined) {
|
|
164
|
+
style.push({ key: 'maxLength', value: props.maxLength.toFixed(0) });
|
|
165
|
+
}
|
|
166
|
+
if (props.className !== undefined) {
|
|
167
|
+
style.push({ key: 'className', value: props.className });
|
|
168
|
+
}
|
|
169
|
+
if (props.inputMaxWidth !== undefined) {
|
|
170
|
+
style.push({ key: 'inputMaxWidth', value: props.inputMaxWidth });
|
|
171
|
+
}
|
|
172
|
+
const rg_inner = {
|
|
173
|
+
key: constants_keyDefinitions.inputKey, role: 'input',
|
|
174
|
+
content: props.inputLabel ? surveys_utils_simpleGenerators.generateLocStrings(props.inputLabel) : undefined,
|
|
175
|
+
description: props.placeholderText ? surveys_utils_simpleGenerators.generateLocStrings(props.placeholderText) : undefined,
|
|
176
|
+
style: style.length > 0 ? [...style] : undefined,
|
|
177
|
+
disabled: props.disabled,
|
|
178
|
+
};
|
|
179
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
180
|
+
};
|
|
181
|
+
const generateMultilineInput = (props) => {
|
|
182
|
+
const rg_inner = {
|
|
183
|
+
key: constants_keyDefinitions.inputKey, role: 'multilineTextInput',
|
|
184
|
+
content: props.inputLabelText ? surveys_utils_simpleGenerators.generateLocStrings(props.inputLabelText) : undefined,
|
|
185
|
+
description: props.placeholderText ? surveys_utils_simpleGenerators.generateLocStrings(props.placeholderText) : undefined,
|
|
186
|
+
style: props.maxLength !== undefined ? [{ key: 'maxLength', value: props.maxLength.toFixed(0) }] : undefined
|
|
187
|
+
};
|
|
188
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
189
|
+
};
|
|
190
|
+
const generateClozeQuestion = (props) => {
|
|
191
|
+
const rg_inner = {
|
|
192
|
+
key: constants_keyDefinitions.clozeKey, role: 'cloze',
|
|
193
|
+
items: props.items.map((item) => {
|
|
194
|
+
const clozeItem = item;
|
|
195
|
+
const comp = surveys_responseTypeGenerators_optionGroupComponents.optionDefToItemComponent(clozeItem);
|
|
196
|
+
return comp;
|
|
197
|
+
})
|
|
198
|
+
};
|
|
199
|
+
return commonQuestionGenerator(props, rg_inner);
|
|
200
|
+
};
|
|
201
|
+
const generateCustomQuestion = (props) => {
|
|
202
|
+
const items = [];
|
|
203
|
+
props.responseItemDefs.forEach(item => {
|
|
204
|
+
const rolePrefix = item.mapToRole !== undefined ? `${item.mapToRole}` : '';
|
|
205
|
+
const role = `${rolePrefix}:${item.role}`;
|
|
206
|
+
delete item['mapToRole'];
|
|
207
|
+
const rg_inner = Object.assign(Object.assign({}, item), { role: role });
|
|
208
|
+
items.push(rg_inner);
|
|
209
|
+
});
|
|
210
|
+
const simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
|
|
211
|
+
// QUESTION TEXT
|
|
212
|
+
simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
|
|
213
|
+
if (props.condition) {
|
|
214
|
+
simpleEditor.setCondition(props.condition);
|
|
215
|
+
}
|
|
216
|
+
if (props.helpGroupContent) {
|
|
217
|
+
simpleEditor.editor.setHelpGroupComponent(surveys_utils_simpleGenerators.generateHelpGroupComponent(props.helpGroupContent));
|
|
218
|
+
}
|
|
219
|
+
if (props.topDisplayCompoments) {
|
|
220
|
+
props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
221
|
+
}
|
|
222
|
+
simpleEditor.editor.addExistingResponseComponent({
|
|
223
|
+
key: constants_keyDefinitions.responseGroupKey,
|
|
224
|
+
role: 'responseGroup',
|
|
225
|
+
items,
|
|
226
|
+
});
|
|
227
|
+
if (props.bottomDisplayCompoments) {
|
|
228
|
+
props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
|
|
229
|
+
}
|
|
230
|
+
if (props.isRequired) {
|
|
231
|
+
simpleEditor.addHasResponseValidation();
|
|
232
|
+
}
|
|
233
|
+
if (props.customValidations) {
|
|
234
|
+
props.customValidations.forEach(v => simpleEditor.editor.addValidation(v));
|
|
235
|
+
}
|
|
236
|
+
if (props.footnoteText) {
|
|
237
|
+
simpleEditor.addDisplayComponent(surveys_utils_componentGenerators.ComponentGenerators.footnote({ content: props.footnoteText }));
|
|
238
|
+
}
|
|
239
|
+
return simpleEditor.getItem();
|
|
240
|
+
};
|
|
241
|
+
const generateDisplay = (props) => {
|
|
242
|
+
const simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, 1);
|
|
243
|
+
props.content.forEach(item => simpleEditor.addDisplayComponent(item));
|
|
244
|
+
if (props.condition) {
|
|
245
|
+
simpleEditor.setCondition(props.condition);
|
|
246
|
+
}
|
|
247
|
+
return simpleEditor.getItem();
|
|
248
|
+
};
|
|
249
|
+
const generateSurveyEnd = (parentKey, content, condition) => {
|
|
250
|
+
const defaultKey = 'surveyEnd';
|
|
251
|
+
const itemKey = [parentKey, defaultKey].join('.');
|
|
252
|
+
const editor = new surveys_surveyEditor_itemEditor.ItemEditor(undefined, { itemKey: itemKey, type: 'surveyEnd', isGroup: false });
|
|
253
|
+
editor.setTitleComponent(surveys_utils_simpleGenerators.generateTitleComponent(content));
|
|
254
|
+
// CONDITION
|
|
255
|
+
editor.setCondition(condition);
|
|
256
|
+
return editor.getItem();
|
|
257
|
+
};
|
|
258
|
+
const initEQ5DHealthIndicatorQuestion = (props) => {
|
|
259
|
+
// init group
|
|
260
|
+
const groupEdit = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, {
|
|
261
|
+
key: props.key,
|
|
262
|
+
isGroup: true,
|
|
263
|
+
role: props.role,
|
|
264
|
+
});
|
|
265
|
+
const instructionTextEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, { role: 'instruction', });
|
|
266
|
+
instructionTextEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(props.instructionText));
|
|
267
|
+
groupEdit.addItemComponent(instructionTextEditor.getComponent());
|
|
268
|
+
const valueBoxTextEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, { role: 'valuebox', });
|
|
269
|
+
valueBoxTextEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(props.valueBoxText));
|
|
270
|
+
groupEdit.addItemComponent(valueBoxTextEditor.getComponent());
|
|
271
|
+
const minHealthTextEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, { role: 'mintext', });
|
|
272
|
+
minHealthTextEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(props.minHealthText));
|
|
273
|
+
groupEdit.addItemComponent(minHealthTextEditor.getComponent());
|
|
274
|
+
const maxHealthTextEditor = new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, { role: 'maxtext', });
|
|
275
|
+
maxHealthTextEditor.setContent(surveys_utils_simpleGenerators.generateLocStrings(props.maxHealthText));
|
|
276
|
+
groupEdit.addItemComponent(maxHealthTextEditor.getComponent());
|
|
277
|
+
return groupEdit.getComponent();
|
|
278
|
+
};
|
|
279
|
+
const SurveyItems = {
|
|
280
|
+
singleChoice: generateSingleChoiceQuestion,
|
|
281
|
+
responsiveSingleChoiceArray: generateResponsiveSingleChoiceArrayQuestion,
|
|
282
|
+
responsiveBipolarLikertArray: generateResponsiveBipolarLikertArray,
|
|
283
|
+
multipleChoice: generateMultipleChoiceQuestion,
|
|
284
|
+
dateInput: generateDatePickerInput,
|
|
285
|
+
textInput: generateTextInputQuestion,
|
|
286
|
+
// eq5dSlider: todo,
|
|
287
|
+
clozeQuestion: generateClozeQuestion,
|
|
288
|
+
numericInput: generateNumericInputQuestion,
|
|
289
|
+
multilineTextInput: generateMultilineInput,
|
|
290
|
+
dropDown: generateDropDownQuestion,
|
|
291
|
+
numericSlider: generateNumericSliderQuestion,
|
|
292
|
+
display: generateDisplay,
|
|
293
|
+
surveyEnd: generateSurveyEnd,
|
|
294
|
+
customQuestion: generateCustomQuestion,
|
|
295
|
+
old: {
|
|
296
|
+
simpleLikertGroup: generateSimpleLikertGroupQuestion,
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
exports.SurveyItems = SurveyItems;
|
|
301
|
+
exports.initEQ5DHealthIndicatorQuestion = initEQ5DHealthIndicatorQuestion;
|
|
302
|
+
//# sourceMappingURL=survey-items.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"survey-items.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|