From 1f4616cbf9c82e4976d1f4b4c018d5e9ff83ad10 Mon Sep 17 00:00:00 2001 From: Georgios Andreadis Date: Wed, 8 Nov 2017 10:28:33 +0100 Subject: Implement room editing Allows for rooms to be edited from the room context menu. Fixes #24 --- src/actions/topology/building.js | 18 +++++++++++++++ .../building/NewRoomConstructionComponent.js | 2 +- .../topology/machine/DeleteMachineComponent.js | 2 +- .../sidebars/topology/machine/UnitAddComponent.js | 2 +- .../sidebars/topology/rack/DeleteRackComponent.js | 2 +- .../sidebars/topology/room/DeleteRoomComponent.js | 2 +- .../sidebars/topology/room/EditRoomComponent.js | 27 ++++++++++++++++++++++ .../topology/room/RackConstructionComponent.js | 13 ++++++++--- .../sidebars/topology/room/RoomSidebarComponent.js | 2 ++ src/containers/app/map/layers/RoomHoverLayer.js | 4 ---- .../sidebars/topology/room/EditRoomContainer.js | 26 +++++++++++++++++++++ .../topology/room/RackConstructionContainer.js | 3 ++- src/reducers/construction-mode.js | 20 ++++++++++++---- 13 files changed, 105 insertions(+), 18 deletions(-) create mode 100644 src/components/app/sidebars/topology/room/EditRoomComponent.js create mode 100644 src/containers/app/sidebars/topology/room/EditRoomContainer.js diff --git a/src/actions/topology/building.js b/src/actions/topology/building.js index 5aef2932..c6381a07 100644 --- a/src/actions/topology/building.js +++ b/src/actions/topology/building.js @@ -7,6 +7,8 @@ export const FINISH_NEW_ROOM_CONSTRUCTION = "FINISH_NEW_ROOM_CONSTRUCTION"; export const CANCEL_NEW_ROOM_CONSTRUCTION = "CANCEL_NEW_ROOM_CONSTRUCTION"; export const CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED = "CANCEL_NEW_ROOM_CONSTRUCTION_SUCCEEDED"; +export const START_ROOM_EDIT = "START_ROOM_EDIT"; +export const FINISH_ROOM_EDIT = "FINISH_ROOM_EDIT"; export const ADD_TILE = "ADD_TILE"; export const DELETE_TILE = "DELETE_TILE"; @@ -64,6 +66,22 @@ export function cancelNewRoomConstructionSucceeded() { }; } +export function startRoomEdit() { + return (dispatch, getState) => { + const { interactionLevel } = getState(); + dispatch({ + type: START_ROOM_EDIT, + roomId: interactionLevel.roomId + }); + }; +} + +export function finishRoomEdit() { + return { + type: FINISH_ROOM_EDIT + }; +} + export function toggleTileAtLocation(positionX, positionY) { return (dispatch, getState) => { const { objects, construction } = getState(); diff --git a/src/components/app/sidebars/topology/building/NewRoomConstructionComponent.js b/src/components/app/sidebars/topology/building/NewRoomConstructionComponent.js index a559c8dd..7b049642 100644 --- a/src/components/app/sidebars/topology/building/NewRoomConstructionComponent.js +++ b/src/components/app/sidebars/topology/building/NewRoomConstructionComponent.js @@ -8,7 +8,7 @@ const NewRoomConstructionComponent = ({ }) => { if (currentRoomInConstruction === -1) { return ( -
+
Construct a new room
diff --git a/src/components/app/sidebars/topology/machine/DeleteMachineComponent.js b/src/components/app/sidebars/topology/machine/DeleteMachineComponent.js index 8da39b30..d8774bf9 100644 --- a/src/components/app/sidebars/topology/machine/DeleteMachineComponent.js +++ b/src/components/app/sidebars/topology/machine/DeleteMachineComponent.js @@ -1,7 +1,7 @@ import React from "react"; const DeleteMachineComponent = ({ onClick }) => ( -
+
Delete this machine
diff --git a/src/components/app/sidebars/topology/machine/UnitAddComponent.js b/src/components/app/sidebars/topology/machine/UnitAddComponent.js index d0082a72..584a4360 100644 --- a/src/components/app/sidebars/topology/machine/UnitAddComponent.js +++ b/src/components/app/sidebars/topology/machine/UnitAddComponent.js @@ -29,7 +29,7 @@ class UnitAddComponent extends React.Component {