mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-19 07:52:16 +00:00
---staging----
This commit is contained in:
@@ -115,6 +115,7 @@ $config['student_tab_order'] = [
|
||||
$config['students_tab_order'] = [
|
||||
'banking',
|
||||
'status',
|
||||
'messages',
|
||||
'groups',
|
||||
'finalexam',
|
||||
'archive',
|
||||
|
||||
@@ -14,13 +14,16 @@ 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'],
|
||||
'sendMessages' => ['admin:r', 'assistenz:r'],
|
||||
'deleteMessage' => ['admin:r', 'assistenz:r'],
|
||||
'getDataVorlage' => ['admin:r', 'assistenz:r'],
|
||||
'getPreviewText' => ['admin:r', 'assistenz:r'],
|
||||
'getReplyData' => ['admin:r', 'assistenz:r'],
|
||||
'getPersonId' => ['admin:r', 'assistenz:r'],
|
||||
'getUid' => ['admin:r', 'assistenz:r'],
|
||||
'getUids' => ['admin:r', 'assistenz:r'],
|
||||
]);
|
||||
|
||||
//Load Models
|
||||
@@ -110,13 +113,39 @@ class Messages extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getMsgVarsPrestudent($id, $typeId)
|
||||
/* public function getMsgVarsPrestudent($id, $typeId)
|
||||
{
|
||||
$prestudent_id = ($typeId == 'uid') ? $this->_getPrestudentIdFromUid($id) : $id;
|
||||
$result = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}*/
|
||||
|
||||
public function getMsgVarsPrestudent($typeId)
|
||||
{
|
||||
$ids = $this->input->post('ids');
|
||||
$messageVarsPrestudent = [];
|
||||
|
||||
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,7 +156,7 @@ class Messages extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getNameOfDefaultRecipient($id, $type_id)
|
||||
/* public function getNameOfDefaultRecipient($id, $type_id)
|
||||
{
|
||||
$id = ($type_id != 'person_id') ? $this->_getPersonId($id, $type_id) : $id;
|
||||
|
||||
@@ -138,11 +167,84 @@ class Messages extends FHCAPI_Controller
|
||||
$name = current($data);
|
||||
|
||||
$this->terminateWithSuccess($name->vorname . " " . $name->nachname );
|
||||
}*/
|
||||
|
||||
public function getNameOfDefaultRecipients($type_id)
|
||||
{
|
||||
$ids = $this->input->post('ids');
|
||||
$recipients = [];
|
||||
|
||||
if (empty($ids)) {
|
||||
throw new InvalidArgumentException("Keine ID(s) übergeben.");
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess($recipients);
|
||||
}
|
||||
|
||||
public function sendMessage($recipient_id)
|
||||
public function sendMessages()
|
||||
{
|
||||
//has to be uid
|
||||
/* if (isset($_POST['data']))
|
||||
{
|
||||
$data = json_decode($_POST['data']);
|
||||
unset($_POST['data']);
|
||||
}
|
||||
else
|
||||
$this->terminateWithError("Data missing ", self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if (isset($_POST['ids']))
|
||||
{
|
||||
$ids = json_decode($_POST['ids']);
|
||||
unset($_POST['ids']);
|
||||
}
|
||||
else
|
||||
$this->terminateWithError("IDs missing ", self::ERROR_TYPE_GENERAL);
|
||||
|
||||
|
||||
if (isset($_POST['uids']))
|
||||
{
|
||||
$uids = json_decode($_POST['uids']);
|
||||
unset($_POST['uids']);
|
||||
}
|
||||
else
|
||||
$this->terminateWithError("UIDs missing ", self::ERROR_TYPE_GENERAL);
|
||||
*/
|
||||
|
||||
if (isset($_POST['data']))
|
||||
{
|
||||
$data = json_decode($_POST['data']);
|
||||
unset($_POST['data']);
|
||||
foreach ($data as $k => $v) {
|
||||
$_POST[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
|
||||
}
|
||||
|
||||
public function sendMessage($recipient_id, $return=false)
|
||||
{
|
||||
//has to be uid TODO(Manu) check
|
||||
// $this->terminateWithError("uid", $recipient_id, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
//default setting
|
||||
@@ -186,46 +288,51 @@ class Messages extends FHCAPI_Controller
|
||||
$relationmessage_id = $this->input->post('relationmessage_id');
|
||||
|
||||
$typeId = $this->input->post('type_id');
|
||||
$id = $this->input->post('id');
|
||||
$ids = $this->input->post('id');
|
||||
|
||||
if($typeId == 'uid')
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$prestudent_id = $this-> _getPrestudentIdFromUid($id);
|
||||
if($typeId == 'uid')
|
||||
{
|
||||
$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);
|
||||
//parseMessagetext for variables Prestudent
|
||||
$result = $this->MessagesModel->parseMessageTextPrestudent($prestudent_id, $body);
|
||||
$bodyParsed[$id] = $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);
|
||||
$result = $this->MessagesModel->parseMessageTextPerson($person_id, $body);
|
||||
$bodyParsed[$id] = $this->getDataOrTerminateWithError($result);
|
||||
$this->terminateWithError($bodyParsed[$id], self::ERROR_TYPE_GENERAL);
|
||||
|
||||
}
|
||||
elseif($typeId == 'person_id')
|
||||
{
|
||||
$result = $this->MessagesModel->parseMessageTextPerson($id, $body);
|
||||
$bodyParsed[$id] = $this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
elseif($typeId == 'prestudent_id')
|
||||
{
|
||||
$result = $this->MessagesModel->parseMessageTextPrestudent($id, $body);
|
||||
$bodyParsed[$id] = $this->getDataOrTerminateWithError($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->terminateWithError("type_id " . $typeId . " not valid", 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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$result = $this->messagelib->sendMessageUser($receiversPersonId, $subject, $bodyParsed, $benutzer->person_id, null, $relationmessage_id);
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function getPreviewText($id, $type_id)
|
||||
public function getPreviewText($type_id)
|
||||
{
|
||||
if (isset($_POST['data']))
|
||||
{
|
||||
@@ -235,30 +342,45 @@ class Messages extends FHCAPI_Controller
|
||||
else
|
||||
$this->terminateWithError("Textbody missing ", 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']);
|
||||
unset($_POST['ids']);
|
||||
}
|
||||
else
|
||||
$this->terminateWithError("IDs missing ", 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("MESSAGES::getPreviewText logic for type_id " . $type_id . " not defined yet", self::ERROR_TYPE_GENERAL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->terminateWithSuccess($bodyParsed);
|
||||
}
|
||||
@@ -343,7 +465,7 @@ class Messages extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess($person->person_id);
|
||||
}
|
||||
|
||||
public function getUid($id, $typeId)
|
||||
public function getUid($typeId)
|
||||
{
|
||||
if (!$typeId)
|
||||
{
|
||||
@@ -387,6 +509,68 @@ class Messages extends FHCAPI_Controller
|
||||
$this->terminateWithSuccess($benutzer->uid);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
elseif ($typeId == 'person_id')
|
||||
{
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
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');
|
||||
foreach ($ids as $id)
|
||||
{
|
||||
$result = $this->PrestudentModel->loadWhere(
|
||||
['prestudent_id' => $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]
|
||||
);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$benutzer = current($data);
|
||||
|
||||
$benutzerIds[$id] = $benutzer->uid;
|
||||
}
|
||||
}
|
||||
elseif($typeId == 'uid' || $typeId == 'mitarbeiter_uid')
|
||||
{
|
||||
$this->terminateWithSuccess($ids);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->terminateWithError("MESSAGES::getUID logic for type_id " . $typeId . " not defined yet", self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
|
||||
//$data = $this->getDataOrTerminateWithError($resultBenutzer);
|
||||
//$benutzer = current($data);
|
||||
|
||||
$this->terminateWithSuccess($benutzerIds);
|
||||
}
|
||||
|
||||
private function _getPersonId($id, $typeId)
|
||||
{
|
||||
if ($typeId == 'uid' || $typeId == 'mitarbeiter_uid')
|
||||
|
||||
@@ -271,7 +271,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'] = [
|
||||
@@ -412,6 +411,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;
|
||||
});
|
||||
|
||||
@@ -44,23 +44,40 @@ export default {
|
||||
url: 'api/frontend/v1/messages/messages/getMessageVarsPerson/' + userParams.id + '/' + userParams.type_id
|
||||
};
|
||||
},
|
||||
getMsgVarsPrestudent(userParams){
|
||||
//TODO(Manu) enable for id_array
|
||||
/* getMsgVarsPrestudent(userParams){
|
||||
return {
|
||||
method: 'post',
|
||||
url: 'api/frontend/v1/messages/messages/getMsgVarsPrestudent/' + userParams.id + '/' + userParams.type_id
|
||||
};
|
||||
}, */
|
||||
getMsgVarsPrestudent(ids, type_id){
|
||||
return {
|
||||
method: 'post',
|
||||
url: 'api/frontend/v1/messages/messages/getMsgVarsPrestudent/' + type_id,
|
||||
params: {ids}
|
||||
};
|
||||
},
|
||||
//TODO(Manu) enable for id_array
|
||||
getPersonId(params){
|
||||
return {
|
||||
method: 'post',
|
||||
url: 'api/frontend/v1/messages/messages/getPersonId/' + params.id + '/' + params.type_id
|
||||
};
|
||||
},
|
||||
getUid(userParams){
|
||||
//TODO(Manu) enable for id_array
|
||||
/* getUid(userParams){
|
||||
return {
|
||||
method: 'get',
|
||||
url: 'api/frontend/v1/messages/messages/getUid/' + userParams.id + '/' + userParams.type_id
|
||||
};
|
||||
}, */
|
||||
getUid(ids, type_id){
|
||||
return {
|
||||
method: 'post',
|
||||
url: 'api/frontend/v1/messages/messages/getUids/' + type_id,
|
||||
params: {ids}
|
||||
};
|
||||
},
|
||||
getDataVorlage(vorlage_kurzbz){
|
||||
return {
|
||||
@@ -68,16 +85,25 @@ export default {
|
||||
url: 'api/frontend/v1/messages/messages/getDataVorlage/' + vorlage_kurzbz
|
||||
};
|
||||
},
|
||||
getNameOfDefaultRecipient(params){
|
||||
/* getNameOfDefaultRecipient(params){
|
||||
console.log(params.id);
|
||||
return {
|
||||
method: 'get',
|
||||
url: 'api/frontend/v1/messages/messages/getNameOfDefaultRecipient/' + params.id + '/' + params.type_id
|
||||
};
|
||||
},
|
||||
getPreviewText(userParams, params){
|
||||
},*/
|
||||
//TODO(Manu) enable for id_array
|
||||
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,12 +113,19 @@ export default {
|
||||
url: 'api/frontend/v1/messages/messages/getReplyData/' + messageId
|
||||
};
|
||||
},
|
||||
sendMessageFromModalContext(id, params) {
|
||||
/* sendMessageFromModalContext(id, params) {
|
||||
return {
|
||||
method: 'post',
|
||||
url: 'api/frontend/v1/messages/messages/sendMessage/' + id,
|
||||
params
|
||||
};
|
||||
}, */
|
||||
sendMessageFromModalContext(params) {
|
||||
return {
|
||||
method: 'post',
|
||||
url: 'api/frontend/v1/messages/messages/sendMessages/',
|
||||
params
|
||||
};
|
||||
},
|
||||
sendMessage(id, params) {
|
||||
return {
|
||||
|
||||
@@ -20,7 +20,7 @@ export default {
|
||||
},
|
||||
typeId: String,
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
messageId: {
|
||||
@@ -43,6 +43,8 @@ export default {
|
||||
vorlagen: [],
|
||||
recipientsArray: [],
|
||||
defaultRecipient: null,
|
||||
defaultRecipients: [],
|
||||
defaultRecipientString: null,
|
||||
editor: null,
|
||||
fieldsUser: [],
|
||||
fieldsPerson: [],
|
||||
@@ -57,6 +59,7 @@ export default {
|
||||
previewBody: "",
|
||||
replyData: null,
|
||||
uid: null,
|
||||
uids: null //necessary?
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -111,6 +114,10 @@ export default {
|
||||
},
|
||||
sendMessage() {
|
||||
const data = new FormData();
|
||||
data.append('data', JSON.stringify(this.formData));
|
||||
data.append('ids', JSON.stringify(this.id));
|
||||
data.append('uids', JSON.stringify(this.uid));
|
||||
|
||||
const params = {
|
||||
id: this.id,
|
||||
type_id: this.typeId
|
||||
@@ -121,8 +128,9 @@ export default {
|
||||
};
|
||||
data.append('data', JSON.stringify(merged));
|
||||
|
||||
//Modal Context?
|
||||
return this.$refs.formMessage
|
||||
.call(this.endpoint.sendMessageFromModalContext(this.uid, data))
|
||||
.call(this.endpoint.sendMessageFromModalContext(data))
|
||||
.then(response => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSent'));
|
||||
this.hideModal('modalNewMessage');
|
||||
@@ -146,14 +154,15 @@ 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(this.endpoint.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();
|
||||
@@ -201,13 +210,10 @@ export default {
|
||||
this.previewBody = this.previewText;
|
||||
});
|
||||
},
|
||||
//TODO(Manu) check if No_UID
|
||||
getUid(id, typeId){
|
||||
const params = {
|
||||
id: id,
|
||||
type_id: typeId
|
||||
};
|
||||
this.$api
|
||||
.call(this.endpoint.getUid(params))
|
||||
.call(this.endpoint.getUid(this.id, this.typeId))
|
||||
.then(result => {
|
||||
this.uid = result.data;
|
||||
})
|
||||
@@ -281,12 +287,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(this.endpoint.getMsgVarsPrestudent(this.id, this.typeId))
|
||||
.then(result => {
|
||||
this.fieldsPrestudent = result.data;
|
||||
const prestudent = this.fieldsPrestudent[0];
|
||||
@@ -310,7 +312,7 @@ export default {
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
|
||||
this.$api
|
||||
/* this.$api
|
||||
.call(this.endpoint.getNameOfDefaultRecipient({
|
||||
id: this.id,
|
||||
type_id: this.typeId}))
|
||||
@@ -320,6 +322,16 @@ export default {
|
||||
'uid': this.uid,
|
||||
'details': this.defaultRecipient});
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);*/
|
||||
|
||||
//for multiaction too
|
||||
this.$api
|
||||
.call(this.endpoint.getNameOfDefaultRecipients(this.id, this.typeId))
|
||||
.then(result => {
|
||||
this.defaultRecipients = result.data;
|
||||
this.defaultRecipientString = Object.values(this.defaultRecipients).join("; ");
|
||||
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
|
||||
//case of reply
|
||||
@@ -367,6 +379,8 @@ export default {
|
||||
</template>
|
||||
|
||||
<form-form ref="formNewMassage">
|
||||
|
||||
{{defaultRecipients}} | {{defaultRecipient}} || {{uid}}
|
||||
|
||||
<div class="tab-content" id="msg_preview_content">
|
||||
<div class="tab-pane fade show active" id="msg" role="tabpanel" aria-labelledby="msg-tab">
|
||||
@@ -381,7 +395,7 @@ export default {
|
||||
type="text"
|
||||
name="recipient"
|
||||
:label="$p.t('messages/recipient')"
|
||||
v-model="defaultRecipient"
|
||||
v-model="defaultRecipientString"
|
||||
disabled
|
||||
>
|
||||
</form-input>
|
||||
@@ -502,17 +516,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>
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ export default {
|
||||
},
|
||||
typeId: String,
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
messageLayout: String,
|
||||
@@ -346,7 +346,7 @@ 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
|
||||
|
||||
@@ -31,7 +31,7 @@ export default {
|
||||
}
|
||||
},
|
||||
id: {
|
||||
type: [Number, String],
|
||||
type: Array,
|
||||
required: true
|
||||
},
|
||||
showTable: Boolean,
|
||||
@@ -124,6 +124,7 @@ export default {
|
||||
},
|
||||
template: `
|
||||
<div class="core-messages h-100 pb-3">
|
||||
{{typeId}} {{id}}
|
||||
|
||||
<message-modal
|
||||
ref="modalMsg"
|
||||
@@ -150,9 +151,8 @@ export default {
|
||||
>
|
||||
</form-only>
|
||||
</div>
|
||||
|
||||
|
||||
<div v-if="showTable">
|
||||
|
||||
<div v-if="showTable && id.length==1">
|
||||
<table-messages
|
||||
ref="templateTableMessage"
|
||||
:type-id="typeId"
|
||||
|
||||
@@ -14,26 +14,48 @@ export default {
|
||||
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"
|
||||
:endpoint="endpoint"
|
||||
type-id="prestudent_id"
|
||||
:id="prestudent_ids"
|
||||
messageLayout="twoColumnsTableLeft"
|
||||
open-mode="modal"
|
||||
show-table
|
||||
>
|
||||
</core-messages>
|
||||
</template>
|
||||
<template v-else >
|
||||
<core-messages
|
||||
ref="formc"
|
||||
:endpoint="endpoint"
|
||||
type-id="person_id"
|
||||
:id="person_ids"
|
||||
messageLayout="twoColumnsTableLeft"
|
||||
open-mode="modal"
|
||||
show-table
|
||||
>
|
||||
</core-messages>
|
||||
</template>
|
||||
</div>
|
||||
`
|
||||
};
|
||||
Reference in New Issue
Block a user