case-editor-tools 1.0.0-beta.19 → 1.0.0-beta.22

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.
@@ -37,7 +37,7 @@ export declare const StudyEngineActions: {
37
37
  updateFlag: (key: string, newValue: string) => Expression;
38
38
  removeFlag: (key: string) => Expression;
39
39
  assignedSurveys: {
40
- add: (surveyKey: string, category: 'prio' | 'normal' | 'optional', activeFrom?: number | Expression | undefined, activeUntil?: number | Expression | undefined) => Expression;
40
+ add: (surveyKey: string, category: 'immediate' | 'prio' | 'normal' | 'optional', activeFrom?: number | Expression | undefined, activeUntil?: number | Expression | undefined) => Expression;
41
41
  removeAll: () => Expression;
42
42
  remove: (surveyKey: string, selector: 'first' | 'last' | 'all') => Expression;
43
43
  };
@@ -73,7 +73,7 @@ export declare const StudyEngine: {
73
73
  updateFlag: (key: string, newValue: string) => Expression;
74
74
  removeFlag: (key: string) => Expression;
75
75
  assignedSurveys: {
76
- add: (surveyKey: string, category: 'prio' | 'normal' | 'optional', activeFrom?: number | Expression | undefined, activeUntil?: number | Expression | undefined) => Expression;
76
+ add: (surveyKey: string, category: 'immediate' | 'prio' | 'normal' | 'optional', activeFrom?: number | Expression | undefined, activeUntil?: number | Expression | undefined) => Expression;
77
77
  removeAll: () => Expression;
78
78
  remove: (surveyKey: string, selector: 'first' | 'last' | 'all') => Expression;
79
79
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "case-editor-tools",
3
3
  "description": "Javascript tools to simplify survey and study coding for CASE.",
4
- "version": "1.0.0-beta.19",
4
+ "version": "1.0.0-beta.22",
5
5
  "main": "index.js",
6
6
  "license": "Apache-2.0",
7
7
  "repository": "github:case-framework/case-editor-tools",
@@ -1,4 +1,4 @@
1
- import { ItemGroupComponent, Expression, ItemComponent, SurveyItem, ExpressionArg, ResponseItem } from "survey-engine/data_types";
1
+ import { ItemGroupComponent, Expression, ItemComponent, SurveyItem, ExpressionArg, ResponseComponent } from "survey-engine/data_types";
2
2
  import { ClozeQuestionProps, DateInputQuestionProps, GenericQuestionProps, MultiLineTextInput, NumericInputQuestionProps, OptionDef, ResponsiveBipolarLikertArrayQuestionProps, ResponsiveSingleChoiceArrayQuestionProps, TextInputQuestionProps } from "./types/item-properties";
3
3
  import { LikertGroupRow } from "./responseTypeGenerators/likertGroupComponents";
4
4
  interface OptionQuestionProps extends GenericQuestionProps {
@@ -20,11 +20,11 @@ interface NumericSliderProps extends GenericQuestionProps {
20
20
  max?: number | ExpressionArg;
21
21
  stepSize?: number | ExpressionArg;
22
22
  }
23
- interface CustomResponseItem extends ResponseItem {
23
+ interface CustomResponseItem extends ResponseComponent {
24
24
  mapToRole?: 'singleChoiceGroup' | 'multipleChoiceGroup' | 'input';
25
25
  }
26
26
  interface CustomQuestionProps extends GenericQuestionProps {
27
- responseItemDef: CustomResponseItem;
27
+ responseItemDefs: CustomResponseItem[];
28
28
  }
29
29
  interface DisplayProps {
30
30
  parentKey: string;
@@ -199,10 +199,43 @@ const generateClozeQuestion = (props) => {
199
199
  return commonQuestionGenerator(props, rg_inner);
200
200
  };
201
201
  const generateCustomQuestion = (props) => {
202
- const roleSuffix = props.responseItemDef.mapToRole !== undefined ? `:${props.responseItemDef.mapToRole}` : '';
203
- const role = `${props.responseItemDef}${roleSuffix}`;
204
- const rg_inner = Object.assign(Object.assign({}, props.responseItemDef), { role: role });
205
- return commonQuestionGenerator(props, rg_inner);
202
+ const items = [];
203
+ props.responseItemDefs.forEach(item => {
204
+ const rolePrefix = item.mapToRole !== undefined ? `${item.mapToRole}` : '';
205
+ const role = `${rolePrefix}:${item.role}`;
206
+ const rg_inner = Object.assign(Object.assign({}, item), { role: role });
207
+ items.push(rg_inner);
208
+ });
209
+ const simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, props.version ? props.version : 1);
210
+ // QUESTION TEXT
211
+ simpleEditor.setTitle(props.questionText, props.questionSubText, props.titleClassName);
212
+ if (props.condition) {
213
+ simpleEditor.setCondition(props.condition);
214
+ }
215
+ if (props.helpGroupContent) {
216
+ simpleEditor.editor.setHelpGroupComponent(surveys_utils_simpleGenerators.generateHelpGroupComponent(props.helpGroupContent));
217
+ }
218
+ if (props.topDisplayCompoments) {
219
+ props.topDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
220
+ }
221
+ simpleEditor.editor.addExistingResponseComponent({
222
+ key: constants_keyDefinitions.responseGroupKey,
223
+ role: 'responseGroup',
224
+ items,
225
+ });
226
+ if (props.bottomDisplayCompoments) {
227
+ props.bottomDisplayCompoments.forEach(comp => simpleEditor.addDisplayComponent(comp));
228
+ }
229
+ if (props.isRequired) {
230
+ simpleEditor.addHasResponseValidation();
231
+ }
232
+ if (props.customValidations) {
233
+ props.customValidations.forEach(v => simpleEditor.editor.addValidation(v));
234
+ }
235
+ if (props.footnoteText) {
236
+ simpleEditor.addDisplayComponent(surveys_utils_componentGenerators.ComponentGenerators.footnote({ content: props.footnoteText }));
237
+ }
238
+ return simpleEditor.getItem();
206
239
  };
207
240
  const generateDisplay = (props) => {
208
241
  const simpleEditor = new surveys_utils_simpleQuestionEditor.SimpleQuestionEditor(props.parentKey, props.itemKey, 1);
@@ -1 +1 @@
1
- {"version":3,"file":"survey-items.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"survey-items.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}