mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-21 08:52:21 +00:00
add Vorlagendropdown Component and Listboxes for Messaging Variables
This commit is contained in:
@@ -9,6 +9,14 @@ class Messages extends FHCAPI_Controller
|
||||
{
|
||||
parent::__construct([
|
||||
'getMessages' => ['admin:r', 'assistenz:r'],
|
||||
'getVorlagen' => ['admin:r', 'assistenz:r'],
|
||||
'getMessageVarsPerson' => ['admin:r', 'assistenz:r'],
|
||||
'getMsgVarsPrestudent' => ['admin:r', 'assistenz:r'],
|
||||
'getMsgVarsLoggedInUser' => ['admin:r', 'assistenz:r'],
|
||||
'getNameOfDefaultRecipient' => ['admin:r', 'assistenz:r'],
|
||||
'sendMessage' => ['admin:r', 'assistenz:r'],
|
||||
'deleteMessage' => ['admin:r', 'assistenz:r'],
|
||||
'getVorlagentext' => ['admin:r', 'assistenz:r'],
|
||||
]);
|
||||
|
||||
//Load Models
|
||||
@@ -20,6 +28,7 @@ class Messages extends FHCAPI_Controller
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
$this->load->library('form_validation');
|
||||
$this->load->library('MessageLib');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
@@ -29,11 +38,17 @@ class Messages extends FHCAPI_Controller
|
||||
|
||||
public function getMessages($id, $type_id)
|
||||
{
|
||||
//$this->terminateWithError("in backend " . $type_id . ": " . $id, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
if ($type_id != "person_id")
|
||||
switch($type_id)
|
||||
{
|
||||
$this->terminateWithError("logic for type_id " . $type_id . " not defined yet", self::ERROR_TYPE_GENERAL);
|
||||
case 'uid':
|
||||
$id = $this->_getPersonIdFromUid($id);
|
||||
break;
|
||||
case 'person_id':
|
||||
$id = $id;
|
||||
break;
|
||||
default:
|
||||
$this->terminateWithError("MESSAGES::getMessages logic for type_id " . $type_id . " not defined yet", self::ERROR_TYPE_GENERAL);
|
||||
break;
|
||||
}
|
||||
|
||||
$result = $this->MessageModel->getMessagesForTable($id);
|
||||
@@ -42,4 +57,227 @@ class Messages extends FHCAPI_Controller
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getVorlagen()
|
||||
{
|
||||
//get oe of user
|
||||
$uid = getAuthUID();
|
||||
$this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
|
||||
$result = $this->BenutzerfunktionModel->getBenutzerfunktionByUid($uid, 'oezuordnung');
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$oe_kurzbz = current($data);
|
||||
|
||||
// $this->terminateWithError("oe: ". $oe_kurzbz->oe_kurzbz, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$this->load->model('system/Vorlage_model', 'VorlageModel');
|
||||
|
||||
//39 Stück Variante OE
|
||||
$result = $this->VorlageModel->getAllVorlagenByOe($oe_kurzbz->oe_kurzbz);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
|
||||
//IF ADMIN 167
|
||||
$this->VorlageModel->addOrder('vorlage_kurzbz', 'ASC');
|
||||
//only HTML-vorlagen -> for admin
|
||||
$result = $this->VorlageModel->loadWhere(
|
||||
array(
|
||||
'mimetype' => 'text/html'
|
||||
));
|
||||
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getVorlagentext($vorlage_kurzbz)
|
||||
{
|
||||
//$this->terminateWithError("vor " . $vorlage_kurzbz, self::ERROR_TYPE_GENERAL);
|
||||
//$studiengang_kz = 227; //TODO(Manu) check dynamisieren NULL
|
||||
$studiengang_kz = 0;
|
||||
$this->load->model('system/Vorlagestudiengang_model', 'VorlagestudiengangModel');
|
||||
$this->VorlagestudiengangModel->addOrder('version', 'DESC');
|
||||
|
||||
$result = $this->VorlagestudiengangModel->loadWhere(
|
||||
[
|
||||
'vorlage_kurzbz' =>$vorlage_kurzbz,
|
||||
'studiengang_kz' => $studiengang_kz
|
||||
]);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
//not correct with Vorlage
|
||||
$vorlage = current($data);
|
||||
|
||||
//$this->terminateWithSuccess($data);
|
||||
$this->terminateWithSuccess($vorlage->text);
|
||||
}
|
||||
|
||||
public function getMessageVarsPerson()
|
||||
{
|
||||
$result = $this->MessageModel->getMessageVarsPerson();
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getMsgVarsPrestudent($uid)
|
||||
{
|
||||
|
||||
$prestudent_id = $this-> _getPrestudentIdFromUid($uid);
|
||||
|
||||
// $this->terminateWithError("prestudent_id " . $prestudent_id, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
$result = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getMsgVarsLoggedInUser()
|
||||
{
|
||||
$uid = getAuthUID();
|
||||
|
||||
$result = $this->MessageModel->getMsgVarsLoggedInUser();
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getNameOfDefaultRecipient($id, $type_id)
|
||||
{
|
||||
switch($type_id)
|
||||
{
|
||||
case 'uid':
|
||||
$id = $this->_getPersonIdFromUid($id);
|
||||
break;
|
||||
case 'person_id':
|
||||
$id = $id;
|
||||
break;
|
||||
default:
|
||||
$this->terminateWithError("MESSAGES::getNameOfDefaultRecipient logic for type_id " . $type_id . " not defined yet", self::ERROR_TYPE_GENERAL);
|
||||
break;
|
||||
}
|
||||
|
||||
$this->load->model('person/Person_model', 'PersonModel');
|
||||
|
||||
$result = $this->PersonModel->load($id);
|
||||
//$this->terminateWithSuccess($result);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$name = current($data);
|
||||
|
||||
$this->terminateWithSuccess($name->vorname . " " . $name->nachname );
|
||||
}
|
||||
|
||||
public function sendMessage($recipient_id)
|
||||
{
|
||||
//TODO(manu) Problems with Vorlagen...
|
||||
//TODO(Manu) Problems with VARS
|
||||
$receiversPersonId = $this->_getPersonIdFromUid($recipient_id);
|
||||
|
||||
$uid = getAuthUID();
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$result = $this->BenutzerModel->loadWhere(
|
||||
['uid' => $uid]
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$benutzer = current($data);
|
||||
|
||||
if (isset($_POST['data']))
|
||||
{
|
||||
$data = json_decode($_POST['data']);
|
||||
unset($_POST['data']);
|
||||
foreach ($data as $k => $v) {
|
||||
$_POST[$k] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
$subject = $this->input->post('subject');
|
||||
|
||||
$body = $this->input->post('body');
|
||||
|
||||
// $this->terminateWithError("rp_id " . $receiversPersonId, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
/* $subject = $this->input->post('subject');
|
||||
|
||||
$formData = $this->input->post('data');*/
|
||||
|
||||
//$_POST['subject'] = $formData['subject'];
|
||||
// $subject = $formData['subject'];
|
||||
// $body = $formData['body'];
|
||||
|
||||
// $subject = isset($_POST['subject']) ? $_POST['subject'] : null;
|
||||
// $body = isset($_POST['body']) ? $_POST['body'] : null;
|
||||
|
||||
// $this->terminateWithError("person_id " . $receiversPersonId, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
// $this->terminateWithError("subject " . $subject, self::ERROR_TYPE_GENERAL);
|
||||
// $this->terminateWithError("body " . $body, self::ERROR_TYPE_GENERAL);
|
||||
|
||||
// $this->terminateWithError("person_id " . $benutzer->person_id, self::ERROR_TYPE_GENERAL);
|
||||
// $this->terminateWithError("subject " . $subject, self::ERROR_TYPE_GENERAL);
|
||||
$result = $this->messagelib->sendMessageUser($receiversPersonId, $subject, $body, $benutzer->person_id);
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
public function deleteMessage($messageId)
|
||||
{
|
||||
// Start DB transaction
|
||||
$this->db->trans_begin();
|
||||
|
||||
$result = $this->MessageModel->deleteMessageRecipient($messageId);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$result = $this->MessageModel->deleteMessageStatus($messageId);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$result = $this->MessageModel->deleteMessage($messageId);
|
||||
if (isError($result)) {
|
||||
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$this->db->trans_commit();
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
|
||||
private function _getPersonIdFromUid($uid)
|
||||
{
|
||||
$this->load->model('person/Benutzer_model', 'BenutzerModel');
|
||||
$result = $this->BenutzerModel->loadWhere(
|
||||
['uid' => $uid]
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$benutzer = current($data);
|
||||
|
||||
return $benutzer->person_id;
|
||||
}
|
||||
|
||||
private function _getPrestudentIdFromUid($uid)
|
||||
{
|
||||
$this->load->model('crm/Student_model', 'StudentModel');
|
||||
$result = $this->StudentModel->loadWhere(
|
||||
['student_uid' => $uid]
|
||||
);
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$student = current($data);
|
||||
|
||||
return $student->prestudent_id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Vorlagen extends FHCAPI_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'getVorlagen' => ['admin:r', 'assistenz:r'],
|
||||
'getVorlagenByLoggedInUser' => ['admin:r', 'assistenz:r'],
|
||||
]);
|
||||
|
||||
//Load Models
|
||||
$this->load->model('system/Vorlage_model', 'VorlageModel');
|
||||
|
||||
// Additional Permission Checks
|
||||
//TODO(manu) check permissions
|
||||
|
||||
// Load Libraries
|
||||
$this->load->library('VariableLib', ['uid' => getAuthUID()]);
|
||||
$this->load->library('form_validation');
|
||||
$this->load->library('VorlageLib');
|
||||
|
||||
// Load language phrases
|
||||
$this->loadPhrases([
|
||||
'ui'
|
||||
]);
|
||||
}
|
||||
|
||||
public function getVorlagen()
|
||||
{
|
||||
$this->load->model('system/Vorlage_model', 'VorlageModel');
|
||||
|
||||
$this->VorlageModel->addOrder('vorlage_kurzbz', 'ASC');
|
||||
|
||||
$result = $this->VorlageModel->loadWhere(
|
||||
array(
|
||||
'mimetype' => 'text/html'
|
||||
));
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
public function getVorlagenByLoggedInUser()
|
||||
{
|
||||
//get oe of user
|
||||
$uid = getAuthUID();
|
||||
$this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel');
|
||||
$result = $this->BenutzerfunktionModel->getBenutzerfunktionByUid($uid, 'oezuordnung');
|
||||
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
$oe_kurzbz = current($data);
|
||||
|
||||
$result = $this->VorlageModel->getAllVorlagenByOe($oe_kurzbz->oe_kurzbz);
|
||||
$data = $this->getDataOrTerminateWithError($result);
|
||||
|
||||
$this->terminateWithSuccess($data);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -282,4 +282,46 @@ class Message_model extends DB_Model
|
||||
|
||||
return $this->execQuery($sql, $parametersArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a messages from tableMessages and tbl_msg_recipient
|
||||
* TODO(MANU) CHECK IF NECESSARY
|
||||
* dependency with other tables
|
||||
* in case of reply... more messages
|
||||
* maybe anonimize it
|
||||
* @param $message_id
|
||||
* @return boolean success
|
||||
*/
|
||||
public function deleteMessageRecipient($message_id)
|
||||
{
|
||||
$sql = "
|
||||
DELETE FROM public.tbl_msg_recipient
|
||||
WHERE message_id = ?;
|
||||
";
|
||||
|
||||
return $this->execQuery($sql, array($message_id));
|
||||
}
|
||||
|
||||
|
||||
public function deleteMessageStatus($message_id)
|
||||
{
|
||||
$sql = "
|
||||
DELETE FROM public.tbl_msg_status
|
||||
WHERE message_id = ?;
|
||||
";
|
||||
|
||||
return $this->execQuery($sql, array($message_id));
|
||||
}
|
||||
|
||||
public function deleteMessage($message_id)
|
||||
{
|
||||
$sql = "
|
||||
DELETE FROM public.tbl_msg_message
|
||||
WHERE message_id = ?;
|
||||
";
|
||||
|
||||
return $this->execQuery($sql, array($message_id));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -21,4 +21,120 @@ class Vorlage_model extends DB_Model
|
||||
|
||||
return $this->execQuery($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all Vorlagen
|
||||
* that belongs to the organisation units of the user
|
||||
* and the parents of those organisation units until the root of the
|
||||
* @param Array Array of $oe_kurzbz
|
||||
* @return object Array of Vorlagen
|
||||
*/
|
||||
public function getAllVorlagenByOe($oe_kurzbz)
|
||||
{
|
||||
// Loads library OrganisationseinheitLib
|
||||
$this->load->library('OrganisationseinheitLib');
|
||||
|
||||
$vorlage = success(array()); // Default value
|
||||
|
||||
$table = '(
|
||||
SELECT v.vorlage_kurzbz,
|
||||
v.bezeichnung,
|
||||
vs.version,
|
||||
vs.oe_kurzbz,
|
||||
vs.aktiv,
|
||||
vs.subject,
|
||||
vs.text,
|
||||
v.mimetype
|
||||
FROM tbl_vorlagestudiengang vs
|
||||
JOIN tbl_vorlage v USING(vorlage_kurzbz)
|
||||
) templates';
|
||||
|
||||
$alias = 'templates';
|
||||
|
||||
$fields = array(
|
||||
'templates.vorlage_kurzbz AS id',
|
||||
'templates.bezeichnung || \' (\' || UPPER(templates.oe_kurzbz) || \')\' AS description'
|
||||
);
|
||||
|
||||
$where = 'templates.aktiv = TRUE
|
||||
AND templates.subject IS NOT NULL
|
||||
AND templates.text IS NOT NULL
|
||||
AND templates.mimetype = \'text/html\'
|
||||
GROUP BY 1, 2, 3';
|
||||
|
||||
$order_by = 'description ASC';
|
||||
|
||||
if (!is_array($oe_kurzbz))
|
||||
{
|
||||
$vorlage = $this->organisationseinheitlib->treeSearchEntire(
|
||||
$table,
|
||||
$alias,
|
||||
$fields,
|
||||
$where,
|
||||
$order_by,
|
||||
$oe_kurzbz
|
||||
);
|
||||
}
|
||||
else // is an array
|
||||
{
|
||||
// Get the vorlage for each organisation unit
|
||||
foreach($oe_kurzbz as $val)
|
||||
{
|
||||
$tmpVorlage = $this->organisationseinheitlib->treeSearchEntire(
|
||||
$table,
|
||||
$alias,
|
||||
$fields,
|
||||
$where,
|
||||
$order_by,
|
||||
$val
|
||||
);
|
||||
|
||||
// Everything is ok and data are inside
|
||||
if (hasData($tmpVorlage))
|
||||
{
|
||||
// If it's the first vorlage copy it
|
||||
if (!hasData($vorlage))
|
||||
{
|
||||
for ($j = 0; $j < count(getData($tmpVorlage)); $j++)
|
||||
{
|
||||
if (getData($tmpVorlage)[$j]->id != '')
|
||||
{
|
||||
array_push($vorlage->retval, getData($tmpVorlage)[$j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else // checks for duplicates, if it's not already present push it into the array getData($vorlage)
|
||||
{
|
||||
for ($j = 0; $j < count(getData($tmpVorlage)); $j++)
|
||||
{
|
||||
$found = false;
|
||||
$currentTmpVorlageData = null;
|
||||
|
||||
for ($i = 0; $i < count(getData($vorlage)); $i++)
|
||||
{
|
||||
$currentTmpVorlageData = getData($tmpVorlage)[$j];
|
||||
|
||||
if (getData($vorlage)[$i]->id == getData($tmpVorlage)[$j]->id
|
||||
&& getData($vorlage)[$i]->_pk == getData($tmpVorlage)[$j]->_pk
|
||||
&& getData($vorlage)[$i]->_ppk == getData($tmpVorlage)[$j]->_ppk
|
||||
&& getData($vorlage)[$i]->_jtpk == getData($tmpVorlage)[$j]->_jtpk)
|
||||
{
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$found && $currentTmpVorlageData->id != '')
|
||||
{
|
||||
array_push($vorlage->retval, $currentTmpVorlageData);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $vorlage;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ import cms from "./cms.js";
|
||||
import lehre from "./lehre.js";
|
||||
import addons from "./addons.js";
|
||||
import messages from "./messages.js";
|
||||
import vorlagen from "./vorlagen.js";
|
||||
|
||||
export default {
|
||||
search,
|
||||
@@ -54,5 +55,6 @@ export default {
|
||||
cms,
|
||||
lehre,
|
||||
addons,
|
||||
messages
|
||||
messages,
|
||||
vorlagen
|
||||
};
|
||||
|
||||
@@ -2,4 +2,33 @@ export default {
|
||||
getMessages(url, config, params){
|
||||
return this.$fhcApi.get('api/frontend/v1/messages/messages/getMessages/' + params.id + '/' + params.type);
|
||||
},
|
||||
getVorlagen(){
|
||||
return this.$fhcApi.get('api/frontend/v1/messages/messages/getVorlagen/');
|
||||
},
|
||||
getMsgVarsLoggedInUser(){
|
||||
return this.$fhcApi.get('api/frontend/v1/messages/messages/getMsgVarsLoggedInUser/');
|
||||
},
|
||||
getMessageVarsPerson(){
|
||||
return this.$fhcApi.get('api/frontend/v1/messages/messages/getMessageVarsPerson/');
|
||||
},
|
||||
getMsgVarsPrestudent(uid){
|
||||
return this.$fhcApi.get('api/frontend/v1/messages/messages/getMsgVarsPrestudent/' + uid);
|
||||
},
|
||||
getVorlagentext(vorlage_kurzbz){
|
||||
return this.$fhcApi.get('api/frontend/v1/messages/messages/getVorlagentext/' + vorlage_kurzbz);
|
||||
},
|
||||
getNameOfDefaultRecipient(params){
|
||||
return this.$fhcApi.get('api/frontend/v1/messages/messages/getNameOfDefaultRecipient/' + params.id + '/' + params.type_id);
|
||||
},
|
||||
sendMessage(form, id, data) {
|
||||
console.log("factory " + id);
|
||||
console.log(JSON.stringify(data));
|
||||
|
||||
return this.$fhcApi.post(form, 'api/frontend/v1/messages/messages/sendMessage/' + id,
|
||||
data
|
||||
);
|
||||
},
|
||||
deleteMessage(messageId){
|
||||
return this.$fhcApi.post('api/frontend/v1/messages/messages/deleteMessage/' + messageId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
export default {
|
||||
getVorlagen() {
|
||||
return this.$fhcApi.get('api/frontend/v1/vorlagen/vorlagen/getVorlagen/');
|
||||
},
|
||||
getVorlagenByLoggedInUser() {
|
||||
return this.$fhcApi.get('api/frontend/v1/vorlagen/vorlagen/getVorlagenByLoggedInUser/');
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,448 @@
|
||||
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';
|
||||
|
||||
|
||||
export default {
|
||||
components: {
|
||||
FormForm,
|
||||
FormInput,
|
||||
ListBox,
|
||||
DropdownComponent
|
||||
},
|
||||
props: {
|
||||
endpoint: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
typeId: String,
|
||||
id: {
|
||||
type: [Number, String],
|
||||
required: true
|
||||
},
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
|
||||
formData: {
|
||||
recipient: this.id,
|
||||
subject: null,
|
||||
body: null,
|
||||
vorlage_kurzbz: null,
|
||||
selectedValue: '',
|
||||
},
|
||||
statusNew: true,
|
||||
vorlagen: [],
|
||||
defaultRecipient: null,
|
||||
editor: null,
|
||||
isVisible: true,
|
||||
fieldsUser: [],
|
||||
fieldsPerson: [],
|
||||
fieldsPrestudent: [],
|
||||
selectedFieldPrestudent: null,
|
||||
selectedFieldUser: null,
|
||||
selectedFieldPerson: null,
|
||||
itemsPrestudent: [],
|
||||
itemsPerson: [],
|
||||
itemsUser: [],
|
||||
selectedFieldStudent: null,
|
||||
itemsStudent: [
|
||||
{ label: "Variable 1", value: "var1" },
|
||||
{ label: "Variable 2", value: "var2" },
|
||||
{ label: "Variable 3", value: "var3" }
|
||||
]
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initTinyMCE() {
|
||||
const vm = this;
|
||||
tinymce.init({
|
||||
target: this.$refs.editor.$refs.input, //Important: not selector: to enable multiple import of component
|
||||
//height: 800,
|
||||
//plugins: ['lists'],
|
||||
toolbar: 'styleselect | bold italic underline | alignleft aligncenter alignright alignjustify',
|
||||
style_formats: [
|
||||
{title: 'Blocks', block: 'div'},
|
||||
{title: 'Paragraph', block: 'p'},
|
||||
{title: 'Heading 1', block: 'h1'},
|
||||
{title: 'Heading 2', block: 'h2'},
|
||||
{title: 'Heading 3', block: 'h3'},
|
||||
{title: 'Heading 4', block: 'h4'},
|
||||
{title: 'Heading 5', block: 'h5'},
|
||||
{title: 'Heading 6', block: 'h6'},
|
||||
],
|
||||
autoresize_bottom_margin: 16,
|
||||
|
||||
setup: (editor) => {
|
||||
vm.editor = editor;
|
||||
|
||||
editor.on('input', () => {
|
||||
const newContent = editor.getContent();
|
||||
vm.formData.body = newContent;
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
updateText(value) {
|
||||
this.formData.body = value;
|
||||
},
|
||||
sendMessage(){
|
||||
//TODO(Manu) check default recipient(s)
|
||||
const data = new FormData();
|
||||
|
||||
data.append('data', JSON.stringify(this.formData));
|
||||
return this.$fhcApi.factory.messages.person.sendMessage(this.$refs.formVorlage, this.id, data)
|
||||
.then(response => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSent'));
|
||||
//this.hideModal('messageModal');
|
||||
this.resetForm();
|
||||
}).catch(this.$fhcAlert.handleSystemError)
|
||||
.finally(() => {
|
||||
//this.resetForm();
|
||||
//closeModal
|
||||
//closewindwo
|
||||
}
|
||||
);
|
||||
},
|
||||
getVorlagentext(vorlage_kurzbz){
|
||||
//console.log(typeof vorlage_kurzbz);
|
||||
return this.$fhcApi.factory.messages.person.getVorlagentext(vorlage_kurzbz)
|
||||
.then(response => {
|
||||
//this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSent'));
|
||||
//this.hideModal('messageModal');
|
||||
//this.resetForm();
|
||||
//TODO(Manu) CHECK
|
||||
this.formData.body = response.data;
|
||||
}).catch(this.$fhcAlert.handleSystemError)
|
||||
.finally(() => {
|
||||
//this.resetForm();
|
||||
//closeModal
|
||||
//closewindwo
|
||||
});
|
||||
},
|
||||
insertVariable(selectedItem){
|
||||
if (this.editor) {
|
||||
this.editor.insertContent(selectedItem.value + " ");
|
||||
} else {
|
||||
console.error("Editor instance is not available.");
|
||||
}
|
||||
},
|
||||
//TODO(Manu) refactor
|
||||
/* insertVariablePrestudent() {
|
||||
if (this.editor) {
|
||||
//const lastVariable = this.selectedFieldsPrestudent[this.selectedFieldsPrestudent.length - 1].value;
|
||||
const lastVariable = this.selectedFieldPrestudent.value;
|
||||
|
||||
//Use insertContent method
|
||||
this.editor.insertContent(lastVariable + " ");
|
||||
} else {
|
||||
console.error("Editor instance is not available.");
|
||||
}
|
||||
},*/
|
||||
/* insertVariablePrestudentByClick(selectedItem) {
|
||||
|
||||
if (selectedItem) {
|
||||
this.editor.insertContent(selectedItem.value + " ");
|
||||
console.log("Eingefügte Variable:", selectedItem);
|
||||
} else {
|
||||
console.warn("Keine Variable ausgewählt!");
|
||||
}
|
||||
},
|
||||
|
||||
insertVariablePerson() {
|
||||
if (this.editor) {
|
||||
//const lastVariable = this.selectedFieldsPrestudent[this.selectedFieldsPrestudent.length - 1].value;
|
||||
const lastVariable = this.selectedFieldPerson.value;
|
||||
|
||||
//Use insertContent method
|
||||
this.editor.insertContent(lastVariable + " ");
|
||||
} else {
|
||||
console.error("Editor instance is not available.");
|
||||
}
|
||||
},
|
||||
insertVariableUser() {
|
||||
if (this.editor) {
|
||||
console.log(this.selectedFieldUser.value);
|
||||
const lastVariable = this.selectedFieldUser.value;
|
||||
|
||||
//Multiple
|
||||
//const lastVariable = this.selectedFieldsPrestudent[this.selectedFieldsPrestudent.length - 1].value;
|
||||
|
||||
//Use insertContent method
|
||||
this.editor.insertContent(lastVariable + " ");
|
||||
this.selectedFieldUser = null;
|
||||
} else {
|
||||
console.error("Editor instance is not available.");
|
||||
}
|
||||
},
|
||||
insertVariableStudent(selectedItem) {
|
||||
if (selectedItem) {
|
||||
console.log("Eingefügte Variable:", selectedItem);
|
||||
this.editor.insertContent(selectedItem.value + " ");
|
||||
} else {
|
||||
console.warn("Keine Variable ausgewählt!");
|
||||
}
|
||||
},*/
|
||||
replyMessage(message_id){
|
||||
console.log("auf message " + message_id + " antworten");
|
||||
},
|
||||
resetForm(){
|
||||
this.formData = {
|
||||
vorlage_kurzbz: null,
|
||||
body: null,
|
||||
subject: null,
|
||||
};
|
||||
if (this.editor) {
|
||||
this.editor.setContent("");
|
||||
}
|
||||
this.$refs.dropdownComp.setValue(null);
|
||||
|
||||
},
|
||||
toggleDivNewMessage(){
|
||||
this.isVisible = !this.isVisible;
|
||||
},
|
||||
handleSelectedVorlage(vorlage_kurzbz) {
|
||||
if (typeof vorlage_kurzbz === "string") {
|
||||
this.getVorlagentext(vorlage_kurzbz);
|
||||
this.formData.subject = vorlage_kurzbz;
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
'formData.body': {
|
||||
handler(newVal) {
|
||||
const tinymcsVal = this.editor.getContent();
|
||||
|
||||
if (newVal && tinymcsVal != newVal) {
|
||||
//Inhalt des Editors aktualisieren
|
||||
this.editor.setContent(newVal);
|
||||
}
|
||||
}
|
||||
},
|
||||
'formData.vorlage_kurzbz': {
|
||||
handler(newVal){
|
||||
// console.log("Vorlage: " + newVal);
|
||||
|
||||
if (newVal && newVal != null) {
|
||||
this.formData.subject = newVal;
|
||||
return this.getVorlagentext(newVal);
|
||||
}
|
||||
//TODO(Manu) own function or retval to getVorlagentext
|
||||
//component VorlagenComponent
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
created(){
|
||||
|
||||
if(this.typeId == 'person_id'){
|
||||
this.$fhcApi.factory.messages.person.getMessageVarsPerson()
|
||||
.then(result => {
|
||||
this.fieldsPerson = result.data;
|
||||
this.itemsPerson = Object.entries(this.fieldsPerson).map(([key, value]) => ({
|
||||
label: value,
|
||||
value: '{' + value + '}'
|
||||
}));
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
}
|
||||
|
||||
if(this.typeId == 'uid') {
|
||||
this.$fhcApi.factory.messages.person.getMsgVarsPrestudent(this.id)
|
||||
.then(result => {
|
||||
this.fieldsPrestudent = result.data;
|
||||
const prestudent = this.fieldsPrestudent[0];
|
||||
//Just for testing with inserting values
|
||||
/* this.itemsPrestudent = Object.entries(prestudent).map(([key, value]) => ({
|
||||
label: key,
|
||||
value: value
|
||||
}));*/
|
||||
this.itemsPrestudent = Object.entries(prestudent).map(([key, value]) => ({
|
||||
label: key,
|
||||
value: '{' + key + '}'
|
||||
}));
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
}
|
||||
|
||||
this.$fhcApi.factory.messages.person.getMsgVarsLoggedInUser()
|
||||
.then(result => {
|
||||
this.fieldsUser = result.data;
|
||||
const user = this.fieldsUser;
|
||||
this.itemsUser = Object.entries(user).map(([key, value]) => ({
|
||||
label: value,
|
||||
value: '{' + value + '}'
|
||||
}));
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
|
||||
this.$fhcApi.factory.messages.person.getNameOfDefaultRecipient({
|
||||
id: this.id,
|
||||
type_id: this.typeId})
|
||||
.then(result => {
|
||||
this.defaultRecipient = result.data;
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
},
|
||||
async mounted() {
|
||||
this.initTinyMCE();
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.editor.destroy();
|
||||
},
|
||||
template: `
|
||||
<div class="messages-detail-newmessage">
|
||||
<h4>New Message</h4>
|
||||
|
||||
<div v-show="isVisible">
|
||||
<h4>New Message</h4>
|
||||
|
||||
{{typeId}} {{id}}
|
||||
|
||||
{{formData.subject}}
|
||||
{{formData.vorlage_kurzbz}}
|
||||
|
||||
<p v-if="formData.body">
|
||||
formData.body befüllt
|
||||
</p>
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-8">
|
||||
|
||||
<form-form class="row g-3 mt-2" ref="formMessage">
|
||||
|
||||
<div class="row mb-3">
|
||||
|
||||
<form-input
|
||||
type="text"
|
||||
name="recipient"
|
||||
:label="$p.t('messages/recipient')"
|
||||
v-model="defaultRecipient"
|
||||
disabled
|
||||
>
|
||||
</form-input>
|
||||
</div>
|
||||
|
||||
<div class="row mb-3">
|
||||
<form-input
|
||||
type="text"
|
||||
name="subject"
|
||||
:label="$p.t('global/betreff') + ' *'"
|
||||
v-model="formData.subject"
|
||||
>
|
||||
</form-input>
|
||||
</div>
|
||||
|
||||
<!--Tiny MCE-->
|
||||
<div class="row mb-3">
|
||||
<form-input
|
||||
ref="editor"
|
||||
:label="$p.t('global','nachricht') + ' *'"
|
||||
type="textarea"
|
||||
v-model="formData.body"
|
||||
name="text"
|
||||
rows="15"
|
||||
cols="75"
|
||||
>
|
||||
</form-input>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<DropdownComponent
|
||||
ref="dropdownComp"
|
||||
:label="$p.t('global/vorlage')"
|
||||
@change="handleSelectedVorlage"
|
||||
useLoggedInUserOe
|
||||
>
|
||||
</DropdownComponent>
|
||||
</div>
|
||||
|
||||
</form-form>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-4">
|
||||
|
||||
<div v-if="this.fieldsPrestudent.length > 0">
|
||||
<strong>Felder Prestudent</strong>
|
||||
<div class="border p-3 overflow-auto" style="height: 200px;">
|
||||
|
||||
<list-box
|
||||
v-model="selectedFieldPrestudent"
|
||||
:options="itemsPrestudent"
|
||||
optionLabel="label"
|
||||
>
|
||||
<template #option="slotProps">
|
||||
<div @dblclick="insertVariable(slotProps.option)">
|
||||
{{ slotProps.option.label }}
|
||||
</div>
|
||||
</template>
|
||||
</list-box>
|
||||
|
||||
</div>
|
||||
|
||||
<button class="m-3" @click="insertVariablePrestudent">Insert Variable</button>
|
||||
<p>{{selectedFieldPrestudent}}</p>
|
||||
|
||||
</div>
|
||||
|
||||
<div v-if="this.fieldsPerson.length > 0">
|
||||
<strong>Felder Person</strong>
|
||||
<div class="border p-3 overflow-auto" style="height: 200px;">
|
||||
|
||||
<list-box
|
||||
v-model="selectedFieldPerson"
|
||||
:options="itemsPerson"
|
||||
optionLabel="label"
|
||||
>
|
||||
<template #option="slotProps">
|
||||
<div @dblclick="insertVariable(slotProps.option)">
|
||||
{{ slotProps.option.label }}
|
||||
</div>
|
||||
</template>
|
||||
</list-box>
|
||||
|
||||
</div>
|
||||
<button class="m-3" @click="insertVariablePerson">Insert Variable</button>
|
||||
<p>{{selectedFieldPerson}}</p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<strong>Meine Felder</strong>
|
||||
<div class="border p-3 overflow-auto" style="height: 200px;">
|
||||
|
||||
<list-box
|
||||
v-model="selectedFieldUser"
|
||||
:options="itemsUser"
|
||||
optionLabel="label"
|
||||
>
|
||||
<template #option="slotProps">
|
||||
<div @dblclick="insertVariable(slotProps.option)">
|
||||
{{ slotProps.option.label }}
|
||||
</div>
|
||||
</template>
|
||||
</list-box>
|
||||
|
||||
</div>
|
||||
<button class="m-3" @click="insertVariableUser">Insert Variable</button>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="d-grid gap-2 d-md-flex justify-content-md-end">
|
||||
|
||||
<button class="btn btn-secondary" @click="resetForm">Reset All</button>
|
||||
|
||||
<button v-if="statusNew" type="button" class="btn btn-primary" @click="sendMessage()">{{$p.t('ui', 'nachrichtSenden')}}</button>
|
||||
<button v-else type="button" class="btn btn-primary" @click="replyMessage(formData.message_id)">{{$p.t('global', 'reply')}}</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<button type="button" class="btn btn-warning" @click="toggleDivNewMessage()">Toggle NewMessage</button>
|
||||
<hr>
|
||||
</div>
|
||||
`
|
||||
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import {CoreFilterCmpt} from "../../filter/Filter.js";
|
||||
import FormForm from '../../Form/Form.js';
|
||||
//import FormInput from '../../Form/Input.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
CoreFilterCmpt,
|
||||
FormForm,
|
||||
// FormInput
|
||||
},
|
||||
inject: {
|
||||
cisRoot: {
|
||||
from: 'cisRoot'
|
||||
},
|
||||
},
|
||||
props: {
|
||||
endpoint: {
|
||||
@@ -121,7 +124,7 @@ export default {
|
||||
button.addEventListener(
|
||||
'click',
|
||||
() =>
|
||||
this.deleteMessage(cell.getData().message_id)
|
||||
this.actionDeleteMessage(cell.getData().message_id)
|
||||
);
|
||||
container.append(button);
|
||||
|
||||
@@ -197,7 +200,6 @@ export default {
|
||||
const selectedMessage = row.getData().message_id;
|
||||
const body = row.getData().body;
|
||||
this.previewBody = body;
|
||||
console.log(selectedMessage);
|
||||
}
|
||||
},
|
||||
],
|
||||
@@ -209,11 +211,45 @@ export default {
|
||||
reply(message_id){
|
||||
console.log("in reply " + message_id);
|
||||
},
|
||||
actionDeleteMessage(message_id){
|
||||
this.$fhcAlert
|
||||
.confirmDelete()
|
||||
.then(result => result
|
||||
? message_id
|
||||
: Promise.reject({handled: true}))
|
||||
.then(this.deleteMessage)
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
},
|
||||
deleteMessage(message_id){
|
||||
console.log("deleteMessage " + message_id);
|
||||
// console.log("deleteMessage " + message_id);
|
||||
return this.$fhcApi.factory.messages.person.deleteMessage(message_id)
|
||||
.then(response => {
|
||||
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete'));
|
||||
}).catch(this.$fhcAlert.handleSystemError)
|
||||
.finally(()=> {
|
||||
window.scrollTo(0, 0);
|
||||
this.reload();
|
||||
});
|
||||
},
|
||||
actionNewMessage(){
|
||||
console.log("action new message");
|
||||
//console.log("action new message");
|
||||
if (this.openMode == "window") {
|
||||
console.log("openInNewWindow")
|
||||
const linkWindowNewMessage = this.cisRoot + '/public/js/components/Messages/Details/NewMessage.js';
|
||||
window.open(linkWindowNewMessage, '_blank');
|
||||
}
|
||||
else if (this.openmode == "modal"){
|
||||
console.log("open with bootstrap Modal");
|
||||
}
|
||||
else if (this.openmode == "showDiv"){
|
||||
console.log("open div in NewMessage.js");
|
||||
//emit to NewMessage.js
|
||||
}
|
||||
else
|
||||
console.log("no valid openmode: yet to be developed");
|
||||
},
|
||||
reload() {
|
||||
this.$refs.table.reloadTable();
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
@@ -238,8 +274,9 @@ export default {
|
||||
},
|
||||
template: `
|
||||
<div class="messages-detail-table">
|
||||
<p>endpoint: {{endpoint}}</p>
|
||||
<p>{{messageLayout}}</p>
|
||||
<!-- <p>endpoint: {{endpoint}}</p>-->
|
||||
<!-- {{cisRoot}}-->
|
||||
<!-- <p>{{messageLayout}}</p>-->
|
||||
|
||||
<!-- {{statusText[0] }}
|
||||
<hr>
|
||||
|
||||
@@ -34,10 +34,12 @@ export default {
|
||||
},
|
||||
template: `
|
||||
<div class="core-messages h-100 pb-3">
|
||||
<p>endpoint Messages.js: {{endpoint}}</p>
|
||||
<!-- <p>endpoint Messages.js: {{endpoint}}</p>-->
|
||||
<div v-if="showNew">
|
||||
<NewMessage
|
||||
|
||||
:type-id="typeId"
|
||||
:id="id"
|
||||
:endpoint="endpoint"
|
||||
>
|
||||
</NewMessage>
|
||||
</div>
|
||||
|
||||
@@ -12,10 +12,11 @@ export default {
|
||||
<core-messages
|
||||
ref="formc"
|
||||
endpoint="$fhcApi.factory.messages.person"
|
||||
type-id="person_id"
|
||||
:id="modelValue.person_id"
|
||||
messageLayout="listTableTop"
|
||||
type-id="uid"
|
||||
:id="modelValue.uid"
|
||||
messageLayout="twoColumnsTableLeft"
|
||||
show-table
|
||||
show-new
|
||||
>
|
||||
</core-messages>
|
||||
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
import {CoreFilterCmpt} from "../filter/Filter.js";
|
||||
import FormForm from '../Form/Form';
|
||||
import FormInput from '../Form/Input.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
FormForm,
|
||||
FormInput,
|
||||
CoreFilterCmpt
|
||||
},
|
||||
props: {
|
||||
label: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
modelValue: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
/* oe: {
|
||||
type: Array,
|
||||
required: false
|
||||
}, */
|
||||
isAdmin: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
},
|
||||
useLoggedInUserOe: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
vorlagen: [],
|
||||
selectedValue: null,
|
||||
vorlagenOe: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
updateValue() {
|
||||
// console.log("in COMPO: update: " + this.selectedValue + ' jetzt ' + 'InfocenterMailErgaenzungsprfEng');
|
||||
this.$emit('change', this.selectedValue);
|
||||
//this.$emit('change', this.selectedValue); // Emit-Event beim Ändern des Wertes
|
||||
},
|
||||
setValue(value) {
|
||||
this.selectedValue = value;
|
||||
},
|
||||
},
|
||||
created() {
|
||||
|
||||
if(this.isAdmin) {
|
||||
this.$fhcApi.factory.vorlagen.getVorlagen()
|
||||
.then(result => {
|
||||
this.vorlagen = result.data;
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
}
|
||||
|
||||
if(this.useLoggedInUserOe){
|
||||
this.$fhcApi.factory.vorlagen.getVorlagenByLoggedInUser()
|
||||
.then(result => {
|
||||
console.log(this.vorlagenOe);
|
||||
this.vorlagenOe = result.data;
|
||||
})
|
||||
.catch(this.$fhcAlert.handleSystemError);
|
||||
}
|
||||
},
|
||||
template: `
|
||||
<div class="core-vorlagen-dropdown">
|
||||
<div v-if="isAdmin" class="col-sm-8 pt-3">
|
||||
<form-input
|
||||
ref="dropdown"
|
||||
type="select"
|
||||
:label="label"
|
||||
@change="updateValue"
|
||||
v-model="selectedValue"
|
||||
>
|
||||
<option
|
||||
v-for="vorlage in vorlagen"
|
||||
:key="vorlage.vorlage_kurzbz"
|
||||
:value="vorlage.vorlage_kurzbz"
|
||||
>
|
||||
{{vorlage.bezeichnung}}
|
||||
</option>
|
||||
</form-input>
|
||||
</div>
|
||||
|
||||
<div v-if="useLoggedInUserOe" class="col-sm-8 pt-3">
|
||||
<form-input
|
||||
ref="dropdown"
|
||||
type="select"
|
||||
:label="label"
|
||||
@change="updateValue"
|
||||
v-model="selectedValue"
|
||||
>
|
||||
<option
|
||||
v-for="vorlage in vorlagenOe"
|
||||
:key="vorlage.id"
|
||||
:value="vorlage.id"
|
||||
>
|
||||
{{vorlage.description}}
|
||||
</option>
|
||||
</form-input>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
`,
|
||||
}
|
||||
@@ -37519,6 +37519,26 @@ array(
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'app' => 'core',
|
||||
'category' => 'ui',
|
||||
'phrase' => 'successSent',
|
||||
'insertvon' => 'system',
|
||||
'phrases' => array(
|
||||
array(
|
||||
'sprache' => 'German',
|
||||
'text' => 'Nachricht erfolgreich versandt',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
),
|
||||
array(
|
||||
'sprache' => 'English',
|
||||
'text' => 'Message sent successfully',
|
||||
'description' => '',
|
||||
'insertvon' => 'system'
|
||||
)
|
||||
)
|
||||
),
|
||||
/////////// FHC4 Phrases Messages END ///////////
|
||||
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user