case-editor-tools 1.4.0 → 1.4.1
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/expression-utils/expressionGen.js +8 -1
- package/expression-utils/expressionGen.js.map +1 -1
- package/expression-utils/studyEngineExpressions.js +2 -0
- package/expression-utils/studyEngineExpressions.js.map +1 -1
- package/index-8e5154bb.js +79 -0
- package/index-8e5154bb.js.map +1 -0
- package/package.json +1 -1
- package/surveys/index.js +2 -1
- package/surveys/index.js.map +1 -1
- package/surveys/survey-editor/item-editor.js +457 -6
- package/surveys/survey-editor/item-editor.js.map +1 -1
- package/surveys/survey-editor/survey-editor.js +7 -6
- package/surveys/survey-editor/survey-editor.js.map +1 -1
- package/surveys/survey-engine-expressions.js +2 -0
- package/surveys/survey-engine-expressions.js.map +1 -1
- package/surveys/survey-items.js +2 -1
- package/surveys/survey-items.js.map +1 -1
- package/surveys/types/group.js +2 -1
- package/surveys/types/group.js.map +1 -1
- package/surveys/types/index.js +2 -1
- package/surveys/types/index.js.map +1 -1
- package/surveys/types/survey-definition.js +2 -1
- package/surveys/types/survey-definition.js.map +1 -1
- package/surveys/utils/optionDefGenerators.js +2 -0
- package/surveys/utils/optionDefGenerators.js.map +1 -1
- package/surveys/utils/simple-question-editor.js +2 -1
- package/surveys/utils/simple-question-editor.js.map +1 -1
- package/types/studyRules.js +2 -0
- package/types/studyRules.js.map +1 -1
- package/item-editor-b2c1632b.js +0 -535
- package/item-editor-b2c1632b.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"survey-editor.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"survey-editor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -5,6 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var constants_keyDefinitions = require('../constants/key-definitions.js');
|
|
6
6
|
var types_duration = require('../types/duration.js');
|
|
7
7
|
var expressionUtils_expressionGen = require('../expression-utils/expressionGen.js');
|
|
8
|
+
require('../index-8e5154bb.js');
|
|
9
|
+
require('../logger/logger.js');
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Logical OR expression
|
|
@@ -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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/surveys/survey-items.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var surveys_surveyEditor_componentEditor = require('./survey-editor/component-editor.js');
|
|
6
|
-
var surveys_surveyEditor_itemEditor = require('
|
|
6
|
+
var surveys_surveyEditor_itemEditor = require('./survey-editor/item-editor.js');
|
|
7
7
|
var surveys_utils_componentGenerators = require('./utils/componentGenerators.js');
|
|
8
8
|
var types_duration = require('../types/duration.js');
|
|
9
9
|
var constants_keyDefinitions = require('../constants/key-definitions.js');
|
|
@@ -13,6 +13,7 @@ var surveys_surveyEngineExpressions = require('./survey-engine-expressions.js');
|
|
|
13
13
|
var surveys_types_itemProperties = require('./types/item-properties.js');
|
|
14
14
|
var surveys_responseTypeGenerators_optionGroupComponents = require('./responseTypeGenerators/optionGroupComponents.js');
|
|
15
15
|
var surveys_responseTypeGenerators_likertGroupComponents = require('./responseTypeGenerators/likertGroupComponents.js');
|
|
16
|
+
require('../index-8e5154bb.js');
|
|
16
17
|
require('./utils/randomKeyGenerator.js');
|
|
17
18
|
require('../logger/logger.js');
|
|
18
19
|
require('../expression-utils/expressionGen.js');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"survey-items.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"survey-items.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/surveys/types/group.js
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var logger_logger = require('../../logger/logger.js');
|
|
6
|
-
var surveys_surveyEditor_itemEditor = require('
|
|
6
|
+
var surveys_surveyEditor_itemEditor = require('../survey-editor/item-editor.js');
|
|
7
7
|
var surveys_utils_simpleGenerators = require('../utils/simple-generators.js');
|
|
8
|
+
require('../../index-8e5154bb.js');
|
|
8
9
|
require('../survey-editor/component-editor.js');
|
|
9
10
|
require('../utils/randomKeyGenerator.js');
|
|
10
11
|
require('./item-properties.js');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"group.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"group.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/surveys/types/index.js
CHANGED
|
@@ -7,7 +7,8 @@ var surveys_types_item = require('./item.js');
|
|
|
7
7
|
var surveys_types_itemProperties = require('./item-properties.js');
|
|
8
8
|
var surveys_types_surveyDefinition = require('./survey-definition.js');
|
|
9
9
|
require('../../logger/logger.js');
|
|
10
|
-
require('
|
|
10
|
+
require('../survey-editor/item-editor.js');
|
|
11
|
+
require('../../index-8e5154bb.js');
|
|
11
12
|
require('../survey-editor/component-editor.js');
|
|
12
13
|
require('../utils/randomKeyGenerator.js');
|
|
13
14
|
require('../utils/simple-generators.js');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var logger_logger = require('../../logger/logger.js');
|
|
6
|
-
var surveys_surveyEditor_itemEditor = require('
|
|
6
|
+
var surveys_surveyEditor_itemEditor = require('../survey-editor/item-editor.js');
|
|
7
7
|
var surveys_surveyEditor_surveyEditor = require('../survey-editor/survey-editor.js');
|
|
8
8
|
var surveys_utils_simpleGenerators = require('../utils/simple-generators.js');
|
|
9
|
+
require('../../index-8e5154bb.js');
|
|
9
10
|
require('../survey-editor/component-editor.js');
|
|
10
11
|
require('../utils/randomKeyGenerator.js');
|
|
11
12
|
require('./item-properties.js');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"survey-definition.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"survey-definition.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -7,6 +7,8 @@ var surveys_utils_randomKeyGenerator = require('./randomKeyGenerator.js');
|
|
|
7
7
|
require('../../constants/key-definitions.js');
|
|
8
8
|
require('../../types/duration.js');
|
|
9
9
|
require('../../expression-utils/expressionGen.js');
|
|
10
|
+
require('../../index-8e5154bb.js');
|
|
11
|
+
require('../../logger/logger.js');
|
|
10
12
|
|
|
11
13
|
const option = (key, content, extraProps) => {
|
|
12
14
|
const styles = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"optionDefGenerators.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"optionDefGenerators.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var constants_keyDefinitions = require('../../constants/key-definitions.js');
|
|
6
|
-
var surveys_surveyEditor_itemEditor = require('
|
|
6
|
+
var surveys_surveyEditor_itemEditor = require('../survey-editor/item-editor.js');
|
|
7
7
|
var surveys_utils_simpleGenerators = require('./simple-generators.js');
|
|
8
|
+
require('../../index-8e5154bb.js');
|
|
8
9
|
require('../survey-editor/component-editor.js');
|
|
9
10
|
require('./randomKeyGenerator.js');
|
|
10
11
|
require('../../logger/logger.js');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simple-question-editor.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"simple-question-editor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/types/studyRules.js
CHANGED
|
@@ -6,6 +6,8 @@ var expressionUtils_studyEngineExpressions = require('../expression-utils/studyE
|
|
|
6
6
|
require('../constants/key-definitions.js');
|
|
7
7
|
require('./duration.js');
|
|
8
8
|
require('../expression-utils/expressionGen.js');
|
|
9
|
+
require('../index-8e5154bb.js');
|
|
10
|
+
require('../logger/logger.js');
|
|
9
11
|
|
|
10
12
|
class StudyRules {
|
|
11
13
|
constructor(enterRules, submitRules, timerRules, mergeRules) {
|
package/types/studyRules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"studyRules.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"studyRules.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/item-editor-b2c1632b.js
DELETED
|
@@ -1,535 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var surveys_surveyEditor_componentEditor = require('./surveys/survey-editor/component-editor.js');
|
|
4
|
-
var surveys_utils_randomKeyGenerator = require('./surveys/utils/randomKeyGenerator.js');
|
|
5
|
-
var logger_logger = require('./logger/logger.js');
|
|
6
|
-
|
|
7
|
-
var data_types = {};
|
|
8
|
-
|
|
9
|
-
var expression = {};
|
|
10
|
-
|
|
11
|
-
Object.defineProperty(expression, '__esModule', { value: true });
|
|
12
|
-
|
|
13
|
-
const isExpression = (value) => {
|
|
14
|
-
return typeof (value) === 'object' && value.name !== undefined && value.name.length > 0;
|
|
15
|
-
};
|
|
16
|
-
const expressionArgParser = (arg) => {
|
|
17
|
-
switch (arg.dtype) {
|
|
18
|
-
case 'num':
|
|
19
|
-
return arg.num;
|
|
20
|
-
case 'str':
|
|
21
|
-
return arg.str;
|
|
22
|
-
case 'exp':
|
|
23
|
-
return arg.exp;
|
|
24
|
-
default:
|
|
25
|
-
return arg.str;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
expression.expressionArgParser = expressionArgParser;
|
|
30
|
-
expression.isExpression = isExpression;
|
|
31
|
-
|
|
32
|
-
var surveyItem = {};
|
|
33
|
-
|
|
34
|
-
Object.defineProperty(surveyItem, '__esModule', { value: true });
|
|
35
|
-
|
|
36
|
-
const isSurveyGroupItem$1 = (item) => {
|
|
37
|
-
const items = item.items;
|
|
38
|
-
return items !== undefined && items.length > 0;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
surveyItem.isSurveyGroupItem = isSurveyGroupItem$1;
|
|
42
|
-
|
|
43
|
-
var surveyItemComponent = {};
|
|
44
|
-
|
|
45
|
-
Object.defineProperty(surveyItemComponent, '__esModule', { value: true });
|
|
46
|
-
|
|
47
|
-
const isItemGroupComponent$1 = (item) => {
|
|
48
|
-
const items = item.items;
|
|
49
|
-
return items !== undefined && items.length > 0;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
surveyItemComponent.isItemGroupComponent = isItemGroupComponent$1;
|
|
53
|
-
|
|
54
|
-
var response = {};
|
|
55
|
-
|
|
56
|
-
Object.defineProperty(response, '__esModule', { value: true });
|
|
57
|
-
|
|
58
|
-
const isSurveyGroupItemResponse = (item) => {
|
|
59
|
-
const items = item.items;
|
|
60
|
-
return items !== undefined && items.length > 0;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
response.isSurveyGroupItemResponse = isSurveyGroupItemResponse;
|
|
64
|
-
|
|
65
|
-
Object.defineProperty(data_types, '__esModule', { value: true });
|
|
66
|
-
|
|
67
|
-
var data_types_expression = expression;
|
|
68
|
-
var data_types_surveyItem = surveyItem;
|
|
69
|
-
var data_types_surveyItemComponent = surveyItemComponent;
|
|
70
|
-
var data_types_response = response;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
data_types.expressionArgParser = data_types_expression.expressionArgParser;
|
|
75
|
-
data_types.isExpression = data_types_expression.isExpression;
|
|
76
|
-
var isSurveyGroupItem = data_types.isSurveyGroupItem = data_types_surveyItem.isSurveyGroupItem;
|
|
77
|
-
var isItemGroupComponent = data_types.isItemGroupComponent = data_types_surveyItemComponent.isItemGroupComponent;
|
|
78
|
-
data_types.isSurveyGroupItemResponse = data_types_response.isSurveyGroupItemResponse;
|
|
79
|
-
|
|
80
|
-
const initialRootComp = () => {
|
|
81
|
-
return {
|
|
82
|
-
role: 'root',
|
|
83
|
-
order: { name: 'sequential' },
|
|
84
|
-
items: []
|
|
85
|
-
};
|
|
86
|
-
};
|
|
87
|
-
class ItemEditor {
|
|
88
|
-
constructor(existingItem, newItem) {
|
|
89
|
-
this.surveyItem = { key: '' };
|
|
90
|
-
if (existingItem) {
|
|
91
|
-
this.surveyItem = Object.assign({}, existingItem);
|
|
92
|
-
// console.log(this.surveyItem);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
const key = (newItem === null || newItem === void 0 ? void 0 : newItem.itemKey) ? newItem.itemKey : 'no key';
|
|
96
|
-
if (newItem === null || newItem === void 0 ? void 0 : newItem.isGroup) {
|
|
97
|
-
const currentItem = {
|
|
98
|
-
key,
|
|
99
|
-
items: [],
|
|
100
|
-
};
|
|
101
|
-
this.surveyItem = currentItem;
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
const currentItem = {
|
|
105
|
-
key,
|
|
106
|
-
};
|
|
107
|
-
if (newItem === null || newItem === void 0 ? void 0 : newItem.type) {
|
|
108
|
-
currentItem.type = newItem.type;
|
|
109
|
-
}
|
|
110
|
-
this.surveyItem = currentItem;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
getItem() {
|
|
115
|
-
return Object.assign({}, this.surveyItem);
|
|
116
|
-
}
|
|
117
|
-
getItemJSON(pretty) {
|
|
118
|
-
return JSON.stringify(this.surveyItem, undefined, pretty ? ' ' : undefined);
|
|
119
|
-
}
|
|
120
|
-
setKey(newKey) {
|
|
121
|
-
this.surveyItem.key = newKey;
|
|
122
|
-
}
|
|
123
|
-
setConfidentialMode(confidentialMode) {
|
|
124
|
-
this.surveyItem.confidentialMode = confidentialMode;
|
|
125
|
-
}
|
|
126
|
-
addToFollows(key) {
|
|
127
|
-
if (!this.surveyItem.follows) {
|
|
128
|
-
this.surveyItem.follows = [];
|
|
129
|
-
}
|
|
130
|
-
if (this.surveyItem.follows.includes(key)) {
|
|
131
|
-
console.warn('follows array already includes key: ', key);
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
this.surveyItem.follows.push(key);
|
|
135
|
-
}
|
|
136
|
-
removeFromFollows(key) {
|
|
137
|
-
if (!this.surveyItem.follows) {
|
|
138
|
-
console.warn('follows array already empty');
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
if (!this.surveyItem.follows.includes(key)) {
|
|
142
|
-
console.warn('follows array does not include key: ', key);
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
this.surveyItem.follows = this.surveyItem.follows.filter(k => k !== key);
|
|
146
|
-
}
|
|
147
|
-
;
|
|
148
|
-
clearFollows() {
|
|
149
|
-
if (!this.surveyItem.follows) {
|
|
150
|
-
console.warn('follows array already empty');
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
this.surveyItem.follows = undefined;
|
|
154
|
-
}
|
|
155
|
-
;
|
|
156
|
-
setCondition(exp) {
|
|
157
|
-
this.surveyItem.condition = exp;
|
|
158
|
-
}
|
|
159
|
-
;
|
|
160
|
-
setPriority(prio) {
|
|
161
|
-
this.surveyItem.priority = prio;
|
|
162
|
-
}
|
|
163
|
-
;
|
|
164
|
-
setMetadata(data) {
|
|
165
|
-
this.surveyItem.metadata = data;
|
|
166
|
-
}
|
|
167
|
-
// methods for survey group items:
|
|
168
|
-
addSurveyItem(item, atPosition) {
|
|
169
|
-
if (atPosition !== undefined) {
|
|
170
|
-
this.surveyItem.items.splice(atPosition, 0, Object.assign({}, item));
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
this.surveyItem.items.push(Object.assign({}, item));
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
;
|
|
177
|
-
updateSurveyItem(item) {
|
|
178
|
-
const ind = this.surveyItem.items.findIndex(it => item.key === it.key);
|
|
179
|
-
if (ind < 0) {
|
|
180
|
-
console.warn('item not found in the items array');
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
this.surveyItem.items[ind] = Object.assign({}, item);
|
|
184
|
-
}
|
|
185
|
-
;
|
|
186
|
-
removeItem(key) {
|
|
187
|
-
if (!this.surveyItem.items.find(it => it.key === key)) {
|
|
188
|
-
console.warn('group items does not contain item with key: ', key);
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
this.surveyItem.items = this.surveyItem.items.filter(it => it.key !== key);
|
|
192
|
-
}
|
|
193
|
-
;
|
|
194
|
-
changeItemPosition(key, newPosition) {
|
|
195
|
-
console.warn('unimplemented');
|
|
196
|
-
}
|
|
197
|
-
;
|
|
198
|
-
setSelectionMethod(exp) {
|
|
199
|
-
this.surveyItem.selectionMethod = exp;
|
|
200
|
-
}
|
|
201
|
-
;
|
|
202
|
-
// methods for survey single items:
|
|
203
|
-
setItemType(type) {
|
|
204
|
-
this.surveyItem.type = type;
|
|
205
|
-
}
|
|
206
|
-
;
|
|
207
|
-
setTitleComponent(title) {
|
|
208
|
-
const currentItem = this.surveyItem;
|
|
209
|
-
if (!currentItem.components) {
|
|
210
|
-
currentItem.components = Object.assign({}, initialRootComp());
|
|
211
|
-
}
|
|
212
|
-
title.role = 'title';
|
|
213
|
-
const ind = currentItem.components.items.findIndex(comp => comp.role === 'title');
|
|
214
|
-
if (ind < 0) {
|
|
215
|
-
currentItem.components.items.push(Object.assign({}, title));
|
|
216
|
-
return;
|
|
217
|
-
}
|
|
218
|
-
currentItem.components.items[ind] = Object.assign({}, title);
|
|
219
|
-
}
|
|
220
|
-
setHelpGroupComponent(helpGroup) {
|
|
221
|
-
const currentItem = this.surveyItem;
|
|
222
|
-
if (!currentItem.components) {
|
|
223
|
-
currentItem.components = Object.assign({}, initialRootComp());
|
|
224
|
-
}
|
|
225
|
-
helpGroup.role = 'helpGroup';
|
|
226
|
-
const ind = currentItem.components.items.findIndex(comp => comp.role === 'helpGroup');
|
|
227
|
-
if (ind < 0) {
|
|
228
|
-
currentItem.components.items.push(Object.assign({}, helpGroup));
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
currentItem.components.items[ind] = Object.assign({}, helpGroup);
|
|
232
|
-
}
|
|
233
|
-
;
|
|
234
|
-
// for warning, error, texts:
|
|
235
|
-
addDisplayComponent(comp, atPosition) {
|
|
236
|
-
const currentItem = this.surveyItem;
|
|
237
|
-
if (!currentItem.components) {
|
|
238
|
-
currentItem.components = Object.assign({}, initialRootComp());
|
|
239
|
-
}
|
|
240
|
-
if (atPosition !== undefined) {
|
|
241
|
-
currentItem.components.items.splice(atPosition, 0, Object.assign({}, comp));
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
currentItem.components.items.push(Object.assign({}, comp));
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
;
|
|
248
|
-
updateDisplayComponent(at, comp) {
|
|
249
|
-
const currentItem = this.surveyItem;
|
|
250
|
-
if (!currentItem.components || !currentItem.components.items || currentItem.components.items.length <= at + 1 || at < 0) {
|
|
251
|
-
console.warn('component not found at ', at);
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
currentItem.components.items[at] = Object.assign({}, comp);
|
|
255
|
-
}
|
|
256
|
-
;
|
|
257
|
-
removeDisplayComponent(at) {
|
|
258
|
-
const currentItem = this.surveyItem;
|
|
259
|
-
if (!currentItem.components || !currentItem.components.items || currentItem.components.items.length <= at + 1 || at < 0) {
|
|
260
|
-
console.warn('component not found at ', at);
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
currentItem.components.items.splice(at, 1);
|
|
264
|
-
}
|
|
265
|
-
;
|
|
266
|
-
addNewResponseComponent(props, parentKey, atPosition) {
|
|
267
|
-
const currentItem = this.surveyItem;
|
|
268
|
-
if (!currentItem.components) {
|
|
269
|
-
currentItem.components = Object.assign({}, initialRootComp());
|
|
270
|
-
}
|
|
271
|
-
if (!parentKey) {
|
|
272
|
-
props.role = 'responseGroup';
|
|
273
|
-
if (!props.key) {
|
|
274
|
-
props.key = 'rg';
|
|
275
|
-
}
|
|
276
|
-
props.isGroup = true;
|
|
277
|
-
const newComponent = (new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, props)).getComponent();
|
|
278
|
-
const ind = currentItem.components.items.findIndex(comp => comp.role === 'responseGroup');
|
|
279
|
-
if (ind < 0) {
|
|
280
|
-
currentItem.components.items.push(newComponent);
|
|
281
|
-
return Object.assign({}, newComponent);
|
|
282
|
-
}
|
|
283
|
-
currentItem.components.items[ind] = newComponent;
|
|
284
|
-
return Object.assign({}, newComponent);
|
|
285
|
-
}
|
|
286
|
-
const ids = parentKey.split('.');
|
|
287
|
-
let obj = undefined;
|
|
288
|
-
for (const currentKey of ids) {
|
|
289
|
-
if (!obj) {
|
|
290
|
-
const ind = currentItem.components.items.findIndex(c => c.key === currentKey);
|
|
291
|
-
if (ind < 0) {
|
|
292
|
-
console.warn('response component not found: ', currentKey);
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
obj = currentItem.components.items[ind];
|
|
296
|
-
continue;
|
|
297
|
-
}
|
|
298
|
-
if (!isItemGroupComponent(obj)) {
|
|
299
|
-
obj.items = [];
|
|
300
|
-
// leaf found
|
|
301
|
-
break;
|
|
302
|
-
}
|
|
303
|
-
const index = obj.items.findIndex(it => it.key === currentKey);
|
|
304
|
-
if (index < 0) {
|
|
305
|
-
console.warn('item component cannot be found: ', currentKey);
|
|
306
|
-
return;
|
|
307
|
-
}
|
|
308
|
-
obj = obj.items[index];
|
|
309
|
-
}
|
|
310
|
-
if (!obj) {
|
|
311
|
-
console.warn('survey item cannot be found: ', parentKey);
|
|
312
|
-
return;
|
|
313
|
-
}
|
|
314
|
-
if (obj.items.find(it => props.key === it.key)) {
|
|
315
|
-
logger_logger.Logger.criticalError('Duplicate key: ' + props.key);
|
|
316
|
-
return undefined;
|
|
317
|
-
}
|
|
318
|
-
const newComponent = (new surveys_surveyEditor_componentEditor.ComponentEditor(undefined, props)).getComponent();
|
|
319
|
-
if (atPosition !== undefined) {
|
|
320
|
-
obj.items.splice(atPosition, 0, newComponent);
|
|
321
|
-
}
|
|
322
|
-
else {
|
|
323
|
-
obj.items.push(newComponent);
|
|
324
|
-
}
|
|
325
|
-
return newComponent;
|
|
326
|
-
}
|
|
327
|
-
;
|
|
328
|
-
addExistingResponseComponent(newComp, parentKey, atPosition) {
|
|
329
|
-
const currentItem = this.surveyItem;
|
|
330
|
-
if (!currentItem.components) {
|
|
331
|
-
currentItem.components = Object.assign({}, initialRootComp());
|
|
332
|
-
}
|
|
333
|
-
if (newComp.key === undefined) {
|
|
334
|
-
newComp.key = surveys_utils_randomKeyGenerator.generateRandomKey(4);
|
|
335
|
-
}
|
|
336
|
-
if (!parentKey) {
|
|
337
|
-
const ind = currentItem.components.items.findIndex(comp => comp.role === 'responseGroup');
|
|
338
|
-
if (ind < 0) {
|
|
339
|
-
currentItem.components.items.push(newComp);
|
|
340
|
-
return Object.assign({}, newComp);
|
|
341
|
-
}
|
|
342
|
-
currentItem.components.items[ind] = newComp;
|
|
343
|
-
return Object.assign({}, newComp);
|
|
344
|
-
}
|
|
345
|
-
const ids = parentKey.split('.');
|
|
346
|
-
let obj = undefined;
|
|
347
|
-
for (const currentKey of ids) {
|
|
348
|
-
if (!obj) {
|
|
349
|
-
const ind = currentItem.components.items.findIndex(c => c.key === currentKey);
|
|
350
|
-
if (ind < 0) {
|
|
351
|
-
console.warn('response component not found: ', currentKey);
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
obj = currentItem.components.items[ind];
|
|
355
|
-
continue;
|
|
356
|
-
}
|
|
357
|
-
if (!isItemGroupComponent(obj)) {
|
|
358
|
-
obj.items = [];
|
|
359
|
-
// leaf found
|
|
360
|
-
break;
|
|
361
|
-
}
|
|
362
|
-
const index = obj.items.findIndex(it => it.key === currentKey);
|
|
363
|
-
if (index < 0) {
|
|
364
|
-
console.warn('item component cannot be found: ', currentKey);
|
|
365
|
-
return;
|
|
366
|
-
}
|
|
367
|
-
obj = obj.items[index];
|
|
368
|
-
}
|
|
369
|
-
if (!obj) {
|
|
370
|
-
console.warn('item component cannot be found: ', parentKey);
|
|
371
|
-
return;
|
|
372
|
-
}
|
|
373
|
-
if (obj.items.find(it => newComp.key === it.key)) {
|
|
374
|
-
logger_logger.Logger.criticalError('Duplicate key: ' + newComp.key);
|
|
375
|
-
return undefined;
|
|
376
|
-
}
|
|
377
|
-
if (atPosition !== undefined) {
|
|
378
|
-
obj.items.splice(atPosition, 0, newComp);
|
|
379
|
-
}
|
|
380
|
-
else {
|
|
381
|
-
obj.items.push(newComp);
|
|
382
|
-
}
|
|
383
|
-
return newComp;
|
|
384
|
-
}
|
|
385
|
-
;
|
|
386
|
-
updateResponseComponent(path, item) {
|
|
387
|
-
const currentItem = this.surveyItem;
|
|
388
|
-
if (!currentItem.components) {
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
const responseGroup = currentItem.components.items.find(comp => comp.role === 'responseGroup');
|
|
392
|
-
if (!responseGroup) {
|
|
393
|
-
console.warn('no responseGroup found');
|
|
394
|
-
return;
|
|
395
|
-
}
|
|
396
|
-
if (responseGroup.key === path) {
|
|
397
|
-
const ind = currentItem.components.items.findIndex(it => it.key === path);
|
|
398
|
-
if (ind < 0) {
|
|
399
|
-
console.warn('item component cannot be found: ', path);
|
|
400
|
-
return;
|
|
401
|
-
}
|
|
402
|
-
currentItem.components.items[ind] = Object.assign({}, item);
|
|
403
|
-
return;
|
|
404
|
-
}
|
|
405
|
-
const ids = path.split('.');
|
|
406
|
-
const parentIds = ids.slice(1, ids.length - 1);
|
|
407
|
-
let obj = responseGroup;
|
|
408
|
-
for (const currentKey of parentIds) {
|
|
409
|
-
if (!isItemGroupComponent(obj)) {
|
|
410
|
-
// leaf found
|
|
411
|
-
break;
|
|
412
|
-
}
|
|
413
|
-
const index = obj.items.findIndex(it => it.key === currentKey);
|
|
414
|
-
if (index < 0) {
|
|
415
|
-
console.warn('item component cannot be found: ', currentKey);
|
|
416
|
-
return;
|
|
417
|
-
}
|
|
418
|
-
obj = obj.items[index];
|
|
419
|
-
}
|
|
420
|
-
if (!obj) {
|
|
421
|
-
console.warn('survey item cannot be found: ', path);
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
424
|
-
const ind = obj.items.findIndex(it => it.key === ids[ids.length - 1]);
|
|
425
|
-
if (ind < 0) {
|
|
426
|
-
console.warn('item component cannot be found: ', path);
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
obj.items[ind] = Object.assign({}, item);
|
|
430
|
-
}
|
|
431
|
-
;
|
|
432
|
-
removeResponseComponent(keyPath) {
|
|
433
|
-
const currentItem = this.surveyItem;
|
|
434
|
-
if (!currentItem.components) {
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
const responseGroup = currentItem.components.items.find(comp => comp.role === 'responseGroup');
|
|
438
|
-
if (!responseGroup) {
|
|
439
|
-
console.warn('no responseGroup found');
|
|
440
|
-
return;
|
|
441
|
-
}
|
|
442
|
-
if (responseGroup.key === keyPath) {
|
|
443
|
-
currentItem.components.items = currentItem.components.items.filter(it => it.role !== 'responseGroup');
|
|
444
|
-
return;
|
|
445
|
-
}
|
|
446
|
-
const ids = keyPath.split('.');
|
|
447
|
-
const parentIds = ids.slice(1, ids.length - 1);
|
|
448
|
-
let obj = responseGroup;
|
|
449
|
-
for (const currentKey of parentIds) {
|
|
450
|
-
if (!isItemGroupComponent(obj)) {
|
|
451
|
-
// leaf found
|
|
452
|
-
break;
|
|
453
|
-
}
|
|
454
|
-
const index = obj.items.findIndex(it => it.key === currentKey);
|
|
455
|
-
if (index < 0) {
|
|
456
|
-
console.warn('item component cannot be found: ', currentKey);
|
|
457
|
-
return;
|
|
458
|
-
}
|
|
459
|
-
obj = obj.items[index];
|
|
460
|
-
}
|
|
461
|
-
if (!obj) {
|
|
462
|
-
console.warn('survey item cannot be found: ', keyPath);
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
|
-
obj.items = obj.items.filter(comp => comp.key !== ids[ids.length - 1]);
|
|
466
|
-
}
|
|
467
|
-
;
|
|
468
|
-
findResponseComponent(key) {
|
|
469
|
-
const currentItem = this.surveyItem;
|
|
470
|
-
if (!currentItem.components) {
|
|
471
|
-
return;
|
|
472
|
-
}
|
|
473
|
-
const ids = key.split('.');
|
|
474
|
-
let obj = undefined;
|
|
475
|
-
for (const currentKey of ids) {
|
|
476
|
-
if (!obj) {
|
|
477
|
-
const ind = currentItem.components.items.findIndex(c => c.key === currentKey);
|
|
478
|
-
if (ind < 0) {
|
|
479
|
-
console.warn('item component not found: ', currentKey);
|
|
480
|
-
return;
|
|
481
|
-
}
|
|
482
|
-
obj = currentItem.components.items[ind];
|
|
483
|
-
continue;
|
|
484
|
-
}
|
|
485
|
-
if (!isItemGroupComponent(obj)) {
|
|
486
|
-
obj.items = [];
|
|
487
|
-
// leaf found
|
|
488
|
-
break;
|
|
489
|
-
}
|
|
490
|
-
const index = obj.items.findIndex(it => it.key === currentKey);
|
|
491
|
-
if (index < 0) {
|
|
492
|
-
console.warn('item component cannot be found: ', currentKey);
|
|
493
|
-
return;
|
|
494
|
-
}
|
|
495
|
-
obj = obj.items[index];
|
|
496
|
-
}
|
|
497
|
-
if (!obj) {
|
|
498
|
-
console.warn('item component cannot be found: ', key);
|
|
499
|
-
return;
|
|
500
|
-
}
|
|
501
|
-
return obj;
|
|
502
|
-
}
|
|
503
|
-
;
|
|
504
|
-
addValidation(v) {
|
|
505
|
-
const currentItem = this.surveyItem;
|
|
506
|
-
if (!currentItem.validations) {
|
|
507
|
-
currentItem.validations = [];
|
|
508
|
-
}
|
|
509
|
-
if (currentItem.validations.find(valid => v.key === valid.key)) {
|
|
510
|
-
console.warn('validation key already used: ', v.key);
|
|
511
|
-
return;
|
|
512
|
-
}
|
|
513
|
-
currentItem.validations.push(Object.assign({}, v));
|
|
514
|
-
this.surveyItem = Object.assign({}, currentItem);
|
|
515
|
-
}
|
|
516
|
-
;
|
|
517
|
-
removeValidation(vKey) {
|
|
518
|
-
const currentItem = this.surveyItem;
|
|
519
|
-
if (!currentItem.validations) {
|
|
520
|
-
console.warn('validation key not found used: ', vKey);
|
|
521
|
-
return;
|
|
522
|
-
}
|
|
523
|
-
if (currentItem.validations.find(valid => vKey === valid.key)) {
|
|
524
|
-
console.warn('validation key not found used: ', vKey);
|
|
525
|
-
return;
|
|
526
|
-
}
|
|
527
|
-
currentItem.validations = currentItem.validations.filter(v => v.key !== vKey);
|
|
528
|
-
this.surveyItem = Object.assign({}, currentItem);
|
|
529
|
-
}
|
|
530
|
-
;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
exports.ItemEditor = ItemEditor;
|
|
534
|
-
exports.isSurveyGroupItem = isSurveyGroupItem;
|
|
535
|
-
//# sourceMappingURL=item-editor-b2c1632b.js.map
|