Skip to content

Commit

Permalink
fix: Update browser page title depending on current view/table (#668)
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr authored Nov 13, 2023
1 parent 0578b37 commit 0e207b8
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default {
data() {
return {
loading: false,
defaultPageTitle: false,
}
},
computed: {
Expand Down Expand Up @@ -60,10 +61,29 @@ export default {
}
if (currentRoute.path.startsWith('/table/')) {
this.$store.commit('setActiveTableId', parseInt(currentRoute.params.tableId))
this.setPageTitle(this.$store.getters.activeTable.title)
} else if (currentRoute.path.startsWith('/view/')) {
this.$store.commit('setActiveViewId', parseInt(currentRoute.params.viewId))
this.setPageTitle(this.$store.getters.activeView.title)
}
},
setPageTitle(title) {
if (this.defaultPageTitle === false) {
const appTitle = t('tables', 'Tables')
this.defaultPageTitle = window.document.title
if (this.defaultPageTitle.indexOf(` - ${appTitle} - `) !== -1) {
this.defaultPageTitle = this.defaultPageTitle.substring(this.defaultPageTitle.indexOf(` - ${appTitle} - `) + 3)
}
if (this.defaultPageTitle.indexOf(`${appTitle} - `) !== 0) {
this.defaultPageTitle = `${appTitle} - ` + this.defaultPageTitle
}
}
let newTitle = this.defaultPageTitle
if (title !== '') {
newTitle = `${title} - ${newTitle}`
}
window.document.title = newTitle
},
},
}
</script>
Expand Down

0 comments on commit 0e207b8

Please sign in to comment.