diff --git a/src/common/utilities.js b/src/common/utilities.js index f384105..dac0f4a 100644 --- a/src/common/utilities.js +++ b/src/common/utilities.js @@ -74,9 +74,10 @@ export function insetSourceFrom (allSources) { if (!event.sources) { sources = [] } else { - sources = event.sources.map(id => ( - allSources.hasOwnProperty(id) ? allSources[id] : null - )) + sources = event.sources.map(src => { + const id = typeof src === 'object' ? src.id : src + return allSources.hasOwnProperty(id) ? allSources[id] : null + }) } return { ...event, diff --git a/src/components/Card.jsx b/src/components/Card.jsx index 57ad170..3e9df64 100644 --- a/src/components/Card.jsx +++ b/src/components/Card.jsx @@ -13,7 +13,7 @@ class Card extends React.Component { constructor (props) { super(props) this.state = { - isOpen: false + isOpen: false, } } @@ -135,17 +135,25 @@ class Card extends React.Component { render () { const { isSelected, idx } = this.props - - return ( + console.info(this.props) + return (
  • { + console.info('getting clicked') + if (!this.state.isOpen) { + const selectedEventFormat = idx > 0 ? [this.props.event] : this.props.event + this.props.onSelect(selectedEventFormat, idx) + } else { + console.info('NOT OPEN') + } + }} > {this.renderMain()} {this.state.isOpen ? this.renderExtra() : null} - {isSelected ? this.renderCaret() : null} + {this.renderCaret()}
  • ) } diff --git a/src/components/CardStack.jsx b/src/components/CardStack.jsx index 65fd3f9..85e3351 100644 --- a/src/components/CardStack.jsx +++ b/src/components/CardStack.jsx @@ -59,6 +59,7 @@ class CardStack extends React.Component { return events.map((event, idx) => { const thisRef = React.createRef() this.refs[idx] = thisRef + return ( this.props.onSelect(idx)} + onSelect={this.props.onSelect} + idx={idx} features={this.props.features} />) }) @@ -79,6 +81,7 @@ class CardStack extends React.Component { renderSelectedCards () { const { selected } = this.props + if (selected.length > 0) { return this.renderCards(selected) } diff --git a/src/components/Layout.js b/src/components/Layout.js index a67e9b9..a90174f 100644 --- a/src/components/Layout.js +++ b/src/components/Layout.js @@ -83,6 +83,7 @@ class Dashboard extends React.Component { } handleSelect (selected, axis) { + console.info(selected) const matchedEvents = [] const TIMELINE_AXIS = 0 if (axis === TIMELINE_AXIS) { @@ -97,7 +98,9 @@ class Dashboard extends React.Component { ptr >= 0 && (events[idx].datetime).getTime() === (events[ptr].datetime).getTime() ) { - matchedEvents.push(events[ptr]) + if (events[ptr].id !== selected.id) { + matchedEvents.push(events[ptr]) + } ptr -= 1 } // check events after @@ -107,15 +110,16 @@ class Dashboard extends React.Component { ptr < events.length && (events[idx].datetime).getTime() === (events[ptr].datetime).getTime() ) { + if (events[ptr].id !== selected.id) { matchedEvents.push(events[ptr]) - ptr += 1 + } + ptr += 1 } - } else { // Map... + } else { // Map.. const std = { ...selected } delete std.sources Object.values(std).forEach(ev => matchedEvents.push(ev)) } - console.info(matchedEvents) this.props.actions.updateSelected(matchedEvents) } @@ -371,7 +375,8 @@ export default connect( state => ({ ...state, narrativeIdx: selectors.selectNarrativeIdx(state), - narratives: selectors.selectNarratives(state) + narratives: selectors.selectNarratives(state), + selected: selectors.selectSelected(state) }), mapDispatchToProps )(Dashboard) diff --git a/src/selectors/index.js b/src/selectors/index.js index 1706b13..4b5d2b6 100644 --- a/src/selectors/index.js +++ b/src/selectors/index.js @@ -267,7 +267,6 @@ export const selectSelected = createSelector( if (selected.length === 0) { return [] } - return selected.map(insetSourceFrom(sources)) } ) diff --git a/src/store/initial.js b/src/store/initial.js index bb130ed..beb475b 100644 --- a/src/store/initial.js +++ b/src/store/initial.js @@ -29,7 +29,7 @@ const initial = { */ app: { errors: { - source: null + source: false }, highlighted: null, selected: [],