fix up navigation to use react-router
This commit is contained in:
parent
8010e7d497
commit
4c1646fdef
4 changed files with 30 additions and 17 deletions
|
@ -44,18 +44,21 @@ const ReactApp = {
|
|||
},
|
||||
handleUpdate: function(location) {
|
||||
const self = ReactApp
|
||||
const pathname = this.state.location.pathname
|
||||
// TODO: also handle page title updates
|
||||
switch (this.state.location.pathname.split('/')[1]) {
|
||||
switch (pathname.split('/')[1]) {
|
||||
case '':
|
||||
if (Active.Mapper) $('#yield').hide()
|
||||
ExploreMaps.updateFromPath(this.state.location.pathname)
|
||||
if (Active.Mapper) {
|
||||
$('#yield').hide()
|
||||
ExploreMaps.updateFromPath(pathname)
|
||||
self.mapId = null
|
||||
Active.Map = null
|
||||
Active.Topic = null
|
||||
}
|
||||
break
|
||||
case 'explore':
|
||||
$('#yield').hide()
|
||||
ExploreMaps.updateFromPath(this.state.location.pathname)
|
||||
ExploreMaps.updateFromPath(pathname)
|
||||
self.mapId = null
|
||||
Active.Map = null
|
||||
Active.Topic = null
|
||||
|
@ -64,8 +67,13 @@ const ReactApp = {
|
|||
$('#yield').hide()
|
||||
break
|
||||
case 'maps':
|
||||
if (!pathname.includes('request_access')) {
|
||||
$('#yield').hide()
|
||||
self.mapId = this.state.location.pathname.split('/')[2]
|
||||
self.mapId = pathname.split('/')[2]
|
||||
}
|
||||
break
|
||||
default:
|
||||
$('#yield').show()
|
||||
break
|
||||
}
|
||||
self.render()
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
/* global $, Hogan, Bloodhound, CanvasLoader */
|
||||
|
||||
import { browserHistory } from 'react-router'
|
||||
|
||||
import Active from '../Active'
|
||||
|
||||
const Search = {
|
||||
|
@ -189,11 +191,11 @@ const Search = {
|
|||
|
||||
if (['topic', 'map', 'mapper'].indexOf(datum.rtype) !== -1) {
|
||||
if (datum.rtype === 'topic') {
|
||||
// TODO: navigate to topic datum.id
|
||||
browserHistory.push(`/topics/${datum.id}`)
|
||||
} else if (datum.rtype === 'map') {
|
||||
// TODO: navigate to map datum.id
|
||||
browserHistory.push(`/maps/${datum.id}`)
|
||||
} else if (datum.rtype === 'mapper') {
|
||||
// TODO: navigate to mapper section datum.id
|
||||
browserHistory.push(`/explore/mapper/${datum.id}`)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* global $, Hogan, Bloodhound, Countable */
|
||||
|
||||
import outdent from 'outdent'
|
||||
import { browserHistory } from 'react-router'
|
||||
|
||||
import Active from '../Active'
|
||||
import DataModel from '../DataModel'
|
||||
|
@ -376,7 +377,7 @@ const InfoBox = {
|
|||
DataModel.Maps.Mine.remove(map)
|
||||
DataModel.Maps.Shared.remove(map)
|
||||
map.destroy()
|
||||
// TODO: navigate home
|
||||
browserHistory.push('/')
|
||||
GlobalUI.notifyUser('Map eliminated')
|
||||
} else if (!authorized) {
|
||||
window.alert("Hey now. We can't just go around willy nilly deleting other people's maps now can we? Run off and find something constructive to do, eh?")
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import outdent from 'outdent'
|
||||
import { find as _find } from 'lodash'
|
||||
import { browserHistory } from 'react-router'
|
||||
|
||||
import Active from '../Active'
|
||||
import AutoLayout from '../AutoLayout'
|
||||
|
@ -84,7 +85,6 @@ const Map = {
|
|||
launch: function(id) {
|
||||
const self = Map
|
||||
var start = function() {
|
||||
document.title = Active.Map.get('name') + ' | Metamaps'
|
||||
Map.setAccessRequest()
|
||||
$('#filter_by_mapper h3').html('MAPPERS') // TODO: rewrite filter box in react
|
||||
Visualize.type = 'ForceDirected'
|
||||
|
@ -97,7 +97,9 @@ const Map = {
|
|||
Filter.checkMappers()
|
||||
Realtime.startActiveMap()
|
||||
Loading.hide()
|
||||
$('#header_content').html(Active.Map.get('name')) // TODO: make this use ReactApp.mobileTitle to set this
|
||||
document.title = Active.Map.get('name') + ' | Metamaps'
|
||||
ReactApp.mobileTitle = Active.Map.get('name')
|
||||
ReactApp.render()
|
||||
}
|
||||
function isLoaded() {
|
||||
if (InfoBox.generateBoxHTML) start()
|
||||
|
@ -210,7 +212,7 @@ const Map = {
|
|||
var map = Active.Map
|
||||
DataModel.Maps.Active.remove(map)
|
||||
DataModel.Maps.Featured.remove(map)
|
||||
// TODO: navigate home
|
||||
browserHistory.push('/')
|
||||
GlobalUI.notifyUser('Sorry! That map has been changed to Private.')
|
||||
},
|
||||
cantEditNow: function() {
|
||||
|
@ -223,7 +225,7 @@ const Map = {
|
|||
confirmString += 'Do you want to reload and enable realtime collaboration?'
|
||||
var c = window.confirm(confirmString)
|
||||
if (c) {
|
||||
// TODO: reload the map somehow
|
||||
window.location.reload()
|
||||
}
|
||||
},
|
||||
editedByActiveMapper: function() {
|
||||
|
|
Loading…
Add table
Reference in a new issue