diff --git a/typings/READ_THIS.txt b/typings/READ_THIS.txt
deleted file mode 100644
index 04fdc6436..000000000
--- a/typings/READ_THIS.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-I hope that we can someday not use this folder and use all the @types/* repositories.
-
-Some (legacy) libraries don't work with the newer typings (eg: react-redux).
-
-In those rare circumstances, we can put them in here.
-
-Hopefully, this folder will go away some day.
diff --git a/webpack/sequences/locals_list.tsx b/webpack/sequences/locals_list.tsx
index 3b28e14e1..2760f8cff 100644
--- a/webpack/sequences/locals_list.tsx
+++ b/webpack/sequences/locals_list.tsx
@@ -19,7 +19,7 @@ export const ParentVariableForm =
const { sequence, resources, onChange } = props;
const { x, y, z } = props.parent.location;
const isDisabled = !props.parent.editable;
-
+ const list = generateList(resources, [PARENT]);
return
@@ -27,9 +27,11 @@ export const ParentVariableForm =
{
+ const list2 = generateList(resources, [PARENT]);
+ console.dir(list2);
console.error("FINISH ME");
handleSelect(props.resources, ddi);
onChange({ x: -23, y: -23, z: -23 });
diff --git a/webpack/sequences/step_tiles/tile_move_absolute/__tests__/handle_select_test.ts b/webpack/sequences/step_tiles/tile_move_absolute/__tests__/handle_select_test.ts
index 7a74b52fa..558b9f2e8 100644
--- a/webpack/sequences/step_tiles/tile_move_absolute/__tests__/handle_select_test.ts
+++ b/webpack/sequences/step_tiles/tile_move_absolute/__tests__/handle_select_test.ts
@@ -32,19 +32,6 @@ describe("handleSelect()", () => {
});
});
- it("handles 'parameter_declaration's", () => {
- const result = handleSelect(fakeResourceIndex(), {
- headingId: "parameter",
- value: "parent",
- label: "1"
- });
- expect(result.kind).toBe("parameter_declaration");
- if (result.kind == "parameter_declaration") {
- expect(result.args.label).toBe("parent");
- expect(result.args.data_type).toBe("point");
- }
- });
-
it("returns location data: identifier", () => {
const location = handleSelect(fakeResourceIndex(),
{
diff --git a/webpack/sequences/step_tiles/tile_move_absolute/handle_select.ts b/webpack/sequences/step_tiles/tile_move_absolute/handle_select.ts
index fdddb7aa4..26b35962a 100644
--- a/webpack/sequences/step_tiles/tile_move_absolute/handle_select.ts
+++ b/webpack/sequences/step_tiles/tile_move_absolute/handle_select.ts
@@ -2,50 +2,73 @@
* figures out the corresponding Tool | Coordinate | Point */
import { DropDownItem } from "../../../ui/index";
import { ResourceIndex } from "../../../resources/interfaces";
-import { KnownGroupTag, LocationData } from "./interfaces";
-import { findPointerByTypeAndId, findToolById } from "../../../resources/selectors";
-import { bail } from "../../../util";
-import { ParameterDeclaration, Coordinate } from "farmbot";
+import { LocationData } from "./interfaces";
+import {
+ ParameterDeclaration,
+ Coordinate,
+ ScopeDeclaration,
+ ScopeDeclarationBodyItem,
+ VariableDeclaration
+} from "farmbot";
export type CeleryVariable = LocationData | ParameterDeclaration;
-export const EMPTY_COORD: Coordinate = {
- kind: "coordinate",
- args: { x: 0, y: 0, z: 0 }
-};
+export const EMPTY_COORD: Coordinate =
+ ({ kind: "coordinate", args: { x: 0, y: 0, z: 0 } });
-/** Takes a DropDownItem and turns it into data suitable
-* for MoveAbsolute["args"]["location"] */
-export let handleSelect = (index: ResourceIndex, input: DropDownItem): CeleryVariable => {
- const tag = input.headingId as (KnownGroupTag | "parameter");
- const label = "" + input.value;
- const id = parseInt(label);
- switch (tag) {
- case "ToolSlot":
- case "GenericPointer":
- case "Plant":
- const p = findPointerByTypeAndId(index, tag, id);
- if (p && p.body.id) {
- return {
- kind: "point",
- args: { pointer_type: tag, pointer_id: p.body.id }
- };
- } else {
- return bail("Bad point_id: " + JSON.stringify(p));
+const toolVar = (value: string | number): VariableDeclaration => ({
+ kind: "variable_declaration",
+ args: {
+ label: "parent",
+ data_value: {
+ kind: "tool",
+ args: {
+ tool_id: parseInt("" + value)
}
- case "Tool":
- const tool_id = findToolById(index, id)
- .body
- .id || bail("No id");
- return { kind: "tool", args: { tool_id } };
- case "identifier":
- return { kind: "identifier", args: { label } };
- case "parameter":
- // AUTHOR'S NOTE: At the time of writing, the only parameter supported
- // is `parent` which is always has a `data_type` of `point`. This will
- // need to be updated later.
- const data_type = "point";
- return { kind: "parameter_declaration", args: { label, data_type } };
- default:
- return EMPTY_COORD;
+ }
+ }
+});
+
+const pointVar =
+ (pointer_type: "Plant" | "GenericPointer", value: string | number): VariableDeclaration => ({
+ kind: "variable_declaration",
+ args: {
+ label: "parent",
+ data_value: {
+ kind: "point",
+ args: { pointer_type, pointer_id: parseInt("" + value) }
+ }
+ }
+ });
+
+const manualEntry: VariableDeclaration = {
+ kind: "variable_declaration",
+ args: {
+ label: "parent",
+ data_value: { kind: "coordinate", args: { x: 0, y: 0, z: 0 } }
}
};
+
+const parentParameter: ParameterDeclaration = {
+ kind: "parameter_declaration",
+ args: { label: "parent", data_type: "point" }
+};
+const createNewParent =
+ (_index: ResourceIndex, input: DropDownItem): ScopeDeclarationBodyItem | undefined => {
+ switch (input.headingId) {
+ case "Plant":
+ case "GenericPointer": return pointVar(input.headingId, input.value);
+ case "Tool": return toolVar(input.value);
+ case "parameter": return parentParameter; // Caller decides X/Y/Z
+ case "Other": return manualEntry;
+ }
+ return undefined;
+ };
+
+export let handleSelect =
+ (index: ResourceIndex, input: DropDownItem): ScopeDeclaration => {
+ const sd: ScopeDeclaration =
+ ({ kind: "scope_declaration", args: {}, body: [] });
+ const parent = createNewParent(index, input);
+ parent && sd.body /** lol */ && sd.body.push(parent);
+ return sd;
+ };
diff --git a/webpack/sequences/step_tiles/tile_move_absolute/select.tsx b/webpack/sequences/step_tiles/tile_move_absolute/select.tsx
index c7110e874..d77632f68 100644
--- a/webpack/sequences/step_tiles/tile_move_absolute/select.tsx
+++ b/webpack/sequences/step_tiles/tile_move_absolute/select.tsx
@@ -1,13 +1,12 @@
import * as React from "react";
import { generateList, PARENT_DDI } from "./generate_list";
-import { handleSelect } from "./handle_select";
import { formatSelectedDropdown } from "./format_selected_dropdown";
import { TileMoveAbsProps } from "./interfaces";
import { FBSelect, DropDownItem } from "../../../ui/index";
import { Feature } from "../../../devices/interfaces";
export function TileMoveAbsSelect(props: TileMoveAbsProps) {
- const { selectedItem, resources, onChange, shouldDisplay } = props;
+ const { selectedItem, resources, shouldDisplay } = props;
const i = selectedItem;
const additionalItems: DropDownItem[] =
shouldDisplay(Feature.variables) ? PARENT_DDI : [];
@@ -15,9 +14,7 @@ export function TileMoveAbsSelect(props: TileMoveAbsProps) {
allowEmpty={true}
list={generateList(resources, additionalItems)}
selectedItem={formatSelectedDropdown(resources, i)}
- onChange={(x: DropDownItem) => {
- const y = handleSelect(resources, x);
- // This guard is only to please the type checker. -RC 10 Aug 18
- (y.kind !== "parameter_declaration") && onChange(y);
+ onChange={(_x: DropDownItem) => {
+ console.error("RE-write this!");
}} />;
}