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) {
|
handleUpdate: function(location) {
|
||||||
const self = ReactApp
|
const self = ReactApp
|
||||||
|
const pathname = this.state.location.pathname
|
||||||
// TODO: also handle page title updates
|
// TODO: also handle page title updates
|
||||||
switch (this.state.location.pathname.split('/')[1]) {
|
switch (pathname.split('/')[1]) {
|
||||||
case '':
|
case '':
|
||||||
if (Active.Mapper) $('#yield').hide()
|
if (Active.Mapper) {
|
||||||
ExploreMaps.updateFromPath(this.state.location.pathname)
|
$('#yield').hide()
|
||||||
self.mapId = null
|
ExploreMaps.updateFromPath(pathname)
|
||||||
Active.Map = null
|
self.mapId = null
|
||||||
Active.Topic = null
|
Active.Map = null
|
||||||
|
Active.Topic = null
|
||||||
|
}
|
||||||
break
|
break
|
||||||
case 'explore':
|
case 'explore':
|
||||||
$('#yield').hide()
|
$('#yield').hide()
|
||||||
ExploreMaps.updateFromPath(this.state.location.pathname)
|
ExploreMaps.updateFromPath(pathname)
|
||||||
self.mapId = null
|
self.mapId = null
|
||||||
Active.Map = null
|
Active.Map = null
|
||||||
Active.Topic = null
|
Active.Topic = null
|
||||||
|
@ -64,8 +67,13 @@ const ReactApp = {
|
||||||
$('#yield').hide()
|
$('#yield').hide()
|
||||||
break
|
break
|
||||||
case 'maps':
|
case 'maps':
|
||||||
$('#yield').hide()
|
if (!pathname.includes('request_access')) {
|
||||||
self.mapId = this.state.location.pathname.split('/')[2]
|
$('#yield').hide()
|
||||||
|
self.mapId = pathname.split('/')[2]
|
||||||
|
}
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
$('#yield').show()
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
self.render()
|
self.render()
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/* global $, Hogan, Bloodhound, CanvasLoader */
|
/* global $, Hogan, Bloodhound, CanvasLoader */
|
||||||
|
|
||||||
|
import { browserHistory } from 'react-router'
|
||||||
|
|
||||||
import Active from '../Active'
|
import Active from '../Active'
|
||||||
|
|
||||||
const Search = {
|
const Search = {
|
||||||
|
@ -189,11 +191,11 @@ const Search = {
|
||||||
|
|
||||||
if (['topic', 'map', 'mapper'].indexOf(datum.rtype) !== -1) {
|
if (['topic', 'map', 'mapper'].indexOf(datum.rtype) !== -1) {
|
||||||
if (datum.rtype === 'topic') {
|
if (datum.rtype === 'topic') {
|
||||||
// TODO: navigate to topic datum.id
|
browserHistory.push(`/topics/${datum.id}`)
|
||||||
} else if (datum.rtype === 'map') {
|
} else if (datum.rtype === 'map') {
|
||||||
// TODO: navigate to map datum.id
|
browserHistory.push(`/maps/${datum.id}`)
|
||||||
} else if (datum.rtype === 'mapper') {
|
} 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 */
|
/* global $, Hogan, Bloodhound, Countable */
|
||||||
|
|
||||||
import outdent from 'outdent'
|
import outdent from 'outdent'
|
||||||
|
import { browserHistory } from 'react-router'
|
||||||
|
|
||||||
import Active from '../Active'
|
import Active from '../Active'
|
||||||
import DataModel from '../DataModel'
|
import DataModel from '../DataModel'
|
||||||
|
@ -376,7 +377,7 @@ const InfoBox = {
|
||||||
DataModel.Maps.Mine.remove(map)
|
DataModel.Maps.Mine.remove(map)
|
||||||
DataModel.Maps.Shared.remove(map)
|
DataModel.Maps.Shared.remove(map)
|
||||||
map.destroy()
|
map.destroy()
|
||||||
// TODO: navigate home
|
browserHistory.push('/')
|
||||||
GlobalUI.notifyUser('Map eliminated')
|
GlobalUI.notifyUser('Map eliminated')
|
||||||
} else if (!authorized) {
|
} 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?")
|
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 outdent from 'outdent'
|
||||||
import { find as _find } from 'lodash'
|
import { find as _find } from 'lodash'
|
||||||
|
import { browserHistory } from 'react-router'
|
||||||
|
|
||||||
import Active from '../Active'
|
import Active from '../Active'
|
||||||
import AutoLayout from '../AutoLayout'
|
import AutoLayout from '../AutoLayout'
|
||||||
|
@ -84,7 +85,6 @@ const Map = {
|
||||||
launch: function(id) {
|
launch: function(id) {
|
||||||
const self = Map
|
const self = Map
|
||||||
var start = function() {
|
var start = function() {
|
||||||
document.title = Active.Map.get('name') + ' | Metamaps'
|
|
||||||
Map.setAccessRequest()
|
Map.setAccessRequest()
|
||||||
$('#filter_by_mapper h3').html('MAPPERS') // TODO: rewrite filter box in react
|
$('#filter_by_mapper h3').html('MAPPERS') // TODO: rewrite filter box in react
|
||||||
Visualize.type = 'ForceDirected'
|
Visualize.type = 'ForceDirected'
|
||||||
|
@ -97,7 +97,9 @@ const Map = {
|
||||||
Filter.checkMappers()
|
Filter.checkMappers()
|
||||||
Realtime.startActiveMap()
|
Realtime.startActiveMap()
|
||||||
Loading.hide()
|
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() {
|
function isLoaded() {
|
||||||
if (InfoBox.generateBoxHTML) start()
|
if (InfoBox.generateBoxHTML) start()
|
||||||
|
@ -210,7 +212,7 @@ const Map = {
|
||||||
var map = Active.Map
|
var map = Active.Map
|
||||||
DataModel.Maps.Active.remove(map)
|
DataModel.Maps.Active.remove(map)
|
||||||
DataModel.Maps.Featured.remove(map)
|
DataModel.Maps.Featured.remove(map)
|
||||||
// TODO: navigate home
|
browserHistory.push('/')
|
||||||
GlobalUI.notifyUser('Sorry! That map has been changed to Private.')
|
GlobalUI.notifyUser('Sorry! That map has been changed to Private.')
|
||||||
},
|
},
|
||||||
cantEditNow: function() {
|
cantEditNow: function() {
|
||||||
|
@ -223,7 +225,7 @@ const Map = {
|
||||||
confirmString += 'Do you want to reload and enable realtime collaboration?'
|
confirmString += 'Do you want to reload and enable realtime collaboration?'
|
||||||
var c = window.confirm(confirmString)
|
var c = window.confirm(confirmString)
|
||||||
if (c) {
|
if (c) {
|
||||||
// TODO: reload the map somehow
|
window.location.reload()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
editedByActiveMapper: function() {
|
editedByActiveMapper: function() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue