Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh(Contexts): set active navigation entry #1037

Merged
merged 1 commit into from
May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,15 @@ export default {
if (currentRoute.path.startsWith('/table/')) {
this.$store.commit('setActiveTableId', parseInt(currentRoute.params.tableId))
this.setPageTitle(this.$store.getters.activeTable.title)
this.switchActiveMenuEntry(document.querySelector('header .header-left .app-menu li[data-app-id="tables"]'))
} else if (currentRoute.path.startsWith('/view/')) {
this.$store.commit('setActiveViewId', parseInt(currentRoute.params.viewId))
this.setPageTitle(this.$store.getters.activeView.title)
this.switchActiveMenuEntry(document.querySelector('header .header-left .app-menu li[data-app-id="tables"]'))
} else if (currentRoute.path.startsWith('/application/')) {
this.$store.commit('setActiveContextId', parseInt(currentRoute.params.contextId))
this.setPageTitle(this.$store.getters.activeContext.name)
this.switchActiveMenuEntry(document.querySelector('header .header-left .app-menu li[data-app-id="tables_application_' + currentRoute.params.contextId + '"]'))

// move the focus away from nav bar (import for app-internal switch)
const appContent = document.getElementById('app-content-vue')
Expand All @@ -82,6 +85,11 @@ export default {
appContent.tabIndex = oldTabIndex
}
},
switchActiveMenuEntry(targetElement) {
const currentlyActive = document.querySelector('header .header-left .app-menu li.app-menu-entry__active')
currentlyActive.classList.remove('app-menu-entry__active')
targetElement.classList.add('app-menu-entry__active')
},
setPageTitle(title) {
if (this.defaultPageTitle === false) {
const appTitle = t('tables', 'Tables')
Expand Down
Loading