@pie-element/multi-trait-rubric 6.3.4-next.3 → 7.0.0-beta.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/CHANGELOG.md +0 -11
- package/configure/CHANGELOG.md +0 -11
- package/configure/lib/common.js +375 -534
- package/configure/lib/common.js.map +1 -1
- package/configure/lib/defaults.js +35 -6
- package/configure/lib/defaults.js.map +1 -1
- package/configure/lib/index.js +96 -162
- package/configure/lib/index.js.map +1 -1
- package/configure/lib/main.js +346 -437
- package/configure/lib/main.js.map +1 -1
- package/configure/lib/modals.js +178 -333
- package/configure/lib/modals.js.map +1 -1
- package/configure/lib/scale.js +358 -463
- package/configure/lib/scale.js.map +1 -1
- package/configure/lib/trait.js +253 -358
- package/configure/lib/trait.js.map +1 -1
- package/configure/lib/traitsHeader.js +199 -264
- package/configure/lib/traitsHeader.js.map +1 -1
- package/configure/lib/utils.js +43 -74
- package/configure/lib/utils.js.map +1 -1
- package/configure/package.json +12 -9
- package/controller/lib/defaults.js +2 -3
- package/controller/lib/defaults.js.map +1 -1
- package/controller/lib/index.js +66 -123
- package/controller/lib/index.js.map +1 -1
- package/controller/lib/utils.js +1 -3
- package/controller/lib/utils.js.map +1 -1
- package/controller/package.json +1 -1
- package/lib/index.js +40 -77
- package/lib/index.js.map +1 -1
- package/lib/main.js +99 -140
- package/lib/main.js.map +1 -1
- package/lib/scale.js +217 -299
- package/lib/scale.js.map +1 -1
- package/lib/trait.js +51 -71
- package/lib/trait.js.map +1 -1
- package/package.json +10 -8
- package/esm/configure.js +0 -30404
- package/esm/configure.js.map +0 -1
- package/esm/controller.js +0 -176
- package/esm/controller.js.map +0 -1
- package/esm/element.js +0 -11204
- package/esm/element.js.map +0 -1
- package/esm/package.json +0 -3
package/configure/lib/scale.js
CHANGED
|
@@ -1,95 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
-
|
|
18
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
-
|
|
20
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
-
|
|
22
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
-
|
|
7
|
+
exports.default = exports.Scale = void 0;
|
|
24
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
-
|
|
26
9
|
var _react = _interopRequireDefault(require("react"));
|
|
27
|
-
|
|
28
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
|
|
32
|
-
var _ArrowBackIos = _interopRequireDefault(require("@material-ui/icons/ArrowBackIos"));
|
|
33
|
-
|
|
34
|
-
var _ArrowForwardIos = _interopRequireDefault(require("@material-ui/icons/ArrowForwardIos"));
|
|
35
|
-
|
|
11
|
+
var _styles = require("@mui/material/styles");
|
|
12
|
+
var _ArrowBackIos = _interopRequireDefault(require("@mui/icons-material/ArrowBackIos"));
|
|
13
|
+
var _ArrowForwardIos = _interopRequireDefault(require("@mui/icons-material/ArrowForwardIos"));
|
|
36
14
|
var _drag = require("@pie-lib/drag");
|
|
37
|
-
|
|
38
|
-
var _renderUi = require("@pie-lib/render-ui");
|
|
39
|
-
|
|
40
15
|
var _traitsHeader = _interopRequireDefault(require("./traitsHeader"));
|
|
41
|
-
|
|
42
16
|
var _trait = _interopRequireDefault(require("./trait"));
|
|
43
|
-
|
|
44
17
|
var _common = require("./common");
|
|
45
|
-
|
|
46
18
|
var _modals = require("./modals");
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
},
|
|
63
|
-
maxPoints: {
|
|
64
|
-
width: '300px',
|
|
65
|
-
marginTop: theme.spacing.unit * 2,
|
|
66
|
-
marginBottom: theme.spacing.unit * 4
|
|
67
|
-
},
|
|
68
|
-
trait: {
|
|
69
|
-
background: _renderUi.color.secondaryBackground(),
|
|
70
|
-
marginTop: theme.spacing.unit * 2,
|
|
71
|
-
marginBottom: theme.spacing.unit * 2,
|
|
72
|
-
padding: theme.spacing.unit * 2
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
var Scale = /*#__PURE__*/function (_React$Component) {
|
|
78
|
-
(0, _inherits2["default"])(Scale, _React$Component);
|
|
79
|
-
|
|
80
|
-
var _super = _createSuper(Scale);
|
|
81
|
-
|
|
82
|
-
function Scale() {
|
|
83
|
-
var _this;
|
|
84
|
-
|
|
85
|
-
(0, _classCallCheck2["default"])(this, Scale);
|
|
86
|
-
|
|
87
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
88
|
-
args[_key] = arguments[_key];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
92
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
|
|
19
|
+
const AdjustedBlockWidth = _common.BlockWidth + 2 * 8; // 8 is padding
|
|
20
|
+
|
|
21
|
+
const ScaleWrapper = (0, _styles.styled)('div')(({
|
|
22
|
+
theme
|
|
23
|
+
}) => ({
|
|
24
|
+
display: 'flex',
|
|
25
|
+
flexDirection: 'column',
|
|
26
|
+
wordBreak: 'break-word',
|
|
27
|
+
position: 'relative',
|
|
28
|
+
marginBottom: theme.spacing(2.5)
|
|
29
|
+
}));
|
|
30
|
+
class Scale extends _react.default.Component {
|
|
31
|
+
constructor(...args) {
|
|
32
|
+
super(...args);
|
|
33
|
+
(0, _defineProperty2.default)(this, "state", {
|
|
93
34
|
showDecreaseMaxPointsDialog: false,
|
|
94
35
|
showDeleteScaleDialog: false,
|
|
95
36
|
showDeleteTraitDialog: false,
|
|
@@ -99,28 +40,27 @@ var Scale = /*#__PURE__*/function (_React$Component) {
|
|
|
99
40
|
showInfoDialog: false,
|
|
100
41
|
infoDialogText: ''
|
|
101
42
|
});
|
|
102
|
-
(0, _defineProperty2
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
43
|
+
(0, _defineProperty2.default)(this, "set", newState => this.setState(newState));
|
|
44
|
+
// Max Points
|
|
45
|
+
(0, _defineProperty2.default)(this, "updateMaxPointsFieldValue", ({
|
|
46
|
+
target
|
|
47
|
+
}) => {
|
|
48
|
+
const {
|
|
49
|
+
scale,
|
|
50
|
+
scaleIndex,
|
|
51
|
+
onScaleChanged
|
|
52
|
+
} = this.props || {};
|
|
53
|
+
const {
|
|
54
|
+
maxPoints
|
|
55
|
+
} = scale;
|
|
56
|
+
const numberValue = parseInt(target.value, 10);
|
|
57
|
+
this.setState({
|
|
117
58
|
currentPosition: 0,
|
|
118
59
|
showLeft: false,
|
|
119
|
-
showRight:
|
|
60
|
+
showRight: this.secondaryBlockRef && this.secondaryBlockRef.scrollWidth - this.secondaryBlockRef.offsetWidth
|
|
120
61
|
});
|
|
121
|
-
|
|
122
62
|
if (numberValue < maxPoints) {
|
|
123
|
-
|
|
63
|
+
this.showDecreaseMaxPointsModal({
|
|
124
64
|
newMaxPoints: numberValue
|
|
125
65
|
});
|
|
126
66
|
} else {
|
|
@@ -129,428 +69,383 @@ var Scale = /*#__PURE__*/function (_React$Component) {
|
|
|
129
69
|
});
|
|
130
70
|
}
|
|
131
71
|
});
|
|
132
|
-
(0, _defineProperty2
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
scaleIndex = _ref5.scaleIndex,
|
|
151
|
-
onScaleChanged = _ref5.onScaleChanged;
|
|
152
|
-
|
|
72
|
+
(0, _defineProperty2.default)(this, "showDecreaseMaxPointsModal", ({
|
|
73
|
+
newMaxPoints
|
|
74
|
+
}) => this.set({
|
|
75
|
+
showDecreaseMaxPointsDialog: true,
|
|
76
|
+
newMaxPoints
|
|
77
|
+
}));
|
|
78
|
+
(0, _defineProperty2.default)(this, "hideDecreaseMaxPointsModal", () => this.set({
|
|
79
|
+
showDecreaseMaxPointsDialog: false,
|
|
80
|
+
newMaxPoints: undefined
|
|
81
|
+
}));
|
|
82
|
+
(0, _defineProperty2.default)(this, "changeMaxPoints", () => {
|
|
83
|
+
const {
|
|
84
|
+
newMaxPoints
|
|
85
|
+
} = this.state || {};
|
|
86
|
+
const {
|
|
87
|
+
scaleIndex,
|
|
88
|
+
onScaleChanged
|
|
89
|
+
} = this.props || {};
|
|
153
90
|
if (newMaxPoints) {
|
|
154
91
|
onScaleChanged(scaleIndex, {
|
|
155
92
|
maxPoints: newMaxPoints
|
|
156
93
|
});
|
|
157
94
|
}
|
|
158
|
-
|
|
159
|
-
_this.hideDecreaseMaxPointsModal();
|
|
160
|
-
});
|
|
161
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "showDeleteScaleModal", function () {
|
|
162
|
-
return _this.set({
|
|
163
|
-
showDeleteScaleDialog: true
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "hideDeleteScaleModal", function () {
|
|
167
|
-
return _this.set({
|
|
168
|
-
showDeleteScaleDialog: false
|
|
169
|
-
});
|
|
95
|
+
this.hideDecreaseMaxPointsModal();
|
|
170
96
|
});
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
97
|
+
// Delete Scale
|
|
98
|
+
(0, _defineProperty2.default)(this, "showDeleteScaleModal", () => this.set({
|
|
99
|
+
showDeleteScaleDialog: true
|
|
100
|
+
}));
|
|
101
|
+
(0, _defineProperty2.default)(this, "hideDeleteScaleModal", () => this.set({
|
|
102
|
+
showDeleteScaleDialog: false
|
|
103
|
+
}));
|
|
104
|
+
(0, _defineProperty2.default)(this, "deleteScale", () => {
|
|
105
|
+
const {
|
|
106
|
+
scaleIndex,
|
|
107
|
+
onScaleRemoved
|
|
108
|
+
} = this.props || {};
|
|
109
|
+
this.hideDeleteScaleModal();
|
|
178
110
|
onScaleRemoved(scaleIndex);
|
|
179
111
|
});
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
traitLabel = _ref8.traitLabel;
|
|
204
|
-
|
|
112
|
+
// Delete Trait
|
|
113
|
+
(0, _defineProperty2.default)(this, "showDeleteTraitModal", traitToDeleteIndex => this.set({
|
|
114
|
+
showDeleteTraitDialog: true,
|
|
115
|
+
traitToDeleteIndex
|
|
116
|
+
}));
|
|
117
|
+
(0, _defineProperty2.default)(this, "hideDeleteTraitModal", () => this.set({
|
|
118
|
+
showDeleteTraitDialog: false,
|
|
119
|
+
traitToDeleteIndex: undefined
|
|
120
|
+
}));
|
|
121
|
+
(0, _defineProperty2.default)(this, "onTraitRemoved", () => {
|
|
122
|
+
const {
|
|
123
|
+
traitToDeleteIndex
|
|
124
|
+
} = this.state;
|
|
125
|
+
const {
|
|
126
|
+
scale,
|
|
127
|
+
scaleIndex,
|
|
128
|
+
onScaleChanged,
|
|
129
|
+
minNoOfTraits
|
|
130
|
+
} = this.props || {};
|
|
131
|
+
let {
|
|
132
|
+
traits,
|
|
133
|
+
traitLabel
|
|
134
|
+
} = scale || {};
|
|
205
135
|
if (traitToDeleteIndex < 0 || traitToDeleteIndex >= traits.length) return;
|
|
206
|
-
|
|
207
136
|
if (traits.length === minNoOfTraits) {
|
|
208
|
-
|
|
209
|
-
infoDialogText:
|
|
137
|
+
this.set({
|
|
138
|
+
infoDialogText: `There can't be less than ${minNoOfTraits} ${(traitLabel || 'trait').toLowerCase()}s.`,
|
|
210
139
|
showInfoDialog: true
|
|
211
140
|
});
|
|
212
|
-
|
|
213
141
|
return false;
|
|
214
142
|
}
|
|
215
|
-
|
|
216
|
-
traits = [].concat((0, _toConsumableArray2["default"])(traits.slice(0, traitToDeleteIndex)), (0, _toConsumableArray2["default"])(traits.slice(traitToDeleteIndex + 1)));
|
|
143
|
+
traits = [...traits.slice(0, traitToDeleteIndex), ...traits.slice(traitToDeleteIndex + 1)];
|
|
217
144
|
onScaleChanged(scaleIndex, {
|
|
218
|
-
traits
|
|
145
|
+
traits
|
|
219
146
|
});
|
|
220
|
-
|
|
221
|
-
_this.hideDeleteTraitModal();
|
|
147
|
+
this.hideDeleteTraitModal();
|
|
222
148
|
});
|
|
223
|
-
(0, _defineProperty2
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
149
|
+
(0, _defineProperty2.default)(this, "onTraitAdded", () => {
|
|
150
|
+
const {
|
|
151
|
+
scale,
|
|
152
|
+
scaleIndex,
|
|
153
|
+
onScaleChanged,
|
|
154
|
+
maxNoOfTraits
|
|
155
|
+
} = this.props || {};
|
|
156
|
+
const {
|
|
157
|
+
traits,
|
|
158
|
+
scorePointsLabels
|
|
159
|
+
} = scale || {};
|
|
234
160
|
if (traits.length === maxNoOfTraits) {
|
|
235
|
-
|
|
236
|
-
infoDialogText:
|
|
161
|
+
this.set({
|
|
162
|
+
infoDialogText: `There can't be more than ${maxNoOfTraits} scales.`,
|
|
237
163
|
showInfoDialog: true
|
|
238
164
|
});
|
|
239
|
-
|
|
240
165
|
return false;
|
|
241
166
|
}
|
|
242
|
-
|
|
243
167
|
traits.push({
|
|
244
168
|
name: '',
|
|
245
169
|
description: '',
|
|
246
170
|
standards: [],
|
|
247
171
|
scorePointsDescriptors: Array.from({
|
|
248
172
|
length: scorePointsLabels.length
|
|
249
|
-
},
|
|
250
|
-
return '';
|
|
251
|
-
})
|
|
173
|
+
}, () => '')
|
|
252
174
|
});
|
|
253
175
|
onScaleChanged(scaleIndex, {
|
|
254
|
-
traits
|
|
176
|
+
traits
|
|
255
177
|
});
|
|
256
178
|
});
|
|
257
|
-
(0, _defineProperty2
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
179
|
+
(0, _defineProperty2.default)(this, "onTraitChanged", (traitIndex, trait) => {
|
|
180
|
+
const {
|
|
181
|
+
scale,
|
|
182
|
+
scaleIndex,
|
|
183
|
+
onScaleChanged
|
|
184
|
+
} = this.props || {};
|
|
185
|
+
const {
|
|
186
|
+
traits
|
|
187
|
+
} = scale || {};
|
|
266
188
|
if (traitIndex >= 0 && traitIndex < traits.length) {
|
|
267
189
|
traits[traitIndex] = trait;
|
|
268
190
|
onScaleChanged(scaleIndex, {
|
|
269
|
-
traits
|
|
191
|
+
traits
|
|
270
192
|
});
|
|
271
193
|
}
|
|
272
194
|
});
|
|
273
|
-
(0, _defineProperty2
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
195
|
+
(0, _defineProperty2.default)(this, "onTraitDropped", event => {
|
|
196
|
+
const {
|
|
197
|
+
active,
|
|
198
|
+
over
|
|
199
|
+
} = event;
|
|
200
|
+
if (!over || !active) return;
|
|
201
|
+
const activeData = active.data.current;
|
|
202
|
+
const overData = over.data.current;
|
|
203
|
+
if (activeData?.type === 'trait' && overData?.type === 'trait') {
|
|
204
|
+
const oldIndex = activeData.index;
|
|
205
|
+
const newIndex = overData.index;
|
|
206
|
+
if (oldIndex === newIndex) return;
|
|
207
|
+
const {
|
|
208
|
+
scale,
|
|
209
|
+
scaleIndex,
|
|
210
|
+
onScaleChanged
|
|
211
|
+
} = this.props || {};
|
|
212
|
+
const {
|
|
213
|
+
traits
|
|
214
|
+
} = scale || {};
|
|
215
|
+
const cup = traits[oldIndex];
|
|
216
|
+
const remainingTraits = traits.filter((item, index) => index !== oldIndex);
|
|
217
|
+
const newTraits = [...remainingTraits.slice(0, newIndex), cup, ...remainingTraits.slice(newIndex)];
|
|
218
|
+
onScaleChanged(scaleIndex, {
|
|
219
|
+
traits: newTraits
|
|
220
|
+
});
|
|
221
|
+
}
|
|
291
222
|
});
|
|
292
|
-
(0, _defineProperty2
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
223
|
+
(0, _defineProperty2.default)(this, "decreasePosition", () => {
|
|
224
|
+
const {
|
|
225
|
+
currentPosition
|
|
226
|
+
} = this.state;
|
|
227
|
+
const decreasedPosition = currentPosition - (currentPosition === AdjustedBlockWidth / 2 ? AdjustedBlockWidth / 2 : AdjustedBlockWidth);
|
|
228
|
+
this.setState({
|
|
297
229
|
currentPosition: decreasedPosition,
|
|
298
|
-
showRight: decreasedPosition <
|
|
230
|
+
showRight: decreasedPosition < this.secondaryBlockRef.scrollWidth - this.secondaryBlockRef.offsetWidth,
|
|
299
231
|
showLeft: decreasedPosition > 0
|
|
300
232
|
});
|
|
301
233
|
});
|
|
302
|
-
(0, _defineProperty2
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
234
|
+
(0, _defineProperty2.default)(this, "increasePosition", () => {
|
|
235
|
+
const {
|
|
236
|
+
currentPosition
|
|
237
|
+
} = this.state;
|
|
238
|
+
const increasedPosition = currentPosition + (currentPosition === 0 ? AdjustedBlockWidth / 2 : AdjustedBlockWidth);
|
|
239
|
+
this.setState({
|
|
307
240
|
currentPosition: increasedPosition,
|
|
308
|
-
showRight: increasedPosition <
|
|
241
|
+
showRight: increasedPosition < this.secondaryBlockRef.scrollWidth - this.secondaryBlockRef.offsetWidth,
|
|
309
242
|
showLeft: increasedPosition > 0
|
|
310
243
|
});
|
|
311
244
|
});
|
|
312
|
-
return _this;
|
|
313
245
|
}
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
this.setState({
|
|
320
|
-
showRight: this.secondaryBlockRef.scrollWidth - this.secondaryBlockRef.offsetWidth
|
|
321
|
-
});
|
|
322
|
-
}
|
|
246
|
+
componentDidMount() {
|
|
247
|
+
if (this.state.showRight === null && this.secondaryBlockRef) {
|
|
248
|
+
this.setState({
|
|
249
|
+
showRight: this.secondaryBlockRef.scrollWidth - this.secondaryBlockRef.offsetWidth
|
|
250
|
+
});
|
|
323
251
|
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
this.
|
|
329
|
-
|
|
330
|
-
});
|
|
331
|
-
}
|
|
252
|
+
}
|
|
253
|
+
componentDidUpdate(prevProps) {
|
|
254
|
+
if (prevProps.scale.maxPoints !== this.props.scale.maxPoints || prevProps.showDescription !== this.props.showDescription || prevProps.excludeZero !== this.props.excludeZero) {
|
|
255
|
+
this.setState({
|
|
256
|
+
showRight: this.secondaryBlockRef.scrollWidth - this.secondaryBlockRef.offsetWidth
|
|
257
|
+
});
|
|
332
258
|
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
// determining the score points values
|
|
401
|
-
|
|
402
|
-
for (var pointValue = maxPoints; pointValue >= excludeZero ? 1 : 0; pointValue -= 1) {
|
|
403
|
-
scorePointsValues.push(pointValue);
|
|
259
|
+
}
|
|
260
|
+
UNSAFE_componentWillReceiveProps(nextProps) {
|
|
261
|
+
if (nextProps.excludeZero !== this.props.excludeZero || nextProps.showStandards !== this.props.showStandards || nextProps.showDescription !== this.props.showDescription) {
|
|
262
|
+
this.setState({
|
|
263
|
+
currentPosition: 0,
|
|
264
|
+
showLeft: false,
|
|
265
|
+
showRight: this.secondaryBlockRef && this.secondaryBlockRef.scrollWidth - this.secondaryBlockRef.offsetWidth
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
render() {
|
|
270
|
+
const {
|
|
271
|
+
errors,
|
|
272
|
+
scale,
|
|
273
|
+
scaleIndex,
|
|
274
|
+
showStandards,
|
|
275
|
+
onScaleChanged,
|
|
276
|
+
excludeZero,
|
|
277
|
+
showDescription,
|
|
278
|
+
showLevelTagInput,
|
|
279
|
+
showScorePointLabels,
|
|
280
|
+
enableDragAndDrop,
|
|
281
|
+
spellCheck,
|
|
282
|
+
width,
|
|
283
|
+
uploadSoundSupport,
|
|
284
|
+
maxPointsEnabled,
|
|
285
|
+
mathMlOptions = {},
|
|
286
|
+
maxMaxPoints,
|
|
287
|
+
expandedPluginProps = {},
|
|
288
|
+
labelPluginProps = {},
|
|
289
|
+
imageSupport = {}
|
|
290
|
+
} = this.props || {};
|
|
291
|
+
const {
|
|
292
|
+
maxPoints,
|
|
293
|
+
scorePointsLabels,
|
|
294
|
+
traitLabel,
|
|
295
|
+
traits
|
|
296
|
+
} = scale || {};
|
|
297
|
+
const {
|
|
298
|
+
showDecreaseMaxPointsDialog,
|
|
299
|
+
showDeleteScaleDialog,
|
|
300
|
+
showDeleteTraitDialog,
|
|
301
|
+
currentPosition,
|
|
302
|
+
showRight,
|
|
303
|
+
showLeft,
|
|
304
|
+
showInfoDialog,
|
|
305
|
+
infoDialogText
|
|
306
|
+
} = this.state;
|
|
307
|
+
const {
|
|
308
|
+
traitsErrors,
|
|
309
|
+
scorePointsErrors
|
|
310
|
+
} = errors || {};
|
|
311
|
+
const currentScaleTraitsErrors = traitsErrors && traitsErrors[scaleIndex] || {};
|
|
312
|
+
const currentScalePointsLabelsErrors = scorePointsErrors && scorePointsErrors[scaleIndex] || {};
|
|
313
|
+
const scorePointsValues = [];
|
|
314
|
+
const secondaryBlockWidth = parseInt(width) - _common.DragHandleSpace - _common.PrimaryBlockWidth || 320; // 320 is minWidth
|
|
315
|
+
|
|
316
|
+
// determining the score points values
|
|
317
|
+
for (let pointValue = maxPoints; pointValue >= excludeZero ? 1 : 0; pointValue -= 1) {
|
|
318
|
+
scorePointsValues.push(pointValue);
|
|
319
|
+
}
|
|
320
|
+
return /*#__PURE__*/_react.default.createElement(_drag.DragProvider, {
|
|
321
|
+
onDragEnd: this.onTraitDropped
|
|
322
|
+
}, /*#__PURE__*/_react.default.createElement(ScaleWrapper, {
|
|
323
|
+
key: `scale-${scaleIndex}`,
|
|
324
|
+
ref: ref => {
|
|
325
|
+
this.scaleWrapper = ref;
|
|
404
326
|
}
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
ref: function ref(_ref18) {
|
|
410
|
-
_this2.scaleWrapper = _ref18;
|
|
411
|
-
}
|
|
412
|
-
}, /*#__PURE__*/_react["default"].createElement(_traitsHeader["default"], {
|
|
413
|
-
setSecondaryBlockRef: function setSecondaryBlockRef(ref) {
|
|
414
|
-
if (ref) {
|
|
415
|
-
_this2.secondaryBlockRef = ref;
|
|
416
|
-
}
|
|
417
|
-
},
|
|
418
|
-
key: 'header-key',
|
|
419
|
-
errors: currentScalePointsLabelsErrors,
|
|
420
|
-
traitLabel: traitLabel,
|
|
421
|
-
scorePointsValues: scorePointsValues,
|
|
422
|
-
scorePointsLabels: scorePointsLabels,
|
|
423
|
-
onScaleChange: function onScaleChange(params) {
|
|
424
|
-
return onScaleChanged(scaleIndex, params);
|
|
425
|
-
},
|
|
426
|
-
onTraitLabelChange: function onTraitLabelChange(label) {
|
|
427
|
-
return onScaleChanged(scaleIndex, {
|
|
428
|
-
traitLabel: label
|
|
429
|
-
});
|
|
430
|
-
},
|
|
431
|
-
showStandards: showStandards,
|
|
432
|
-
showDescription: showDescription,
|
|
433
|
-
showLevelTagInput: showLevelTagInput,
|
|
434
|
-
showScorePointLabels: showScorePointLabels,
|
|
435
|
-
maxPoints: maxPoints,
|
|
436
|
-
updateMaxPointsFieldValue: this.updateMaxPointsFieldValue,
|
|
437
|
-
scaleIndex: scaleIndex,
|
|
438
|
-
showDeleteScaleModal: this.showDeleteScaleModal,
|
|
439
|
-
currentPosition: currentPosition,
|
|
440
|
-
secondaryBlockWidth: secondaryBlockWidth,
|
|
441
|
-
spellCheck: spellCheck,
|
|
442
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
443
|
-
maxPointsEnabled: maxPointsEnabled,
|
|
444
|
-
mathMlOptions: mathMlOptions,
|
|
445
|
-
maxMaxPoints: maxMaxPoints,
|
|
446
|
-
expandedPluginProps: expandedPluginProps,
|
|
447
|
-
labelPluginProps: labelPluginProps,
|
|
448
|
-
imageSupport: imageSupport
|
|
449
|
-
}), traits.map(function (trait, index) {
|
|
450
|
-
return /*#__PURE__*/_react["default"].createElement(_trait["default"], {
|
|
451
|
-
key: index,
|
|
452
|
-
index: index,
|
|
453
|
-
error: currentScaleTraitsErrors && currentScaleTraitsErrors[index],
|
|
454
|
-
trait: trait,
|
|
455
|
-
traitLabel: traitLabel || 'Trait',
|
|
456
|
-
scorePointsValues: scorePointsValues,
|
|
457
|
-
scorePointsLabels: scorePointsLabels,
|
|
458
|
-
onTraitRemoved: function onTraitRemoved() {
|
|
459
|
-
return _this2.showDeleteTraitModal(index);
|
|
460
|
-
},
|
|
461
|
-
onTraitChanged: function onTraitChanged(trait) {
|
|
462
|
-
return _this2.onTraitChanged(index, trait);
|
|
463
|
-
},
|
|
464
|
-
onTraitDropped: _this2.onTraitDropped,
|
|
465
|
-
showStandards: showStandards,
|
|
466
|
-
showDescription: showDescription,
|
|
467
|
-
maxPoints: maxPoints,
|
|
468
|
-
currentPosition: currentPosition,
|
|
469
|
-
enableDragAndDrop: enableDragAndDrop,
|
|
470
|
-
secondaryBlockWidth: secondaryBlockWidth,
|
|
471
|
-
spellCheck: spellCheck,
|
|
472
|
-
uploadSoundSupport: uploadSoundSupport,
|
|
473
|
-
mathMlOptions: mathMlOptions,
|
|
474
|
-
expandedPluginProps: expandedPluginProps,
|
|
475
|
-
labelPluginProps: labelPluginProps,
|
|
476
|
-
imageSupport: imageSupport
|
|
477
|
-
});
|
|
478
|
-
}), /*#__PURE__*/_react["default"].createElement(_common.Arrow, {
|
|
479
|
-
width: "".concat(AdjustedBlockWidth / 2, "px"),
|
|
480
|
-
show: showLeft,
|
|
481
|
-
onClick: this.decreasePosition,
|
|
482
|
-
left: "".concat(_common.PrimaryBlockWidth, "px"),
|
|
483
|
-
showLevelTagInput: showLevelTagInput
|
|
484
|
-
}, /*#__PURE__*/_react["default"].createElement(_ArrowBackIos["default"], null)), /*#__PURE__*/_react["default"].createElement(_common.Arrow, {
|
|
485
|
-
width: "".concat(AdjustedBlockWidth / 2, "px"),
|
|
486
|
-
show: showRight,
|
|
487
|
-
onClick: this.increasePosition,
|
|
488
|
-
showLevelTagInput: showLevelTagInput
|
|
489
|
-
}, /*#__PURE__*/_react["default"].createElement(_ArrowForwardIos["default"], null)), /*#__PURE__*/_react["default"].createElement(_common.MultiTraitButton, {
|
|
490
|
-
onClick: this.onTraitAdded
|
|
491
|
-
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
492
|
-
dangerouslySetInnerHTML: {
|
|
493
|
-
__html: "Add ".concat(traitLabel || ' Trait')
|
|
327
|
+
}, /*#__PURE__*/_react.default.createElement(_traitsHeader.default, {
|
|
328
|
+
setSecondaryBlockRef: ref => {
|
|
329
|
+
if (ref) {
|
|
330
|
+
this.secondaryBlockRef = ref;
|
|
494
331
|
}
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
}),
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
332
|
+
},
|
|
333
|
+
key: 'header-key',
|
|
334
|
+
errors: currentScalePointsLabelsErrors,
|
|
335
|
+
traitLabel: traitLabel,
|
|
336
|
+
scorePointsValues: scorePointsValues,
|
|
337
|
+
scorePointsLabels: scorePointsLabels,
|
|
338
|
+
onScaleChange: params => onScaleChanged(scaleIndex, params),
|
|
339
|
+
onTraitLabelChange: label => onScaleChanged(scaleIndex, {
|
|
340
|
+
traitLabel: label
|
|
341
|
+
}),
|
|
342
|
+
showStandards: showStandards,
|
|
343
|
+
showDescription: showDescription,
|
|
344
|
+
showLevelTagInput: showLevelTagInput,
|
|
345
|
+
showScorePointLabels: showScorePointLabels,
|
|
346
|
+
maxPoints: maxPoints,
|
|
347
|
+
updateMaxPointsFieldValue: this.updateMaxPointsFieldValue,
|
|
348
|
+
scaleIndex: scaleIndex,
|
|
349
|
+
showDeleteScaleModal: this.showDeleteScaleModal,
|
|
350
|
+
currentPosition: currentPosition,
|
|
351
|
+
secondaryBlockWidth: secondaryBlockWidth,
|
|
352
|
+
spellCheck: spellCheck,
|
|
353
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
354
|
+
maxPointsEnabled: maxPointsEnabled,
|
|
355
|
+
mathMlOptions: mathMlOptions,
|
|
356
|
+
maxMaxPoints: maxMaxPoints,
|
|
357
|
+
expandedPluginProps: expandedPluginProps,
|
|
358
|
+
labelPluginProps: labelPluginProps,
|
|
359
|
+
imageSupport: imageSupport
|
|
360
|
+
}), traits.map((trait, index) => /*#__PURE__*/_react.default.createElement(_trait.default, {
|
|
361
|
+
key: index,
|
|
362
|
+
index: index,
|
|
363
|
+
error: currentScaleTraitsErrors && currentScaleTraitsErrors[index],
|
|
364
|
+
trait: trait,
|
|
365
|
+
traitLabel: traitLabel || 'Trait',
|
|
366
|
+
scorePointsValues: scorePointsValues,
|
|
367
|
+
scorePointsLabels: scorePointsLabels,
|
|
368
|
+
onTraitRemoved: () => this.showDeleteTraitModal(index),
|
|
369
|
+
onTraitChanged: trait => this.onTraitChanged(index, trait),
|
|
370
|
+
showStandards: showStandards,
|
|
371
|
+
showDescription: showDescription,
|
|
372
|
+
maxPoints: maxPoints,
|
|
373
|
+
currentPosition: currentPosition,
|
|
374
|
+
enableDragAndDrop: enableDragAndDrop,
|
|
375
|
+
secondaryBlockWidth: secondaryBlockWidth,
|
|
376
|
+
spellCheck: spellCheck,
|
|
377
|
+
uploadSoundSupport: uploadSoundSupport,
|
|
378
|
+
mathMlOptions: mathMlOptions,
|
|
379
|
+
expandedPluginProps: expandedPluginProps,
|
|
380
|
+
labelPluginProps: labelPluginProps,
|
|
381
|
+
imageSupport: imageSupport
|
|
382
|
+
})), /*#__PURE__*/_react.default.createElement(_common.Arrow, {
|
|
383
|
+
width: `${AdjustedBlockWidth / 2}px`,
|
|
384
|
+
show: showLeft,
|
|
385
|
+
onClick: this.decreasePosition,
|
|
386
|
+
left: `${_common.PrimaryBlockWidth}px`,
|
|
387
|
+
showLevelTagInput: showLevelTagInput
|
|
388
|
+
}, /*#__PURE__*/_react.default.createElement(_ArrowBackIos.default, null)), /*#__PURE__*/_react.default.createElement(_common.Arrow, {
|
|
389
|
+
width: `${AdjustedBlockWidth / 2}px`,
|
|
390
|
+
show: showRight,
|
|
391
|
+
onClick: this.increasePosition,
|
|
392
|
+
showLevelTagInput: showLevelTagInput
|
|
393
|
+
}, /*#__PURE__*/_react.default.createElement(_ArrowForwardIos.default, null)), /*#__PURE__*/_react.default.createElement(_common.MultiTraitButton, {
|
|
394
|
+
onClick: this.onTraitAdded
|
|
395
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
396
|
+
dangerouslySetInnerHTML: {
|
|
397
|
+
__html: `Add ${traitLabel || ' Trait'}`
|
|
398
|
+
}
|
|
399
|
+
})), /*#__PURE__*/_react.default.createElement(_modals.DecreaseMaxPoints, {
|
|
400
|
+
open: !!showDecreaseMaxPointsDialog,
|
|
401
|
+
deleteScorePoints: this.changeMaxPoints,
|
|
402
|
+
cancel: this.hideDecreaseMaxPointsModal
|
|
403
|
+
}), /*#__PURE__*/_react.default.createElement(_modals.DeleteScale, {
|
|
404
|
+
open: !!showDeleteScaleDialog,
|
|
405
|
+
scaleIndex: scaleIndex,
|
|
406
|
+
deleteScale: this.deleteScale,
|
|
407
|
+
cancel: this.hideDeleteScaleModal
|
|
408
|
+
}), /*#__PURE__*/_react.default.createElement(_modals.DeleteTrait, {
|
|
409
|
+
open: !!showDeleteTraitDialog,
|
|
410
|
+
deleteTrait: this.onTraitRemoved,
|
|
411
|
+
cancel: this.hideDeleteTraitModal,
|
|
412
|
+
traitLabel: traitLabel.toLowerCase()
|
|
413
|
+
}), /*#__PURE__*/_react.default.createElement(_modals.InfoDialog, {
|
|
414
|
+
open: showInfoDialog,
|
|
415
|
+
text: infoDialogText,
|
|
416
|
+
onClose: () => this.set({
|
|
417
|
+
showInfoDialog: false
|
|
418
|
+
})
|
|
419
|
+
})));
|
|
420
|
+
}
|
|
421
|
+
}
|
|
523
422
|
exports.Scale = Scale;
|
|
524
423
|
Scale.propTypes = {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
description: _propTypes["default"].string
|
|
424
|
+
errors: _propTypes.default.object,
|
|
425
|
+
scale: _propTypes.default.shape({
|
|
426
|
+
maxPoints: _propTypes.default.number,
|
|
427
|
+
scorePointsLabels: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
428
|
+
traitLabel: _propTypes.default.string,
|
|
429
|
+
traits: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
430
|
+
name: _propTypes.default.string,
|
|
431
|
+
standards: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
432
|
+
scorePointsDescriptors: _propTypes.default.arrayOf(_propTypes.default.string),
|
|
433
|
+
description: _propTypes.default.string
|
|
536
434
|
}))
|
|
537
435
|
}),
|
|
538
|
-
width: _propTypes
|
|
539
|
-
excludeZero: _propTypes
|
|
540
|
-
scaleIndex: _propTypes
|
|
541
|
-
onScaleChanged: _propTypes
|
|
542
|
-
onScaleRemoved: _propTypes
|
|
543
|
-
showStandards: _propTypes
|
|
544
|
-
showLevelTagInput: _propTypes
|
|
545
|
-
showDescription: _propTypes
|
|
546
|
-
uploadSoundSupport: _propTypes
|
|
547
|
-
showScorePointLabels: _propTypes
|
|
548
|
-
enableDragAndDrop: _propTypes
|
|
549
|
-
expandedPluginProps: _propTypes
|
|
550
|
-
labelPluginProps: _propTypes
|
|
436
|
+
width: _propTypes.default.string,
|
|
437
|
+
excludeZero: _propTypes.default.bool,
|
|
438
|
+
scaleIndex: _propTypes.default.number,
|
|
439
|
+
onScaleChanged: _propTypes.default.func,
|
|
440
|
+
onScaleRemoved: _propTypes.default.func,
|
|
441
|
+
showStandards: _propTypes.default.bool,
|
|
442
|
+
showLevelTagInput: _propTypes.default.bool,
|
|
443
|
+
showDescription: _propTypes.default.bool,
|
|
444
|
+
uploadSoundSupport: _propTypes.default.object,
|
|
445
|
+
showScorePointLabels: _propTypes.default.bool,
|
|
446
|
+
enableDragAndDrop: _propTypes.default.bool,
|
|
447
|
+
expandedPluginProps: _propTypes.default.object,
|
|
448
|
+
labelPluginProps: _propTypes.default.object
|
|
551
449
|
};
|
|
552
|
-
|
|
553
|
-
var _default = (0, _drag.withDragContext)((0, _styles.withStyles)(styles)(Scale));
|
|
554
|
-
|
|
555
|
-
exports["default"] = _default;
|
|
450
|
+
var _default = exports.default = Scale;
|
|
556
451
|
//# sourceMappingURL=scale.js.map
|