From afb3ce4cae98d7b325659d653d2355d4b01e0377 Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Tue, 2 Dec 2025 07:54:13 +0100 Subject: [PATCH] modify using open mode newTab or window with multiple Recipients via post request --- application/controllers/NeueNachricht.php | 9 ++- .../api/frontend/v1/messages/Messages.php | 10 +++ application/views/Nachrichten.php | 4 ++ public/js/apps/Nachrichten.js | 7 ++- .../Messages/Details/NewMessage/NewDiv.js | 39 +++++++----- public/js/components/Messages/Messages.js | 61 +++++++++++++------ 6 files changed, 93 insertions(+), 37 deletions(-) diff --git a/application/controllers/NeueNachricht.php b/application/controllers/NeueNachricht.php index 9b61b78ef..b0ff5c554 100644 --- a/application/controllers/NeueNachricht.php +++ b/application/controllers/NeueNachricht.php @@ -20,11 +20,18 @@ class NeueNachricht extends Auth_Controller */ public function _remap() { + $typeid = $this->input->post('typeid'); + $ids = ($this->input->post('ids') && strpos($this->input->post('ids'), ',')) + ? explode(',', $this->input->post('ids')) + : $this->input->post('ids'); + //now working $this->load->view('Nachrichten', [ 'permissions' => [ 'assistenz_schreibrechte' => $this->permissionlib->isBerechtigt('assistenz','suid'), - ] + ], + 'ids' => $ids, + 'typeid' => $typeid ]); } } diff --git a/application/controllers/api/frontend/v1/messages/Messages.php b/application/controllers/api/frontend/v1/messages/Messages.php index b3cb31bb6..714492203 100644 --- a/application/controllers/api/frontend/v1/messages/Messages.php +++ b/application/controllers/api/frontend/v1/messages/Messages.php @@ -122,6 +122,9 @@ class Messages extends FHCAPI_Controller public function getMsgVarsPrestudent($typeId) { $ids = $this->input->post('ids'); + if(!is_array($ids)) { + $ids = array($ids); + } $messageVarsPrestudent = []; if($typeId == 'uid') @@ -169,6 +172,9 @@ class Messages extends FHCAPI_Controller public function getNameOfDefaultRecipients($type_id) { $ids = $this->input->post('ids'); + if(!is_array($ids)) { + $ids = array($ids); + } $recipients = []; if (empty($ids)) { @@ -301,6 +307,10 @@ class Messages extends FHCAPI_Controller if (isset($_POST['ids'])) { $ids = json_decode($_POST['ids']); + if(!is_array($ids)) + { + $ids = array($ids); + } unset($_POST['ids']); } else diff --git a/application/views/Nachrichten.php b/application/views/Nachrichten.php index cf34bfd53..0d0e8e707 100644 --- a/application/views/Nachrichten.php +++ b/application/views/Nachrichten.php @@ -40,6 +40,10 @@ $configArray = [ cis-root="" :permissions="" :config="" + + :id ="" + type-id ="" + > diff --git a/public/js/apps/Nachrichten.js b/public/js/apps/Nachrichten.js index 84b9ddee5..ab9baf084 100644 --- a/public/js/apps/Nachrichten.js +++ b/public/js/apps/Nachrichten.js @@ -1,14 +1,15 @@ import NewMessage from "../components/Messages/Details/NewMessage/NewDiv.js"; -import Phrasen from "../plugin/Phrasen.js"; +import Phrasen from "../plugins/Phrasen.js"; const ciPath = FHC_JS_DATA_STORAGE_OBJECT.app_root.replace(/(https:|)(^|\/\/)(.*?\/)/g, '') + FHC_JS_DATA_STORAGE_OBJECT.ci_router; const router = VueRouter.createRouter({ history: VueRouter.createWebHistory(), routes: [ - { path: `/${ciPath}/NeueNachricht/:id/:typeId`, component: NewMessage }, - { path: `/${ciPath}/NeueNachricht/:id/:typeId/:messageId`, component: NewMessage }, + { path: `/${ciPath}/NeueNachricht`, component: NewMessage, props: true }, + { path: `/${ciPath}/NeueNachricht/:id/:typeId`, component: NewMessage, props: true }, + { path: `/${ciPath}/NeueNachricht/:id/:typeId/:messageId`, component: NewMessage, props: true }, ] }); diff --git a/public/js/components/Messages/Details/NewMessage/NewDiv.js b/public/js/components/Messages/Details/NewMessage/NewDiv.js index 07fdf569d..8c8e371a0 100644 --- a/public/js/components/Messages/Details/NewMessage/NewDiv.js +++ b/public/js/components/Messages/Details/NewMessage/NewDiv.js @@ -13,33 +13,23 @@ export default { DropdownComponent, }, props: { +/* endpoint: { type: Object, required: true }, +*/ openMode: String, - tempTypeId: String, - tempId: { + typeId: String, + id: { type: Array, required: false }, - tempMessageId: { + messageId: { type: Number, required: false, } }, - computed: { - //params with routes for new tab and new window AND props for inSamePage - id(){ - return this.$props.tempId || this.$route.params.id; - }, - typeId(){ - return this.$props.tempTypeId || this.$route.params.typeId; - }, - messageId(){ - return this.$props.tempMessageId ||this.$route.params.messageId; - }, - }, data(){ return { formData: { @@ -223,6 +213,25 @@ export default { }, }, created(){ + const missingparamsmsgs = []; + if(!this.typeId) + { + // TODO(bh) Phrase + missingparamsmsgs.push('Fehlender oder ungültiger Parameter Empfänger-Id-Typ.'); + } + + if(!this.id || this.id.length < 1) + { + // TODO(bh) Phrase + missingparamsmsgs.push('Fehlender oder ungültiger Parameter Empfänger-Id(s).'); + } + + if(missingparamsmsgs.length > 0) + { + this.$fhcAlert.alertMultiple(missingparamsmsgs, 'warn', 'Warning', true); + return; + } + if(this.typeId == 'person_id' || this.typeId == 'mitarbeiter_uid'){ this.$api .call(ApiMessages.getMessageVarsPerson(this.id, this.typeId)) diff --git a/public/js/components/Messages/Messages.js b/public/js/components/Messages/Messages.js index 0785877d8..61a260ffd 100644 --- a/public/js/components/Messages/Messages.js +++ b/public/js/components/Messages/Messages.js @@ -65,15 +65,20 @@ export default { } }, methods: { + getControllerUrl() { + return FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/NeueNachricht'; + }, reloadTable(){ this.$refs.templateTableMessage.reload(); }, handleMessage(id, typeId, messageId){ this.messageId = messageId; if (this.openMode == "window") { + //this.$refs['newMsgForm'].submit(); this.openInNewWindow(id, typeId, messageId); } else if (this.openMode == "newTab"){ + //this.$refs['newMsgForm'].submit(); this.openInNewTab(id, typeId, messageId); } else if (this.openMode == "modal"){ @@ -85,37 +90,48 @@ export default { else console.log("no valid openMode"); }, - openInNewTab(id, typeId, messageId= null){ + openInNewTab(id, typeId, messageId=null){ + if(id.length > 1) + { + this.$refs['newMsgForm'].submit(); + return; + } - let path = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router; + let path = this.getControllerUrl(); if (messageId){ - path += "/NeueNachricht/" + id + "/" + typeId + "/" + messageId; + path += "/" + encodeURIComponent(id) + "/" + encodeURIComponent(typeId) + "/" + encodeURIComponent(messageId); } else { - path += "/NeueNachricht/" + id + "/" + typeId; + path += "/" + encodeURIComponent(id) + "/" + encodeURIComponent(typeId); } const newTab = window.open(path, "_blank"); - }, openInNewWindow(id, typeId, messageId){ - let path = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router; - - if (messageId){ - path += "/NeueNachricht/" + id + "/" + typeId + "/" + messageId; - } - - else { - path += "/NeueNachricht/" + id + "/" + typeId; - } - const width = Math.round(window.innerWidth * 0.75); const height = Math.round(window.innerHeight * 0.75); const left = Math.round((window.innerWidth - width) / 2); const top = Math.round((window.innerHeight - height) / 2); + if(id.length > 1) + { + const newWindow = window.open('', "NewMsgWindow", `width=${width},height=${height},left=${left},top=${top}`); + this.$refs['newMsgForm'].submit(); + return; + } + + let path = this.getControllerUrl(); + + if (messageId){ + path += "/" + encodeURIComponent(id) + "/" + encodeURIComponent(typeId) + "/" + encodeURIComponent(messageId); + } + + else { + path += "/" + encodeURIComponent(id) + "/" + encodeURIComponent(typeId); + } + const newWindow = window.open(path, "_blank", `width=${width},height=${height},left=${left},top=${top}`); }, resetMessageId(){ @@ -125,6 +141,15 @@ export default { }, template: `
+ +
+ + +