From b2fef71b4779aaadbe662b606935a84a019700e3 Mon Sep 17 00:00:00 2001 From: ma0068 Date: Fri, 4 Apr 2025 09:53:54 +0200 Subject: [PATCH] added name attribute to components --- .../Messages/Details/Depr_NewMessage.js | 480 ------------------ .../Messages/Details/NewMessage/Modal.js | 1 + .../Messages/Details/NewMessage/NewDiv.js | 1 + .../Messages/Details/TableMessages.js | 3 +- public/js/components/Messages/Messages.js | 1 + .../Studentenverwaltung/Details/Messages.js | 1 + 6 files changed, 5 insertions(+), 482 deletions(-) delete mode 100644 public/js/components/Messages/Details/Depr_NewMessage.js diff --git a/public/js/components/Messages/Details/Depr_NewMessage.js b/public/js/components/Messages/Details/Depr_NewMessage.js deleted file mode 100644 index 33ff74d9c..000000000 --- a/public/js/components/Messages/Details/Depr_NewMessage.js +++ /dev/null @@ -1,480 +0,0 @@ -import FormForm from '../../Form/Form.js'; -import FormInput from '../../Form/Input.js'; -import ListBox from "../../../../../index.ci.php/public/js/components/primevue/listbox/listbox.esm.min.js"; -import DropdownComponent from '../../VorlagenDropdown/VorlagenDropdown.js'; -import MessageModal from "../Details/NewMessage/Modal.js"; - -export default { - components: { - FormForm, - FormInput, - ListBox, - DropdownComponent, - MessageModal, - }, - props: { - endpoint: { - type: String, - required: true - }, - typeId: String, - id: { - type: [Number, String], - required: true - }, - openMode: String, - }, - data(){ - return { - formData: { - recipient: this.id, - subject: null, - body: null, - vorlage_kurzbz: null, - selectedValue: '', - }, - statusNew: true, - vorlagen: [], - defaultRecipient: null, - editor: null, - isVisible: false, - fieldsUser: [], - fieldsPerson: [], - fieldsPrestudent: [], - selectedFieldPrestudent: null, - selectedFieldUser: null, - selectedFieldPerson: null, - itemsPrestudent: [], - itemsPerson: [], - itemsUser: [], - previewText: null, - previewBody: "" - } - }, - methods: { - initTinyMCE() { - const vm = this; - tinymce.init({ - target: this.$refs.editor.$refs.input, //Important: not selector: to enable multiple import of component - //height: 800, - //plugins: ['lists'], - toolbar: 'styleselect | bold italic underline | alignleft aligncenter alignright alignjustify', - style_formats: [ - {title: 'Blocks', block: 'div'}, - {title: 'Paragraph', block: 'p'}, - {title: 'Heading 1', block: 'h1'}, - {title: 'Heading 2', block: 'h2'}, - {title: 'Heading 3', block: 'h3'}, - {title: 'Heading 4', block: 'h4'}, - {title: 'Heading 5', block: 'h5'}, - {title: 'Heading 6', block: 'h6'}, - ], - autoresize_bottom_margin: 16, - - setup: (editor) => { - vm.editor = editor; - - editor.on('input', () => { - const newContent = editor.getContent(); - vm.formData.body = newContent; - }); - }, - }); - }, - updateText(value) { - this.formData.body = value; - }, - sendMessage() { - //TODO(Manu) check default recipient(s) - const data = new FormData(); - const params = { - id: this.id, - type_id: this.typeId - }; - const merged = { - ...this.formData, - ...params - }; - data.append('data', JSON.stringify(merged)); - - return this.$fhcApi.factory.messages.person.sendMessage( - this.$refs.formMessage, - this.id, - data) - .then(response => { - this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSent')); - //this.hideModal('messageModal'); - this.hideTemplate(); - this.resetForm(); - }).catch(this.$fhcAlert.handleSystemError) - .finally(() => { - //this.resetForm(); - //closeModal - //closewindwo - this.$emit('reloadTable'); - } - ); - }, - getVorlagentext(vorlage_kurzbz){ - //console.log(typeof vorlage_kurzbz); - return this.$fhcApi.factory.messages.person.getVorlagentext(vorlage_kurzbz) - .then(response => { - //this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSent')); - //this.hideModal('messageModal'); - //this.resetForm(); - //TODO(Manu) CHECK - this.formData.body = response.data; - }).catch(this.$fhcAlert.handleSystemError) - .finally(() => { - //this.resetForm(); - //closeModal - //closewindwo - }); - }, - getPreviewText(){ - const data = new FormData(); - - data.append('data', JSON.stringify(this.formData.body)); - return this.$fhcApi.factory.messages.person.getPreviewText({ - id: this.id, - type_id: this.typeId}, data) - .then(response => { - this.previewText = response.data; - }).catch(this.$fhcAlert.handleSystemError) - .finally(() => { - //this.resetForm(); - //closeModal - //closewindwo - }); - }, - insertVariable(selectedItem){ - if (this.editor) { - this.editor.insertContent(selectedItem.value + " "); - //TODO(Manu) check: nicht mal mit Punkt adden gehts ohne eintrag nach vars -/* this.editor.focus(); - this.editor.setDirty(true);*/ - - //this.editor.fire('change'); //forces - - //this.editor.undoManager.add(); - - //this.editor.insertContent(selectedItem.value + "\u00A0"); - //this.editor.insertContent(`${selectedItem.value} `); - //this.editor.selection.setCursorLocation(this.editor.getBody(), 1); - - } else { - console.error("Editor instance is not available."); - } - }, - replyMessage(message_id){ - console.log("auf message " + message_id + " antworten"); - }, - resetForm(){ - this.formData = { - vorlage_kurzbz: null, - body: null, - subject: null, - }; - if (this.editor) { - this.editor.setContent(""); - } - this.$refs.dropdownComp.setValue(null); - - }, -/* toggleDivNewMessage(){ - this.isVisible = !this.isVisible; - },*/ - handleSelectedVorlage(vorlage_kurzbz) { - if (typeof vorlage_kurzbz === "string") { - this.getVorlagentext(vorlage_kurzbz); - this.formData.subject = vorlage_kurzbz; - } - }, - hideTemplate(){ - if (this.openMode == "showDiv") - this.isVisible = false; - }, - showTemplate(id, typeId){ - if (this.openMode == "showDiv") - this.isVisible = true; - //just for testing: - this.isVisible = true; - }, - showPreview(){ - this.getPreviewText().then(() => { - this.previewBody = this.previewText; - }); - }, - }, - watch: { - 'formData.body': { - handler(newVal) { - const tinymcsVal = this.editor.getContent(); - - if (newVal && tinymcsVal != newVal) { - //Inhalt des Editors aktualisieren - this.editor.setContent(newVal); - } - } - }, - 'formData.vorlage_kurzbz': { - handler(newVal){ - // console.log("Vorlage: " + newVal); - - if (newVal && newVal != null) { - this.formData.subject = newVal; - return this.getVorlagentext(newVal); - } - } - } - }, - created(){ - if(this.typeId == 'person_id'){ - this.$fhcApi.factory.messages.person.getMessageVarsPerson() - .then(result => { - this.fieldsPerson = result.data; - this.itemsPerson = Object.entries(this.fieldsPerson).map(([key, value]) => ({ - label: value, - value: '{' + value + '}' - })); - }) - .catch(this.$fhcAlert.handleSystemError); - } - if(this.typeId == 'uid') { - this.$fhcApi.factory.messages.person.getMsgVarsPrestudent(this.id) - .then(result => { - this.fieldsPrestudent = result.data; - const prestudent = this.fieldsPrestudent[0]; - //Just for testing with inserting values -/* this.itemsPrestudent = Object.entries(prestudent).map(([key, value]) => ({ - label: key, - value: value - }));*/ - this.itemsPrestudent = Object.entries(prestudent).map(([key, value]) => ({ - label: key.toLowerCase(), - value: '{' + key.toLowerCase() + '}' - })); - }) - .catch(this.$fhcAlert.handleSystemError); - } - - this.$fhcApi.factory.messages.person.getMsgVarsLoggedInUser() - .then(result => { - this.fieldsUser = result.data; - const user = this.fieldsUser; - this.itemsUser = Object.entries(user).map(([key, value]) => ({ - label: value, - value: '{' + value + '}' - })); - }) - .catch(this.$fhcAlert.handleSystemError); - - this.$fhcApi.factory.messages.person.getNameOfDefaultRecipient({ - id: this.id, - type_id: this.typeId}) - .then(result => { - this.defaultRecipient = result.data; - }) - .catch(this.$fhcAlert.handleSystemError); - }, - async mounted() { - this.initTinyMCE(); - }, - beforeDestroy() { - this.editor.destroy(); - }, - template: ` -
- - - - - -
-
- -

New Message

- - -
-
- - - -
- - - -
- -
- - -
- - -
- - -
- -
- - -
- -
-
- -
-
- Felder Prestudent -
- - - - - -
- - -

{{selectedFieldPrestudent}}

- -
- -
- Felder Person -
- - - - - -
- -

{{selectedFieldPerson}}

-
- -
- Meine Felder -
- - - - - -
- -
- -
- - - - - -
- -
- -
- -
- -

Vorschau:

-
- - -
- - -
- -
-
- -
-
- -
-
-
-
-
- -
- -
- -
- -
- -
- ` - -} \ No newline at end of file diff --git a/public/js/components/Messages/Details/NewMessage/Modal.js b/public/js/components/Messages/Details/NewMessage/Modal.js index 03345e9d4..33698f1c8 100644 --- a/public/js/components/Messages/Details/NewMessage/Modal.js +++ b/public/js/components/Messages/Details/NewMessage/Modal.js @@ -5,6 +5,7 @@ import ListBox from "../../../../../../index.ci.php/public/js/components/primevu import DropdownComponent from "../../../VorlagenDropdown/VorlagenDropdown.js"; export default { + name: "ModalNewMessages", components: { BsModal, FormForm, diff --git a/public/js/components/Messages/Details/NewMessage/NewDiv.js b/public/js/components/Messages/Details/NewMessage/NewDiv.js index 4331dd734..d8db657df 100644 --- a/public/js/components/Messages/Details/NewMessage/NewDiv.js +++ b/public/js/components/Messages/Details/NewMessage/NewDiv.js @@ -4,6 +4,7 @@ import ListBox from "../../../../../../index.ci.php/public/js/components/primevu import DropdownComponent from '../../../VorlagenDropdown/VorlagenDropdown.js'; export default { + name: "ComponentNewMessages", components: { FormForm, FormInput, diff --git a/public/js/components/Messages/Details/TableMessages.js b/public/js/components/Messages/Details/TableMessages.js index 89a118fd1..9047d6726 100644 --- a/public/js/components/Messages/Details/TableMessages.js +++ b/public/js/components/Messages/Details/TableMessages.js @@ -1,12 +1,11 @@ import {CoreFilterCmpt} from "../../filter/Filter.js"; import FormForm from '../../Form/Form.js'; -//import NewMessage from "../Details/NewMessage.js"; export default { + name: "TableMessages", components: { CoreFilterCmpt, FormForm, - // NewMessage, }, inject: { cisRoot: { diff --git a/public/js/components/Messages/Messages.js b/public/js/components/Messages/Messages.js index 5aa7eb7de..337883be3 100644 --- a/public/js/components/Messages/Messages.js +++ b/public/js/components/Messages/Messages.js @@ -2,6 +2,7 @@ import TableMessages from "./Details/TableMessages.js"; import FormOnly from "./Details/NewMessage/NewDiv.js"; import MessageModal from "../Messages/Details/NewMessage/Modal.js"; export default { + name: "MessagesComponent", components: { TableMessages, FormOnly, diff --git a/public/js/components/Stv/Studentenverwaltung/Details/Messages.js b/public/js/components/Stv/Studentenverwaltung/Details/Messages.js index 4c1d9bd6b..0c46a6333 100644 --- a/public/js/components/Stv/Studentenverwaltung/Details/Messages.js +++ b/public/js/components/Stv/Studentenverwaltung/Details/Messages.js @@ -1,6 +1,7 @@ import CoreMessages from "../../../Messages/Messages.js"; export default { + name: "TabMessages", components: { CoreMessages },