source: imaps-frontend/src/scripts/shapes/Entrance.js@ 0c6b92a

main
Last change on this file since 0c6b92a was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago

Pred finalna verzija

  • Property mode set to 100644
File size: 2.5 KB
Line 
1import {_registerNode} from "konva/lib/Global";
2import MapNode from "../base/MapNode.js";
3import {node} from "prop-types";
4
5export default class Entrance extends MapNode {
6
7 constructor(attrs, id) {
8
9 if (!attrs.fromLoad) {
10 attrs.height *= 2;
11 }
12 super(
13 {
14 x: attrs.position.x,
15 y: attrs.position.y,
16 width: attrs.width,
17 height: attrs.height,
18 fill: "rgb(126,238,167)",
19 stroke: "#252627",
20 strokeWidth: 1,
21 opacity: 0.9,
22 name: "mapObj",
23 draggable: true,
24 rotation: attrs.rotation,
25 zIndex: 1,
26 },
27 attrs.layer,
28 attrs.blockSize,
29 attrs.snap
30 );
31 this.type = "Entrance";
32 this.eventName = "openEntranceModalEvent";
33 this.floorNum = attrs.floorNum
34
35 this.id = id;
36
37 this._info = {
38 name: `Entrance${id} [${this.floorNum}F]`,
39 connectedRoom: "",
40 description: "",
41 isMainEntrance: false,
42 selectedPin: "",
43 selectedPins: [],
44 };
45
46 this.initText();
47 this.moveToTop();
48 }
49
50 loadInfo(attrs) {
51 this.info.name = attrs.obj_name;
52 this.info.connectedRoom = attrs.connected_room;
53 this.info.description = attrs.description;
54 this.info.isMainEntrance = attrs.is_main_entrance;
55 this.info.selectedPins = attrs.connected_pins;
56 this.floorNum = attrs.floor_num;
57 }
58
59 saveShapeDetails() {
60 console.info("fnum entrance",this.attrs.floorNum)
61
62 this.setAttr("connected_pins", this.info.selectedPins);
63 this.setAttr("obj_name", this.info.name);
64 this.setAttr("description", this.info.description);
65 this.setAttr("is_main_entrance", this.info.isMainEntrance);
66 this.setAttr("connected_room", this.info.connectedRoom);
67 this.setAttr("floor_num",this.floorNum);
68 }
69
70 connect(node, draw = true) {
71 if(this.floorNum !== node.floorNum) return;
72
73 super.connect(node)
74 }
75
76 setInfo(infoObj) {
77 console.log("SA VIKNA SETINFO")
78 this.info = infoObj;
79 if(this.info.connectedRoom == null || this.info.connectedRoom === "" ){
80 this.strokeWidth(2);
81 this.stroke("#a10114")
82 }else{
83 this.strokeWidth(1)
84 this.stroke("black")
85 }
86 }
87}
88
89Entrance.prototype.className = "Entrance";
90_registerNode(Entrance);
Note: See TracBrowser for help on using the repository browser.