diff --git a/application/controllers/api/frontend/v1/stv/Config.php b/application/controllers/api/frontend/v1/stv/Config.php index 935928c81..2fb436384 100644 --- a/application/controllers/api/frontend/v1/stv/Config.php +++ b/application/controllers/api/frontend/v1/stv/Config.php @@ -63,12 +63,12 @@ class Config extends FHCAPI_Controller 'config' => $config['details'] ]; - $showSuffix = $config['notes']['showCountNotes'] ?? false; $result['notes'] = [ 'title' => $this->p->t('stv', 'tab_notes'), 'component' => './Stv/Studentenverwaltung/Details/Notizen.js', 'config' => $config['notes'], - 'showSuffix' => $showSuffix && ($config['notes']['showCountNotes'] ?? false) + 'showSuffix' => ($config['notes']['showCountNotes'] ?? false), + 'suffixhelper' => APP_ROOT . 'public/js/helpers/Stv/Studentenverwaltung/Details/Notizen/NotizenSuffixHelper.js' ]; $result['contact'] = [ diff --git a/public/js/components/Notiz/Notiz.js b/public/js/components/Notiz/Notiz.js index ab4230681..58168fbc7 100644 --- a/public/js/components/Notiz/Notiz.js +++ b/public/js/components/Notiz/Notiz.js @@ -295,8 +295,7 @@ export default { showType_id: false, showId: false, showLastupdate: false - }, - newCount: null + } } }, methods: { @@ -368,7 +367,6 @@ export default { .catch(this.$fhcAlert.handleSystemError) .finally(() => { window.scrollTo(0, 0); - this.getCountNotes(); }); }, deleteNotiz(notiz_id) { @@ -383,7 +381,6 @@ export default { .catch(this.$fhcAlert.handleSystemError) .finally(() => { window.scrollTo(0, 0); - this.getCountNotes(); }); }, loadNotiz(notiz_id) { @@ -427,7 +424,6 @@ export default { .catch(this.$fhcAlert.handleSystemError) .finally(() => { window.scrollTo(0, 0); - this.getCountNotes(); }); }, reload() { @@ -505,18 +501,6 @@ export default { const columnToShow = "show" + column.charAt(0).toUpperCase() + column.slice(1); this.showVariables[columnToShow] = true; }); - }, - getCountNotes(){ - return this.$api - .call(this.endpoint.getCountNotes(this.id)) - .then( - result => { - this.newCount = result.data; - this.$nextTick(() => { - this.$emit('updateCount', this.newCount); - }); - }) - .catch(this.$fhcAlert.handleSystemError); } }, created() { @@ -527,9 +511,6 @@ export default { if (this.showTinyMce) { await this.initTinyMCE(); } - this.$nextTick(() => { - this.getCountNotes(); - }); }, watch: { //watcher für Tinymce-Textfeld diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js b/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js index 6d7033012..ea6776dce 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js @@ -16,12 +16,6 @@ export default { countNotiz: '' }; }, - methods: { - updateCountNotes(countNew){ - this.headerSuffix = "(" + countNew + ")"; - this.$emit('update:suffix', this.headerSuffix); - } - }, template: `
@@ -37,7 +31,7 @@ export default { show-document show-tiny-mce :visibleColumns="['titel','text','verfasser','bearbeiter','dokumente']" - @updateCount="updateCountNotes" + @reload="$emit('update:suffix')" > diff --git a/public/js/components/Tabs.js b/public/js/components/Tabs.js index 349fcf01c..aedd5c1c9 100644 --- a/public/js/components/Tabs.js +++ b/public/js/components/Tabs.js @@ -14,7 +14,7 @@ export default { emits: [ 'update:modelValue', 'change', - 'changed', + 'changed' ], props: { config: { @@ -67,9 +67,9 @@ export default { } }, methods: { - handleTabClick: function(index) { + handleTabClick: function (e) { let keys = Object.keys(this.tabs); - this.change(keys[index]); + this.change(keys[e.index]); }, change(key) { this.$emit("change", key) @@ -108,7 +108,8 @@ export default { title: Vue.computed(() => item.title || key), config: item.config, key, - value + value, + suffixhelper: item.suffixhelper ?? null }; } @@ -125,15 +126,35 @@ export default { } this.tabs = tabs; }, - updateSuffix(event) { - if (this.currentTab?.value) { - this.currentTab.value.suffix = event; + updateSuffix() { + this.getTabSuffix(this.currentTab); + }, + async getTabSuffix(tab) { + if (!tab.value.showSuffix) { + return; } + + if (tab.suffixhelper !== null) { + const suffixhelper = await import(tab.suffixhelper); + const suffix = await suffixhelper.getSuffix(this.$api, this.modelValue); + tab.value.suffix = suffix; + } else { + tab.value.suffix = ''; + } + }, + getTabSuffixes() { + Object.entries(this.tabs).forEach(([key, item]) => this.getTabSuffix(item)); } }, created() { this.initConfig(this.config); }, + mounted() { + this.getTabSuffixes(); + }, + updated() { + this.getTabSuffixes(); + }, template: `