From b09f85748bba5c83b77f29b36c4a6321165df4b2 Mon Sep 17 00:00:00 2001 From: efarooqui Date: Wed, 28 Apr 2021 18:10:41 -0700 Subject: [PATCH 1/6] Modifying lat long to have decimals and not commas; adding extra title field to associations --- src/reducers/validate/associationsSchema.js | 1 + src/reducers/validate/validators.js | 4 ++++ 2 files changed, 5 insertions(+) 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({ From d6c5b551527f70c4fee8d0b7f85c6d1c7f832c4b Mon Sep 17 00:00:00 2001 From: Ebrahem Farooqui Date: Wed, 28 Apr 2021 18:48:07 -0700 Subject: [PATCH 2/6] open street maps is our default base map --- src/components/space/carto/Map.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/space/carto/Map.js b/src/components/space/carto/Map.js index 864b1bd..3e7e0e5 100644 --- a/src/components/space/carto/Map.js +++ b/src/components/space/carto/Map.js @@ -26,6 +26,7 @@ import { } from "../../../common/utilities"; // NB: important constants for map, TODO: make statics +// Note: Base map is OpenStreetMaps by default const supportedMapboxMap = ["streets", "satellite"]; const defaultToken = "your_token"; From 1d10ef1d99566138b5f86efc64a86163548d9a53 Mon Sep 17 00:00:00 2001 From: Ebrahem Farooqui Date: Wed, 28 Apr 2021 19:49:03 -0700 Subject: [PATCH 3/6] Triggering job from develop branch --- src/components/space/carto/Map.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/space/carto/Map.js b/src/components/space/carto/Map.js index 3e7e0e5..a1fa588 100644 --- a/src/components/space/carto/Map.js +++ b/src/components/space/carto/Map.js @@ -26,7 +26,7 @@ import { } from "../../../common/utilities"; // NB: important constants for map, TODO: make statics -// Note: Base map is OpenStreetMaps by default +// Note: Base map is OpenStreetMaps by default; can choose another base map const supportedMapboxMap = ["streets", "satellite"]; const defaultToken = "your_token"; From 123ed80d743de660a287aecfbe83ab8836bb982d Mon Sep 17 00:00:00 2001 From: efarooqui Date: Fri, 30 Apr 2021 17:47:16 -0700 Subject: [PATCH 4/6] Allow categories to be selected by title and not id; allow for primary key field --- src/common/utilities.js | 2 +- src/components/controls/CategoriesListPanel.js | 8 ++++---- src/components/time/Categories.js | 4 ++-- src/components/time/Timeline.js | 11 ++++++----- src/components/time/atoms/Events.js | 4 ++-- src/components/time/atoms/Markers.js | 2 +- src/reducers/app.js | 2 +- 7 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/common/utilities.js b/src/common/utilities.js index 7cbf8cb..145cdc6 100644 --- a/src/common/utilities.js +++ b/src/common/utilities.js @@ -159,7 +159,7 @@ export function getEventCategories(event, categories) { const matchedCategories = []; if (event.associations && event.associations.length > 0) { event.associations.reduce((acc, val) => { - const foundCategory = categories.find((cat) => cat.id === val); + const foundCategory = categories.find((cat) => cat.title === val); if (foundCategory) acc.push(foundCategory); return acc; }, matchedCategories); diff --git a/src/components/controls/CategoriesListPanel.js b/src/components/controls/CategoriesListPanel.js index f5e0054..bd62217 100644 --- a/src/components/controls/CategoriesListPanel.js +++ b/src/components/controls/CategoriesListPanel.js @@ -15,14 +15,14 @@ const CategoriesListPanel = ({ {categories.map((cat) => { return (
  • onCategoryFilter(cat.id)} + label={cat.title} + isActive={activeCategories.includes(cat.title)} + onClickCheckbox={() => onCategoryFilter(cat.title)} />
  • ); diff --git a/src/components/time/Categories.js b/src/components/time/Categories.js index 5a98cdd..8d04e91 100644 --- a/src/components/time/Categories.js +++ b/src/components/time/Categories.js @@ -34,7 +34,7 @@ class TimelineCategories extends React.Component { ) { return null; } - + console.info(this.props.getCategoryY(cat)); return ( <> 0; const renderedCategories = categoriesExist - ? this.props.categories.map((cat, idx) => this.renderCategory(cat, idx)) + ? categories.map((cat, idx) => this.renderCategory(cat, idx)) : this.renderCategory(fallbackLabel, 0); return ( diff --git a/src/components/time/Timeline.js b/src/components/time/Timeline.js index 77b09c4..3872993 100644 --- a/src/components/time/Timeline.js +++ b/src/components/time/Timeline.js @@ -96,7 +96,7 @@ class Timeline extends React.Component { const { features } = this.props; if (features.GRAPH_NONLOCATED && features.GRAPH_NONLOCATED.categories) { categories = categories.filter( - (cat) => !features.GRAPH_NONLOCATED.categories.includes(cat.id) + (cat) => !features.GRAPH_NONLOCATED.categories.includes(cat.title) ); } const extraPadding = 0; @@ -107,7 +107,7 @@ class Timeline extends React.Component { const catsYpos = categories.map((g, i) => { return (i + 1) * catHeight + marginTop + extraPadding / 2; }); - const catMap = categories.map((c) => c.id); + const catMap = categories.map((c) => c.title); return (cat) => { const idx = catMap.indexOf(cat); @@ -305,6 +305,7 @@ class Timeline extends React.Component { const { features, domain } = this.props; const { USE_CATEGORIES, GRAPH_NONLOCATED } = features; const { categories } = domain; + const categoriesExist = USE_CATEGORIES && categories && categories.length > 0; @@ -313,7 +314,7 @@ class Timeline extends React.Component { } const { category } = event; - + console.info(event); if (GRAPH_NONLOCATED && GRAPH_NONLOCATED.categories.includes(category)) { const { project } = event; return ( @@ -394,7 +395,7 @@ class Timeline extends React.Component { onDragEnd={() => { this.onDragEnd(); }} - categories={categories.map((c) => c.id)} + categories={categories.map((c) => c.title)} features={this.props.features} fallbackLabel={ copy[this.props.app.language].timeline @@ -467,7 +468,7 @@ function mapStateToProps(state) { categories: ((state) => { const allcats = selectors.getCategories(state); const active = selectors.getActiveCategories(state); - return allcats.filter((c) => active.includes(c.id)); + return allcats.filter((c) => active.includes(c.title)); })(state), narratives: state.domain.narratives, }, diff --git a/src/components/time/atoms/Events.js b/src/components/time/atoms/Events.js index 0d50f82..2402b03 100644 --- a/src/components/time/atoms/Events.js +++ b/src/components/time/atoms/Events.js @@ -134,9 +134,9 @@ const TimelineEvents = ({ // those timelines: so we create as many event 'shadows' as there are // categories const evShadows = getEventCategories(event, categories).map((cat) => { - const y = getY({ ...event, category: cat.id }); + const y = getY({ ...event, category: cat.title }); - const colour = event.colour ? event.colour : getCategoryColor(cat.id); + const colour = event.colour ? event.colour : getCategoryColor(cat.title); const styles = { fill: colour, fillOpacity: y > 0 ? calcOpacity(1) : 0, diff --git a/src/components/time/atoms/Markers.js b/src/components/time/atoms/Markers.js index abdc9a8..186aa00 100644 --- a/src/components/time/atoms/Markers.js +++ b/src/components/time/atoms/Markers.js @@ -65,7 +65,7 @@ const TimelineMarkers = ({ (isLatitude(event.latitude) && isLongitude(event.longitude)) || (features.GRAPH_NONLOCATED && event.projectOffset !== -1); const evShadows = getEventCategories(event, categories).map((cat) => - getEventY({ ...event, category: cat.id }) + getEventY({ ...event, category: cat.title }) ); function renderMarkerForEvent(y) { diff --git a/src/reducers/app.js b/src/reducers/app.js index 459d3c2..d137850 100644 --- a/src/reducers/app.js +++ b/src/reducers/app.js @@ -243,7 +243,7 @@ function setNotLoading(appState) { function setInitialCategories(appState, action) { const categories = action.values.reduce((acc, val) => { - if (val.mode === ASSOCIATION_MODES.CATEGORY) acc.push(val.id); + if (val.mode === ASSOCIATION_MODES.CATEGORY) acc.push(val.title); return acc; }, []); From 604ff44ff22187d4254edbd05b7d4edc0c7876a8 Mon Sep 17 00:00:00 2001 From: efarooqui Date: Fri, 30 Apr 2021 17:49:59 -0700 Subject: [PATCH 5/6] Removing misc comments --- src/components/time/Categories.js | 2 +- src/components/time/Timeline.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/time/Categories.js b/src/components/time/Categories.js index 8d04e91..74e7074 100644 --- a/src/components/time/Categories.js +++ b/src/components/time/Categories.js @@ -34,7 +34,7 @@ class TimelineCategories extends React.Component { ) { return null; } - console.info(this.props.getCategoryY(cat)); + return ( <> Date: Fri, 30 Apr 2021 18:57:34 -0700 Subject: [PATCH 6/6] Extraneous comment --- src/components/time/Timeline.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/time/Timeline.js b/src/components/time/Timeline.js index 4472c46..c5b5744 100644 --- a/src/components/time/Timeline.js +++ b/src/components/time/Timeline.js @@ -304,6 +304,7 @@ class Timeline extends React.Component { getY(event) { const { features, domain } = this.props; const { USE_CATEGORIES, GRAPH_NONLOCATED } = features; + // Categories represent active categories here const { categories } = domain; const categoriesExist =