From 3f736cd3db63f106eac02f220477b4a0f3b0eceb Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Thu, 31 Aug 2017 17:59:51 +0200 Subject: Implement room creation --- src/components/map/groups/DatacenterGroup.js | 16 ++++++------ src/components/map/groups/RoomGroup.js | 39 ++++++++++++++++------------ src/components/map/groups/TileGroup.js | 8 +++--- src/components/map/groups/WallGroup.js | 22 ++++++++++++++++ 4 files changed, 57 insertions(+), 28 deletions(-) create mode 100644 src/components/map/groups/WallGroup.js (limited to 'src/components/map/groups') diff --git a/src/components/map/groups/DatacenterGroup.js b/src/components/map/groups/DatacenterGroup.js index 2f4dc2eb..0830ac4e 100644 --- a/src/components/map/groups/DatacenterGroup.js +++ b/src/components/map/groups/DatacenterGroup.js @@ -12,8 +12,8 @@ const DatacenterGroup = ({datacenter, interactionLevel}) => { if (interactionLevel.mode === "BUILDING") { return ( - {datacenter.rooms.map(room => ( - + {datacenter.roomIds.map(roomId => ( + ))} ); @@ -21,14 +21,14 @@ const DatacenterGroup = ({datacenter, interactionLevel}) => { return ( - {datacenter.rooms - .filter(room => room.id !== interactionLevel.roomId) - .map(room => ) + {datacenter.roomIds + .filter(roomId => roomId !== interactionLevel.roomId) + .map(roomId => ) } {interactionLevel.mode === "ROOM" ? : null} - {datacenter.rooms - .filter(room => room.id === interactionLevel.roomId) - .map(room => ) + {datacenter.roomIds + .filter(roomId => roomId === interactionLevel.roomId) + .map(roomId => ) } ); diff --git a/src/components/map/groups/RoomGroup.js b/src/components/map/groups/RoomGroup.js index b6c285e9..85d3c7c9 100644 --- a/src/components/map/groups/RoomGroup.js +++ b/src/components/map/groups/RoomGroup.js @@ -2,35 +2,40 @@ import React from "react"; import {Group} from "react-konva"; import GrayContainer from "../../../containers/map/GrayContainer"; import TileContainer from "../../../containers/map/TileContainer"; +import WallContainer from "../../../containers/map/WallContainer"; import Shapes from "../../../shapes/index"; -import {deriveWallLocations} from "../../../util/tile-calculations"; -import WallSegment from "../elements/WallSegment"; -const RoomGroup = ({room, interactionLevel, onClick}) => { +const RoomGroup = ({room, interactionLevel, currentRoomInConstruction, onClick}) => { + if (currentRoomInConstruction === room.id) { + return ( + + {room.tileIds.map(tileId => ( + + ))} + + ); + } + return ( - + {(() => { if (interactionLevel.mode === "OBJECT" && interactionLevel.roomId === room.id) { return [ - room.tiles - .filter(tile => tile.id !== interactionLevel.tileId) - .map(tile => ), + room.tileIds + .filter(tileId => tileId !== interactionLevel.tileId) + .map(tileId => ), , - room.tiles - .filter(tile => tile.id === interactionLevel.tileId) - .map(tile => ) + room.tileIds + .filter(tileId => tileId === interactionLevel.tileId) + .map(tileId => ) ]; } else { - return room.tiles.map(tile => ( - + return room.tileIds.map(tileId => ( + )); } })()} - {deriveWallLocations(room).map((wallSegment, index) => ( - - ))} + ); }; diff --git a/src/components/map/groups/TileGroup.js b/src/components/map/groups/TileGroup.js index 5920a2b6..8fbdeb31 100644 --- a/src/components/map/groups/TileGroup.js +++ b/src/components/map/groups/TileGroup.js @@ -1,10 +1,11 @@ +import PropTypes from "prop-types"; import React from "react"; import {Group} from "react-konva"; import Shapes from "../../../shapes/index"; import RoomTile from "../elements/RoomTile"; import RackGroup from "./RackGroup"; -const TileGroup = ({tile, onClick}) => { +const TileGroup = ({tile, newTile, onClick}) => { let tileObject; switch (tile.objectType) { case "RACK": @@ -16,9 +17,9 @@ const TileGroup = ({tile, onClick}) => { return ( onClick(tile)} > - + {tileObject} ); @@ -26,6 +27,7 @@ const TileGroup = ({tile, onClick}) => { TileGroup.propTypes = { tile: Shapes.Tile, + newTile: PropTypes.bool, }; export default TileGroup; diff --git a/src/components/map/groups/WallGroup.js b/src/components/map/groups/WallGroup.js new file mode 100644 index 00000000..f21d91a5 --- /dev/null +++ b/src/components/map/groups/WallGroup.js @@ -0,0 +1,22 @@ +import PropTypes from "prop-types"; +import React from "react"; +import {Group} from "react-konva"; +import Shapes from "../../../shapes/index"; +import {deriveWallLocations} from "../../../util/tile-calculations"; +import WallSegment from "../elements/WallSegment"; + +const WallGroup = ({tiles}) => { + return ( + + {deriveWallLocations(tiles).map((wallSegment, index) => ( + + ))} + + ); +}; + +WallGroup.propTypes = { + tiles: PropTypes.arrayOf(Shapes.Tile).isRequired, +}; + +export default WallGroup; -- cgit v1.2.3