CC: @roryAronson

pull/1381/head
Rick Carlino 2019-08-15 14:19:01 -05:00
parent 5237295111
commit 61872841a7
5 changed files with 15 additions and 15 deletions

View File

@ -30,7 +30,7 @@ export const unselectPlant = (dispatch: Function) => () => {
/** Unselect plant and close plant info or select panel if selected and open. */
export const closePlantInfo = (dispatch: Function) => () => {
const mode = getMode();
const mode = getMode("closePlantInfo");
if (mode == Mode.editPlant || mode == Mode.boxSelect) {
unselectPlant(dispatch)();
history.push("/app/designer/plants");

View File

@ -45,7 +45,7 @@ export const resizeBox = (props: {
props.setMapState({ selectionBox: newSelectionBox });
// Select all plants within the updated selection box
const payload = getSelected(props.plants, newSelectionBox);
if (payload && getMode() === Mode.none) {
if (payload && getMode("resizeBox") === Mode.none) {
history.push("/app/designer/plants/select");
}
props.dispatch({ type: Actions.SELECT_PLANT, payload });

View File

@ -56,7 +56,7 @@ export class GardenMap extends
get xySwap() { return this.mapTransformProps.xySwap; }
/** Currently editing a plant? */
get isEditing(): boolean { return getMode() === Mode.editPlant; }
get isEditing(): boolean { return getMode("isEditing") === Mode.editPlant; }
/** Display plant animations? */
get animate(): boolean {
@ -93,7 +93,7 @@ export class GardenMap extends
/** Map drag start actions. */
startDrag = (e: React.MouseEvent<SVGElement>): void => {
switch (getMode()) {
switch (getMode("startDrag")) {
case Mode.editPlant:
beginPlantDrag({
plant: this.getPlant(),
@ -123,7 +123,7 @@ export class GardenMap extends
/** Return the selected plant, mode-allowing. */
getPlant = (): TaggedPlant | undefined => {
switch (getMode()) {
switch (getMode("getPlant")) {
case Mode.boxSelect:
case Mode.moveTo:
case Mode.createPoint:
@ -134,7 +134,7 @@ export class GardenMap extends
}
handleDragOver = (e: React.DragEvent<HTMLElement>) => {
switch (getMode()) {
switch (getMode("handleDragOver")) {
case Mode.addPlant:
case Mode.clickToAdd:
e.preventDefault(); // Allows dragged-in plants to be placed in the map
@ -143,7 +143,7 @@ export class GardenMap extends
}
handleDragEnter = (e: React.DragEvent<HTMLElement>) => {
switch (getMode()) {
switch (getMode("handleDragEnter")) {
case Mode.addPlant:
e.preventDefault();
}
@ -162,7 +162,7 @@ export class GardenMap extends
};
click = (e: React.MouseEvent<SVGElement>) => {
switch (getMode()) {
switch (getMode("click")) {
case Mode.clickToAdd:
// Create a new plant in the map
this.handleDrop(e);
@ -179,7 +179,7 @@ export class GardenMap extends
/** Map drag actions. */
drag = (e: React.MouseEvent<SVGElement>) => {
switch (getMode()) {
switch (getMode("drag")) {
case Mode.editPlant:
dragPlant({
getPlant: this.getPlant,
@ -217,7 +217,7 @@ export class GardenMap extends
/** Return to garden (unless selecting more plants). */
closePanel = () => {
switch (getMode()) {
switch (getMode("closePanel")) {
case Mode.boxSelect:
return this.props.designer.selectedPlants
? () => { }

View File

@ -62,7 +62,7 @@ export const getPanelStatus = (): MapPanelStatus => {
if (history.getCurrentLocation().pathname === "/app/designer") {
return MapPanelStatus.closed;
}
const mode = getMode();
const mode = getMode("getPanelStatus");
if (window.innerWidth <= 450 &&
(mode === Mode.moveTo || mode === Mode.clickToAdd)) {
return MapPanelStatus.short;
@ -286,10 +286,10 @@ export const transformForQuadrant =
};
/** Determine the current map mode based on path. */
export const getMode = (): Mode => {
export const getMode = (why = "test"): Mode => {
console.log(why);
const pathArray = getPathArray();
if (pathArray) {
console.log(JSON.stringify(pathArray));
if ((pathArray[3] === "groups") && pathArray[4]) {
return Mode.addPointToGroup;
}
@ -334,7 +334,7 @@ export const getGardenCoordinates = (props: {
export const maybeNoPointer =
(defaultStyle: React.CSSProperties): React.SVGProps<SVGGElement>["style"] => {
switch (getMode()) {
switch (getMode("maybeNoPointer")) {
case Mode.boxSelect:
case Mode.clickToAdd:
case Mode.moveTo:

View File

@ -56,7 +56,7 @@ function route<T, U>(info: UnboundRouteConfig<T, U>) {
const { $ } = info;
return {
$,
enter: async (x) => {
enter: async () => {
try {
const comp = (await info.getModule())[info.key];
if (info.children) {