From b2d8b81ab5e5c25d96b46be6d0d42069dbde4be4 Mon Sep 17 00:00:00 2001 From: ma0068 Date: Thu, 7 Aug 2025 15:30:04 +0200 Subject: [PATCH] Changes for Tab Notes - change layout to classicFas to enable input note with one click less - extend Tab component: add headerSuffix - show count of messages in header --- application/config/stv.php | 4 ++ .../api/frontend/v1/stv/Config.php | 7 +- application/core/Notiz_Controller.php | 17 +++++ public/js/api/factory/notiz/person.js | 6 ++ public/js/components/Notiz/Notiz.js | 33 ++++++++-- .../Studentenverwaltung/Details/Notizen.js | 39 ++++++----- public/js/components/Tabs.js | 66 +++++++++++++------ 7 files changed, 128 insertions(+), 44 deletions(-) diff --git a/application/config/stv.php b/application/config/stv.php index 1fdd5b28a..30181d651 100644 --- a/application/config/stv.php +++ b/application/config/stv.php @@ -57,6 +57,10 @@ $config['tabs'] = //if true, Anrechnungen can be added and edited in tab Anrechnungen 'editableAnrechnungen' => false, ], + 'notes' => [ + //if true, the count of Messages will be shown in the header of the Tab Messages + 'showCountNotes' => true + ] ]; // List of fields to show when ZGV_DOKTOR_ANZEIGEN is defined diff --git a/application/controllers/api/frontend/v1/stv/Config.php b/application/controllers/api/frontend/v1/stv/Config.php index adf9f729e..935928c81 100644 --- a/application/controllers/api/frontend/v1/stv/Config.php +++ b/application/controllers/api/frontend/v1/stv/Config.php @@ -62,10 +62,15 @@ class Config extends FHCAPI_Controller 'component' => './Stv/Studentenverwaltung/Details/Details.js', 'config' => $config['details'] ]; + + $showSuffix = $config['notes']['showCountNotes'] ?? false; $result['notes'] = [ 'title' => $this->p->t('stv', 'tab_notes'), - 'component' => './Stv/Studentenverwaltung/Details/Notizen.js' + 'component' => './Stv/Studentenverwaltung/Details/Notizen.js', + 'config' => $config['notes'], + 'showSuffix' => $showSuffix && ($config['notes']['showCountNotes'] ?? false) ]; + $result['contact'] = [ 'title' => $this->p->t('stv', 'tab_contact'), 'component' => './Stv/Studentenverwaltung/Details/Kontakt.js', diff --git a/application/core/Notiz_Controller.php b/application/core/Notiz_Controller.php index 472ac7669..c2bb03267 100644 --- a/application/core/Notiz_Controller.php +++ b/application/core/Notiz_Controller.php @@ -21,6 +21,7 @@ abstract class Notiz_Controller extends FHCAPI_Controller 'loadDokumente' => self::DEFAULT_PERMISSION_R, 'getMitarbeiter' => self::DEFAULT_PERMISSION_R, 'isBerechtigt' => self::DEFAULT_PERMISSION_R, + 'getCountNotes' => self::DEFAULT_PERMISSION_R, ]; if(!is_array($permissions)) @@ -459,4 +460,20 @@ abstract class Notiz_Controller extends FHCAPI_Controller return $this->terminateWithSuccess($result); } + public function getCountNotes($person_id) + { + $this->NotizzuordnungModel->addSelect('COUNT(*) AS anzahl', false); + + $result = $this->NotizzuordnungModel->loadWhere( + array('person_id' => $person_id) + ); + + if (isError($result)) { + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + + $anzahl = current(getData($result)); + return $this->terminateWithSuccess($anzahl->anzahl ?: 0); + } + } \ No newline at end of file diff --git a/public/js/api/factory/notiz/person.js b/public/js/api/factory/notiz/person.js index 33b572d1a..c75e79acf 100644 --- a/public/js/api/factory/notiz/person.js +++ b/public/js/api/factory/notiz/person.js @@ -83,5 +83,11 @@ export default { method: 'get', url: 'api/frontend/v1/notiz/notizPerson/isBerechtigt/' }; + }, + getCountNotes(person_id){ + return { + method: 'get', + url: 'api/frontend/v1/notiz/notizPerson/getCountNotes/' + person_id + }; } }; diff --git a/public/js/components/Notiz/Notiz.js b/public/js/components/Notiz/Notiz.js index 5a3944803..ab4230681 100644 --- a/public/js/components/Notiz/Notiz.js +++ b/public/js/components/Notiz/Notiz.js @@ -296,6 +296,7 @@ export default { showId: false, showLastupdate: false }, + newCount: null } }, methods: { @@ -367,6 +368,7 @@ export default { .catch(this.$fhcAlert.handleSystemError) .finally(() => { window.scrollTo(0, 0); + this.getCountNotes(); }); }, deleteNotiz(notiz_id) { @@ -381,6 +383,7 @@ export default { .catch(this.$fhcAlert.handleSystemError) .finally(() => { window.scrollTo(0, 0); + this.getCountNotes(); }); }, loadNotiz(notiz_id) { @@ -424,6 +427,7 @@ export default { .catch(this.$fhcAlert.handleSystemError) .finally(() => { window.scrollTo(0, 0); + this.getCountNotes(); }); }, reload() { @@ -464,7 +468,6 @@ export default { }); }, initTinyMCE() { - const vm = this; tinymce.init({ target: this.$refs.editor.$refs.input, //Important: not selector: to enable multiple import of component @@ -503,15 +506,30 @@ export default { 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() { this.initializeShowVariables(); this.getUid(); }, async mounted() { - if(this.showTinyMce){ - this.initTinyMCE(); + if (this.showTinyMce) { + await this.initTinyMCE(); } + this.$nextTick(() => { + this.getCountNotes(); + }); }, watch: { //watcher für Tinymce-Textfeld @@ -548,16 +566,17 @@ export default { this.reload(); } }, - beforeDestroy() { - if(this.showTinyMce) { - this.editor.destroy(); + beforeUnmount() { + if (this.editor && tinymce.get(this.editor.id)) { + tinymce.get(this.editor.id).remove(); + this.editor = null; } }, template: `
- + - - - - + + + + +