modify using open mode newTab or window with multiple Recipients via post request

This commit is contained in:
Harald Bamberger
2025-12-02 07:54:13 +01:00
parent be2b578f82
commit afb3ce4cae
6 changed files with 93 additions and 37 deletions
+8 -1
View File
@@ -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
]);
}
}
@@ -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
+4
View File
@@ -40,6 +40,10 @@ $configArray = [
cis-root="<?= CIS_ROOT; ?>"
:permissions="<?= htmlspecialchars(json_encode($permissions)); ?>"
:config="<?= htmlspecialchars(json_encode($configArray)); ?>"
<?php if($ids !== null && $typeid !== null) { ?>
:id ="<?= htmlspecialchars(json_encode($ids)); ?>"
type-id ="<?= htmlspecialchars($typeid); ?>"
<?php } ?>
>
</router-view>
</div>
+4 -3
View File
@@ -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 },
]
});
@@ -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))
+43 -18
View File
@@ -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: `
<div class="core-messages h-100 pb-3">
<!-- TODO(bh) set target _self for debugging post but _blank for newTab -->
<form ref="newMsgForm"
method="post"
:action="getControllerUrl()"
:target="(openMode === 'window') ? 'NewMsgWindow' : '_blank'"
>
<input type="hidden" name="typeid" :value="typeId">
<input type="hidden" name="ids" :value="id">
</form>
<message-modal
ref="modalMsg"
@@ -142,9 +167,9 @@ export default {
<div v-if="isVisibleDiv" class="overflow-auto m-3" style="max-height: 500px; border: 1px solid #ccc;">
<form-only
ref="templateNewMessage"
:temp-type-id="typeId"
:temp-id="id"
:temp-message-id="messageId"
:type-id="typeId"
:id="id"
:message-id="messageId"
:endpoint="endpoint"
:openMode="openMode"
@reloadTable="reloadTable"