remove plants from default criteria
parent
85be07efe5
commit
309737dd33
|
@ -1,7 +1,7 @@
|
||||||
import { every, get, uniq, gt, lt, isNumber } from "lodash";
|
import { every, get, uniq, gt, lt, isNumber, isEqual } from "lodash";
|
||||||
import { TaggedPoint, TaggedPointGroup } from "farmbot";
|
import { TaggedPoint, TaggedPointGroup } from "farmbot";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { PointGroupCriteria } from "./interfaces";
|
import { PointGroupCriteria, DEFAULT_CRITERIA } from "./interfaces";
|
||||||
|
|
||||||
/** Check if a string or number criteria field is empty. */
|
/** Check if a string or number criteria field is empty. */
|
||||||
const eqCriteriaEmpty =
|
const eqCriteriaEmpty =
|
||||||
|
@ -45,6 +45,7 @@ export const selectPointsByCriteria = (
|
||||||
allPoints: TaggedPoint[],
|
allPoints: TaggedPoint[],
|
||||||
now = moment(),
|
now = moment(),
|
||||||
): TaggedPoint[] => {
|
): TaggedPoint[] => {
|
||||||
|
if (isEqual(criteria, DEFAULT_CRITERIA)) { return []; }
|
||||||
const check = checkCriteria(criteria, now);
|
const check = checkCriteria(criteria, now);
|
||||||
return allPoints.filter(point =>
|
return allPoints.filter(point =>
|
||||||
every(Object.keys(criteria).map((key: keyof PointGroupCriteria) =>
|
every(Object.keys(criteria).map((key: keyof PointGroupCriteria) =>
|
||||||
|
|
|
@ -15,7 +15,7 @@ export const DEFAULT_CRITERIA: Readonly<PointGroupCriteria> = {
|
||||||
number_eq: {},
|
number_eq: {},
|
||||||
number_gt: {},
|
number_gt: {},
|
||||||
number_lt: {},
|
number_lt: {},
|
||||||
string_eq: { pointer_type: ["Plant"] },
|
string_eq: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface GroupCriteriaProps {
|
export interface GroupCriteriaProps {
|
||||||
|
|
|
@ -83,8 +83,8 @@ export const NumberCriteriaSelection = (props: NumberCriteriaProps) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const DAY_OPERATOR_DDI_LOOKUP = (): { [x: string]: DropDownItem } => ({
|
const DAY_OPERATOR_DDI_LOOKUP = (): { [x: string]: DropDownItem } => ({
|
||||||
["<"]: { label: t("less than"), value: "<" },
|
["<"]: { label: t("Less than"), value: "<" },
|
||||||
[">"]: { label: t("greater than"), value: ">" },
|
[">"]: { label: t("Greater than"), value: ">" },
|
||||||
});
|
});
|
||||||
|
|
||||||
/** Edit and view day criteria. */
|
/** Edit and view day criteria. */
|
||||||
|
|
Loading…
Reference in New Issue