Skip to content

Commit

Permalink
Fix navigation issues with model cards
Browse files Browse the repository at this point in the history
Fixes openhab#2196.
Reverts openhab#2074.

I have tried messing around with the browser history manually to fix that issue, however trying several approaches, none worked perfect.
This is the best solution I could come up with, it at least remembers which tab you had opened when you navigate back to the home page from any other page.

Signed-off-by: Florian Hotze <[email protected]>
  • Loading branch information
florian-h05 committed Dec 10, 2023
1 parent 4fd7c8c commit 95dc62f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export default {
setTimeout(() => { this.$f7.card.close(this.$refs.card.$el) }, 100)
},
back (evt) {
console.debug(evt.state)
if (!evt.state || evt.state.cardId === this.cardId) return
if (this.opened) this.closeCard()
}
Expand Down
40 changes: 1 addition & 39 deletions bundles/org.openhab.ui/web/src/js/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,45 +92,7 @@ export default [
// keepAlive: true,
options: {
transition: 'f7-dive'
},
routes: [
{
path: 'overview',
component: HomePage,
options: {
props: {
initialTab: 'overview'
}
}
},
{
path: 'locations',
component: HomePage,
options: {
props: {
initialTab: 'locations'
}
}
},
{
path: 'equipment',
component: HomePage,
options: {
props: {
initialTab: 'equipment'
}
}
},
{
path: 'properties',
component: HomePage,
options: {
props: {
initialTab: 'properties'
}
}
}
]
}
},
{
path: '/page/:uid',
Expand Down
7 changes: 3 additions & 4 deletions bundles/org.openhab.ui/web/src/pages/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ import ModelTab from './home/model-tab.vue'
import HomeCards from './home/homecards-mixin'
export default {
props: ['initialTab'],
mixins: [HomeCards],
components: {
OverviewTab,
Expand All @@ -101,7 +100,7 @@ export default {
showCards: false,
showPinToHome: false,
showExitToApp: false,
currentTab: this.initialTab || 'overview',
currentTab: this.$f7.data.currentHomeTab || 'overview',
overviewPageKey: this.$utils.id(),
items: []
}
Expand Down Expand Up @@ -165,7 +164,7 @@ export default {
},
methods: {
onPageBeforeIn () {
this.$f7router.updateCurrentUrl('/' + this.currentTab)
this.$f7.data.currentHomeTab = this.currentTab
this.overviewPageKey = this.$utils.id()
},
onPageAfterIn () {
Expand All @@ -176,6 +175,7 @@ export default {
},
onPageBeforeOut () {
this.$store.dispatch('stopTrackingStates')
this.$f7.data.currentHomeTab = this.currentTab
},
onPageInit () {
this.$store.subscribe((mutation, state) => {
Expand All @@ -197,7 +197,6 @@ export default {
},
switchTab (tab) {
this.currentTab = tab
this.$f7router.updateCurrentUrl('/' + this.currentTab)
},
tabVisible (tab) {
if (!this.tabsVisible) return false
Expand Down

0 comments on commit 95dc62f

Please sign in to comment.