diff --git a/application/controllers/api/frontend/v1/stv/Config.php b/application/controllers/api/frontend/v1/stv/Config.php index 4d3a5f8ee..ad6f50c72 100644 --- a/application/controllers/api/frontend/v1/stv/Config.php +++ b/application/controllers/api/frontend/v1/stv/Config.php @@ -64,6 +64,7 @@ class Config extends FHCAPI_Controller $config = []; + #number_displayed_past_studiensemester $result = $this->VariableModel->getVariables(getAuthUID(), ['number_displayed_past_studiensemester']); $data = $this->getDataOrTerminateWithError($result); @@ -76,6 +77,21 @@ class Config extends FHCAPI_Controller ?? $number_displayed_past_studiensemester_default ]; + #font_size + $result = $this->VariableModel->getVariables(getAuthUID(), ['stv_font_size']); + $data = $this->getDataOrTerminateWithError($result); + $config['font_size'] = [ + "type" => "select", + "label" => "Font size", + "value" => $data['stv_font_size'] ?? "fs_normal", + "options" => [ + "fs_small" => "klein",// TODO(chris): phrase + "fs_normal" => "normal",// TODO(chris): phrase + "fs_big" => "groß",// TODO(chris): phrase + "fs_huge" => "sehr groß"// TODO(chris): phrase + ] + ]; + // TODO(chris): Event $this->terminateWithSuccess($config); @@ -86,7 +102,6 @@ class Config extends FHCAPI_Controller */ public function set() { - // TODO(chris): rewrite to batch saving $this->load->model('system/Variable_model', 'VariableModel'); $this->load->library('form_validation'); @@ -95,6 +110,11 @@ class Config extends FHCAPI_Controller "Anzahl angezeigter vergangender Studiensemester",// TODO(chris): phrase 'required|integer' ); + $this->form_validation->set_rules( + 'font_size', + "Font size",// TODO(chris): phrase + 'required|in_list[fs_small,fs_normal,fs_big,fs_huge]' + ); // TODO(chris): Event @@ -107,6 +127,11 @@ class Config extends FHCAPI_Controller 'number_displayed_past_studiensemester', $this->input->post('number_displayed_past_studiensemester') ); + $this->VariableModel->setVariable( + getAuthUID(), + 'stv_font_size', + $this->input->post('font_size') + ); // TODO(chris): Event diff --git a/public/css/Studentenverwaltung.css b/public/css/Studentenverwaltung.css index d92e3dfac..a91b10bd7 100644 --- a/public/css/Studentenverwaltung.css +++ b/public/css/Studentenverwaltung.css @@ -9,6 +9,18 @@ html { font-size: .875em; } +html.fs_small { + font-size: .5em; +} +html.fs_normal { + font-size: .875em; +} +html.fs_big { + font-size: 1em; +} +html.fs_huge { + font-size: 1.4em; +} .navbar-dark .navbar-brand:focus { box-shadow: 0 0 0 .25rem rgba(13,110,253,.25); diff --git a/public/js/components/Stv/Studentenverwaltung.js b/public/js/components/Stv/Studentenverwaltung.js index 9db3f9e7b..b98f5cb50 100644 --- a/public/js/components/Stv/Studentenverwaltung.js +++ b/public/js/components/Stv/Studentenverwaltung.js @@ -152,6 +152,22 @@ export default { }, 'url_mode': function () { this.handlePersonUrl(); + }, + 'appconfig.font_size'() { + // add to html class + const classList = Object.keys(this.$refs.config.setup.font_size.options); + classList.forEach(cn => document.documentElement.classList.remove(cn)); + document.documentElement.classList.add(this.appconfig.font_size); + // recalc Tabulator heights + if (this.$el) { + const tabulatorEls = this.$el.querySelectorAll('.tabulator'); + for (const el of tabulatorEls) { + const tabulators = Tabulator.findTable(el); + if (tabulators) { + tabulators[0].searchRows().forEach(row => row.normalizeHeight()); + } + } + } } }, methods: { @@ -430,6 +446,6 @@ export default { - + ` }; diff --git a/public/js/components/Stv/Studentenverwaltung/Config.js b/public/js/components/Stv/Studentenverwaltung/Config.js index f7a6363cd..7c89fc3ea 100644 --- a/public/js/components/Stv/Studentenverwaltung/Config.js +++ b/public/js/components/Stv/Studentenverwaltung/Config.js @@ -60,10 +60,15 @@ export default { .then(res => { this.setup = {}; Object.keys(res.data).forEach(key => { - const conf = { ...res.data[key] }; - this.tempValues[key] = conf.value; - delete conf.value; - this.setup[key] = conf; + const binding = { ...res.data[key] }; + delete binding.value; + delete binding.options; + const options = res.data[key].options; + this.tempValues[key] = res.data[key].value; + this.setup[key] = { + binding, + options + }; }); this.$emit('update:modelValue', { ...this.tempValues }); }) @@ -80,11 +85,19 @@ export default { >