diff --git a/public/js/api/factory/messages/messages.js b/public/js/api/factory/messages/messages.js new file mode 100644 index 000000000..8424e14f2 --- /dev/null +++ b/public/js/api/factory/messages/messages.js @@ -0,0 +1,112 @@ +/** + * Copyright (C) 2025 fhcomplete.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +export default { + //TODO(manu) check how to get params size and page + getMessages(params) { + console.log('page ' + params.page + ' size ' + params.size); + return { + method: 'get', + url: 'api/frontend/v1/messages/messages/getMessages/' + + params.id + '/' + + params.type + '/' + + params.size + '/' + + params.page + }; + }, + getVorlagen(){ + return { + method: 'get', + url: 'api/frontend/v1/messages/messages/getVorlagen/' + }; + }, + getMsgVarsLoggedInUser(){ + return { + method: 'get', + url: 'api/frontend/v1/messages/messages/getMsgVarsLoggedInUser/' + }; + }, + getMessageVarsPerson(userParams){ + return { + method: 'post', + url: 'api/frontend/v1/messages/messages/getMessageVarsPerson/' + userParams.id + '/' + userParams.type_id + }; + }, + getMsgVarsPrestudent(userParams){ + return { + method: 'post', + url: 'api/frontend/v1/messages/messages/getMsgVarsPrestudent/' + userParams.id + '/' + userParams.type_id + }; + }, + getPersonId(params){ + return { + method: 'post', + url: 'api/frontend/v1/messages/messages/getPersonId/' + params.id + '/' + params.type_id + }; + }, + getUid(userParams){ + return { + method: 'get', + url: 'api/frontend/v1/messages/messages/getUid/' + userParams.id + '/' + userParams.type_id + }; + }, + getVorlagentext(vorlage_kurzbz){ + return { + method: 'get', + url: 'api/frontend/v1/messages/messages/getVorlagentext/' + vorlage_kurzbz + }; + }, + getNameOfDefaultRecipient(params){ + return { + method: 'get', + url: 'api/frontend/v1/messages/messages/getNameOfDefaultRecipient/' + params.id + '/' + params.type_id + }; + }, + getPreviewText(userParams, params){ + return { + method: 'post', + url: 'api/frontend/v1/messages/messages/getPreviewText/' + userParams.id + '/' + userParams.type_id, + params + }; + }, + getReplyData(messageId){ + return { + method: 'get', + url: 'api/frontend/v1/messages/messages/getReplyData/' + messageId + }; + }, + sendMessageFromModalContext(id, params) { + return { + method: 'post', + url: 'api/frontend/v1/messages/messages/sendMessage/' + id, + params + }; + }, + sendMessage(id, params) { + return { + method: 'post', + url: 'api/frontend/v1/messages/messages/sendMessage/' + id, + params + }; + }, + deleteMessage(messageId){ + return { + method: 'post', + url: 'api/frontend/v1/messages/messages/deleteMessage/' + messageId + }; + } +} \ No newline at end of file diff --git a/public/js/api/messages/person.js b/public/js/api/messages/person.js index 9bfae6f38..f41050770 100644 --- a/public/js/api/messages/person.js +++ b/public/js/api/messages/person.js @@ -3,7 +3,7 @@ export default { console.log('page ' + params.page + ' size ' + params.size); return this.$fhcApi.get('api/frontend/v1/messages/messages/getMessages/' + params.id + '/' + params.type + '/' + params.size + '/' + params.page); }, - getVorlagen(){ +/* getVorlagen(){ return this.$fhcApi.get('api/frontend/v1/messages/messages/getVorlagen/'); }, getMsgVarsLoggedInUser(){ @@ -44,5 +44,5 @@ export default { }, deleteMessage(messageId){ return this.$fhcApi.post('api/frontend/v1/messages/messages/deleteMessage/' + messageId); - } + }*/ } \ 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 33698f1c8..5bbf29f16 100644 --- a/public/js/components/Messages/Details/NewMessage/Modal.js +++ b/public/js/components/Messages/Details/NewMessage/Modal.js @@ -4,6 +4,8 @@ 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 ApiMessages from '../../../../api/factory/messages/messages.js'; + export default { name: "ModalNewMessages", components: { @@ -104,10 +106,8 @@ export default { }; data.append('data', JSON.stringify(merged)); - return this.$fhcApi.factory.messages.person.sendMessageFromModalContext( - this.$refs.formMessage, - this.uid, - data) + return this.$refs.formMessage + .call(ApiMessages.sendMessageFromModalContext(this.uid, data)) .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSent')); this.hideModal('modalNewMessage'); @@ -122,7 +122,8 @@ export default { ); }, getVorlagentext(vorlage_kurzbz){ - return this.$fhcApi.factory.messages.person.getVorlagentext(vorlage_kurzbz) + return this.$api + .call(ApiMessages.getVorlagentext(vorlage_kurzbz)) .then(response => { this.formData.body = response.data; }).catch(this.$fhcAlert.handleSystemError) @@ -136,9 +137,10 @@ export default { 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) + return this.$api + .call(ApiMessages.getPreviewText({ + id: this.id, + type_id: this.typeId}, data)) .then(response => { this.previewText = response.data; }).catch(this.$fhcAlert.handleSystemError) @@ -200,7 +202,8 @@ export default { id: id, type_id: typeId }; - this.$fhcApi.factory.messages.person.getUid(params) + this.$api + .call(ApiMessages.getUid(params)) .then(result => { this.uid = result.data; }) @@ -238,9 +241,9 @@ export default { if (!newMessageId) return; try { - const result = await this.$fhcApi.factory.messages.person.getReplyData(newMessageId); + //const result = await this.$fhcApi.factory.messages.person.getReplyData(newMessageId); + const result = await this.$api.call(ApiMessages.getReplyData(newMessageId)); this.replyData = result.data; - console.log(this.replyData); if (this.replyData.length > 0) { this.formData.subject = this.replyData[0].replySubject; @@ -261,7 +264,9 @@ export default { id: this.id, type_id: this.typeId }; - this.$fhcApi.factory.messages.person.getMessageVarsPerson(params) + //this.$fhcApi.factory.messages.person.getMessageVarsPerson(params) + this.$api + .call(ApiMessages.getMessageVarsPerson(params)) .then(result => { this.fieldsPerson = result.data; const person = this.fieldsPerson[0]; @@ -278,7 +283,8 @@ export default { id: this.id, type_id: this.typeId }; - this.$fhcApi.factory.messages.person.getMsgVarsPrestudent(params) + this.$api + .call(ApiMessages.getMsgVarsPrestudent(params)) .then(result => { this.fieldsPrestudent = result.data; const prestudent = this.fieldsPrestudent[0]; @@ -290,7 +296,8 @@ export default { .catch(this.$fhcAlert.handleSystemError); } - this.$fhcApi.factory.messages.person.getMsgVarsLoggedInUser() + this.$api + .call(ApiMessages.getMsgVarsLoggedInUser()) .then(result => { this.fieldsUser = result.data; const user = this.fieldsUser; @@ -301,9 +308,10 @@ export default { }) .catch(this.$fhcAlert.handleSystemError); - this.$fhcApi.factory.messages.person.getNameOfDefaultRecipient({ - id: this.id, - type_id: this.typeId}) + this.$api + .call(ApiMessages.getNameOfDefaultRecipient({ + id: this.id, + type_id: this.typeId})) .then(result => { this.defaultRecipient = result.data; this.recipientsArray.push({ @@ -314,7 +322,8 @@ export default { //case of reply if(this.messageId) { - this.$fhcApi.factory.messages.person.getReplyData(this.messageId) + this.$api + .call(ApiMessages.getReplyData(this.messageId)) .then(result => { this.replyData = result.data; this.formData.subject = this.replyData[0].replySubject; @@ -380,7 +389,7 @@ export default { :label="$p.t('global','nachricht') + ' *'" type="textarea" v-model="formData.body" - name="text" + name="body" rows="15" cols="75" > diff --git a/public/js/components/Messages/Details/NewMessage/NewDiv.js b/public/js/components/Messages/Details/NewMessage/NewDiv.js index d8db657df..11335ed2a 100644 --- a/public/js/components/Messages/Details/NewMessage/NewDiv.js +++ b/public/js/components/Messages/Details/NewMessage/NewDiv.js @@ -2,6 +2,7 @@ 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 ApiMessages from "../../../../api/factory/messages/messages"; export default { name: "ComponentNewMessages", @@ -119,9 +120,11 @@ export default { data.append('data', JSON.stringify(merged)); //this.uid is necessary for existing sendFunction - return this.$fhcApi.factory.messages.person.sendMessage( +/* return this.$fhcApi.factory.messages.person.sendMessage( this.uid, - data) + data)*/ + return this.$api + .call(ApiMessages.sendMessage(this.uid, data)) .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSent')); this.hideTemplate(); @@ -140,7 +143,9 @@ export default { ); }, getVorlagentext(vorlage_kurzbz){ - return this.$fhcApi.factory.messages.person.getVorlagentext(vorlage_kurzbz) + // return this.$fhcApi.factory.messages.person.getVorlagentext(vorlage_kurzbz) + return this.$api + .call(ApiMessages.getVorlagentext(vorlage_kurzbz)) .then(response => { this.formData.body = response.data; }).catch(this.$fhcAlert.handleSystemError) @@ -152,9 +157,13 @@ export default { const data = new FormData(); data.append('data', JSON.stringify(this.formData.body)); - return this.$fhcApi.factory.messages.person.getPreviewText({ +/* return this.$fhcApi.factory.messages.person.getPreviewText({ id: id, - type_id: typeId}, data) + type_id: typeId}, data)*/ + return this.$api + .call(ApiMessages.getPreviewText({ + id: this.id, + type_id: this.typeId}, data)) .then(response => { this.previewText = response.data; }).catch(this.$fhcAlert.handleSystemError) @@ -226,7 +235,8 @@ export default { id: id, type_id: typeId }; - this.$fhcApi.factory.messages.person.getUid(params) + this.$api + .call(ApiMessages.getUid(params)) .then(result => { this.uid = result.data; }) @@ -262,7 +272,9 @@ export default { id: this.id, type_id: this.typeId }; - this.$fhcApi.factory.messages.person.getMessageVarsPerson(params) + // this.$fhcApi.factory.messages.person.getMessageVarsPerson(params) + this.$api + .call(ApiMessages.getMessageVarsPerson(params)) .then(result => { this.fieldsPerson = result.data; const person = this.fieldsPerson[0]; @@ -279,7 +291,9 @@ export default { id: this.id, type_id: this.typeId }; - this.$fhcApi.factory.messages.person.getMsgVarsPrestudent(params) + //this.$fhcApi.factory.messages.person.getMsgVarsPrestudent(params) + this.$api + .call(ApiMessages.getMsgVarsPrestudent(params)) .then(result => { this.fieldsPrestudent = result.data; const prestudent = this.fieldsPrestudent[0]; @@ -292,7 +306,8 @@ export default { .catch(this.$fhcAlert.handleSystemError); } - this.$fhcApi.factory.messages.person.getMsgVarsLoggedInUser() + this.$api + .call(ApiMessages.getMsgVarsLoggedInUser()) .then(result => { this.fieldsUser = result.data; const user = this.fieldsUser; @@ -303,10 +318,11 @@ export default { }) .catch(this.$fhcAlert.handleSystemError); - this.$fhcApi.factory.messages.person.getNameOfDefaultRecipient({ - id: this.id, - type_id: this.typeId - }).then(result => { + this.$api + .call(ApiMessages.getNameOfDefaultRecipient({ + id: this.id, + type_id: this.typeId})) + .then(result => { this.defaultRecipient = result.data; this.recipientsArray.push({ 'uid': this.uid, @@ -316,7 +332,8 @@ export default { //case of reply if(this.messageId != null) { - this.$fhcApi.factory.messages.person.getReplyData(this.messageId) + this.$api + .call(ApiMessages.getReplyData(this.messageId)) .then(result => { this.replyData = result.data; this.formData.subject = this.replyData[0].replySubject; diff --git a/public/js/components/Messages/Details/TableMessages.js b/public/js/components/Messages/Details/TableMessages.js index 9047d6726..07fdd8f20 100644 --- a/public/js/components/Messages/Details/TableMessages.js +++ b/public/js/components/Messages/Details/TableMessages.js @@ -1,6 +1,8 @@ import {CoreFilterCmpt} from "../../filter/Filter.js"; import FormForm from '../../Form/Form.js'; +import ApiMessages from '../../../api/factory/messages/messages.js'; + export default { name: "TableMessages", components: { @@ -27,8 +29,20 @@ export default { }, data(){ return { +/* paginationSize: 15, + paginationInitialPage: 1,*/ tabulatorOptions: { ajaxURL: 'dummy', + //TODO(Manu) how to handle size and page? +/* ajaxRequestFunc: () => this.$api.call( + ApiMessages.getMessages({ + id: this.id, + type: this.typeId, + size: this.paginationSize, + page: this.paginationInitialPage + }) + ),*/ + //OLD WORKING VERSION ajaxRequestFunc: this.$fhcApi.factory.messages.person.getMessages, ajaxParams: () => { return { @@ -36,6 +50,7 @@ export default { type: this.typeId }; }, + ajaxResponse: (url, params, response) => this.buildTreemap(response), //ajaxResponse: (url, params, response) => this.buildTreemap(response.data), columns: [ @@ -222,7 +237,8 @@ export default { .catch(this.$fhcAlert.handleSystemError); }, deleteMessage(message_id){ - return this.$fhcApi.factory.messages.person.deleteMessage(message_id) + return this.$api + .call(ApiMessages.deleteMessage(message_id)) .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete')); }).catch(this.$fhcAlert.handleSystemError) @@ -276,13 +292,11 @@ export default { } }); - // to avoid endless loop - if (iteration > messages.length) break; - } - return {data: messageNested, last_page}; -} - - + // to avoid endless loop + if (iteration > messages.length) break; + } + return {data: messageNested, last_page}; + } }, computed: { statusText(){ @@ -310,11 +324,12 @@ export default { id: this.id, type_id: this.typeId }; - this.$fhcApi.factory.messages.person.getPersonId(params) - .then(result => { - this.personId = result.data; - }) - .catch(this.$fhcAlert.handleSystemError); + this.$api + .call(ApiMessages.getPersonId(params)) + .then(result => { + this.personId = result.data; + }) + .catch(this.$fhcAlert.handleSystemError); } }, template: ` @@ -353,7 +368,6 @@ export default { -