From b26f61b9a32c1888cfd6328814b4508203a0feb5 Mon Sep 17 00:00:00 2001 From: Luka Trovic Date: Tue, 28 Dec 2021 17:36:35 +0100 Subject: [PATCH] show board name in browser title Signed-off-by: Luka Trovic --- src/components/Controls.vue | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/components/Controls.vue b/src/components/Controls.vue index 63bd11d6a..e3795e44c 100644 --- a/src/components/Controls.vue +++ b/src/components/Controls.vue @@ -239,6 +239,7 @@ export default { isAddStackVisible: false, filter: { tags: [], users: [], due: '', unassigned: false }, showAddCardModal: false, + defaultPageTitle: false, } }, @@ -266,11 +267,17 @@ export default { return [...this.board.labels].sort((a, b) => (a.title < b.title) ? -1 : 1) }, }, + beforeDestroy() { + this.setPageTitle('') + }, watch: { board(current, previous) { if (current?.id !== previous?.id) { this.clearFilter() } + if (current) { + this.setPageTitle(current.title) + } }, }, methods: { @@ -330,6 +337,22 @@ export default { clickHideAddCardModel() { 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 + }, }, }