summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjc0b <j@jc0b.computer>2020-07-29 17:31:31 +0200
committerFabian Mastenbroek <mail.fabianm@gmail.com>2020-08-24 19:48:46 +0200
commitb817af6802c1168f17f87308aa922bee5f629a24 (patch)
treeecc1f3128ceef7cc54ebc09fbcc515b9cb7e584e
parent0a984529480c08aaf6af9f6f657d4ed805e77d49 (diff)
Adding prefabs works now
-rw-r--r--frontend/src/sagas/objects.js7
-rw-r--r--frontend/src/sagas/prefabs.js13
2 files changed, 12 insertions, 8 deletions
diff --git a/frontend/src/sagas/objects.js b/frontend/src/sagas/objects.js
index cc19eb75..58dee6be 100644
--- a/frontend/src/sagas/objects.js
+++ b/frontend/src/sagas/objects.js
@@ -148,7 +148,8 @@ export const updateTopologyOnServer = function* (id) {
export const getTopologyAsObject = function* (id, keepIds) {
const topologyStore = yield select(OBJECT_SELECTORS['topology'])
-
+ console.log(topologyStore)
+ //console.log("DEBUG: roomIds = " + topologyStore[id].roomIds)
const rooms = yield getAllRooms(topologyStore[id].roomIds, keepIds)
return {
_id: keepIds ? id : undefined,
@@ -167,10 +168,10 @@ export const getAllRooms = function* (roomIds, keepIds) {
for(let i in roomIds){
console.log("DEBUG: on iteration " + i + ", roomStore has value = " + roomStore[i])
- let tiles = yield getAllRoomTiles(roomStore[i], keepIds)
+ let tiles = yield getAllRoomTiles(roomStore[roomIds[i]], keepIds)
rooms.push({
_id: keepIds ? i : undefined,
- name: roomStore[i].name,
+ name: roomStore[roomIds[i]].name,
tiles: tiles,
}
)
diff --git a/frontend/src/sagas/prefabs.js b/frontend/src/sagas/prefabs.js
index 93af105a..1c21215a 100644
--- a/frontend/src/sagas/prefabs.js
+++ b/frontend/src/sagas/prefabs.js
@@ -1,14 +1,17 @@
import {call, put, select} from "redux-saga/effects";
import {addToStore} from "../actions/objects";
import {addPrefab} from "../api/routes/prefabs";
-import {getTopologyAsObject} from "./objects";
+import {getRackById, getTopologyAsObject} from "./objects";
export function* onAddPrefab(action) {
try {
- const state = yield select((state) => state)
- console.log("DEBUG: " + state.objects.tile[state.interactionLevel.tileId].rack._id)
- const currentRackId = yield select((state) => state.objects.tile[state.interactionLevel.tileId].rack._id)
- const currentRackJson = yield call(getTopologyAsObject, currentRackId)
+ // const state = yield select((state) => state)
+ // console.log("DEBUG: tileId = " + state.interactionLevel.tileId)
+ // console.log(state.objects.tile[state.interactionLevel.tileId])
+ // console.log("DEBUG: " + state.objects.tile[state.interactionLevel.tileId].rackId)
+ const currentRackId = yield select((state) => state.objects.tile[state.interactionLevel.tileId].rackId)
+ console.log("DEBUG: currentRackId = " + currentRackId)
+ const currentRackJson = yield getRackById(currentRackId, false)
const prefab = yield call(addPrefab, { name: action.name, rack: currentRackJson })
yield put(addToStore('prefab', prefab))