mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
Merge branch 'feature-69438/FHC4_Studierendenverwaltung/FeedbackPunkte' into studvw_2025-12_rc3
This commit is contained in:
@@ -119,6 +119,7 @@ $config['student_tab_order'] = [
|
||||
$config['students_tab_order'] = [
|
||||
'banking',
|
||||
'status',
|
||||
'messages',
|
||||
'groups',
|
||||
'finalexam',
|
||||
'combinePeople',
|
||||
|
||||
@@ -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
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Messages extends FHCAPI_Controller
|
||||
@@ -14,6 +13,7 @@ class Messages extends FHCAPI_Controller
|
||||
'getMsgVarsPrestudent' => ['admin:r', 'assistenz:r'],
|
||||
'getMsgVarsLoggedInUser' => ['admin:r', 'assistenz:r'],
|
||||
'getNameOfDefaultRecipient' => ['admin:r', 'assistenz:r'],
|
||||
'getNameOfDefaultRecipients' => ['admin:r', 'assistenz:r'],
|
||||
'sendMessage' => ['admin:r', 'assistenz:r'],
|
||||
'deleteMessage' => ['admin:r', 'assistenz:r'],
|
||||
'getDataVorlage' => ['admin:r', 'assistenz:r'],
|
||||
@@ -21,6 +21,7 @@ class Messages extends FHCAPI_Controller
|
||||
'getReplyData' => ['admin:r', 'assistenz:r'],
|
||||
'getPersonId' => ['admin:r', 'assistenz:r'],
|
||||
'getUid' => ['admin:r', 'assistenz:r'],
|
||||
'getUids' => ['admin:r', 'assistenz:r'],
|
||||
]);
|
||||
|
||||
//Load Models
|
||||
@@ -37,7 +38,7 @@ class Messages extends FHCAPI_Controller
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui'
|
||||
'ui', 'messages'
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -101,22 +102,49 @@ class Messages extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess($vorlage);
|
||||
}
|
||||
|
||||
public function getMessageVarsPerson($id, $typeId)
|
||||
public function getMessageVarsPerson($typeId)
|
||||
{
|
||||
$person_id = ($typeId == 'mitarbeiter_uid') ? $this->_getPersonId($id, $typeId) : $id;
|
||||
$result = $this->MessageModel->getMsgVarsDataByPersonId($person_id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$ids = $this->input->post('ids');
|
||||
$messageVarsPerson = [];
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$person_id = ($typeId == 'mitarbeiter_uid') ? $this->_getPersonId($id, $typeId) : $id;
|
||||
$result = $this->MessageModel->getMsgVarsDataByPersonId($person_id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$messageVarsPerson[] = current($data);
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess($messageVarsPerson);
|
||||
}
|
||||
|
||||
public function getMsgVarsPrestudent($id, $typeId)
|
||||
public function getMsgVarsPrestudent($typeId)
|
||||
{
|
||||
$prestudent_id = ($typeId == 'uid') ? $this->_getPrestudentIdFromUid($id) : $id;
|
||||
$result = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$ids = $this->input->post('ids');
|
||||
if(!is_array($ids)) {
|
||||
$ids = array($ids);
|
||||
}
|
||||
$messageVarsPrestudent = [];
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
if($typeId == 'uid')
|
||||
{
|
||||
$prestudent_ids = [];
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$prestudent_ids[] = $this->_getPrestudentIdFromUid($id);
|
||||
}
|
||||
}
|
||||
else
|
||||
$prestudent_ids = $ids;
|
||||
|
||||
foreach ($prestudent_ids as $prestudent_id)
|
||||
{
|
||||
$result = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$messageVarsPrestudent[] = current($data);
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess($messageVarsPrestudent);
|
||||
}
|
||||
|
||||
public function getMsgVarsLoggedInUser()
|
||||
@@ -127,27 +155,45 @@ class Messages extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getNameOfDefaultRecipient($id, $type_id)
|
||||
public function getNameOfDefaultRecipients($type_id)
|
||||
{
|
||||
$id = ($type_id != 'person_id') ? $this->_getPersonId($id, $type_id) : $id;
|
||||
$ids = $this->input->post('ids');
|
||||
if(!is_array($ids)) {
|
||||
$ids = array($ids);
|
||||
}
|
||||
$recipients = [];
|
||||
|
||||
if (empty($ids)) {
|
||||
|
||||
throw new InvalidArgumentException($this->p->t('ui', 'errorMissingOrInvalidParameters', ['parameter'=> 'Id(s)']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
if($type_id != 'person_id'){
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$person_id = $this->_getPersonId($id, $type_id);
|
||||
$result = $this->PersonModel->load($person_id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$name = current($data);
|
||||
$recipients[$id] = $name->vorname . " " . $name->nachname;
|
||||
}
|
||||
}
|
||||
else {
|
||||
foreach ($ids as $id) {
|
||||
$result = $this->PersonModel->load($id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$name = current($data);
|
||||
$recipients[$id] = $name->vorname . " " . $name->nachname;
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->PersonModel->load($id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$name = current($data);
|
||||
|
||||
$this->terminateWithSuccess($name->vorname . " " . $name->nachname );
|
||||
$this->terminateWithSuccess($recipients);
|
||||
}
|
||||
|
||||
public function sendMessage($recipient_id)
|
||||
public function sendMessage($typeId)
|
||||
{
|
||||
//has to be uid
|
||||
// $this->terminateWithError("uid", $recipient_id, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
//default setting
|
||||
$receiversPersonId = $this->_getPersonId($recipient_id, 'uid');
|
||||
|
||||
$resultReturn = [];
|
||||
$uid = getAuthUID();
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$result = $this->BenutzerModel->loadWhere(
|
||||
@@ -185,47 +231,61 @@ class Messages extends FHCAPI_Controller
|
||||
$body = $this->input->post('body');
|
||||
$relationmessage_id = $this->input->post('relationmessage_id');
|
||||
|
||||
$typeId = $this->input->post('type_id');
|
||||
$id = $this->input->post('id');
|
||||
|
||||
if($typeId == 'uid')
|
||||
if (isset($_POST['ids']))
|
||||
{
|
||||
$prestudent_id = $this-> _getPrestudentIdFromUid($id);
|
||||
|
||||
//parseMessagetext for variables Prestudent
|
||||
$result = $this->MessagesModel->parseMessageTextPrestudent($prestudent_id, $body);
|
||||
$bodyParsed = $this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
if($typeId == 'mitarbeiter_uid')
|
||||
{
|
||||
$person_id = $this->_getPersonId($id, $typeId);
|
||||
|
||||
$result = $this->MessagesModel->parseMessageTextPerson($person_id, $body);
|
||||
$bodyParsed = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithError($bodyParsed, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
}
|
||||
elseif($typeId == 'person_id')
|
||||
{
|
||||
$result = $this->MessagesModel->parseMessageTextPerson($id, $body);
|
||||
$bodyParsed = $this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
elseif($typeId == 'prestudent_id')
|
||||
{
|
||||
$result = $this->MessagesModel->parseMessageTextPrestudent($id, $body);
|
||||
$bodyParsed = $this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->terminateWithError("type_id " . $typeId . " not valid", self::ERROR_TYPE_GENERAL);
|
||||
$ids = json_decode($_POST['ids']);
|
||||
unset($_POST['ids']);
|
||||
foreach ($data as $k => $v) {
|
||||
$_POST[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$result = $this->messagelib->sendMessageUser($receiversPersonId, $subject, $bodyParsed, $benutzer->person_id, null, $relationmessage_id);
|
||||
if (!is_array($ids)) {
|
||||
$ids = [$ids];
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$receiversPersonId = $typeId == "person_id" ? $id : $this->_getPersonId($id, $typeId);
|
||||
|
||||
if($typeId == 'uid')
|
||||
{
|
||||
$prestudent_id = $this-> _getPrestudentIdFromUid($id);
|
||||
|
||||
$result = $this->MessagesModel->parseMessageTextPrestudent($prestudent_id, $body);
|
||||
$bodyParsed = $this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
if($typeId == 'mitarbeiter_uid')
|
||||
{
|
||||
$person_id = $this->_getPersonId($id, $typeId);
|
||||
|
||||
$result = $this->MessagesModel->parseMessageTextPerson($person_id, $body);
|
||||
$bodyParsed = $this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
elseif($typeId == 'person_id')
|
||||
{
|
||||
$result = $this->MessagesModel->parseMessageTextPerson($id, $body);
|
||||
$bodyParsed = $this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
elseif($typeId == 'prestudent_id')
|
||||
{
|
||||
$result = $this->MessagesModel->parseMessageTextPrestudent($id, $body);
|
||||
$bodyParsed = $this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->terminateWithError($this->p->t('messages', 'error_missingLogic', ['type'=> $typeId]), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$result =$this->messagelib->sendMessageUser($receiversPersonId, $subject, $bodyParsed, $benutzer->person_id, null, $relationmessage_id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$resultReturn[] = current($data);
|
||||
|
||||
}
|
||||
$this->terminateWithSuccess($resultReturn);
|
||||
}
|
||||
|
||||
public function getPreviewText($id, $type_id)
|
||||
public function getPreviewText($type_id)
|
||||
{
|
||||
if (isset($_POST['data']))
|
||||
{
|
||||
@@ -233,39 +293,60 @@ class Messages extends FHCAPI_Controller
|
||||
unset($_POST['data']);
|
||||
}
|
||||
else
|
||||
$this->terminateWithError("Textbody missing ", self::ERROR_TYPE_GENERAL);
|
||||
$this->terminateWithError($this->p->t('messages', 'errorMissingOrInvalidParameters', ['parameter'=> "Textbody"]), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
switch($type_id)
|
||||
if (isset($_POST['ids']))
|
||||
{
|
||||
case 'uid':
|
||||
$prestudent_id = $this->_getPrestudentIdFromUid($id);
|
||||
$result = $this->MessagesModel->parseMessageTextPrestudent($prestudent_id, $data);
|
||||
break;
|
||||
case 'prestudent_id':
|
||||
$result = $this->MessagesModel->parseMessageTextPrestudent($id, $data);
|
||||
break;
|
||||
case 'person_id':
|
||||
$result = $this->MessagesModel->parseMessageTextPerson($id, $data);
|
||||
break;
|
||||
case 'mitarbeiter_uid':
|
||||
{
|
||||
$person_id = $this->_getPersonId($id, $type_id);
|
||||
$result = $this->MessagesModel->parseMessageTextPerson($person_id, $data);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->terminateWithError("MESSAGES::getPreviewText logic for type_id " . $type_id . " not defined yet", self::ERROR_TYPE_GENERAL);
|
||||
break;
|
||||
$ids = json_decode($_POST['ids']);
|
||||
if(!is_array($ids))
|
||||
{
|
||||
$ids = array($ids);
|
||||
}
|
||||
unset($_POST['ids']);
|
||||
}
|
||||
else
|
||||
$this->terminateWithError($this->p->t('ui', 'errorMissingOrInvalidParameters', ['parameter'=> 'Id(s)']), self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$bodyParsed = $this->getDataOrTerminateWithError($result);
|
||||
$bodyParsed = [];
|
||||
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
switch($type_id)
|
||||
{
|
||||
case 'uid':
|
||||
$prestudent_id = $this->_getPrestudentIdFromUid($id);
|
||||
$result = $this->MessagesModel->parseMessageTextPrestudent($prestudent_id, $data);
|
||||
$bodyParsed[$id] = $this->getDataOrTerminateWithError($result);
|
||||
break;
|
||||
case 'prestudent_id':
|
||||
$result = $this->MessagesModel->parseMessageTextPrestudent($id, $data);
|
||||
$bodyParsed[$id] = $this->getDataOrTerminateWithError($result);
|
||||
break;
|
||||
case 'person_id':
|
||||
$result = $this->MessagesModel->parseMessageTextPerson($id, $data);
|
||||
$bodyParsed[$id] = $this->getDataOrTerminateWithError($result);
|
||||
break;
|
||||
case 'mitarbeiter_uid':
|
||||
{
|
||||
$person_id = $this->_getPersonId($id, $type_id);
|
||||
$result = $this->MessagesModel->parseMessageTextPerson($person_id, $data);
|
||||
$bodyParsed[$id] = $this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->terminateWithError($this->p->t('messages', 'error_missingLogic', ['type'=> $type_id]), self::ERROR_TYPE_GENERAL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess($bodyParsed);
|
||||
}
|
||||
|
||||
public function getReplyData($messageId)
|
||||
{
|
||||
//TODO(Manu) validation of messageId: if number
|
||||
if (!is_numeric($messageId)) {
|
||||
$this->terminateWithError($this->p->t('ui', 'error_valueNotNumeric', ['value'=> 'Message ID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$this->MessageModel->addSelect('public.tbl_msg_message.*');
|
||||
$this->MessageModel->addSelect('r.*');
|
||||
@@ -288,7 +369,6 @@ class Messages extends FHCAPI_Controller
|
||||
$replyBody = $this->_getReplyBody($body, $dataMessage[0]->nachname, $dataMessage[0]->vorname, $dataMessage[0]->insertamum);
|
||||
|
||||
$dataMessage[0]->replyBody = $replyBody;
|
||||
$dataMessage[0]->rest = "Help Manu";
|
||||
$dataMessage[0]->replySubject = $prefix . $subject;
|
||||
|
||||
$this->terminateWithSuccess($dataMessage);
|
||||
@@ -336,6 +416,11 @@ class Messages extends FHCAPI_Controller
|
||||
['prestudent_id' => $id]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->terminateWithError($this->p->t('messages', 'error_missingLogic', ['type'=> $typeId]), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$person = current($data);
|
||||
@@ -343,8 +428,11 @@ class Messages extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess($person->person_id);
|
||||
}
|
||||
|
||||
public function getUid($id, $typeId)
|
||||
public function getUids($typeId)
|
||||
{
|
||||
$ids = $this->input->post('ids');
|
||||
$benutzerIds = [];
|
||||
|
||||
if (!$typeId)
|
||||
{
|
||||
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Type ID']), self::ERROR_TYPE_GENERAL);
|
||||
@@ -352,39 +440,50 @@ class Messages extends FHCAPI_Controller
|
||||
elseif ($typeId == 'person_id')
|
||||
{
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$result = $this->BenutzerModel->loadWhere(
|
||||
['person_id' => $id]
|
||||
);
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$result = $this->BenutzerModel->loadWhere(
|
||||
['person_id' => $id]
|
||||
);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$benutzer = current($data);
|
||||
|
||||
$benutzerIds[$id] = $benutzer->uid;
|
||||
}
|
||||
}
|
||||
elseif($typeId == 'prestudent_id')
|
||||
{
|
||||
$this->load->model('crm/Prestudent_model', 'PrestudentModel');
|
||||
$result = $this->PrestudentModel->loadWhere(
|
||||
['prestudent_id' => $id]
|
||||
);
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$result = $this->PrestudentModel->loadWhere(
|
||||
['prestudent_id' => $id]
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$person = current($data);
|
||||
$person_id = $person->person_id;
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$person = current($data);
|
||||
$person_id = $person->person_id;
|
||||
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$result = $this->BenutzerModel->loadWhere(
|
||||
['person_id' => $person_id]
|
||||
);
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$result = $this->BenutzerModel->loadWhere(
|
||||
['person_id' => $person_id]
|
||||
);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$benutzer = current($data);
|
||||
|
||||
$benutzerIds[$id] = $benutzer->uid;
|
||||
}
|
||||
}
|
||||
elseif($typeId == 'uid' || $typeId == 'mitarbeiter_uid')
|
||||
{
|
||||
$this->terminateWithSuccess($id);
|
||||
$this->terminateWithSuccess($ids);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->terminateWithError("MESSAGES::getUID logic for type_id " . $typeId . " not defined yet", self::ERROR_TYPE_GENERAL);
|
||||
$this->terminateWithError($this->p->t('messages', 'error_missingLogic', ['type'=> $typeId]), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$benutzer = current($data);
|
||||
|
||||
$this->terminateWithSuccess($benutzer->uid);
|
||||
$this->terminateWithSuccess($benutzerIds);
|
||||
}
|
||||
|
||||
private function _getPersonId($id, $typeId)
|
||||
@@ -403,11 +502,16 @@ class Messages extends FHCAPI_Controller
|
||||
['prestudent_id' => $id]
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->terminateWithError($this->p->t('messages', 'error_missingLogic', ['type'=> $typeId]), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
if (count($data) < 1)
|
||||
{
|
||||
$this->terminateWithError('Error: Messages API no person_id found.');
|
||||
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Person ID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$person = current($data);
|
||||
|
||||
@@ -416,7 +520,6 @@ class Messages extends FHCAPI_Controller
|
||||
|
||||
private function _getPrestudentIdFromUid($uid)
|
||||
{
|
||||
// $this->terminateWithError($uid, self::ERROR_TYPE_GENERAL);
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$result = $this->StudentModel->loadWhere(
|
||||
['student_uid' => $uid]
|
||||
@@ -425,7 +528,7 @@ class Messages extends FHCAPI_Controller
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
if (count($data) < 1)
|
||||
{
|
||||
$this->terminateWithError('Error: Messages API no prestudent_id found.');
|
||||
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Prestudent ID']), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
$student = current($data);
|
||||
|
||||
|
||||
@@ -362,7 +362,6 @@ class Config extends FHCAPI_Controller
|
||||
$result['messages'] = [
|
||||
'title' => $this->p->t('stv', 'tab_messages'),
|
||||
'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Messages.js'),
|
||||
'showOnlyWithUid' => true
|
||||
];
|
||||
|
||||
$result['grades'] = [
|
||||
@@ -512,6 +511,11 @@ class Config extends FHCAPI_Controller
|
||||
'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Kontaktieren.js'),
|
||||
];
|
||||
|
||||
$result['messages'] = [
|
||||
'title' => $this->p->t('stv', 'tab_messages'),
|
||||
'component' => absoluteJsImportUrl('public/js/components/Stv/Studentenverwaltung/Details/Messages.js'),
|
||||
];
|
||||
|
||||
Events::trigger('stv_conf_students', function & () use (&$result) {
|
||||
return $result;
|
||||
});
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -38,16 +38,18 @@ export default {
|
||||
url: 'api/frontend/v1/messages/messages/getMsgVarsLoggedInUser/'
|
||||
};
|
||||
},
|
||||
getMessageVarsPerson(userParams){
|
||||
getMessageVarsPerson(ids, type_id){
|
||||
return {
|
||||
method: 'post',
|
||||
url: 'api/frontend/v1/messages/messages/getMessageVarsPerson/' + userParams.id + '/' + userParams.type_id
|
||||
url: 'api/frontend/v1/messages/messages/getMessageVarsPerson/' + type_id,
|
||||
params: {ids}
|
||||
};
|
||||
},
|
||||
getMsgVarsPrestudent(userParams){
|
||||
getMsgVarsPrestudent(ids, type_id){
|
||||
return {
|
||||
method: 'post',
|
||||
url: 'api/frontend/v1/messages/messages/getMsgVarsPrestudent/' + userParams.id + '/' + userParams.type_id
|
||||
url: 'api/frontend/v1/messages/messages/getMsgVarsPrestudent/' + type_id,
|
||||
params: {ids}
|
||||
};
|
||||
},
|
||||
getPersonId(params){
|
||||
@@ -56,28 +58,23 @@ export default {
|
||||
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
|
||||
};
|
||||
},
|
||||
getDataVorlage(vorlage_kurzbz){
|
||||
return {
|
||||
method: 'get',
|
||||
url: 'api/frontend/v1/messages/messages/getDataVorlage/' + vorlage_kurzbz
|
||||
};
|
||||
},
|
||||
getNameOfDefaultRecipient(params){
|
||||
return {
|
||||
method: 'get',
|
||||
url: 'api/frontend/v1/messages/messages/getNameOfDefaultRecipient/' + params.id + '/' + params.type_id
|
||||
};
|
||||
},
|
||||
getPreviewText(userParams, params){
|
||||
getNameOfDefaultRecipients(ids, type_id){
|
||||
return {
|
||||
method: 'post',
|
||||
url: 'api/frontend/v1/messages/messages/getPreviewText/' + userParams.id + '/' + userParams.type_id,
|
||||
url: 'api/frontend/v1/messages/messages/getNameOfDefaultRecipients/' + type_id,
|
||||
params: {ids}
|
||||
};
|
||||
},
|
||||
getPreviewText(type_id, params){
|
||||
return {
|
||||
method: 'post',
|
||||
url: 'api/frontend/v1/messages/messages/getPreviewText/' + type_id,
|
||||
params
|
||||
};
|
||||
},
|
||||
@@ -87,17 +84,10 @@ export default {
|
||||
url: 'api/frontend/v1/messages/messages/getReplyData/' + messageId
|
||||
};
|
||||
},
|
||||
sendMessageFromModalContext(id, params) {
|
||||
sendMessage(type_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,
|
||||
url: 'api/frontend/v1/messages/messages/sendMessage/' + type_id,
|
||||
params
|
||||
};
|
||||
},
|
||||
|
||||
@@ -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 },
|
||||
]
|
||||
});
|
||||
|
||||
|
||||
@@ -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: {
|
||||
@@ -14,13 +16,9 @@ export default {
|
||||
ListBox
|
||||
},
|
||||
props: {
|
||||
endpoint: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
typeId: String,
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
messageId: {
|
||||
@@ -43,6 +41,8 @@ export default {
|
||||
vorlagen: [],
|
||||
recipientsArray: [],
|
||||
defaultRecipient: null,
|
||||
defaultRecipients: [],
|
||||
defaultRecipientString: null,
|
||||
editor: null,
|
||||
fieldsUser: [],
|
||||
fieldsPerson: [],
|
||||
@@ -56,7 +56,6 @@ export default {
|
||||
previewText: null,
|
||||
previewBody: "",
|
||||
replyData: null,
|
||||
uid: null,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -111,34 +110,28 @@ export default {
|
||||
},
|
||||
sendMessage() {
|
||||
const data = new FormData();
|
||||
const params = {
|
||||
id: this.id,
|
||||
type_id: this.typeId
|
||||
};
|
||||
const merged = {
|
||||
...this.formData,
|
||||
...params
|
||||
};
|
||||
data.append('data', JSON.stringify(merged));
|
||||
data.append('data', JSON.stringify(this.formData));
|
||||
data.append('ids', JSON.stringify(this.id));
|
||||
|
||||
return this.$refs.formMessage
|
||||
.call(this.endpoint.sendMessageFromModalContext(this.uid, data))
|
||||
.call(ApiMessages.sendMessage(this.typeId, data))
|
||||
.then(response => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSent'));
|
||||
this.hideModal('modalNewMessage');
|
||||
this.resetForm();
|
||||
}).catch(this.$fhcAlert.handleSystemError)
|
||||
.finally(() => {
|
||||
//this.resetForm();
|
||||
//closeModal
|
||||
//closewindwo
|
||||
|
||||
//just emit if no multitasking
|
||||
if(this.id.length == 1){
|
||||
this.$emit('reloadTable');
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
getDataVorlage(vorlage_kurzbz){
|
||||
return this.$api
|
||||
.call(this.endpoint.getDataVorlage(vorlage_kurzbz))
|
||||
.call(ApiMessages.getDataVorlage(vorlage_kurzbz))
|
||||
.then(response => {
|
||||
this.formData.body = response.data.text;
|
||||
this.formData.subject = response.data.subject;
|
||||
@@ -146,17 +139,17 @@ export default {
|
||||
},
|
||||
getPreviewText(){
|
||||
const data = new FormData();
|
||||
|
||||
data.append('data', JSON.stringify(this.formData.body));
|
||||
data.append('ids', JSON.stringify(this.id));
|
||||
|
||||
return this.$api
|
||||
.call(this.endpoint.getPreviewText({
|
||||
id: this.id,
|
||||
type_id: this.typeId}, data))
|
||||
.call(ApiMessages.getPreviewText(
|
||||
this.typeId, data))
|
||||
.then(response => {
|
||||
this.previewText = response.data;
|
||||
const previews = response.data;
|
||||
this.previewText = previews[this.defaultRecipient];
|
||||
}).catch(this.$fhcAlert.handleSystemError)
|
||||
.finally(() => {
|
||||
//this.resetForm();
|
||||
//closeModal
|
||||
//closewindwo
|
||||
});
|
||||
@@ -171,7 +164,7 @@ export default {
|
||||
this.editor.save();
|
||||
|
||||
} else {
|
||||
console.error("Editor instance is not available.");
|
||||
console.error(this.$p.t('messages', 'errorEditorNotAvailable'));
|
||||
}
|
||||
},
|
||||
resetForm(){
|
||||
@@ -180,6 +173,7 @@ export default {
|
||||
body: null,
|
||||
subject: null,
|
||||
};
|
||||
|
||||
this.$emit('resetMessageId');
|
||||
|
||||
if (this.editor) {
|
||||
@@ -201,18 +195,6 @@ export default {
|
||||
this.previewBody = this.previewText;
|
||||
});
|
||||
},
|
||||
getUid(id, typeId){
|
||||
const params = {
|
||||
id: id,
|
||||
type_id: typeId
|
||||
};
|
||||
this.$api
|
||||
.call(this.endpoint.getUid(params))
|
||||
.then(result => {
|
||||
this.uid = result.data;
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
},
|
||||
show(){
|
||||
this.$refs.modalNewMessage.show();
|
||||
},
|
||||
@@ -245,7 +227,7 @@ export default {
|
||||
if (!newMessageId) return;
|
||||
|
||||
try {
|
||||
const result = await this.$api.call(this.endpoint.getReplyData(newMessageId));
|
||||
const result = await this.$api.call(ApiMessages.getReplyData(newMessageId));
|
||||
this.replyData = result.data;
|
||||
|
||||
if (this.replyData.length > 0) {
|
||||
@@ -260,15 +242,9 @@ export default {
|
||||
}
|
||||
},
|
||||
created(){
|
||||
this.getUid(this.id, this.typeId);
|
||||
|
||||
if(this.typeId == 'person_id' || this.typeId == 'mitarbeiter_uid'){
|
||||
const params = {
|
||||
id: this.id,
|
||||
type_id: this.typeId
|
||||
};
|
||||
this.$api
|
||||
.call(this.endpoint.getMessageVarsPerson(params))
|
||||
.call(ApiMessages.getMessageVarsPerson(this.id, this.typeId))
|
||||
.then(result => {
|
||||
this.fieldsPerson = result.data;
|
||||
const person = this.fieldsPerson[0];
|
||||
@@ -281,12 +257,8 @@ export default {
|
||||
}
|
||||
|
||||
if(this.typeId == 'prestudent_id' || this.typeId == 'uid'){
|
||||
const params = {
|
||||
id: this.id,
|
||||
type_id: this.typeId
|
||||
};
|
||||
this.$api
|
||||
.call(this.endpoint.getMsgVarsPrestudent(params))
|
||||
.call(ApiMessages.getMsgVarsPrestudent(this.id, this.typeId))
|
||||
.then(result => {
|
||||
this.fieldsPrestudent = result.data;
|
||||
const prestudent = this.fieldsPrestudent[0];
|
||||
@@ -299,7 +271,7 @@ export default {
|
||||
}
|
||||
|
||||
this.$api
|
||||
.call(this.endpoint.getMsgVarsLoggedInUser())
|
||||
.call(ApiMessages.getMsgVarsLoggedInUser())
|
||||
.then(result => {
|
||||
this.fieldsUser = result.data;
|
||||
const user = this.fieldsUser;
|
||||
@@ -311,21 +283,18 @@ export default {
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
|
||||
this.$api
|
||||
.call(this.endpoint.getNameOfDefaultRecipient({
|
||||
id: this.id,
|
||||
type_id: this.typeId}))
|
||||
.call(ApiMessages.getNameOfDefaultRecipients(this.id, this.typeId))
|
||||
.then(result => {
|
||||
this.defaultRecipient = result.data;
|
||||
this.recipientsArray.push({
|
||||
'uid': this.uid,
|
||||
'details': this.defaultRecipient});
|
||||
this.defaultRecipients = result.data;
|
||||
this.defaultRecipientString = Object.values(this.defaultRecipients).join("; ");
|
||||
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
|
||||
//case of reply
|
||||
if(this.messageId) {
|
||||
this.$api
|
||||
.call(this.endpoint.getReplyData(this.messageId))
|
||||
.call(ApiMessages.getReplyData(this.messageId))
|
||||
.then(result => {
|
||||
this.replyData = result.data;
|
||||
this.formData.subject = this.replyData[0].replySubject;
|
||||
@@ -381,7 +350,7 @@ export default {
|
||||
type="text"
|
||||
name="recipient"
|
||||
:label="$p.t('messages/recipient')"
|
||||
v-model="defaultRecipient"
|
||||
v-model="defaultRecipientString"
|
||||
disabled
|
||||
>
|
||||
</form-input>
|
||||
@@ -502,17 +471,17 @@ export default {
|
||||
>
|
||||
<option :value="null">{{ $p.t('messages', 'recipient') }}...</option>
|
||||
<option
|
||||
v-for="recipient in recipientsArray"
|
||||
:key="recipient.uid"
|
||||
:value="recipient.uid"
|
||||
>{{recipient.details}}
|
||||
v-for="(name, id) in defaultRecipients"
|
||||
:key="id"
|
||||
:value="Number(id)"
|
||||
> {{name}}
|
||||
</option>
|
||||
</form-input>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2 mt-4">
|
||||
<br>
|
||||
<button type="button" class="btn btn-secondary" @click="showPreview()">{{ $p.t('ui', 'btnAktualisieren') }}</button>
|
||||
<button type="button" class="btn btn-secondary" @click="showPreview(defaultRecipient)">{{ $p.t('ui', 'btnAktualisieren') }}</button>
|
||||
</div>
|
||||
</form-form>
|
||||
|
||||
|
||||
@@ -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.js"; //props not working with route
|
||||
|
||||
export default {
|
||||
name: "ComponentNewMessages",
|
||||
@@ -12,33 +13,17 @@ export default {
|
||||
DropdownComponent,
|
||||
},
|
||||
props: {
|
||||
endpoint: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
openMode: String,
|
||||
tempTypeId: String,
|
||||
tempId: {
|
||||
type: [Number, String],
|
||||
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: {
|
||||
@@ -53,6 +38,8 @@ export default {
|
||||
vorlagen: [],
|
||||
recipientsArray: [],
|
||||
defaultRecipient: null,
|
||||
defaultRecipients: [],
|
||||
defaultRecipientString: null,
|
||||
editor: null,
|
||||
isVisible: false,
|
||||
fieldsUser: [],
|
||||
@@ -67,8 +54,7 @@ export default {
|
||||
previewText: null,
|
||||
previewBody: "",
|
||||
replyData: null,
|
||||
uid: null,
|
||||
messageSent: false
|
||||
messageSent: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -106,19 +92,11 @@ export default {
|
||||
},
|
||||
sendMessage() {
|
||||
const data = new FormData();
|
||||
data.append('data', JSON.stringify(this.formData));
|
||||
data.append('ids', JSON.stringify(this.id));
|
||||
|
||||
const params = {
|
||||
id: this.id,
|
||||
type_id: this.typeId
|
||||
};
|
||||
|
||||
const merged = {
|
||||
...this.formData,
|
||||
...params
|
||||
};
|
||||
data.append('data', JSON.stringify(merged));
|
||||
return this.$api
|
||||
.call(this.endpoint.sendMessage(this.uid, data))
|
||||
.call(ApiMessages.sendMessage(this.typeId, data))
|
||||
.then(response => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSent'));
|
||||
this.hideTemplate();
|
||||
@@ -126,11 +104,7 @@ export default {
|
||||
this.messageSent = true;
|
||||
}).catch(this.$fhcAlert.handleSystemError)
|
||||
.finally(() => {
|
||||
//TODO(Manu) hier route definieren für openmode in Tab, Page?
|
||||
// ist kein child sondern mit route aufgerufen
|
||||
//würde allerdings neues fenster aktualisiert öffnen, altes bleibt ohne reload gleich
|
||||
//Reload vorheriges tab???
|
||||
if(this.openMode == "inSamePage"){
|
||||
if(this.openMode == "inSamePage" && this.id.length == 1 ){
|
||||
this.$emit('reloadTable');
|
||||
}
|
||||
}
|
||||
@@ -138,25 +112,29 @@ export default {
|
||||
},
|
||||
getDataVorlage(vorlage_kurzbz){
|
||||
return this.$api
|
||||
.call(this.endpoint.getDataVorlage(vorlage_kurzbz))
|
||||
.call(ApiMessages.getDataVorlage(vorlage_kurzbz))
|
||||
.then(response => {
|
||||
this.formData.body = response.data.text;
|
||||
this.formData.subject = response.data.subject;
|
||||
}).catch(this.$fhcAlert.handleSystemError);
|
||||
},
|
||||
getPreviewText(id, typeId){
|
||||
getPreviewText(){
|
||||
console.log("subj" + this.formData.subject);
|
||||
const data = new FormData();
|
||||
|
||||
data.append('data', JSON.stringify(this.formData.body));
|
||||
data.append('ids', JSON.stringify(this.id));
|
||||
|
||||
console.log("subj" + this.formData.subject);
|
||||
|
||||
return this.$api
|
||||
.call(this.endpoint.getPreviewText({
|
||||
id: this.id,
|
||||
type_id: this.typeId}, data))
|
||||
.call(ApiMessages.getPreviewText(
|
||||
this.typeId, data))
|
||||
.then(response => {
|
||||
this.previewText = response.data;
|
||||
const previews = response.data;
|
||||
this.previewText = previews[this.defaultRecipient];
|
||||
}).catch(this.$fhcAlert.handleSystemError)
|
||||
.finally(() => {
|
||||
//this.resetForm();
|
||||
});
|
||||
},
|
||||
insertVariable(selectedItem){
|
||||
@@ -169,7 +147,7 @@ export default {
|
||||
this.editor.save();
|
||||
|
||||
} else {
|
||||
console.error("Editor instance is not available.");
|
||||
console.error(this.$p.t('messages', 'errorEditorNotAvailable'));
|
||||
}
|
||||
},
|
||||
resetForm(){
|
||||
@@ -177,11 +155,13 @@ export default {
|
||||
vorlage_kurzbz: null,
|
||||
body: null,
|
||||
subject: null,
|
||||
recipient: null,
|
||||
selectedValue: null
|
||||
};
|
||||
if (this.editor) {
|
||||
this.editor.setContent("");
|
||||
}
|
||||
this.$refs.dropdownComp.setValue(null);
|
||||
// this.$refs.dropdownComp.setValue(null);
|
||||
|
||||
this.previewBody = null;
|
||||
|
||||
@@ -199,23 +179,25 @@ export default {
|
||||
this.isVisible = false;
|
||||
},
|
||||
showTemplate(){
|
||||
if (this.openMode == "inSamePage")
|
||||
if (this.openMode == "inSamePage") {
|
||||
this.isVisible = true;
|
||||
//to enable send newMessage after sentMessage
|
||||
this.messageSent = false;
|
||||
}
|
||||
},
|
||||
showPreview(id, typeId){
|
||||
this.getPreviewText(id, typeId).then(() => {
|
||||
showPreview(){
|
||||
this.getPreviewText().then(() => {
|
||||
this.previewBody = this.previewText;
|
||||
});
|
||||
},
|
||||
getUid(id, typeId){
|
||||
const params = {
|
||||
id: id,
|
||||
type_id: typeId
|
||||
};
|
||||
loadReplyData(messageId){
|
||||
this.$api
|
||||
.call(this.endpoint.getUid(params))
|
||||
.call(ApiMessages.getReplyData(messageId))
|
||||
.then(result => {
|
||||
this.uid = result.data;
|
||||
this.replyData = result.data;
|
||||
this.formData.subject = this.replyData[0].replySubject;
|
||||
this.formData.body = this.replyData[0].replyBody;
|
||||
this.formData.relationmessage_id = messageId;
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
}
|
||||
@@ -242,38 +224,43 @@ export default {
|
||||
},
|
||||
},
|
||||
created(){
|
||||
this.getUid(this.id, this.typeId);
|
||||
const missingparamsmsgs = [];
|
||||
if(!this.typeId)
|
||||
{
|
||||
missingparamsmsgs.push(this.$p.t('messages', 'errorMissingOrInvalidParameterRecipientTypeId'));
|
||||
}
|
||||
|
||||
if (['person_id', 'mitarbeiter_uid'].includes(this.typeId)){
|
||||
const params = {
|
||||
id: this.id,
|
||||
type_id: this.typeId
|
||||
};
|
||||
if(!this.id || this.id.length < 1)
|
||||
{
|
||||
missingparamsmsgs.push(this.$p.t('messages', 'errorMissingOrInvalidParameterRecipientIds'));
|
||||
}
|
||||
|
||||
this.$api
|
||||
.call(this.endpoint.getMessageVarsPerson(params))
|
||||
.then(result => {
|
||||
this.fieldsPerson = result.data;
|
||||
const person = this.fieldsPerson[0];
|
||||
this.itemsPerson = Object.entries(person).map(([key, value]) => ({
|
||||
label: key.toLowerCase(),
|
||||
value: '{' + key.toLowerCase() + '}'
|
||||
}));
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
}
|
||||
if(missingparamsmsgs.length > 0)
|
||||
{
|
||||
this.$fhcAlert.alertMultiple(missingparamsmsgs, 'warn', 'Warning', true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (['prestudent_id', 'uid'].includes(this.typeId)){
|
||||
const params = {
|
||||
id: this.id,
|
||||
type_id: this.typeId
|
||||
};
|
||||
if(this.typeId == 'person_id' || this.typeId == 'mitarbeiter_uid'){
|
||||
this.$api
|
||||
.call(this.endpoint.getMsgVarsPrestudent(params))
|
||||
.call(ApiMessages.getMessageVarsPerson(this.id, this.typeId))
|
||||
.then(result => {
|
||||
this.fieldsPerson = result.data;
|
||||
const person = this.fieldsPerson[0];
|
||||
this.itemsPerson = Object.entries(person).map(([key, value]) => ({
|
||||
label: key.toLowerCase(),
|
||||
value: '{' + key.toLowerCase() + '}'
|
||||
}));
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
}
|
||||
|
||||
if(this.typeId == 'prestudent_id' || this.typeId == 'uid'){
|
||||
this.$api
|
||||
.call(ApiMessages.getMsgVarsPrestudent(this.id, this.typeId))
|
||||
.then(result => {
|
||||
this.fieldsPrestudent = result.data;
|
||||
const prestudent = this.fieldsPrestudent[0];
|
||||
|
||||
this.itemsPrestudent = Object.entries(prestudent).map(([key, value]) => ({
|
||||
label: key.toLowerCase(),
|
||||
value: '{' + key.toLowerCase() + '}'
|
||||
@@ -283,7 +270,7 @@ export default {
|
||||
}
|
||||
|
||||
this.$api
|
||||
.call(this.endpoint.getMsgVarsLoggedInUser())
|
||||
.call(ApiMessages.getMsgVarsLoggedInUser())
|
||||
.then(result => {
|
||||
this.fieldsUser = result.data;
|
||||
const user = this.fieldsUser;
|
||||
@@ -295,28 +282,26 @@ export default {
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
|
||||
this.$api
|
||||
.call(this.endpoint.getNameOfDefaultRecipient({
|
||||
id: this.id,
|
||||
type_id: this.typeId}))
|
||||
.call(ApiMessages.getNameOfDefaultRecipients(this.id, this.typeId))
|
||||
.then(result => {
|
||||
this.defaultRecipient = result.data;
|
||||
this.recipientsArray.push({
|
||||
'uid': this.uid,
|
||||
'details': this.defaultRecipient});
|
||||
this.defaultRecipients = result.data;
|
||||
this.defaultRecipientString = Object.values(this.defaultRecipients).join("; ");
|
||||
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
|
||||
//case of reply
|
||||
if(this.messageId != null) {
|
||||
this.$api
|
||||
.call(this.endpoint.getReplyData(this.messageId))
|
||||
this.loadReplyData(this.messageId);
|
||||
/* this.$api
|
||||
.call(ApiMessages.getReplyData(this.messageId))
|
||||
.then(result => {
|
||||
this.replyData = result.data;
|
||||
this.formData.subject = this.replyData[0].replySubject;
|
||||
this.formData.body = this.replyData[0].replyBody;
|
||||
this.formData.relationmessage_id = this.messageId;
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
.catch(this.$fhcAlert.handleSystemError);*/
|
||||
}
|
||||
|
||||
},
|
||||
@@ -330,7 +315,7 @@ export default {
|
||||
|
||||
<div class="messages-detail-newmessage-newdiv">
|
||||
<!--new page-->
|
||||
<div v-if="!messageSent" class="overflow-auto m-3">
|
||||
<div v-if="!messageSent" ref="divNewMessage" class="overflow-auto m-3">
|
||||
<h4>{{ $p.t('messages', 'neueNachricht') }}</h4>
|
||||
|
||||
<div class="row">
|
||||
@@ -343,7 +328,7 @@ export default {
|
||||
type="text"
|
||||
name="recipient"
|
||||
:label="$p.t('messages/recipient')"
|
||||
v-model="defaultRecipient"
|
||||
v-model="defaultRecipientString"
|
||||
disabled
|
||||
>
|
||||
</form-input>
|
||||
@@ -472,18 +457,18 @@ export default {
|
||||
v-model="defaultRecipient"
|
||||
>
|
||||
<option :value="null">{{ $p.t('messages', 'recipient') }}...</option>
|
||||
<option
|
||||
v-for="recipient in recipientsArray"
|
||||
:key="recipient.uid"
|
||||
:value="recipient.uid"
|
||||
>{{recipient.details}}
|
||||
<option
|
||||
v-for="(name, id) in defaultRecipients"
|
||||
:key="id"
|
||||
:value="Number(id)"
|
||||
> {{name}}
|
||||
</option>
|
||||
</form-input>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2 mt-4">
|
||||
<br>
|
||||
<button type="button" class="btn btn-secondary" @click="showPreview(id, typeId)">{{ $p.t('ui', 'btnAktualisieren') }}</button>
|
||||
<button type="button" class="btn btn-secondary" @click="showPreview(defaultRecipient)">{{ $p.t('ui', 'btnAktualisieren') }}</button>
|
||||
</div>
|
||||
</form-form>
|
||||
|
||||
|
||||
@@ -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: {
|
||||
@@ -13,13 +15,9 @@ export default {
|
||||
},
|
||||
},
|
||||
props: {
|
||||
endpoint: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
typeId: String,
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
messageLayout: String,
|
||||
@@ -38,12 +36,13 @@ export default {
|
||||
},
|
||||
ajaxResponse: (url, params, response) => this.buildTreemap(response),
|
||||
columns: [
|
||||
{title: "subject", field: "subject"},
|
||||
{title: "body", field: "body", formatter: "html", visible: false},
|
||||
{title: "message_id", field: "message_id", visible: false},
|
||||
{title: "subject", field: "subject", headerFilter: true},
|
||||
{title: "body", field: "body", formatter: "html", visible: false, headerFilter: true},
|
||||
{title: "message_id", field: "message_id", visible: false, headerFilter: true},
|
||||
{
|
||||
title: "Datum",
|
||||
field: "insertamum",
|
||||
headerFilter: true,
|
||||
formatter: function (cell) {
|
||||
const dateStr = cell.getValue();
|
||||
const date = new Date(dateStr); // Convert to Date object
|
||||
@@ -55,16 +54,28 @@ export default {
|
||||
minute: "2-digit",
|
||||
hour12: false
|
||||
});
|
||||
},
|
||||
headerFilterFunc(headerValue, rowValue) {
|
||||
const matches = headerValue.match(/^(([0-9]{2})\.)?([0-9]{2})\.([0-9]{4})?$/);
|
||||
let comparestr = headerValue;
|
||||
if(matches !== null) {
|
||||
const year = (matches[4] !== undefined) ? matches[4] : '';
|
||||
const month = matches[3];
|
||||
const day = (matches[2] !== undefined) ? matches[2] : '';
|
||||
comparestr = year + '-' + month + '-' + day;
|
||||
}
|
||||
return rowValue.match(comparestr);
|
||||
}
|
||||
},
|
||||
{title: "sender", field: "sender"},
|
||||
{title: "recipient", field: "recipient"},
|
||||
{title: "senderId", field: "sender_id"},
|
||||
{title: "recipientId", field: "recipient_id"},
|
||||
{title: "Relationmessage ID", field: "relationmessage_id"},
|
||||
{title: "sender", field: "sender", headerFilter: true},
|
||||
{title: "recipient", field: "recipient", headerFilter: true},
|
||||
{title: "senderId", field: "sender_id", headerFilter: true},
|
||||
{title: "recipientId", field: "recipient_id", headerFilter: true},
|
||||
{title: "Relationmessage ID", field: "relationmessage_id", headerFilter: true},
|
||||
{
|
||||
title: "Status",
|
||||
field: "status",
|
||||
headerFilter: true,
|
||||
formatterParams: [
|
||||
"unread",
|
||||
"read",
|
||||
@@ -73,11 +84,12 @@ export default {
|
||||
],
|
||||
formatter: (cell, formatterParams) => {
|
||||
return formatterParams[cell.getValue()];
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
title: "letzte Änderung",
|
||||
field: "statusdatum",
|
||||
headerFilter: true,
|
||||
formatter: function (cell) {
|
||||
const dateStr = cell.getValue();
|
||||
const date = new Date(dateStr); // Convert to Date object
|
||||
@@ -89,6 +101,17 @@ export default {
|
||||
minute: "2-digit",
|
||||
hour12: false
|
||||
});
|
||||
},
|
||||
headerFilterFunc(headerValue, rowValue) {
|
||||
const matches = headerValue.match(/^(([0-9]{2})\.)?([0-9]{2})\.([0-9]{4})?$/);
|
||||
let comparestr = headerValue;
|
||||
if(matches !== null) {
|
||||
const year = (matches[4] !== undefined) ? matches[4] : '';
|
||||
const month = matches[3];
|
||||
const day = (matches[2] !== undefined) ? matches[2] : '';
|
||||
comparestr = year + '-' + month + '-' + day;
|
||||
}
|
||||
return rowValue.match(comparestr);
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -256,7 +279,7 @@ export default {
|
||||
},
|
||||
deleteMessage(message_id){
|
||||
return this.$api
|
||||
.call(this.endpoint.deleteMessage(message_id))
|
||||
.call(ApiMessages.deleteMessage(message_id))
|
||||
.then(response => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete'));
|
||||
}).catch(this.$fhcAlert.handleSystemError)
|
||||
@@ -322,7 +345,7 @@ export default {
|
||||
},
|
||||
loadAjaxCall(url, config, params){
|
||||
return this.$api.call(
|
||||
this.endpoint.getMessages(params)
|
||||
ApiMessages.getMessages(params)
|
||||
);
|
||||
}
|
||||
},
|
||||
@@ -347,13 +370,13 @@ export default {
|
||||
});*/
|
||||
},
|
||||
created(){
|
||||
if(this.typeId != 'person_id') {
|
||||
if(this.typeId != 'person_id' && Array.isArray(this.id) && this.id.length === 1) {
|
||||
const params = {
|
||||
id: this.id,
|
||||
type_id: this.typeId
|
||||
};
|
||||
this.$api
|
||||
.call(this.endpoint.getPersonId(params))
|
||||
.call(ApiMessages.getPersonId(params))
|
||||
.then(result => {
|
||||
this.personId = result.data;
|
||||
})
|
||||
|
||||
@@ -14,10 +14,6 @@ export default {
|
||||
}
|
||||
},
|
||||
props: {
|
||||
endpoint: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
typeId: {
|
||||
type: String,
|
||||
required: true,
|
||||
@@ -31,7 +27,7 @@ export default {
|
||||
}
|
||||
},
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
showTable: Boolean,
|
||||
@@ -65,6 +61,9 @@ 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();
|
||||
},
|
||||
@@ -77,44 +76,65 @@ export default {
|
||||
this.openInNewTab(id, typeId, messageId);
|
||||
}
|
||||
else if (this.openMode == "modal"){
|
||||
if(!messageId)
|
||||
this.$refs.modalMsg.resetForm();
|
||||
this.$refs.modalMsg.show();
|
||||
}
|
||||
else if (this.openMode == "inSamePage"){
|
||||
console.log("in same Page");
|
||||
this.isVisibleDiv = true;
|
||||
if(messageId)
|
||||
this.$refs.templateNewDivMessage.loadReplyData(messageId);
|
||||
else
|
||||
this.$refs.templateNewDivMessage.resetForm();
|
||||
|
||||
this.$refs.templateNewDivMessage.showTemplate();
|
||||
}
|
||||
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(){
|
||||
@@ -124,13 +144,21 @@ 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"
|
||||
:type-id="typeId"
|
||||
:id="id"
|
||||
:message-id="messageId"
|
||||
:endpoint="endpoint"
|
||||
:openMode="openMode"
|
||||
@reloadTable="reloadTable"
|
||||
@resetMessageId="resetMessageId"
|
||||
@@ -138,26 +166,23 @@ export default {
|
||||
</message-modal>
|
||||
|
||||
<!--in same page-->
|
||||
<div v-if="isVisibleDiv" class="overflow-auto m-3" style="max-height: 500px; border: 1px solid #ccc;">
|
||||
<div v-show="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"
|
||||
:endpoint="endpoint"
|
||||
ref="templateNewDivMessage"
|
||||
:type-id="typeId"
|
||||
:id="id"
|
||||
:message-id="messageId"
|
||||
:openMode="openMode"
|
||||
@reloadTable="reloadTable"
|
||||
>
|
||||
</form-only>
|
||||
</div>
|
||||
|
||||
|
||||
<div v-if="showTable">
|
||||
|
||||
<div v-if="showTable && id.length==1">
|
||||
<table-messages
|
||||
ref="templateTableMessage"
|
||||
:type-id="typeId"
|
||||
:id="id"
|
||||
:endpoint="endpoint"
|
||||
:messageLayout="messageLayout"
|
||||
:openMode="openMode"
|
||||
@newMessage="handleMessage"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import CoreMessages from "../../../Messages/Messages.js";
|
||||
import ApiMessages from "../../../../api/factory/messages/messages.js";
|
||||
//import ApiMessages from "../../../../api/factory/messages/messages.js";
|
||||
|
||||
export default {
|
||||
name: "TabMessages",
|
||||
@@ -11,29 +11,50 @@ export default {
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
endpoint: ApiMessages
|
||||
//endpoint: ApiMessages
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
prestudent_ids() {
|
||||
if (this.modelValue.prestudent_id)
|
||||
{
|
||||
return [this.modelValue.prestudent_id];
|
||||
}
|
||||
return this.modelValue.map(e => e.prestudent_id);
|
||||
},
|
||||
person_ids() {
|
||||
if (this.modelValue.person_id)
|
||||
{
|
||||
return [this.modelValue.person_id];
|
||||
}
|
||||
return this.modelValue.map(e => e.person_id);
|
||||
},
|
||||
},
|
||||
template: `
|
||||
<div class="stv-details-messages h-100 pb-3 overflow-hidden">
|
||||
|
||||
<template v-if="modelValue.prestudent_id">
|
||||
<core-messages
|
||||
ref="formc"
|
||||
:endpoint="endpoint"
|
||||
type-id="prestudent_id"
|
||||
:id="modelValue.prestudent_id"
|
||||
messageLayout="twoColumnsTableLeft"
|
||||
open-mode="modal"
|
||||
show-table
|
||||
>
|
||||
</core-messages>
|
||||
</template>
|
||||
<template v-else>
|
||||
<h3><strong>No valid prestudent_id!</strong></h3>
|
||||
<p>{{modelValue.anmerkungen}}</p>
|
||||
</template>
|
||||
|
||||
<template v-if="prestudent_ids">
|
||||
<core-messages
|
||||
ref="formc"
|
||||
type-id="prestudent_id"
|
||||
:id="prestudent_ids"
|
||||
messageLayout="twoColumnsTableLeft"
|
||||
open-mode="modal"
|
||||
show-table
|
||||
>
|
||||
</core-messages>
|
||||
</template>
|
||||
<template v-else >
|
||||
<core-messages
|
||||
ref="formc"
|
||||
type-id="person_id"
|
||||
:id="person_ids"
|
||||
messageLayout="twoColumnsTableLeft"
|
||||
open-mode="modal"
|
||||
show-table
|
||||
>
|
||||
</core-messages>
|
||||
</template>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
@@ -52330,6 +52330,108 @@ I have been informed that I am under no obligation to consent to the transmissio
|
||||
)
|
||||
),
|
||||
// ### Personen zusammenlegen Phrasen END
|
||||
// ### Refactor Messages START
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'ui',
|
||||
'phrase' => 'errorMissingOrInvalidParameterRecipientTypeId',
|
||||
'insertvon' => 'system',
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'Fehlender oder ungültiger Parameter Type_ID Empfänger',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'Missing or invalid parameter type ID Recipient',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'ui',
|
||||
'phrase' => 'errorMissingOrInvalidParameterRecipientIds',
|
||||
'insertvon' => 'system',
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'Fehlende(r) oder ungültige(r) Parameter Empfänger-Id(s)',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'Missing or invalid parameter(s) Recipient ID(s)',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'ui',
|
||||
'phrase' => 'errorMissingOrInvalidParameters',
|
||||
'insertvon' => 'system',
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'Fehlende(r) oder ungültige(r) Parameter {parameter}',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'Missing or invalid parameter(s) {parameter}',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'messages',
|
||||
'phrase' => 'errorEditorNotAvailable',
|
||||
'insertvon' => 'system',
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'Editor-Instanz nicht verfügbar.',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'Editor instance is not available.',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'messages',
|
||||
'phrase' => 'error_missingLogic',
|
||||
'insertvon' => 'system',
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'Logik für Type ID {type} nicht implementiert.',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'logic for type ID {type} not implemented.',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
),
|
||||
// ### Refactor Messages END
|
||||
);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user