diff --git a/example.config.js b/example.config.js index 30ca530..ac443c1 100644 --- a/example.config.js +++ b/example.config.js @@ -24,11 +24,8 @@ module.exports = { }, features: { USE_CATEGORIES: true, - USE_NARRATIVES: true, - FILTERS_AS_NARRATIVES: true, CATEGORIES_AS_FILTERS: true, USE_ASSOCIATIONS: true, - USE_ASSOCIATION_DESCRIPTIONS: false, USE_SOURCES: true, USE_COVER: true, USE_SEARCH: false, diff --git a/src/components/Card.jsx b/src/components/Card.jsx index 9bca2fc..4079f60 100644 --- a/src/components/Card.jsx +++ b/src/components/Card.jsx @@ -5,10 +5,8 @@ import CardCustomField from './presentational/Card/CustomField' import CardTime from './presentational/Card/Time' import CardLocation from './presentational/Card/Location' import CardCaret from './presentational/Card/Caret' -import CardFilters from './presentational/Card/Filters' import CardSummary from './presentational/Card/Summary' import CardSource from './presentational/Card/Source' -import CardNarrative from './presentational/Card/Narrative' import { makeNiceDate } from '../common/utilities' class Card extends React.Component { @@ -39,18 +37,6 @@ class Card extends React.Component { ) } - renderFilters () { - if (!this.props.filters || (this.props.filters && this.props.filters.length === 0)) { - return null - } - return ( - - ) - } - renderLocation () { return ( this.props.onSelect([event])} - makeTimelabel={(timestamp) => this.makeTimelabel(timestamp)} - next={links.next} - prev={links.prev} - /> - ) - } - } - renderCustomFields () { return this.props.features.CUSTOM_EVENT_FIELDS .map(field => { diff --git a/src/components/Layout.js b/src/components/Layout.js index 4e290ae..36304a9 100644 --- a/src/components/Layout.js +++ b/src/components/Layout.js @@ -303,7 +303,7 @@ class Dashboard extends React.Component { getCategoryColor={this.getCategoryColor} /> 0} + showing={this.props.narratives && this.props.narratives.length !== 0 && !app.associations.narrative && app.associations.filters.length > 0} timelineDims={app.timeline.dimensions} onClickHandler={this.setNarrativeFromFilters} /> diff --git a/src/components/Toolbar/Layout.js b/src/components/Toolbar/Layout.js index dc61ce7..cceab2a 100644 --- a/src/components/Toolbar/Layout.js +++ b/src/components/Toolbar/Layout.js @@ -113,13 +113,13 @@ class Toolbar extends React.Component { } renderToolbarPanels () { - const { features } = this.props + const { features, narratives } = this.props let classes = (this.state._selected >= 0) ? 'toolbar-panels' : 'toolbar-panels folded' return (
{this.renderClosePanel()} - {features.USE_NARRATIVES ? this.renderToolbarNarrativePanel() : null} + {narratives && narratives.length !== 0 ? this.renderToolbarNarrativePanel() : null} {features.CATEGORIES_AS_FILTERS ? this.renderToolbarCategoriesPanel() : null} {features.USE_ASSOCIATIONS ? this.renderToolbarFilterPanel() : null} @@ -145,7 +145,8 @@ class Toolbar extends React.Component { } renderToolbarTabs () { - const { features } = this.props + const { features, narratives } = this.props + const narrativesExist = narratives && narratives.length !== 0 let title = copy[this.props.language].toolbar.title if (process.env.display_title) title = process.env.display_title const narrativesLabel = copy[this.props.language].toolbar.narratives_label @@ -153,15 +154,15 @@ class Toolbar extends React.Component { const categoriesLabel = 'Categories' // TODO: const narrativesIdx = 0 - const categoriesIdx = features.USE_NARRATIVES ? 1 : 0 - const filtersIdx = (features.USE_NARRATIVES && features.CATEGORIES_AS_FILTERS) ? 2 : ( - features.USE_NARRATIVES || features.CATEGORIES_AS_FILTERS ? 1 : 0 + const categoriesIdx = narrativesExist ? 1 : 0 + const filtersIdx = (narrativesExist && features.CATEGORIES_AS_FILTERS) ? 2 : ( + narrativesExist || features.CATEGORIES_AS_FILTERS ? 1 : 0 ) return (

{title}

- {features.USE_NARRATIVES ? this.renderToolbarTab(narrativesIdx, narrativesLabel, 'timeline') : null} + {narrativesExist ? this.renderToolbarTab(narrativesIdx, narrativesLabel, 'timeline') : null} {features.CATEGORIES_AS_FILTERS ? this.renderToolbarTab(categoriesIdx, categoriesLabel, 'widgets') : null} {features.USE_ASSOCIATIONS ? this.renderToolbarTab(filtersIdx, filtersLabel, 'filter_list') : null}
diff --git a/src/components/presentational/Card/Filters.js b/src/components/presentational/Card/Filters.js deleted file mode 100644 index 0b90de4..0000000 --- a/src/components/presentational/Card/Filters.js +++ /dev/null @@ -1,36 +0,0 @@ -import React from 'react' - -import copy from '../../../common/data/copy.json' - -const CardFilters = ({ filters, language }) => { - const filtersLang = copy[language].cardstack.filters - const noFiltersLang = copy[language].cardstack.nofilters - - if (filters.length > 0) { - return ( -
-

{filtersLang}:

-

- {filters.map((filter, idx) => { - return ( - - {filter.name} - {(idx < filters.length - 1) - ? ',' - : ''} - - ) - })} -

-
- ) - } - return ( -
-

{filtersLang}

-

{noFiltersLang}

-
- ) -} - -export default CardFilters diff --git a/src/components/presentational/Card/Narrative.js b/src/components/presentational/Card/Narrative.js deleted file mode 100644 index 150180f..0000000 --- a/src/components/presentational/Card/Narrative.js +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react' - -import CardNarrativeLink from './NarrativeLink' - -const CardNarrative = (props) => ( -
-

Connected events

-
-

-

-
-
-) - -export default CardNarrative diff --git a/src/components/presentational/Card/NarrativeLink.js b/src/components/presentational/Card/NarrativeLink.js deleted file mode 100644 index b292e16..0000000 --- a/src/components/presentational/Card/NarrativeLink.js +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react' - -const CardNarrativeLink = ({ event, makeTimelabel, select }) => { - if (event !== null) { - const timelabel = makeTimelabel(event.timestamp) - - return ( - select(event)}> - {`${timelabel} / ${event.location}`} - - ) - } - - return (None) -} - -export default CardNarrativeLink diff --git a/src/components/presentational/Map/Narratives.js b/src/components/presentational/Map/Narratives.js index 8e0aefa..cbae8c7 100644 --- a/src/components/presentational/Map/Narratives.js +++ b/src/components/presentational/Map/Narratives.js @@ -26,6 +26,8 @@ function MapNarratives ({ return styles[styleName] } + const narrativesExist = narratives && narratives.length !== 0 + function hasNoLocation (step) { return (step.latitude === '' || step.longitude === '') } @@ -141,7 +143,7 @@ function MapNarratives ({ let lastMarked = null - if (features.FILTERS_AS_NARRATIVES) { + if (narrativesExist) { for (let idx = 0; idx < n.steps.length; idx += 1) { const step = n.steps[idx] if (lastMarked) { @@ -174,7 +176,7 @@ function MapNarratives ({ function renderNarrative (n) { const narrativeId = `narrative-${n.id.replace(/ /g, '_')}` - const body = features.FILTERS_AS_NARRATIVES + const body = narrativesExist ? renderBetweenMarked(n) : (features.NARRATIVE_STEP_STYLES ? renderBetweenMarked(n) diff --git a/src/selectors/index.js b/src/selectors/index.js index d5f319c..c8ad30e 100644 --- a/src/selectors/index.js +++ b/src/selectors/index.js @@ -76,7 +76,7 @@ export const selectEvents = createSelector( export const selectNarratives = createSelector( [getEvents, getNarratives, getSources, getFeatures], (events, narrativesMeta, sources, features) => { - if (!features.USE_NARRATIVES) { + if (Array.isArray(narrativesMeta) && narrativesMeta.length === 0) { return [] } const narratives = {}