1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-03-28 18:15:09 +00:00

Enable language detection for public form views

This commit is contained in:
Alexander Haller 2022-08-27 12:30:07 +00:00 committed by Bram Wiepjes
parent 8adf694c11
commit 16844a85af
4 changed files with 23 additions and 12 deletions
changelog.md
web-frontend/modules

View file

@ -14,7 +14,7 @@ For example:
* Add `isort` settings to sort python imports.
* Add row url parameter to `gallery` and `kanban` view.
* Only allow relative urls in the in the original query parameter.
* Infer user language when viewing a public view. [#834](https://gitlab.com/bramw/baserow/-/issues/834)
* Force browser language when viewing a public view. [#834](https://gitlab.com/bramw/baserow/-/issues/834)
* Search automatically after 400ms when chosing a related field via the modal. [#1091](https://gitlab.com/bramw/baserow/-/issues/1091)
### Bug Fixes

View file

@ -0,0 +1,18 @@
/**
* This mixin forces language detection based on the browser settings instead of the
* language stored in the nuxt-i18n cookie.
*/
export default {
data() {
return {
originalLanguageBeforeDetect: null,
}
},
created() {
this.originalLanguageBeforeDetect = this.$i18n.locale
this.$i18n.locale = this.$i18n.getBrowserLocale()
},
beforeDestroy() {
this.$i18n.locale = this.originalLanguageBeforeDetect
},
}

View file

@ -22,9 +22,11 @@ import ViewService from '@baserow/modules/database/services/view'
import { PUBLIC_PLACEHOLDER_ENTITY_ID } from '@baserow/modules/database/utils/constants'
import { DatabaseApplicationType } from '@baserow/modules/database/applicationTypes'
import { mapGetters } from 'vuex'
import languageDetection from '@baserow/modules/core/mixins/languageDetection'
export default {
components: { Table, Notifications },
mixins: [languageDetection],
async asyncData({ store, params, error, app, redirect, route }) {
const slug = params.slug
@ -93,21 +95,12 @@ export default {
}
}
},
data() {
return {
originalLangugaeBeforeDetect: null,
}
},
computed: {
...mapGetters({
fields: 'field/getAll',
view: 'view/getSelected',
}),
},
created() {
this.originalLangugaeBeforeDetect = this.$i18n.locale
this.$i18n.locale = this.$i18n.getBrowserLocale()
},
mounted() {
if (!this.$env.DISABLE_ANONYMOUS_PUBLIC_VIEW_WS_CONNECTIONS) {
this.$realtime.connect(true, true)
@ -117,7 +110,6 @@ export default {
}
},
beforeDestroy() {
this.$i18n.locale = this.originalLangugaeBeforeDetect
if (!this.$env.DISABLE_ANONYMOUS_PUBLIC_VIEW_WS_CONNECTIONS) {
this.$realtime.subscribe(null)
this.$realtime.disconnect()

View file

@ -46,10 +46,11 @@ import FormViewPoweredBy from '@baserow/modules/database/components/view/form/Fo
import { required } from 'vuelidate/lib/validators'
import { mapActions } from 'vuex'
import { isRelativeUrl } from '@baserow/modules/core/utils/url'
import languageDetection from '@baserow/modules/core/mixins/languageDetection'
export default {
components: { FormViewPoweredBy },
mixins: [form, error],
mixins: [form, error, languageDetection],
layout: 'login',
data() {
return {