From bbb802b4142d11f020994ac4d9ae9c1610ac4038 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Sat, 26 Aug 2017 13:53:21 +0200 Subject: Enable going from room to tile and back --- src/components/map/groups/DatacenterGroup.js | 30 +++++++++---------- src/components/map/groups/RoomGroup.js | 43 +++++++++++++++++++--------- src/components/map/groups/TileGroup.js | 6 ++-- 3 files changed, 49 insertions(+), 30 deletions(-) (limited to 'src/components/map/groups') diff --git a/src/components/map/groups/DatacenterGroup.js b/src/components/map/groups/DatacenterGroup.js index cd4baaa5..2f4dc2eb 100644 --- a/src/components/map/groups/DatacenterGroup.js +++ b/src/components/map/groups/DatacenterGroup.js @@ -9,21 +9,7 @@ const DatacenterGroup = ({datacenter, interactionLevel}) => { return ; } - if (interactionLevel.mode === "ROOM") { - return ( - - {datacenter.rooms - .filter(room => room.id !== interactionLevel.roomId) - .map(room => ) - } - - {datacenter.rooms - .filter(room => room.id === interactionLevel.roomId) - .map(room => ) - } - - ); - } else { + if (interactionLevel.mode === "BUILDING") { return ( {datacenter.rooms.map(room => ( @@ -32,6 +18,20 @@ const DatacenterGroup = ({datacenter, interactionLevel}) => { ); } + + return ( + + {datacenter.rooms + .filter(room => room.id !== interactionLevel.roomId) + .map(room => ) + } + {interactionLevel.mode === "ROOM" ? : null} + {datacenter.rooms + .filter(room => room.id === interactionLevel.roomId) + .map(room => ) + } + + ); }; DatacenterGroup.propTypes = { diff --git a/src/components/map/groups/RoomGroup.js b/src/components/map/groups/RoomGroup.js index 179a24a2..b6c285e9 100644 --- a/src/components/map/groups/RoomGroup.js +++ b/src/components/map/groups/RoomGroup.js @@ -1,22 +1,39 @@ import React from "react"; import {Group} from "react-konva"; +import GrayContainer from "../../../containers/map/GrayContainer"; +import TileContainer from "../../../containers/map/TileContainer"; import Shapes from "../../../shapes/index"; import {deriveWallLocations} from "../../../util/tile-calculations"; import WallSegment from "../elements/WallSegment"; -import TileGroup from "./TileGroup"; -const RoomGroup = ({room, onClick}) => ( - - {room.tiles.map(tile => ( - - ))} - {deriveWallLocations(room).map((wallSegment, index) => ( - - ))} - -); +const RoomGroup = ({room, interactionLevel, onClick}) => { + return ( + + {(() => { + if (interactionLevel.mode === "OBJECT" && interactionLevel.roomId === room.id) { + return [ + room.tiles + .filter(tile => tile.id !== interactionLevel.tileId) + .map(tile => ), + , + room.tiles + .filter(tile => tile.id === interactionLevel.tileId) + .map(tile => ) + ]; + } else { + return room.tiles.map(tile => ( + + )); + } + })()} + {deriveWallLocations(room).map((wallSegment, index) => ( + + ))} + + ); +}; RoomGroup.propTypes = { room: Shapes.Room, diff --git a/src/components/map/groups/TileGroup.js b/src/components/map/groups/TileGroup.js index 7493f953..5920a2b6 100644 --- a/src/components/map/groups/TileGroup.js +++ b/src/components/map/groups/TileGroup.js @@ -4,7 +4,7 @@ import Shapes from "../../../shapes/index"; import RoomTile from "../elements/RoomTile"; import RackGroup from "./RackGroup"; -const TileGroup = ({tile}) => { +const TileGroup = ({tile, onClick}) => { let tileObject; switch (tile.objectType) { case "RACK": @@ -15,7 +15,9 @@ const TileGroup = ({tile}) => { } return ( - + {tileObject} -- cgit v1.2.3