Merge pull request #368 from nextcloud/fix/window_title

Update window title
This commit is contained in:
Jan-Christoph Borchardt 2020-05-09 18:37:46 +02:00 committed by GitHub
commit 8d1cd28156
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 2 deletions

View file

@ -0,0 +1,32 @@
/**
* @copyright Copyright (c) 2020 Jonas Rittershofer <jotoeri@users.noreply.github.com>
*
* @author Jonas Rittershofer <jotoeri@users.noreply.github.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export default {
methods: {
setWindowTitle(formTitle) {
if (formTitle === '') {
window.document.title = t('forms', 'Forms') + ' - ' + OC.theme.title
} else {
window.document.title = formTitle + ' - ' + t('forms', 'Forms') + ' - ' + OC.theme.title
}
},
},
}

View file

@ -136,6 +136,7 @@ import QuestionMultiple from '../components/Questions/QuestionMultiple'
import QuestionShort from '../components/Questions/QuestionShort'
import TopBar from '../components/TopBar'
import ViewsMixin from '../mixins/ViewsMixin'
import WindowTitleMixin from '../mixins/WindowTitleMixin'
window.axios = axios
@ -154,7 +155,7 @@ export default {
TopBar,
},
mixins: [ViewsMixin],
mixins: [ViewsMixin, WindowTitleMixin],
data() {
return {
@ -201,10 +202,16 @@ export default {
// TODO: cancel previous request if not done
this.fetchFullForm(this.form.id)
},
// Update Window-Title on title change
'form.title': function() {
this.setWindowTitle(this.form.title)
},
},
beforeMount() {
this.fetchFullForm(this.form.id)
this.setWindowTitle(this.form.title)
},
updated() {

View file

@ -96,6 +96,7 @@ import EmptyContent from '../components/EmptyContent'
import Submission from '../components/Results/Submission'
import TopBar from '../components/TopBar'
import ViewsMixin from '../mixins/ViewsMixin'
import WindowTitleMixin from '../mixins/WindowTitleMixin'
Vue.use(Clipboard)
@ -111,7 +112,7 @@ export default {
TopBar,
},
mixins: [ViewsMixin],
mixins: [ViewsMixin, WindowTitleMixin],
data() {
return {
@ -129,6 +130,7 @@ export default {
beforeMount() {
this.loadFormResults()
this.setWindowTitle(this.form.title)
},
methods: {

View file

@ -85,6 +85,7 @@ import Question from '../components/Questions/Question'
import QuestionLong from '../components/Questions/QuestionLong'
import QuestionShort from '../components/Questions/QuestionShort'
import QuestionMultiple from '../components/Questions/QuestionMultiple'
import WindowTitleMixin from '../mixins/WindowTitleMixin'
export default {
name: 'Submit',
@ -99,6 +100,8 @@ export default {
QuestionMultiple,
},
mixins: [WindowTitleMixin],
data() {
return {
form: loadState('forms', 'form'),
@ -137,6 +140,10 @@ export default {
},
},
beforeMount() {
this.setWindowTitle(this.form.title)
},
methods: {
/**
* Submit the form after the browser validated it 🚀