Skip to content
Snippets Groups Projects
Commit 7c8cd1a5 authored by esikkala's avatar esikkala
Browse files

InstanceHomePage: handle back button

parent b68a1856
No related branches found
No related tags found
No related merge requests found
......@@ -55,6 +55,11 @@ class InstanceHomePage extends React.Component {
if (!this.hasTableData() && prevPathname !== currentPathname && currentPathname.endsWith('table')) {
this.fetchTableData()
}
// handle browser's back button
const localID = this.getLocalIDFromURL()
if (this.state.localID !== localID) {
this.fetchTableData()
}
}
hasTableData = () => {
......@@ -64,16 +69,10 @@ class InstanceHomePage extends React.Component {
fetchTableData = () => {
const { perspectiveConfig } = this.props
const localID = this.getLocalIDFromURL()
this.setState({ localID })
let uri = ''
const base = 'http://ldf.fi/mmm'
const locationArr = this.props.routeProps.location.pathname.split('/')
let localID = locationArr.pop()
perspectiveConfig.instancePageTabs.map(tab => {
if (localID === tab.id) {
localID = locationArr.pop() // pop again if tab id
}
})
this.setState({ localID: localID })
const resultClass = perspectiveConfig.id
switch (resultClass) {
case 'perspective1':
......@@ -127,6 +126,17 @@ class InstanceHomePage extends React.Component {
})
}
getLocalIDFromURL = () => {
const locationArr = this.props.routeProps.location.pathname.split('/')
let localID = locationArr.pop()
this.props.perspectiveConfig.instancePageTabs.map(tab => {
if (localID === tab.id) {
localID = locationArr.pop() // pop again if tab id
}
})
return localID
}
getVisibleRows = rows => {
const { instanceTableData } = this.props.perspectiveState
const visibleRows = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment