From 1361ea41deeaf40644b42ecdef955706caf8dce4 Mon Sep 17 00:00:00 2001 From: hay-kot Date: Wed, 21 Apr 2021 11:32:53 -0800 Subject: [PATCH] fix langauge assignment 1st pass --- dev/scripts/publish-release-branch.sh | 11 +++++ frontend/src/api/siteSettings.js | 4 +- .../Admin/General/HomePageSettings.vue | 40 +++++++++---------- frontend/src/components/UI/LanguageMenu.vue | 8 +--- frontend/src/store/modules/language.js | 24 ----------- frontend/src/store/modules/siteSettings.js | 15 ++++++- frontend/src/store/modules/userSettings.js | 2 +- 7 files changed, 48 insertions(+), 56 deletions(-) create mode 100644 dev/scripts/publish-release-branch.sh diff --git a/dev/scripts/publish-release-branch.sh b/dev/scripts/publish-release-branch.sh new file mode 100644 index 000000000..22bd2aa8e --- /dev/null +++ b/dev/scripts/publish-release-branch.sh @@ -0,0 +1,11 @@ +git checkout dev +git merge --strategy=ours master # keep the content of this branch, but record a merge +git checkout master +git merge dev # fast-forward master up to the merge + + +## TODOs + +# Create New Branch v0.x.x +# Push Branch Version to Github +# Create Pull Request \ No newline at end of file diff --git a/frontend/src/api/siteSettings.js b/frontend/src/api/siteSettings.js index d110d1c51..1b511e8b3 100644 --- a/frontend/src/api/siteSettings.js +++ b/frontend/src/api/siteSettings.js @@ -1,5 +1,6 @@ import { baseURL } from "./api-utils"; import { apiReq } from "./api-utils"; +import { store } from "@/store"; const settingsBase = baseURL + "site-settings"; @@ -11,7 +12,7 @@ const settingsURLs = { customPage: id => `${settingsBase}/custom-pages/${id}`, }; -export const siteSettingsAPI = { +export const siteSettingsAPI = { async get() { let response = await apiReq.get(settingsURLs.siteSettings); return response.data; @@ -19,6 +20,7 @@ export const siteSettingsAPI = { async update(body) { let response = await apiReq.put(settingsURLs.updateSiteSettings, body); + store.dispatch("requestSiteSettings"); return response.data; }, diff --git a/frontend/src/components/Admin/General/HomePageSettings.vue b/frontend/src/components/Admin/General/HomePageSettings.vue index 58eb945af..be38947f1 100644 --- a/frontend/src/components/Admin/General/HomePageSettings.vue +++ b/frontend/src/components/Admin/General/HomePageSettings.vue @@ -117,21 +117,21 @@ -

{{$t('settings.locale-settings')}}

+

{{ $t("settings.locale-settings") }}

+ dense + prepend-icon="mdi-calendar-week-begin" + v-model="settings.firstDayOfWeek" + :items="allDays" + item-text="name" + item-value="value" + :label="$t('settings.first-day-of-week')" + />
@@ -178,33 +178,33 @@ export default { allDays() { return [ { - name: this.$t('general.sunday'), + name: this.$t("general.sunday"), value: 0, }, { - name: this.$t('general.monday'), + name: this.$t("general.monday"), value: 1, }, { - name: this.$t('general.tuesday'), + name: this.$t("general.tuesday"), value: 2, }, { - name: this.$t('general.wednesday'), + name: this.$t("general.wednesday"), value: 3, }, { - name: this.$t('general.thursday'), + name: this.$t("general.thursday"), value: 4, }, { - name: this.$t('general.friday'), + name: this.$t("general.friday"), value: 5, }, { - name: this.$t('general.saturday'), + name: this.$t("general.saturday"), value: 6, - } + }, ]; }, }, @@ -223,10 +223,8 @@ export default { this.settings.categories.splice(index, 1); }, async saveSettings() { - await api.siteSettings.update(this.settings); - this.$store.dispatch("setLang", { - currentVueComponent: this, - language: this.settings.language }); + const newSettings = await api.siteSettings.update(this.settings); + console.log("New Settings", newSettings); this.getOptions(); }, }, diff --git a/frontend/src/components/UI/LanguageMenu.vue b/frontend/src/components/UI/LanguageMenu.vue index 4be3a31dd..180ef4bf1 100644 --- a/frontend/src/components/UI/LanguageMenu.vue +++ b/frontend/src/components/UI/LanguageMenu.vue @@ -69,13 +69,7 @@ export default { methods: { setLanguage(selectedLanguage) { - if (this.siteSettings) { - this.$emit(SELECT_EVENT, selectedLanguage); - } else { - this.$store.dispatch("setLang", { - currentVueComponent: this, - language: selectedLanguage }); - } + this.$emit(SELECT_EVENT, selectedLanguage); }, }, }; diff --git a/frontend/src/store/modules/language.js b/frontend/src/store/modules/language.js index 431070a8e..02a52c353 100644 --- a/frontend/src/store/modules/language.js +++ b/frontend/src/store/modules/language.js @@ -1,5 +1,3 @@ -import VueI18n from "../../i18n"; - const state = { lang: "en-US", allLangs: [ @@ -42,33 +40,11 @@ const state = { ], }; -const mutations = { - setLang(state, payload) { - VueI18n.locale = payload; - state.lang = payload; - }, -}; - -const actions = { - initLang({ getters }, { currentVueComponent }) { - VueI18n.locale = getters.getActiveLang; - currentVueComponent.$vuetify.lang.current = getters.getActiveLang; - }, - setLang({ commit }, { language, currentVueComponent }) { - VueI18n.locale = language; - currentVueComponent.$vuetify.lang.current = language; - commit('setLang', language); - }, -}; - const getters = { - getActiveLang: state => state.lang, getAllLangs: state => state.allLangs, }; export default { state, - mutations, - actions, getters, }; diff --git a/frontend/src/store/modules/siteSettings.js b/frontend/src/store/modules/siteSettings.js index 9b526275a..716afffac 100644 --- a/frontend/src/store/modules/siteSettings.js +++ b/frontend/src/store/modules/siteSettings.js @@ -1,4 +1,6 @@ import { api } from "@/api"; +import VueI18n from "@/i18n"; +import Vuetify from "@/plugins/vuetify"; const state = { siteSettings: { @@ -13,17 +15,26 @@ const state = { const mutations = { setSettings(state, payload) { state.siteSettings = payload; + VueI18n.locale = payload.language; + Vuetify.framework.lang.current = payload.language; }, }; const actions = { - async requestSiteSettings() { + async requestSiteSettings({ commit }) { let settings = await api.siteSettings.get(); - this.commit("setSettings", settings); + commit("setSettings", settings); + }, + async initLang({ getters, commit }) { + // !Can Porbably Remove This? + await actions.requestSiteSettings({ commit }); + VueI18n.locale = getters.getActiveLang; + Vuetify.framework.lang.current = getters.getActiveLang; }, }; const getters = { + getActiveLang: state => state.siteSettings.language, getSiteSettings: state => state.siteSettings, }; diff --git a/frontend/src/store/modules/userSettings.js b/frontend/src/store/modules/userSettings.js index 7c01b12e1..b608e2cf3 100644 --- a/frontend/src/store/modules/userSettings.js +++ b/frontend/src/store/modules/userSettings.js @@ -1,5 +1,5 @@ import { api } from "@/api"; -import Vuetify from "../../plugins/vuetify"; +import Vuetify from "@/plugins/vuetify"; import axios from "axios"; function inDarkMode(payload) {