Skip to content

Commit

Permalink
Make tabbed pages routable
Browse files Browse the repository at this point in the history
This adds the ability to route through tabbed page by their index,
i.e. 0 for the first tab and so on.

Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
  • Loading branch information
florian-h05 committed Jul 5, 2024
1 parent 2d935d6 commit 9066579
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 4 additions & 2 deletions bundles/org.openhab.ui/web/src/js/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ const UserProfilePage = () => import(/* webpackChunkName: "profile-page" */ '../

const SettingsMenuPage = () => import(/* webpackChunkName: "admin-base" */ '../pages/settings/menu/settings-menu.vue')
const ServiceSettingsPage = () => import(/* webpackChunkName: "admin-base" */ '../pages/settings/services/service-settings.vue')
const AddonsListPage = () => import(/* webpackChunkName: "admin-base" */ '@/pages/addons/addons-list.vue')
const AddonsAddPage = () => import(/* webpackChunkName: "admin-base" */ '@/pages/addons/addons-add.vue')
const AddonsConfigureBindingPage = () => import(/* webpackChunkName: "admin-base" */ '@/pages/addons/addon-config.vue')
const AddonsStorePage = () => import(/* webpackChunkName: "admin-base" */ '@/pages/addons/addons-store.vue')
const AddonDetailsPage = () => import(/* webpackChunkName: "admin-base" */ '@/pages/addons/addon-details.vue')
Expand Down Expand Up @@ -145,6 +143,10 @@ export default [
path: '/page/:uid',
component: PageViewPage
},
{
path: '/page/:uid/:initialTab',
component: PageViewPage
},
{
path: '/about/',
async: loadAsync(AboutPage),
Expand Down
14 changes: 12 additions & 2 deletions bundles/org.openhab.ui/web/src/pages/page/page-view.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,20 @@ export default {
'oh-plan-page': () => import(/* webpackChunkName: "plan-page" */ '@/components/widgets/plan/oh-plan-page.vue'),
'oh-chart-page': () => import(/* webpackChunkName: "chart-page" */ '@/components/widgets/chart/oh-chart-page.vue')
},
props: ['uid', 'deep', 'defineVars'],
props: ['uid', 'initialTab', 'deep', 'defineVars'],
data () {
return {
currentTab: 0,
currentTab: this.initialTab ? Number(this.initialTab) : 0,
fullscreen: this.$fullscreen.getState()
}
},
watch: {
pageType (newType, oldType) {
if (oldType === null && newType === 'tabs') {
this.onTabChange(this.currentTab)
}
}
},
computed: {
pageStyle () {
if (!this.context) return null
Expand Down Expand Up @@ -131,6 +138,9 @@ export default {
onTabChange (idx) {
this.currentTab = idx
this.$set(this, 'vars', {})
const url = '/page/' + this.uid + '/' + this.currentTab
this.$f7router.updateCurrentUrl(url)
this.$f7router.url = url
},
onCommand (itemName, command) {
this.$store.dispatch('sendCommand', { itemName, command })
Expand Down

0 comments on commit 9066579

Please sign in to comment.