From a686268839b80da31b4f80e45109dd02be99b5b2 Mon Sep 17 00:00:00 2001 From: Lachlan Kermode Date: Fri, 19 Jun 2020 16:08:45 +0200 Subject: [PATCH] apply narratives only if FILTERS_AS_NARRATIVES set --- src/components/Layout.js | 4 +- .../presentational/Map/Narratives.js | 67 +++++++++++-------- 2 files changed, 43 insertions(+), 28 deletions(-) diff --git a/src/components/Layout.js b/src/components/Layout.js index fe60db6..f989b5a 100644 --- a/src/components/Layout.js +++ b/src/components/Layout.js @@ -1,3 +1,4 @@ +/* global alert */ import React from 'react' import { bindActionCreators } from 'redux' @@ -149,6 +150,7 @@ class Dashboard extends React.Component { id: name, label: name, description: '', + withLines: withSteps, steps: evs }) } @@ -223,7 +225,7 @@ class Dashboard extends React.Component { getCategoryColor={this.getCategoryColor} /> 0} + showing={features.FILTERS_AS_NARRATIVES && !app.narrative && app.filters.filters.length > 0} timelineDims={app.timeline.dimensions} onClickHandler={this.setNarrativeFromFilters} /> diff --git a/src/components/presentational/Map/Narratives.js b/src/components/presentational/Map/Narratives.js index a3fbd7e..8e0aefa 100644 --- a/src/components/presentational/Map/Narratives.js +++ b/src/components/presentational/Map/Narratives.js @@ -10,7 +10,15 @@ const defaultStyles = { stroke: 'none' } -function MapNarratives ({ styles, onSelectNarrative, svg, narrative, narratives, projectPoint, features }) { +function MapNarratives ({ + styles, + onSelectNarrative, + svg, + narrative, + narratives, + projectPoint, + features +}) { function getNarrativeStyle (narrativeId) { const styleName = (narrativeId && narrativeId in styles) ? narrativeId @@ -133,29 +141,32 @@ function MapNarratives ({ styles, onSelectNarrative, svg, narrative, narratives, let lastMarked = null - for (let idx = 0; idx < n.steps.length; idx += 1) { - const step = n.steps[idx] - if (lastMarked) { - arrows.push(renderBetweenSteps(lastMarked, step, { - strokeWidth: '1px', - stroke: step.colour - })) + if (features.FILTERS_AS_NARRATIVES) { + for (let idx = 0; idx < n.steps.length; idx += 1) { + const step = n.steps[idx] + if (lastMarked) { + arrows.push(renderBetweenSteps( + lastMarked, + step, + n.withLines ? { strokeWidth: '1px', stroke: step.colour } : {}) + ) + } + lastMarked = step } - lastMarked = step - } + } else { + for (let idx = 0; idx < n.steps.length; idx += 1) { + const step = n.steps[idx] + const _idx = step.narratives.indexOf(n.id) + const stepStyle = step.narrative___stepStyles[_idx] - // for (let idx = 0; idx < n.steps.length; idx += 1) { - // const step = n.steps[idx] - // const _idx = step.narratives.indexOf(n.id) - // const stepStyle = step.narrative___stepStyles[_idx] - // - // if (stepStyle !== 'None') { - // if (lastMarked) { - // arrows.push(renderBetweenSteps(lastMarked, step, styles.stepStyles[stepStyle])) - // } - // lastMarked = step - // } - // } + if (stepStyle !== 'None') { + if (lastMarked) { + arrows.push(renderBetweenSteps(lastMarked, step, styles.stepStyles[stepStyle])) + } + lastMarked = step + } + } + } return arrows } @@ -163,13 +174,15 @@ function MapNarratives ({ styles, onSelectNarrative, svg, narrative, narratives, function renderNarrative (n) { const narrativeId = `narrative-${n.id.replace(/ /g, '_')}` + const body = features.FILTERS_AS_NARRATIVES + ? renderBetweenMarked(n) + : (features.NARRATIVE_STEP_STYLES + ? renderBetweenMarked(n) + : renderFullNarrative(n)) + return ( - {renderBetweenMarked(n)} - {/* {(features.NARRATIVE_STEP_STYLES */} - {/* ? renderBetweenMarked(n) */} - {/* : renderFullNarrative(n) */} - {/* )} */} + {body} ) }