added set language feature; phrasen plugin with optional reload if non responsive phrasen are used; stundenplan header mode & buttons reworked

This commit is contained in:
Johann Hoffmann
2024-10-24 17:46:42 +02:00
parent 805ed20a18
commit e387671e09
20 changed files with 166 additions and 42 deletions
+16 -2
View File
@@ -2,6 +2,7 @@ import FhcApi from './FhcApi.js';
const categories = Vue.reactive({});
const loadingModules = {};
let reload = false;
function extractCategory(obj, category) {
return obj.filter(e => e.category == category).reduce((res, elem) => {
@@ -19,8 +20,19 @@ function getValueForLoadedPhrase(category, phrase, params) {
return result;
}
const phrasen = {
setLanguage(language, api) {
const catArray = Object.keys(categories)
return api.factory.phrasen.setLanguage(catArray, language).then(res => {
if(reload) window.location.reload()
res.data.forEach(row => {
categories[row.category][row.phrase] = row.text
})
return res
})
},
loadCategory(category) {
if (Array.isArray(category))
return Promise.all(category.map(this.config.globalProperties
@@ -63,12 +75,14 @@ const phrasen = {
export default {
install(app, options) {
reload = options?.reload ?? reload
app.use(FhcApi, options?.fhcApi || undefined);
app.config.globalProperties.$p = {
t: phrasen.t,
loadCategory: cat => phrasen.loadCategory.call(app, cat),
setLanguage: phrasen.setLanguage,
t_ref: phrasen.t_ref
};
app.provide('$p', app.config.globalProperties.$p);
}
}
}