just keep using current mapinfobox

This commit is contained in:
Connor Turland 2017-03-11 21:13:58 -05:00
parent c954ba99f8
commit d2d35c9a3d
7 changed files with 95 additions and 95 deletions

View file

@ -4,6 +4,53 @@
#%> #%>
<div class="templates"> <div class="templates">
<script type="text/template" id="mapInfoBoxTemplate">
<div class="requestTitle">Click here to name this map</div>
<div class="mapInfoName" id="mapInfoName">{{{name}}}</div>
<div class="mapInfoStat">
<div class="infoStatIcon mapContributors hoverForTip">
<img id="mapContribs" class="{{contributors_class}}"
width="25" height="25" src="{{contributor_image}}" />
<span class="count">{{contributor_count}}</span>
<div class="tip">{{{contributor_list}}}</div>
</div>
<div class="infoStatIcon mapTopics">
{{topic_count}}
</div>
<div class="infoStatIcon mapSynapses">
{{synapse_count}}
</div>
<div class="infoStatIcon mapPermission {{permission}} hoverForTip">
{{{map_creator_tip}}}
</div>
<div class="clearfloat"></div>
</div>
<div class="mapInfoDesc" id="mapInfoDesc">
{{{desc}}}
</div>
<div class="mapInfoMeta">
<p class="mapCreatedAt"><span>Created by:</span> {{user_name}} on {{created_at}}</p>
<p class="mapEditedAt"><span>Last edited:</span> {{updated_at}}</p>
<div class="mapInfoButtonsWrapper">
<div class="mapInfoThumbnail">
<div class="thumbnail"></div>
<div class="tooltip">Update Thumbnail</div>
<span>Thumb</span>
</div>
<div class="mapInfoDelete">
<div class="deleteMap"></div>
<span>Delete</span>
</div>
<div class="mapInfoShare">
<div class="mapInfoShareIcon"></div>
<span>Share</span>
</div>
</div>
</div>
</script>
<script type="text/template" id="mapSearchTemplate"> <script type="text/template" id="mapSearchTemplate">
<div class="result{{rtype}}"> <div class="result{{rtype}}">
<div class="searchResIconWrapper"> <div class="searchResIconWrapper">

View file

@ -30,10 +30,10 @@
<%= render :partial => 'maps/newsynapse' %> <%= render :partial => 'maps/newsynapse' %>
<% # for populating the change metacode list on the topic card %> <% # for populating the change metacode list on the topic card %>
<%= render :partial => 'shared/metacodeoptions' %> <%= render :partial => 'shared/metacodeoptions' %>
<script type="text/javascript">
Metamaps.ServerData.unreadNotificationsCount = <%= user_unread_notification_count %>
Metamaps.ServerData.mapIsStarred = <%= @map && current_user.starred_map?(@map) ? true : false %>
</script>
<% end %> <% end %>
<div id="loading"></div> <div id="loading"></div>
<script type="text/javascript">
Metamaps.ServerData.unreadNotificationsCount = <%= user_unread_notification_count %>
Metamaps.ServerData.mapIsStarred = <%= current_user && @map && current_user.starred_map?(@map) ? true : false %>
</script>
<%= render :partial => 'layouts/foot' %> <%= render :partial => 'layouts/foot' %>

View file

@ -11,7 +11,7 @@ import Active from '../Active'
import DataModel from '../DataModel' import DataModel from '../DataModel'
import { ExploreMaps, ChatView, TopicCard } from '../Views' import { ExploreMaps, ChatView, TopicCard } from '../Views'
import Realtime from '../Realtime' import Realtime from '../Realtime'
import Map from '../Map' import Map, { InfoBox } from '../Map'
import Topic from '../Topic' import Topic from '../Topic'
import makeRoutes from '../../components/makeRoutes' import makeRoutes from '../../components/makeRoutes'
let routes let routes
@ -73,7 +73,9 @@ const ReactApp = {
map: Active.Map, map: Active.Map,
mapIsStarred: self.mapIsStarred, mapIsStarred: self.mapIsStarred,
endActiveMap: Map.end, endActiveMap: Map.end,
launchNewMap: Map.launch launchNewMap: Map.launch,
toggleMapInfoBox: InfoBox.toggleBox,
infoBoxHtml: InfoBox.html
// filters // filters
} }
}, },

