2017-03-11 01:49:27 -05:00
|
|
|
import React, { Component, PropTypes } from 'react'
|
|
|
|
|
2017-03-11 09:56:09 -05:00
|
|
|
import DataVis from './DataVis'
|
|
|
|
import MapButtons from './MapButtons'
|
|
|
|
import InfoAndHelp from './InfoAndHelp'
|
|
|
|
import MapControls from './MapControls'
|
2017-03-11 01:49:27 -05:00
|
|
|
import MapChat from './MapChat'
|
|
|
|
import TopicCard from '../TopicCard'
|
|
|
|
|
|
|
|
class MapView extends Component {
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
mapId: PropTypes.string,
|
|
|
|
map: PropTypes.object,
|
|
|
|
mapIsStarred: PropTypes.bool,
|
|
|
|
currentUser: PropTypes.object,
|
|
|
|
endActiveMap: PropTypes.func,
|
|
|
|
launchNewMap: PropTypes.func
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props)
|
2017-03-11 09:56:09 -05:00
|
|
|
this.state = {
|
|
|
|
infoBoxOpen: false,
|
|
|
|
filterBoxOpen: false,
|
|
|
|
chatOpen: false
|
|
|
|
}
|
2017-03-11 01:49:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
window && window.addEventListener('resize', this.resize)
|
|
|
|
this.resize()
|
|
|
|
}
|
|
|
|
|
2017-03-11 09:56:09 -05:00
|
|
|
endMap() {
|
|
|
|
this.setState({
|
|
|
|
infoBoxOpen: false,
|
|
|
|
filterBoxOpen: false,
|
|
|
|
chatOpen: false
|
|
|
|
})
|
|
|
|
this.props.endActiveMap()
|
|
|
|
}
|
|
|
|
|
2017-03-11 01:49:27 -05:00
|
|
|
componentDidUpdate(prevProps) {
|
|
|
|
const oldMapId = prevProps.mapId
|
2017-03-11 09:56:09 -05:00
|
|
|
const { mapId, launchNewMap } = this.props
|
2017-03-11 01:49:27 -05:00
|
|
|
if (!oldMapId && mapId) launchNewMap(mapId)
|
|
|
|
else if (oldMapId && mapId && oldMapId !== mapId) {
|
2017-03-11 09:56:09 -05:00
|
|
|
this.endMap()
|
2017-03-11 01:49:27 -05:00
|
|
|
launchNewMap(mapId)
|
|
|
|
}
|
2017-03-11 09:56:09 -05:00
|
|
|
else if (oldMapId && !mapId) this.endMap()
|
2017-03-11 01:49:27 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
componentWillUnmount() {
|
|
|
|
window && window.removeEventListener('resize', this.resize)
|
|
|
|
}
|
|
|
|
|
|
|
|
resize = () => {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
render = () => {
|
2017-03-11 09:56:09 -05:00
|
|
|
const { map, mapIsStarred, currentUser, onOpen, onClose } = this.props
|
|
|
|
const { infoBoxOpen, filterBoxOpen, chatOpen } = this.state
|
|
|
|
const onChatOpen = () => {
|
|
|
|
this.setState({chatOpen: true})
|
|
|
|
onOpen()
|
|
|
|
}
|
|
|
|
const onChatClose = () => {
|
|
|
|
this.setState({chatOpen: false})
|
|
|
|
onClose()
|
|
|
|
}
|
|
|
|
// TODO: stop using {...this.props} and make explicit
|
2017-03-11 01:49:27 -05:00
|
|
|
return <div className="mapWrapper">
|
2017-03-11 09:56:09 -05:00
|
|
|
<MapButtons currentUser={currentUser} filterBoxOpen={filterBoxOpen} />
|
|
|
|
<DataVis />
|
|
|
|
<TopicCard {...this.props} />
|
|
|
|
<MapChat {...this.props} onOpen={onChatOpen} onClose={onChatClose} chatOpen={chatOpen} />
|
|
|
|
<MapControls />
|
|
|
|
<InfoAndHelp infoBoxOpen={infoBoxOpen} mapIsStarred={mapIsStarred} currentUser={currentUser} map={map} />
|
2017-03-11 01:49:27 -05:00
|
|
|
</div>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default MapView
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
<% if authenticated? %>
|
|
|
|
<% # for creating and pulling in topics and synapses %>
|
|
|
|
<% if controller_name == 'maps' && action_name == "conversation" %>
|
|
|
|
<%= render :partial => 'maps/newtopicsecret' %>
|
|
|
|
<% else %>
|
|
|
|
<%= render :partial => 'maps/newtopic' %>
|
|
|
|
<% end %>
|
|
|
|
<%= render :partial => 'maps/newsynapse' %>
|
|
|
|
<% # for populating the change metacode list on the topic card %>
|
|
|
|
<%= render :partial => 'shared/metacodeoptions' %>
|
|
|
|
<% end %>
|
|
|
|
<%= render :partial => 'layouts/lowermapelements' %>
|
|
|
|
|
|
|
|
<div id="loading"></div>
|
|
|
|
|
|
|
|
<div id="instructions">
|
|
|
|
<div className="addTopic">
|
|
|
|
Double-click to<br>add a topic
|
|
|
|
</div>
|
|
|
|
<div className="tabKey">
|
|
|
|
Use Tab & Shift+Tab to select a metacode
|
|
|
|
</div>
|
|
|
|
<div className="enterKey">
|
|
|
|
Press Enter to add the topic
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
*/
|