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