diff --git a/src/components/controls/FilterListPanel.js b/src/components/controls/FilterListPanel.js index 238f0bc..16529e6 100644 --- a/src/components/controls/FilterListPanel.js +++ b/src/components/controls/FilterListPanel.js @@ -7,7 +7,6 @@ import { getFilterIdxFromColorSet } from "../../common/utilities"; /** recursively get an array of node keys to toggle */ function getFiltersToToggle(filter, activeFilters) { const [key, children] = filter; - // base case: no children to recurse through if (children === {}) return [key]; @@ -21,18 +20,28 @@ function getFiltersToToggle(filter, activeFilters) { } function aggregatePaths(filters) { - function insertPath(children = {}, [headOfPath, ...remainder]) { - const childKey = Object.keys(children).find((key) => key === headOfPath); - if (!childKey) children[headOfPath] = {}; - if (remainder.length > 0) insertPath(children[headOfPath], remainder); + function insertPath( + children = {}, + [headOfPath, ...remainder], + accumulatedPath + ) { + const childKey = Object.keys(children).find((path) => { + const splitPath = path.split("/"); + const pathLeaf = splitPath[splitPath.length - 1]; + return pathLeaf === headOfPath; + }); + accumulatedPath.push(headOfPath); + const accumulatedPlusHead = accumulatedPath.join("/"); + if (!childKey) children[accumulatedPlusHead] = {}; + if (remainder.length > 0) + insertPath(children[accumulatedPlusHead], remainder, accumulatedPath); return children; } const allPaths = []; filters.forEach((filterItem) => allPaths.push(filterItem.filter_paths)); - const aggregatedPaths = allPaths.reduce( - (children, path) => insertPath(children, path), + (children, path) => insertPath(children, path, []), {} ); return aggregatedPaths; diff --git a/src/reducers/validate/associationsSchema.js b/src/reducers/validate/associationsSchema.js index cf721e4..220b597 100644 --- a/src/reducers/validate/associationsSchema.js +++ b/src/reducers/validate/associationsSchema.js @@ -2,6 +2,7 @@ import Joi from "joi"; const associationsSchema = Joi.object().keys({ id: Joi.string().allow("").required(), + title: Joi.string().allow("").required(), desc: Joi.string().allow(""), mode: Joi.string().allow("").required(), filter_paths: Joi.array(), diff --git a/src/reducers/validate/validators.js b/src/reducers/validate/validators.js index 79c878d..e796dba 100644 --- a/src/reducers/validate/validators.js +++ b/src/reducers/validate/validators.js @@ -137,6 +137,10 @@ export function validateDomain(domain, features) { // append events with datetime and sort sanitizedDomain.events = sanitizedDomain.events.filter((event, idx) => { event.id = idx; + // if lat, long come in with commas, replace with decimal format + event.latitude = event.latitude.replace(",", "."); + event.longitude = event.longitude.replace(",", "."); + event.datetime = calcDatetime(event.date, event.time); if (!isValidDate(event.datetime)) { discardedDomain.events.push({