Skip to content

Commit 0091549

Browse files
Merge pull request #1567 from pie-framework/master-copy
Master copy
2 parents bfebe0b + 72cc9ef commit 0091549

17 files changed

Lines changed: 355 additions & 115 deletions

File tree

packages/charting/configure/src/__tests__/__snapshots__/configure.test.js.snap

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ exports[`ChartingConfig renders snapshot 1`] = `
1919
</WithStyles(Typography)>
2020
<Chart
2121
addCategoryEnabled={true}
22-
changeEditableEnabled={true}
23-
changeInteractiveEnabled={true}
22+
changeEditableEnabled={false}
23+
changeInteractiveEnabled={false}
2424
chartType="lineCross"
2525
data={Array []}
2626
defineChart={true}
@@ -44,12 +44,6 @@ exports[`ChartingConfig renders snapshot 1`] = `
4444
}
4545
title=""
4646
/>
47-
<div>
48-
<WithStyles(Checkbox)
49-
checked={true}
50-
onChange={[Function]}
51-
/>
52-
</div>
5347
<Component
5448
open={false}
5549
/>
@@ -216,9 +210,9 @@ exports[`Configure renders snapshot 1`] = `
216210
model={
217211
Object {
218212
"addCategoryEnabled": true,
219-
"changeAddCategoryEnabled": true,
220-
"changeEditableEnabled": true,
221-
"changeInteractiveEnabled": true,
213+
"changeAddCategoryEnabled": false,
214+
"changeEditableEnabled": false,
215+
"changeInteractiveEnabled": false,
222216
"chartType": "lineCross",
223217
"correctAnswer": Object {},
224218
"data": Array [],
@@ -380,9 +374,9 @@ exports[`Configure renders snapshot 1`] = `
380374
model={
381375
Object {
382376
"addCategoryEnabled": true,
383-
"changeAddCategoryEnabled": true,
384-
"changeEditableEnabled": true,
385-
"changeInteractiveEnabled": true,
377+
"changeAddCategoryEnabled": false,
378+
"changeEditableEnabled": false,
379+
"changeInteractiveEnabled": false,
386380
"chartType": "lineCross",
387381
"correctAnswer": Object {},
388382
"data": Array [],
@@ -482,9 +476,9 @@ exports[`Configure renders snapshot 1`] = `
482476
model={
483477
Object {
484478
"addCategoryEnabled": true,
485-
"changeAddCategoryEnabled": true,
486-
"changeEditableEnabled": true,
487-
"changeInteractiveEnabled": true,
479+
"changeAddCategoryEnabled": false,
480+
"changeEditableEnabled": false,
481+
"changeInteractiveEnabled": false,
488482
"chartType": "lineCross",
489483
"correctAnswer": Object {},
490484
"data": Array [],
@@ -556,9 +550,9 @@ exports[`Configure renders snapshot 1`] = `
556550
model={
557551
Object {
558552
"addCategoryEnabled": true,
559-
"changeAddCategoryEnabled": true,
560-
"changeEditableEnabled": true,
561-
"changeInteractiveEnabled": true,
553+
"changeAddCategoryEnabled": false,
554+
"changeEditableEnabled": false,
555+
"changeInteractiveEnabled": false,
562556
"chartType": "lineCross",
563557
"correctAnswer": Object {},
564558
"data": Array [],

packages/charting/configure/src/defaults.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ export default {
3636
teacherInstructionsEnabled: true,
3737
studentInstructionsEnabled: true,
3838
studentNewCategoryDefaultLabel: 'New Category',
39-
changeInteractiveEnabled: true,
40-
changeEditableEnabled: true,
41-
changeAddCategoryEnabled: true,
39+
changeInteractiveEnabled: false,
40+
changeEditableEnabled: false,
41+
changeAddCategoryEnabled: false,
4242
},
4343
configuration: {
4444
spellCheck: {

packages/charting/docs/demo/generate.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ exports.model = (id, element) => ({
22
id,
33
element,
44
addCategoryEnabled: true,
5+
changeInteractiveEnabled: true,
6+
changeEditableEnabled: true,
7+
changeAddCategoryEnabled: true,
58
chartType: 'bar',
69
correctAnswer: {
710
data: [

packages/charting/docs/pie-schema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -504,17 +504,17 @@
504504
"title": "rubricEnabled"
505505
},
506506
"changeInteractiveEnabled": {
507-
"description": "Indicates if teacher can enable/disable data[]:interactive",
507+
"description": "Indicates if teacher can enable/disable data[]:interactive. Default value is false",
508508
"type": "boolean",
509509
"title": "changeInteractiveEnabled"
510510
},
511511
"changeEditableEnabled": {
512-
"description": "Indicates if teacher can enable/disable data[]:editable",
512+
"description": "Indicates if teacher can enable/disable data[]:editable. Default value is false",
513513
"type": "boolean",
514514
"title": "changeEditableEnabled"
515515
},
516516
"changeAddCategoryEnabled": {
517-
"description": "Indicates if teacher can enable/disable addCategoryEnabled",
517+
"description": "Indicates if teacher can enable/disable addCategoryEnabled. Default value is false",
518518
"type": "boolean",
519519
"title": "changeAddCategoryEnabled"
520520
},

packages/charting/docs/pie-schema.json.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,15 @@ Indicates if Rubric is enabled
168168

169169
# `changeInteractiveEnabled` (boolean, required)
170170

171-
Indicates if teacher can enable/disable data[]:interactive
171+
Indicates if teacher can enable/disable data[]:interactive. Default value is false
172172

173173
# `changeEditableEnabled` (boolean, required)
174174

175-
Indicates if teacher can enable/disable data[]:editable
175+
Indicates if teacher can enable/disable data[]:editable. Default value is false
176176

177177
# `changeAddCategoryEnabled` (boolean, required)
178178

179-
Indicates if teacher can enable/disable addCategoryEnabled
179+
Indicates if teacher can enable/disable addCategoryEnabled. Default value is false
180180

181181
# `studentNewCategoryDefaultLabel` (string, required)
182182

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import { Group } from 'react-konva';
4+
import { faDelete } from './icons';
5+
import Image from './image';
6+
import { calculate } from './utils';
7+
8+
const DeleteWidget = ({ height, id, width, x, y, points, outlineColor, handleWidgetClick }) => {
9+
let positionX, positionY;
10+
// if points exist we have an irregular form (polygon) and position should be computed
11+
if (points) {
12+
const { x, y } = calculate(points);
13+
positionX = x;
14+
positionY = y;
15+
} else {
16+
positionX = x + width - 20; // 10 pixels to the left
17+
positionY = y + height - 20; // 10 pixels above
18+
}
19+
20+
return (
21+
<Group onClick={() => handleWidgetClick(id)}>
22+
<Image width={20} height={20} x={positionX} y={positionY} src={faDelete} />
23+
</Group>
24+
);
25+
};
26+
27+
DeleteWidget.propTypes = {
28+
id: PropTypes.string.isRequired,
29+
height: PropTypes.number,
30+
width: PropTypes.number,
31+
x: PropTypes.number.isRequired,
32+
y: PropTypes.number.isRequired,
33+
handleWidgetClick: PropTypes.func.isRequired,
34+
points: PropTypes.arrayOf(
35+
PropTypes.shape({
36+
x: PropTypes.number,
37+
y: PropTypes.number,
38+
}),
39+
),
40+
outlineColor: PropTypes.string.isRequired,
41+
};
42+
43+
export default DeleteWidget;

packages/hotspot/configure/src/__tests__/__snapshots__/hotspot-container.test.js.snap

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ exports[`HotspotContainer render renders 1`] = `
1616
onInputClick={[Function]}
1717
setRef={[Function]}
1818
/>
19-
<WithStyles(RawButton)
20-
disabled={false}
21-
label="Undo"
22-
onClick={[Function]}
23-
/>
2419
<WithStyles(RawButton)
2520
disabled={false}
2621
label="Clear all"
@@ -40,6 +35,7 @@ exports[`HotspotContainer render renders 1`] = `
4035
hotspotColor="rgba(137, 183, 244, 0.65)"
4136
imageUrl="https://cdn.fluence.net/image/0240eb1455ce4c4bb6180232347b6aef_W"
4237
multipleCorrect={true}
38+
onDeleteShape={[Function]}
4339
onUpdateImageDimension={[MockFunction]}
4440
onUpdateShapes={[Function]}
4541
outlineColor="blue"

packages/hotspot/configure/src/__tests__/hotspot-container.test.js

Lines changed: 50 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ describe('HotspotContainer', () => {
7878
let w,
7979
onImageUpload = jest.fn(),
8080
onUpdateImageDimension = jest.fn(),
81+
onDeleteShape = jest.fn(),
8182
onUpdateShapes = jest.fn(),
8283
initialModel = model();
8384
beforeEach(() => {
@@ -91,6 +92,7 @@ describe('HotspotContainer', () => {
9192
outlineColor: initialModel.outlineColor,
9293
onUpdateImageDimension: onUpdateImageDimension,
9394
onUpdateShapes: onUpdateShapes,
95+
onDeleteShape: onDeleteShape,
9496
onImageUpload: onImageUpload,
9597
shapes: initialModel.shapes,
9698
...extras,
@@ -210,6 +212,54 @@ describe('HotspotContainer', () => {
210212
});
211213
});
212214

215+
it('onDeleteShape by id', () => {
216+
console.log('wrapper', wrapper.instance());
217+
wrapper.instance().onDeleteShape('7');
218+
expect(onUpdateShapes).toHaveBeenCalledWith(
219+
groupShapes([
220+
{ correct: true, group: 'rectangles', height: 140, id: '0', index: 0, width: 130, x: 1, y: 1 },
221+
{ group: 'rectangles', height: 140, id: '1', index: 1, width: 130, x: 140, y: 1 },
222+
{ group: 'rectangles', height: 140, id: '2', index: 2, width: 130, x: 280, y: 1 },
223+
{
224+
correct: true,
225+
group: 'polygons',
226+
id: '3',
227+
index: 3,
228+
points: [
229+
{ x: 1, y: 148 },
230+
{ x: 1, y: 288 },
231+
{ x: 129, y: 288 },
232+
{ x: 129, y: 148 },
233+
],
234+
},
235+
{
236+
correct: false,
237+
group: 'polygons',
238+
id: '4',
239+
index: 4,
240+
points: [
241+
{ x: 141, y: 151 },
242+
{ x: 141, y: 289 },
243+
{ x: 269, y: 289 },
244+
{ x: 269, y: 151 },
245+
],
246+
},
247+
{
248+
correct: false,
249+
group: 'polygons',
250+
id: '5',
251+
index: 5,
252+
points: [
253+
{ x: 279, y: 150 },
254+
{ x: 279, y: 289 },
255+
{ x: 407, y: 289 },
256+
{ x: 407, y: 150 },
257+
],
258+
},
259+
]),
260+
);
261+
});
262+
213263
it('onUpdateShapes with no shapes', () => {
214264
wrapper.instance().onUpdateShapes([]);
215265

@@ -219,33 +269,6 @@ describe('HotspotContainer', () => {
219269
});
220270
});
221271

222-
it('handleUndo if no new shape was added', () => {
223-
wrapper.instance().handleUndo();
224-
expect(onUpdateShapes).toHaveBeenLastCalledWith({
225-
...initialModel.shapes,
226-
polygons: initialModel.shapes.polygons.slice(0, -1),
227-
});
228-
});
229-
230-
it('handleUndo if new shape was added', () => {
231-
const newShape = {
232-
id: '7',
233-
height: 140,
234-
width: 130,
235-
x: 280,
236-
y: 1,
237-
index: 6,
238-
};
239-
240-
// first, add a new shape
241-
wrapper.instance().state.shapes = getAllShapes({
242-
...initialModel.shapes,
243-
rectangles: [...initialModel.shapes.rectangles, newShape],
244-
});
245-
wrapper.instance().handleUndo();
246-
expect(onUpdateShapes).toBeCalledWith(initialModel.shapes);
247-
});
248-
249272
it('handleClearAll', () => {
250273
wrapper.instance().handleClearAll();
251274
expect(onUpdateShapes).toHaveBeenLastCalledWith({

0 commit comments

Comments
 (0)