|
@@ -138,42 +138,45 @@ class Admin extends React.Component<{}, AdminState> {
|
|
|
|
|
|
|
|
|
|
|
|
|
addPoint = (canvas: paper.PaperScope) => (event: any) => {
|
|
addPoint = (canvas: paper.PaperScope) => (event: any) => {
|
|
|
- if (!this.state.path) {
|
|
|
|
|
- console.log('new path');
|
|
|
|
|
- let path = new canvas.Path({
|
|
|
|
|
- strokeColor: new Color('red'),
|
|
|
|
|
- strokeWidth: 5,
|
|
|
|
|
- });
|
|
|
|
|
- path.bringToFront();
|
|
|
|
|
- path.add(event.point);
|
|
|
|
|
- this.setState({ path });
|
|
|
|
|
- } else {
|
|
|
|
|
- this.state.path.add(event.point);
|
|
|
|
|
|
|
+ if(this.state.path) {
|
|
|
|
|
+ this.state.path.remove();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ let path = new canvas.Path({
|
|
|
|
|
+ strokeColor: new Color('red'),
|
|
|
|
|
+ strokeWidth: 5,
|
|
|
|
|
+ });
|
|
|
|
|
+ path.bringToFront();
|
|
|
|
|
+ path.add(event.point);
|
|
|
|
|
+ this.setState({ path });
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
|
|
+ showPathDrawings = (items: paper.Item[]) => {
|
|
|
|
|
+ items.forEach(i => {
|
|
|
|
|
+ let group = i.parent;
|
|
|
|
|
+ group.children.forEach(child => {
|
|
|
|
|
+ child.visible = child.id === i.id;
|
|
|
|
|
+ });
|
|
|
|
|
+ })
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
mkDrawingTool = (canvas: paper.PaperScope) => {
|
|
mkDrawingTool = (canvas: paper.PaperScope) => {
|
|
|
let Tool = new canvas.Tool();
|
|
let Tool = new canvas.Tool();
|
|
|
Tool.onMouseDown = this.addPoint(canvas);
|
|
Tool.onMouseDown = this.addPoint(canvas);
|
|
|
- Tool.onMouseDrag = this.addPoint(canvas);
|
|
|
|
|
|
|
+ Tool.onMouseDrag = (event: any) => {
|
|
|
|
|
+ this.state.path?.add(event.point)
|
|
|
|
|
+ };
|
|
|
Tool.onMouseUp = () => {
|
|
Tool.onMouseUp = () => {
|
|
|
const { path } = this.state;
|
|
const { path } = this.state;
|
|
|
if (path) {
|
|
if (path) {
|
|
|
path.add(path.firstSegment);
|
|
path.add(path.firstSegment);
|
|
|
path.closePath();
|
|
path.closePath();
|
|
|
path.simplify();
|
|
path.simplify();
|
|
|
- this.state.data.forEach(d => { d.group.visible = false })
|
|
|
|
|
const items = canvas.project.activeLayer.getItems({
|
|
const items = canvas.project.activeLayer.getItems({
|
|
|
overlapping: path.bounds,
|
|
overlapping: path.bounds,
|
|
|
class: Path,
|
|
class: Path,
|
|
|
});
|
|
});
|
|
|
- let x = items.filter(i => i.data.name !== undefined);
|
|
|
|
|
- x.forEach(i => i.visible = true)
|
|
|
|
|
- console.log('items', x);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ console.log(items);
|
|
|
|
|
+ // this.showPathDrawings(items);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -188,7 +191,12 @@ class Admin extends React.Component<{}, AdminState> {
|
|
|
}
|
|
}
|
|
|
}).then(response => {
|
|
}).then(response => {
|
|
|
const _data = response.data.map((result, index) => {
|
|
const _data = response.data.map((result, index) => {
|
|
|
- let group = new Group();
|
|
|
|
|
|
|
+ let group = new Group({
|
|
|
|
|
+ data: {
|
|
|
|
|
+ ...result.personalInformation,
|
|
|
|
|
+ id: result.id
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
const item = {
|
|
const item = {
|
|
|
...result,
|
|
...result,
|
|
|
canvas: result.canvas.map((item, i) => {
|
|
canvas: result.canvas.map((item, i) => {
|