show board name in browser title

Signed-off-by: Luka Trovic <luka@nextcloud.com>
This commit is contained in:
Luka Trovic
2021-12-28 17:36:35 +01:00
parent bf7203210c
commit b26f61b9a3

View File

@@ -239,6 +239,7 @@ export default {
isAddStackVisible: false, isAddStackVisible: false,
filter: { tags: [], users: [], due: '', unassigned: false }, filter: { tags: [], users: [], due: '', unassigned: false },
showAddCardModal: false, showAddCardModal: false,
defaultPageTitle: false,
} }
}, },
@@ -266,11 +267,17 @@ export default {
return [...this.board.labels].sort((a, b) => (a.title < b.title) ? -1 : 1) return [...this.board.labels].sort((a, b) => (a.title < b.title) ? -1 : 1)
}, },
}, },
beforeDestroy() {
this.setPageTitle('')
},
watch: { watch: {
board(current, previous) { board(current, previous) {
if (current?.id !== previous?.id) { if (current?.id !== previous?.id) {
this.clearFilter() this.clearFilter()
} }
if (current) {
this.setPageTitle(current.title)
}
}, },
}, },
methods: { methods: {
@@ -330,6 +337,22 @@ export default {
clickHideAddCardModel() { clickHideAddCardModel() {
this.showAddCardModal = false this.showAddCardModal = false
}, },
setPageTitle(title) {
if (this.defaultPageTitle === false) {
this.defaultPageTitle = window.document.title
if (this.defaultPageTitle.indexOf(' - Deck - ') !== -1) {
this.defaultPageTitle = this.defaultPageTitle.substring(this.defaultPageTitle.indexOf(' - Deck - ') + 3)
}
if (this.defaultPageTitle.indexOf('Deck - ') !== 0) {
this.defaultPageTitle = 'Deck - ' + this.defaultPageTitle
}
}
let newTitle = this.defaultPageTitle
if (title !== '') {
newTitle = `${title} - ${newTitle}`
}
window.document.title = newTitle
},
}, },
} }
</script> </script>