From 1ddf5a8370ba5f76786d9fd30bce18b4f56042f9 Mon Sep 17 00:00:00 2001 From: ma0068 Date: Tue, 6 Feb 2024 08:08:17 +0100 Subject: [PATCH] Notizcomponent: Tinymce optional --- .../controllers/components/stv/Notiz.php | 8 +- public/js/components/Notiz/NotizComponent.js | 81 ++++++++++--------- .../Studentenverwaltung/Details/Notizen.js | 19 ++--- 3 files changed, 55 insertions(+), 53 deletions(-) diff --git a/application/controllers/components/stv/Notiz.php b/application/controllers/components/stv/Notiz.php index ddf10b8a9..4918e6627 100644 --- a/application/controllers/components/stv/Notiz.php +++ b/application/controllers/components/stv/Notiz.php @@ -224,8 +224,8 @@ class Notiz extends FHC_Controller $bearbeiter_uid = isset($_POST['bearbeiter']) ? $_POST['bearbeiter'] : $uid; $erledigt = $this->input->post('erledigt'); //$type = $this->input->post('typeId'); //soll auch dieser geändert werden können? - $start = $this->input->post('Von'); - $ende = $this->input->post('Bis'); + $start = $this->input->post('von'); + $ende = $this->input->post('bis'); $result = $this->NotizModel->update( [ @@ -443,7 +443,7 @@ class Notiz extends FHC_Controller public function titel_required($value) { if (empty($value)) { - $this->form_validation->set_message('titel_required', $this->p->t('ui','error_fieldRequired',['field' => 'Titel'])); + $this->form_validation->set_message('titel_required', $this->p->t('ui', 'error_fieldRequired', ['field' => 'Titel'])); return false; } else @@ -455,7 +455,7 @@ class Notiz extends FHC_Controller public function text_required($value) { if (empty($value)) { - $this->form_validation->set_message('text_required', $this->p->t('ui','error_fieldRequired',['field' => 'Text'])); + $this->form_validation->set_message('text_required', $this->p->t('ui', 'error_fieldRequired', ['field' => 'Text'])); return false; } else diff --git a/public/js/components/Notiz/NotizComponent.js b/public/js/components/Notiz/NotizComponent.js index 0d6dbae69..dd0abab23 100644 --- a/public/js/components/Notiz/NotizComponent.js +++ b/public/js/components/Notiz/NotizComponent.js @@ -18,7 +18,8 @@ export default { 'typeId', 'id', 'showErweitert', - 'showDocument' + 'showDocument', + 'showTinyMCE' ], data(){ return { @@ -45,7 +46,9 @@ export default { let button = document.createElement('button'); button.className = 'btn btn-outline-secondary btn-action'; button.innerHTML = ''; - button.addEventListener('click', (event) => + button.addEventListener( + 'click', + (event) => this.actionEditNotiz(cell.getData().notiz_id) ); container.append(button); @@ -53,7 +56,9 @@ export default { button = document.createElement('button'); button.className = 'btn btn-outline-secondary btn-action'; button.innerHTML = ''; - button.addEventListener('click', () => + button.addEventListener( + 'click', + () => this.actionDeleteNotiz(cell.getData().notiz_id) ); container.append(button); @@ -61,8 +66,7 @@ export default { return container; }, frozen: true - } - ], + }], layout: 'fitDataFill', layoutColumnsOnNewData: false, height: '150', @@ -109,14 +113,15 @@ export default { this.notizData.titel = this.notizen.titel; this.notizData.statusNew = false; this.notizData.text = this.notizen.text; + this.notizData.intText = this.notizen.text; this.notizData.lastChange = this.notizen.lastupdate; this.notizData.von = this.notizen.start; this.notizData.bis = this.notizen.ende; this.notizData.document = this.notizen.dms_id; this.notizData.erledigt = this.notizen.erledigt; - this.notizData.verfasser = this.notizen.verfasser_uid; //todo(manu) better + this.notizData.verfasser = this.notizen.verfasser_uid; this.notizData.intVerfasser = this.notizen.verfasser_uid; - this.notizData.intBearbeiter = this.notizen.bearbeiter_uid; //todo(manu) better + this.notizData.intBearbeiter = this.notizen.bearbeiter_uid; this.notizData.bearbeiter = this.notizen.bearbeiter_uid; } }) @@ -170,19 +175,17 @@ export default { this.$fhcAlert.alertError('Keine Notiz mit Id ' + notiz_id + ' gefunden'); } }).catch(error => { - this.$fhcAlert.alertError('Fehler bei Löschroutine aufgetreten'); - }).finally(()=> { - window.scrollTo(0, 0); - }); + this.$fhcAlert.alertError('Fehler bei Löschroutine aufgetreten'); + }).finally(()=> { + window.scrollTo(0, 0); + }); }, loadNotiz(notiz_id){ - return CoreRESTClient.get( - 'components/stv/Notiz/loadNotiz/' + notiz_id) + return CoreRESTClient.get('components/stv/Notiz/loadNotiz/' + notiz_id) .then( result => { if(result.data.retval) { this.notizen = result.data.retval; - //console.log(this.notizen); } else { this.notizen = {}; @@ -273,7 +276,7 @@ export default { this.filteredMitarbeiter = CoreRESTClient.getData(result.data); }); }, -/* initTinyMCE() { + initTinyMCE() { const vm = this; tinymce.init({ @@ -299,16 +302,22 @@ export default { editor.on('input', () => { const newContent = editor.getContent(); - vm.intText = newContent; + vm.notizData.text = newContent; + //vm.text = newContent; + console.log('vm.text: ' + newContent); }); }, }); - },*/ + }, + updateText(value) { + this.notizData.text = value; + } }, created(){ this.getUid(); }, async mounted() { + this.initTinyMCE(); await this.$p.loadCategory(['notiz','global']); let cm = this.$refs.table.tabulator.columnManager; @@ -341,11 +350,9 @@ export default { title: this.$p.t('notiz', 'letzte_aenderung') }); }, -/* mounted() { - this.initTinyMCE(); - },*/ -/* watch: { - intText: function(newVal) { + watch: { + //watcher für Tinymce-Textfeld + 'notizData.text': function (newVal) { const tinymcsVal = this.editor.getContent(); if (tinymcsVal != newVal) { @@ -353,11 +360,6 @@ export default { this.editor.setContent(newVal); } }, - },*/ - beforeDestroy() { - this.editor.destroy(); - }, - watch: { //Watcher für autocomplete Bearbeiter und Verfasser 'notizData.intBearbeiter': { handler(newVal) { @@ -376,6 +378,9 @@ export default { deep: true } }, + beforeDestroy() { + this.editor.destroy(); + }, template: `
@@ -431,14 +436,18 @@ export default {
- - - -
+ +
@@ -470,7 +479,7 @@ export default {
-
+
diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js b/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js index 498096ad3..6281401df 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Notizen.js @@ -9,8 +9,10 @@ export default { }, data(){ return { - showErweitert: true, //show details verfasser, bearbeiter, von, bis, erledigt +/* showErweitert: true, //show details verfasser, bearbeiter, von, bis, erledigt showDocument: true, //show upload documents + showTinyMCE: true + */ }; }, template: ` @@ -22,7 +24,8 @@ export default { :id="modelValue.person_id" :showErweitert=true :showDocument=true - > + :showTinyMCE=true + >

@@ -33,19 +36,9 @@ export default { :id="modelValue.prestudent_id" :showErweitert=false :showDocument=true - > + > -

-

Test Projekt

- -
` };