kitchen-simulator
Version:
It is a kitchen simulator (self-contained micro-frontend).
147 lines (146 loc) • 8.1 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = _default;
var _export = require("../class/export");
var _export2 = require("../utils/export");
var _constants = require("../constants");
function _default(state, action) {
switch (action.type) {
case _constants.STORE_DIST_ARRAY:
return _export.Item.storeDistArray(state, action.layerID, action.itemID, action.distArray).updatedState;
case _constants.VALIDATE_ITEM_POSTIONS:
return _export.Item.validateItemPositions(state, action.layerID).updatedState;
case _constants.END_LOADING:
return _export.Item.endLoading(state).updatedState;
case _constants.TOGGLE_LOADING_CABINET:
return _export.Item.toggleLoadingCabinet(state).updatedState;
case _constants.EDIT_WIDTH:
return _export.Item.editWidth(state, action.newWidth, action.layerID, action.itemID).updatedState;
case _constants.DUPLICATE_SELECTED:
return _export.Item.duplicateSelected(state, action.currentObject).updatedState;
case _constants.END_CREATING_CABINET:
return _export.Item.endCreatingCabinet(state).updatedState;
case _constants.UPDATE_POPUP_OPEN:
return _export.Item.updatePopupOpen(state, action.value).updatedState;
case _constants.SELECT_ITEM:
return _export.Item.select(state, action.layerID, action.itemID).updatedState;
case _constants.SELECT_TOOL_DRAWING_ITEM:
state = state.merge({
sceneHistory: _export2.history.historyPush(state.sceneHistory, state.scene)
});
return _export.Item.selectToolDrawingItem(state, action.sceneComponentType).updatedState;
case _constants.REPLACE_ITEM:
return _export.Item.replaceItem(state, action.selectedPos, action.currentObject, action.selectedObject).updatedState;
case _constants.UPDATE_DRAWING_ITEM:
return _export.Item.updateDrawingItem(state, action.layerID, action.x, action.y).updatedState;
case _constants.END_DRAWING_ITEM:
state = state.merge({
sceneHistory: _export2.history.historyPush(state.sceneHistory, state.scene)
});
return _export.Item.endDrawingItem(state, action.layerID, action.x, action.y).updatedState;
case _constants.BEGIN_DRAGGING_ITEM:
state = state.merge({
sceneHistory: _export2.history.historyPush(state.sceneHistory, state.scene)
});
return _export.Item.beginDraggingItem(state, action.layerID, action.itemID, action.x, action.y).updatedState;
case _constants.BEGIN_DRAGGING_ITEM_3D:
state = state.merge({
sceneHistory: _export2.history.historyPush(state.sceneHistory, state.scene)
});
return _export.Item.beginDraggingItem3D(state, action.layerID, action.itemID, action.x, action.y).updatedState;
case _constants.UPDATE_DRAGGING_ITEM:
return _export.Item.updateDraggingItem(state, action.x, action.y).updatedState;
case _constants.UPDATE_DRAGGING_ITEM_CHANGED:
return _export.Item.updateDraggingItemChanged(state, action.x, action.y, action.layerID, action.itemID).updatedState;
case _constants.UPDATE_DRAGGING_ITEM_3DX:
return _export.Item.updateDraggingItem3DX(state, action.x).updatedState;
case _constants.UPDATE_DRAGGING_ITEM_3DY:
return _export.Item.updateDraggingItem3DY(state, action.y).updatedState;
case _constants.END_DRAGGING_ITEM:
state = state.merge({
sceneHistory: _export2.history.historyPush(state.sceneHistory, state.scene)
});
return _export.Item.endDraggingItem(state, action.x, action.y).updatedState;
case _constants.END_DRAGGING_ITEM_3D:
state = state.merge({
sceneHistory: _export2.history.historyPush(state.sceneHistory, state.scene)
});
return _export.Item.endDraggingItem3D(state).updatedState;
case _constants.BEGIN_ROTATING_ITEM:
state = state.merge({
sceneHistory: _export2.history.historyPush(state.sceneHistory, state.scene)
});
return _export.Item.beginRotatingItem(state, action.layerID, action.itemID, action.x, action.y).updatedState;
case _constants.BEGIN_ROTATING_ITEM_3D:
state = state.merge({
sceneHistory: _export2.history.historyPush(state.sceneHistory, state.scene)
});
return _export.Item.beginRotatingItem3D(state, action.layerID, action.itemID, action.x, action.y, action.centerX, action.centerY).updatedState;
case _constants.UPDATE_ROTATING_ITEM:
return _export.Item.updateRotatingItem(state, action.x, action.y).updatedState;
case _constants.UPDATE_ROTATING_ITEM_CHANGED:
return _export.Item.updateRotatingItemChanged(state, action.rotation, action.layerID, action.itemID).updatedState;
case _constants.END_ROTATING_ITEM:
state = state.merge({
sceneHistory: _export2.history.historyPush(state.sceneHistory, state.scene)
});
return _export.Item.endRotatingItem(state, action.x, action.y).updatedState;
case _constants.END_ROTATING_ITEM_3D:
state = state.merge({
sceneHistory: _export2.history.historyPush(state.sceneHistory, state.scene)
});
return _export.Item.endRotatingItem3D(state, action.x, action.y).updatedState;
case _constants.REPLACE_SUBMODULE:
state = state.merge({
sceneHistory: _export2.history.historyPush(state.sceneHistory, state.scene)
});
return _export.Item.replaceSubmodule(state, action.url).updatedState;
case _constants.ANIMATE_OBJECT:
// state = state.merge({ sceneHistory: history.historyPush(state.sceneHistory, state.scene) });
return _export.Item.animateObject(state, action.value).updatedState;
case _constants.REMOVE_REPLACE_SUBMODULE:
return _export.Item.removeReplacingSupport(state).updatedState;
case _constants.ITEM_MOVE_UP:
return _export.Item.updateItemsAltitude(state, action.layerID, action.itemID, action.value).updatedState;
case _constants.SELECT_TOOL_DRAWING_ITEM_3D:
return _export.Item.selectToolDrawingItem3D(state, action.sceneComponentType).updatedState;
case _constants.SET_DOOR_STYLE:
return _export.Item.setDoorStyle(state, action.doorStyle, action.itemCDS, action.isAll).updatedState;
case _constants.SET_HANDLE_MATERIAL:
return _export.Item.setHandleMaterial(state, action.material).updatedState;
case _constants.SET_DOOR_HANDLE:
return _export.Item.setDoorHandle(state, action.doorHandle).updatedState;
case _constants.SET_COUNTER_TOP:
return _export.Item.setCounterTop(state, action.counterTop).updatedState;
case _constants.SET_MOLDING:
return _export.Item.setMolding(state, action.molding, action.isAll).updatedState;
case _constants.UPDATE_MOLDING:
return _export.Item.updateMolding(state).updatedState;
case _constants.SET_WALL_COLOR:
state = state.merge({
sceneHistory: _export2.history.historyPush(state.sceneHistory, state.scene)
}); // save history when this actino performed,so undo enable
return _export.Item.setWallColor(state, action.wallColor).updatedState;
case _constants.SET_MODELLING:
return _export.Item.setModelling(state, action.model).updatedState;
case _constants.SET_BACKSPLASH:
return _export.Item.setBacksplash(state, action.backsplash).updatedState;
case _constants.SET_BACKSPLASH_VISIBLE:
return _export.Item.setBacksplashVisible(state, action.itemID, action.backsplashVisible).updatedState;
case _constants.SET_APPLIANCE_MATERIAL:
return _export.Item.setApplianceMaterial(state, action.material).updatedState;
case _constants.SET_INITIAL_DOOR_STYLE:
return _export.Item.setInitialDoorStyle(state, action.doorStyle).updatedState;
case _constants.UPDATE_ITEM_POSITION:
return _export.Item.updateItemPosition(state, action.layerID, action.itemID, action.pos).updatedState;
// case SET_MOVE_STATUS:
// return state.merge({ moveStatus: action.status });
// case SET_ROTATE_STATUS:
// return state.merge({ rotateStatus: action.status });
default:
return state;
}
}
module.exports = exports.default;