View file

@ -4,12 +4,11 @@ import outdent from 'outdent'
import Active from '../Active' import Active from '../Active'
import DataModel from '../DataModel' import DataModel from '../DataModel'
import GlobalUI from '../GlobalUI' import GlobalUI, { ReactApp } from '../GlobalUI'
import Util from '../Util' import Util from '../Util'
const InfoBox = { const InfoBox = {
isOpen: false, isOpen: false,
changing: false,
selectingPermission: false, selectingPermission: false,
changePermissionText: "<div class='tooltips'>As the creator, you can change the permission of this map, and the permission of all the topics and synapses you have authority to change will change as well.</div>", changePermissionText: "<div class='tooltips'>As the creator, you can change the permission of this map, and the permission of all the topics and synapses you have authority to change will change as well.</div>",
nameHTML: outdent` nameHTML: outdent`
@ -34,12 +33,12 @@ const InfoBox = {
data-bip-value="{{desc}}" data-bip-value="{{desc}}"
>{{desc}}</span>`, >{{desc}}</span>`,
userImageUrl: '', userImageUrl: '',
html: '',
init: function(serverData, updateThumbnail) { init: function(serverData, updateThumbnail) {
var self = InfoBox var self = InfoBox
self.updateThumbnail = updateThumbnail self.updateThumbnail = updateThumbnail
$('.mapInfoIcon').click(self.toggleBox)
$('.mapInfoBox').click(function(event) { $('.mapInfoBox').click(function(event) {
event.stopPropagation() event.stopPropagation()
}) })
@ -47,7 +46,7 @@ const InfoBox = {
self.attachEventListeners() self.attachEventListeners()
self.generateBoxHTML = Hogan.compile('') self.generateBoxHTML = Hogan.compile($('#mapInfoBoxTemplate').html())
self.userImageUrl = serverData['user.png'] self.userImageUrl = serverData['user.png']
@ -71,27 +70,18 @@ const InfoBox = {
open: function() { open: function() {
var self = InfoBox var self = InfoBox
$('.mapInfoIcon div').addClass('hide') $('.mapInfoIcon div').addClass('hide')
if (!self.isOpen && !self.changing) { $('.mapInfoBox').fadeIn(200, function() {
self.changing = true self.isOpen = true
$('.mapInfoBox').fadeIn(200, function() { })
self.changing = false
self.isOpen = true
})
}
}, },
close: function() { close: function() {
var self = InfoBox var self = InfoBox
$('.mapInfoIcon div').removeClass('hide') $('.mapInfoIcon div').removeClass('hide')
if (!self.changing) { $('.mapInfoBox').fadeOut(200, function() {
self.changing = true self.isOpen = false
$('.mapInfoBox').fadeOut(200, function() { self.hidePermissionSelect()
self.changing = false $('.mapContributors .tip').hide()
self.isOpen = false })
self.hidePermissionSelect()
$('.mapContributors .tip').hide()
})
}
}, },
load: function() { load: function() {
var self = InfoBox var self = InfoBox
@ -119,13 +109,8 @@ const InfoBox = {
obj['created_at'] = map.get('created_at_clean') obj['created_at'] = map.get('created_at_clean')
obj['updated_at'] = map.get('updated_at_clean') obj['updated_at'] = map.get('updated_at_clean')
var classes = isCreator ? 'yourMap' : '' self.html = self.generateBoxHTML.render(obj)
classes += canEdit ? ' canEdit' : '' ReactApp.render()
classes += shareable ? ' shareable' : ''
$('.mapInfoBox').removeClass('shareable yourMap canEdit')
.addClass(classes)
.html(self.generateBoxHTML.render(obj))
self.attachEventListeners() self.attachEventListeners()
}, },
attachEventListeners: function() { attachEventListeners: function() {

View file

@ -7,19 +7,20 @@ class InfoAndHelp extends Component {
mapIsStarred: PropTypes.bool, mapIsStarred: PropTypes.bool,
currentUser: PropTypes.object, currentUser: PropTypes.object,
map: PropTypes.object, map: PropTypes.object,
infoBoxOpen: PropTypes.bool onInfoClick: PropTypes.func,
infoBoxhtml: PropTypes.string
} }
render () { render () {
const { mapIsStarred, map, currentUser, infoBoxOpen } = this.props const { mapIsStarred, map, currentUser, onInfoClick, infoBoxHtml } = this.props
const starclassName = mapIsStarred ? 'starred' : '' const starclassName = mapIsStarred ? 'starred' : ''
const tooltip = mapIsStarred ? 'Star' : 'Unstar' const tooltip = mapIsStarred ? 'Star' : 'Unstar'
return <div className="infoAndHelp"> return <div className="infoAndHelp">
{infoBoxOpen && <MapInfoBox map={map} currentUser={currentUser} />} <MapInfoBox map={map} currentUser={currentUser} infoBoxHtml={infoBoxHtml} />
<div className={`starMap infoElement mapElement ${starclassName}`}> <div className={`starMap infoElement mapElement ${starclassName}`}>
<div className="tooltipsAbove">{tooltip}</div> <div className="tooltipsAbove">{tooltip}</div>
</div> </div>
<div className="mapInfoIcon infoElement mapElement"> <div className="mapInfoIcon infoElement mapElement" onClick={onInfoClick}>
<div className="tooltipsAbove">Map Info</div> <div className="tooltipsAbove">Map Info</div>
</div> </div>
<div className="openCheatsheet openLightbox infoElement mapElement" data-open="cheatsheet"> <div className="openCheatsheet openLightbox infoElement mapElement" data-open="cheatsheet">

View file

@ -3,60 +3,20 @@ import React, { Component, PropTypes } from 'react'
class MapInfoBox extends Component { class MapInfoBox extends Component {
static propTypes = { static propTypes = {
currentUser: PropTypes.object, currentUser: PropTypes.object,
map: PropTypes.object map: PropTypes.object,
infoBoxHtml: PropTypes.string
} }
render () { render () {
const { currentUser, map } = this.props const { currentUser, map, infoBoxHtml } = this.props
if (!map) return null if (!map) return null
const html = {__html: infoBoxHtml}
let name, contributors_class, contributor_image, contributor_list, const isCreator = map.authorizePermissionChange(currentUser)
contributor_count, topic_count, synapse_count, map_creator_tip, const canEdit = map.authorizeToEdit(currentUser)
permission, desc, user_name, created_at, updated_at let classes = 'mapInfoBox mapElement mapElementHidden permission '
return <div className="mapInfoBox mapElement mapElementHidden permission"> classes += isCreator ? 'yourMap' : ''
<div className="requestTitle">Click here to name this map</div> classes += canEdit ? ' canEdit' : ''
<div className="mapInfoName" id="mapInfoName">{name}</div> return <div className={classes} dangerouslySetInnerHTML={html}></div>
<div className="mapInfoStat">
<div className="infoStatIcon mapContributors hoverForTip">
<img id="mapContribs" className="{contributors_class}"
width="25" height="25" src="{contributor_image}" />
<span className="count">{contributor_count}</span>
<div className="tip">{contributor_list}</div>
</div>
<div className="infoStatIcon mapTopics">
{topic_count}
</div>
<div className="infoStatIcon mapSynapses">
{synapse_count}
</div>
<div className={`infoStatIcon mapPermission ${permission} hoverForTip`}>
{map_creator_tip}
</div>
<div className="clearfloat"></div>
</div>
<div className="mapInfoDesc" id="mapInfoDesc">
{desc}
</div>
<div className="mapInfoMeta">
<p className="mapCreatedAt"><span>Created by:</span> {user_name} on {created_at}</p>
<p className="mapEditedAt"><span>Last edited:</span> {updated_at}</p>
<div className="mapInfoButtonsWrapper">
<div className="mapInfoThumbnail">
<div className="thumbnail"></div>
<div className="tooltip">Update Thumbnail</div>
<span>Thumb</span>
</div>
<div className="mapInfoDelete">
<div className="deleteMap"></div>
<span>Delete</span>
</div>
<div className="mapInfoShare">
<div className="mapInfoShareIcon"></div>
<span>Share</span>
</div>
</div>
</div>
</div>
} }
} }

View file

@ -13,15 +13,17 @@ class MapView extends Component {
mapId: PropTypes.string, mapId: PropTypes.string,
map: PropTypes.object, map: PropTypes.object,
mapIsStarred: PropTypes.bool, mapIsStarred: PropTypes.bool,
toggleFilterBox: PropTypes.func,
toggleMapInfoBox: PropTypes.func,
infoBoxHtml: PropTypes.string,
currentUser: PropTypes.object, currentUser: PropTypes.object,
endActiveMap: PropTypes.func, endActiveMap: PropTypes.func,
launchNewMap: PropTypes.func launchNewMap: PropTypes.func,
} }
constructor(props) { constructor(props) {
super(props) super(props)
this.state = { this.state = {
infoBoxOpen: false,
filterBoxOpen: false, filterBoxOpen: false,
chatOpen: false chatOpen: false
} }
@ -34,7 +36,6 @@ class MapView extends Component {
endMap() { endMap() {
this.setState({ this.setState({
infoBoxOpen: false,
filterBoxOpen: false, filterBoxOpen: false,
chatOpen: false chatOpen: false
}) })
@ -61,8 +62,8 @@ class MapView extends Component {
} }
render = () => { render = () => {
const { map, mapIsStarred, currentUser, onOpen, onClose } = this.props const { map, mapIsStarred, currentUser, onOpen, onClose, toggleMapInfoBox, toggleFilterBox, infoBoxHtml } = this.props
const { infoBoxOpen, filterBoxOpen, chatOpen } = this.state const { filterBoxOpen, chatOpen } = this.state
const onChatOpen = () => { const onChatOpen = () => {
this.setState({chatOpen: true}) this.setState({chatOpen: true})
onOpen() onOpen()
@ -73,12 +74,16 @@ class MapView extends Component {
} }
// TODO: stop using {...this.props} and make explicit // TODO: stop using {...this.props} and make explicit
return <div className="mapWrapper"> return <div className="mapWrapper">
<MapButtons currentUser={currentUser} filterBoxOpen={filterBoxOpen} /> <MapButtons currentUser={currentUser} onFilterClick={toggleFilterBox} />
<DataVis /> <DataVis />
<TopicCard {...this.props} /> <TopicCard {...this.props} />
<MapChat {...this.props} onOpen={onChatOpen} onClose={onChatClose} chatOpen={chatOpen} /> <MapChat {...this.props} onOpen={onChatOpen} onClose={onChatClose} chatOpen={chatOpen} />
<MapControls /> <MapControls />
<InfoAndHelp infoBoxOpen={infoBoxOpen} mapIsStarred={mapIsStarred} currentUser={currentUser} map={map} /> <InfoAndHelp mapIsStarred={mapIsStarred}
currentUser={currentUser}
map={map}
onInfoClick={toggleMapInfoBox}
infoBoxHtml={infoBoxHtml} />
</div> </div>
} }
} }