commit
8700d50c81
|
@ -33,7 +33,7 @@ describe("<MoveTo />", () => {
|
||||||
it("moves to location: bot's current z value", () => {
|
it("moves to location: bot's current z value", () => {
|
||||||
const wrapper = mount(<MoveTo {...fakeProps()} />);
|
const wrapper = mount(<MoveTo {...fakeProps()} />);
|
||||||
wrapper.find("button").simulate("click");
|
wrapper.find("button").simulate("click");
|
||||||
expect(mockDevice.moveAbsolute).toHaveBeenCalledWith({ x: 1, y: 2, z: 30 });
|
expect(mockDevice.moveAbsolute).toHaveBeenCalledWith({ x: 1, y: 2, z: 3 });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("goes back", () => {
|
it("goes back", () => {
|
||||||
|
|
|
@ -43,7 +43,7 @@ interface MoveToFormState {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MoveToForm extends React.Component<MoveToFormProps, MoveToFormState> {
|
export class MoveToForm extends React.Component<MoveToFormProps, MoveToFormState> {
|
||||||
state = { z: undefined };
|
state = { z: this.props.chosenLocation.z };
|
||||||
|
|
||||||
get vector(): { x: number, y: number, z: number } {
|
get vector(): { x: number, y: number, z: number } {
|
||||||
const { chosenLocation } = this.props;
|
const { chosenLocation } = this.props;
|
||||||
|
|
|
@ -18,6 +18,7 @@ describe("<PlantPanel/>", () => {
|
||||||
const info: FormattedPlantInfo = {
|
const info: FormattedPlantInfo = {
|
||||||
x: 12,
|
x: 12,
|
||||||
y: 34,
|
y: 34,
|
||||||
|
z: 0,
|
||||||
id: undefined,
|
id: undefined,
|
||||||
name: "tomato",
|
name: "tomato",
|
||||||
uuid: "Plant.0.0",
|
uuid: "Plant.0.0",
|
||||||
|
@ -91,7 +92,7 @@ describe("<PlantPanel/>", () => {
|
||||||
expect(history.push).toHaveBeenCalledWith("/app/designer/move_to");
|
expect(history.push).toHaveBeenCalledWith("/app/designer/move_to");
|
||||||
expect(innerDispatch).toHaveBeenLastCalledWith({
|
expect(innerDispatch).toHaveBeenLastCalledWith({
|
||||||
type: Actions.CHOOSE_LOCATION,
|
type: Actions.CHOOSE_LOCATION,
|
||||||
payload: { x: 12, y: 34, z: undefined }
|
payload: { x: 12, y: 34, z: 0 }
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -119,7 +120,7 @@ describe("<EditDatePlanted />", () => {
|
||||||
describe("<EditPlantLocation />", () => {
|
describe("<EditPlantLocation />", () => {
|
||||||
const fakeProps = (): EditPlantLocationProps => ({
|
const fakeProps = (): EditPlantLocationProps => ({
|
||||||
uuid: "Plant.0.0",
|
uuid: "Plant.0.0",
|
||||||
xyLocation: { x: 1, y: 2 },
|
plantLocation: { x: 1, y: 2, z: 0 },
|
||||||
updatePlant: jest.fn(),
|
updatePlant: jest.fn(),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ export function mapStateToProps(props: Everything): EditPlantInfoProps {
|
||||||
export interface FormattedPlantInfo {
|
export interface FormattedPlantInfo {
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
|
z: number;
|
||||||
id: number | undefined;
|
id: number | undefined;
|
||||||
name: string;
|
name: string;
|
||||||
uuid: string;
|
uuid: string;
|
||||||
|
@ -72,6 +73,7 @@ export function formatPlantInfo(plant: TaggedPlant): FormattedPlantInfo {
|
||||||
daysOld: plantAge(plant),
|
daysOld: plantAge(plant),
|
||||||
x: plant.body.x,
|
x: plant.body.x,
|
||||||
y: plant.body.y,
|
y: plant.body.y,
|
||||||
|
z: plant.body.z,
|
||||||
uuid: plant.uuid,
|
uuid: plant.uuid,
|
||||||
plantedAt: plantDate(plant),
|
plantedAt: plantDate(plant),
|
||||||
plantStatus: get(plant, "body.plant_stage", "planned"),
|
plantStatus: get(plant, "body.plant_stage", "planned"),
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { round } from "../map/util";
|
||||||
import { history } from "../../history";
|
import { history } from "../../history";
|
||||||
import { BlurableInput, Row, Col } from "../../ui";
|
import { BlurableInput, Row, Col } from "../../ui";
|
||||||
import { PlantOptions } from "../interfaces";
|
import { PlantOptions } from "../interfaces";
|
||||||
import { PlantStage } from "farmbot";
|
import { PlantStage, Xyz } from "farmbot";
|
||||||
import { Moment } from "moment";
|
import { Moment } from "moment";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { Actions } from "../../constants";
|
import { Actions } from "../../constants";
|
||||||
|
@ -51,19 +51,19 @@ export const EditDatePlanted = (props: EditDatePlantedProps) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface EditPlantLocationProps extends EditPlantProperty {
|
export interface EditPlantLocationProps extends EditPlantProperty {
|
||||||
xyLocation: Record<"x" | "y", number>;
|
plantLocation: Record<Xyz, number>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const EditPlantLocation = (props: EditPlantLocationProps) => {
|
export const EditPlantLocation = (props: EditPlantLocationProps) => {
|
||||||
const { xyLocation, updatePlant, uuid } = props;
|
const { plantLocation, updatePlant, uuid } = props;
|
||||||
return <Row>
|
return <Row>
|
||||||
{["x", "y"].map((axis: "x" | "y") =>
|
{["x", "y", "z"].map((axis: Xyz) =>
|
||||||
<Col xs={6} key={axis}>
|
<Col xs={4} key={axis}>
|
||||||
<label style={{ marginTop: 0 }}>{t("{{axis}} (mm)", { axis })}</label>
|
<label style={{ marginTop: 0 }}>{t("{{axis}} (mm)", { axis })}</label>
|
||||||
<BlurableInput
|
<BlurableInput
|
||||||
type="number"
|
type="number"
|
||||||
value={xyLocation[axis]}
|
value={plantLocation[axis]}
|
||||||
min={0}
|
min={axis == "z" ? undefined : 0}
|
||||||
onCommit={e => updatePlant(uuid, {
|
onCommit={e => updatePlant(uuid, {
|
||||||
[axis]: round(parseIntInput(e.currentTarget.value))
|
[axis]: round(parseIntInput(e.currentTarget.value))
|
||||||
})} />
|
})} />
|
||||||
|
@ -71,11 +71,11 @@ export const EditPlantLocation = (props: EditPlantLocationProps) => {
|
||||||
</Row>;
|
</Row>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const chooseLocation = (to: Record<"x" | "y", number | undefined>) =>
|
const chooseLocation = (to: Record<Xyz, number | undefined>) =>
|
||||||
(dispatch: Function): Promise<void> => {
|
(dispatch: Function): Promise<void> => {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: Actions.CHOOSE_LOCATION,
|
type: Actions.CHOOSE_LOCATION,
|
||||||
payload: { x: to.x, y: to.y, z: undefined }
|
payload: { x: to.x, y: to.y, z: to.z }
|
||||||
});
|
});
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
};
|
};
|
||||||
|
@ -83,6 +83,7 @@ const chooseLocation = (to: Record<"x" | "y", number | undefined>) =>
|
||||||
interface MoveToPlantProps {
|
interface MoveToPlantProps {
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
|
z: number;
|
||||||
dispatch: Function;
|
dispatch: Function;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,8 +91,9 @@ const MoveToPlant = (props: MoveToPlantProps) =>
|
||||||
<button className="fb-button gray no-float"
|
<button className="fb-button gray no-float"
|
||||||
style={{ marginTop: "1rem" }}
|
style={{ marginTop: "1rem" }}
|
||||||
title={t("Move to this plant")}
|
title={t("Move to this plant")}
|
||||||
onClick={() => props.dispatch(chooseLocation({ x: props.x, y: props.y }))
|
onClick={() =>
|
||||||
.then(() => history.push("/app/designer/move_to"))}>
|
props.dispatch(chooseLocation({ x: props.x, y: props.y, z: props.z }))
|
||||||
|
.then(() => history.push("/app/designer/move_to"))}>
|
||||||
{t("Move FarmBot to this plant")}
|
{t("Move FarmBot to this plant")}
|
||||||
</button>;
|
</button>;
|
||||||
|
|
||||||
|
@ -141,7 +143,7 @@ export function PlantPanel(props: PlantPanelProps) {
|
||||||
info, onDestroy, updatePlant, dispatch, inSavedGarden, timeSettings
|
info, onDestroy, updatePlant, dispatch, inSavedGarden, timeSettings
|
||||||
} = props;
|
} = props;
|
||||||
const { slug, plantedAt, daysOld, uuid, plantStatus } = info;
|
const { slug, plantedAt, daysOld, uuid, plantStatus } = info;
|
||||||
const { x, y } = info;
|
const { x, y, z } = info;
|
||||||
const destroy = () => onDestroy(uuid);
|
const destroy = () => onDestroy(uuid);
|
||||||
return <DesignerPanelContent panelName={"plants"}>
|
return <DesignerPanelContent panelName={"plants"}>
|
||||||
<label>
|
<label>
|
||||||
|
@ -174,10 +176,10 @@ export function PlantPanel(props: PlantPanelProps) {
|
||||||
</Row>}
|
</Row>}
|
||||||
<ListItem name={t("Location")}>
|
<ListItem name={t("Location")}>
|
||||||
<EditPlantLocation uuid={uuid}
|
<EditPlantLocation uuid={uuid}
|
||||||
xyLocation={{ x, y }}
|
plantLocation={{ x, y, z }}
|
||||||
updatePlant={updatePlant} />
|
updatePlant={updatePlant} />
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<MoveToPlant x={x} y={y} dispatch={dispatch} />
|
<MoveToPlant x={x} y={y} z={z} dispatch={dispatch} />
|
||||||
<ListItem name={t("Status")}>
|
<ListItem name={t("Status")}>
|
||||||
{(!inSavedGarden)
|
{(!inSavedGarden)
|
||||||
? <EditPlantStatus
|
? <EditPlantStatus
|
||||||
|
|
Loading…
Reference in New Issue