[0c6b92a] | 1 | import {_registerNode} from "konva/lib/Global";
|
---|
| 2 | import MapNode from "../base/MapNode.js";
|
---|
| 3 | import {node} from "prop-types";
|
---|
| 4 |
|
---|
| 5 | export 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 | }
|
---|
[d565449] | 87 | }
|
---|
| 88 |
|
---|
| 89 | Entrance.prototype.className = "Entrance";
|
---|
| 90 | _registerNode(Entrance);
|
---|