Merge branch 'feature-69438/FHC4_Studierendenverwaltung/FeedbackPunkte' into demo-cis40

This commit is contained in:
Harald Bamberger
2025-12-02 09:46:25 +01:00
15 changed files with 506 additions and 307 deletions
+1
View File
@@ -119,6 +119,7 @@ $config['student_tab_order'] = [
$config['students_tab_order'] = [
'banking',
'status',
'messages',
'groups',
'finalexam',
'combinePeople',
+8 -1
View File
@@ -20,11 +20,18 @@ class NeueNachricht extends Auth_Controller
*/
public function _remap()
{
$typeid = $this->input->post('typeid');
$ids = ($this->input->post('ids') && strpos($this->input->post('ids'), ','))
? explode(',', $this->input->post('ids'))
: $this->input->post('ids');
//now working
$this->load->view('Nachrichten', [
'permissions' => [
'assistenz_schreibrechte' => $this->permissionlib->isBerechtigt('assistenz','suid'),
]
],
'ids' => $ids,
'typeid' => $typeid
]);
}
}
@@ -14,6 +14,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 +22,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
@@ -101,22 +103,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,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,16 +167,46 @@ class Messages extends FHCAPI_Controller
$name = current($data);
$this->terminateWithSuccess($name->vorname . " " . $name->nachname );
}*/
public function getNameOfDefaultRecipients($type_id)
{
$ids = $this->input->post('ids');
if(!is_array($ids)) {
$ids = array($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 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 +244,57 @@ 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);
foreach ($ids as $id)
{
$receiversPersonId = $typeId == "person_id" ? $id : $this->_getPersonId($id, $typeId);
$this->terminateWithSuccess($result);
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("type_id " . $typeId . " not valid", 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']))
{
@@ -235,30 +304,49 @@ 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']);
if(!is_array($ids))
{
$ids = array($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 +431,7 @@ class Messages extends FHCAPI_Controller
$this->terminateWithSuccess($person->person_id);
}
public function getUid($id, $typeId)
public function getUid($typeId)
{
if (!$typeId)
{
@@ -387,6 +475,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')
@@ -298,7 +298,7 @@ class Aufnahmetermine extends FHCAPI_Controller
$reihungstestangetreten =
(isset($formData['reihungstestangetreten']) && !empty($formData['reihungstestangetreten']))
? $formData['reihungstestangetreten']
: null;
: false;
$aufnahmegruppe_kurzbz =
(isset($formData['aufnahmegruppe_kurzbz']) && !empty($formData['aufnahmegruppe_kurzbz']))
? $formData['aufnahmegruppe_kurzbz']
@@ -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;
});
@@ -83,7 +83,7 @@ class GemeinsameStudien extends FHCAPI_Controller
{
$this->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
$this->StudiensemesterModel->addOrder('studienjahr_kurzbz', 'DESC');
$this->StudiensemesterModel->addOrder('start', 'DESC');
$result = $this->StudiensemesterModel->load();
$data = $this->getDataOrTerminateWithError($result);
$this->terminateWithSuccess($data);
@@ -147,7 +147,8 @@ class Gruppen extends FHCAPI_Controller
'lehre' => true,
'sichtbar' => true,
'aktiv' => true,
'direktinskription' => false
'direktinskription' => false,
'generiert' => false
]);
$data = $this->getDataOrTerminateWithError($result);
+4
View File
@@ -40,6 +40,10 @@ $configArray = [
cis-root="<?= CIS_ROOT; ?>"
:permissions="<?= htmlspecialchars(json_encode($permissions)); ?>"
:config="<?= htmlspecialchars(json_encode($configArray)); ?>"
<?php if($ids !== null && $typeid !== null) { ?>
:id ="<?= htmlspecialchars(json_encode($ids)); ?>"
type-id ="<?= htmlspecialchars($typeid); ?>"
<?php } ?>
>
</router-view>
</div>
+31 -20
View File
@@ -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,30 @@ export default {
url: 'api/frontend/v1/messages/messages/getPersonId/' + params.id + '/' + params.type_id
};
},
getUid(userParams){
/* getUid(ids, type_id){
return {
method: 'get',
url: 'api/frontend/v1/messages/messages/getUid/' + userParams.id + '/' + userParams.type_id
method: 'post',
url: 'api/frontend/v1/messages/messages/getUids/' + type_id,
params: {ids}
};
},
},*/
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 +91,24 @@ 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
};
},
sendMessage(id, params) {
}, */
sendMessageFromModalContext(type_id, params) {
return {
method: 'post',
url: 'api/frontend/v1/messages/messages/sendMessage/' + id,
url: 'api/frontend/v1/messages/messages/sendMessage/' + type_id,
params
};
},
sendMessage(type_id, params) {
return {
method: 'post',
url: 'api/frontend/v1/messages/messages/sendMessage/' + type_id,
params
};
},
+4 -3
View File
@@ -1,14 +1,15 @@
import NewMessage from "../components/Messages/Details/NewMessage/NewDiv.js";
import Phrasen from "../plugin/Phrasen.js";
import Phrasen from "../plugins/Phrasen.js";
const ciPath = FHC_JS_DATA_STORAGE_OBJECT.app_root.replace(/(https:|)(^|\/\/)(.*?\/)/g, '') + FHC_JS_DATA_STORAGE_OBJECT.ci_router;
const router = VueRouter.createRouter({
history: VueRouter.createWebHistory(),
routes: [
{ path: `/${ciPath}/NeueNachricht/:id/:typeId`, component: NewMessage },
{ path: `/${ciPath}/NeueNachricht/:id/:typeId/:messageId`, component: NewMessage },
{ path: `/${ciPath}/NeueNachricht`, component: NewMessage, props: true },
{ path: `/${ciPath}/NeueNachricht/:id/:typeId`, component: NewMessage, props: true },
{ path: `/${ciPath}/NeueNachricht/:id/:typeId/:messageId`, component: NewMessage, props: true },
]
});
@@ -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: [],
@@ -56,7 +58,7 @@ export default {
previewText: null,
previewBody: "",
replyData: null,
uid: null,
}
},
methods: {
@@ -111,28 +113,22 @@ 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(this.endpoint.sendMessageFromModalContext(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');
}
}
);
},
@@ -146,14 +142,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,18 +198,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();
},
@@ -260,15 +245,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(this.endpoint.getMessageVarsPerson(this.id, this.typeId))
.then(result => {
this.fieldsPerson = result.data;
const person = this.fieldsPerson[0];
@@ -281,12 +260,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];
@@ -311,14 +286,11 @@ export default {
.catch(this.$fhcAlert.handleSystemError);
this.$api
.call(this.endpoint.getNameOfDefaultRecipient({
id: this.id,
type_id: this.typeId}))
.call(this.endpoint.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);
@@ -381,7 +353,7 @@ export default {
type="text"
name="recipient"
:label="$p.t('messages/recipient')"
v-model="defaultRecipient"
v-model="defaultRecipientString"
disabled
>
</form-input>
@@ -502,17 +474,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,23 @@ 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 +44,8 @@ export default {
vorlagen: [],
recipientsArray: [],
defaultRecipient: null,
defaultRecipients: [],
defaultRecipientString: null,
editor: null,
isVisible: false,
fieldsUser: [],
@@ -67,8 +60,7 @@ export default {
previewText: null,
previewBody: "",
replyData: null,
uid: null,
messageSent: false
messageSent: false,
}
},
methods: {
@@ -106,19 +98,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,37 +110,34 @@ 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');
}
this.resetForm();
}
);
},
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(){
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();
});
},
insertVariable(selectedItem){
@@ -177,11 +158,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;
@@ -202,23 +185,11 @@ export default {
if (this.openMode == "inSamePage")
this.isVisible = true;
},
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
};
this.$api
.call(this.endpoint.getUid(params))
.then(result => {
this.uid = result.data;
})
.catch(this.$fhcAlert.handleSystemError);
}
},
watch: {
'formData.body': {
@@ -242,38 +213,45 @@ export default {
},
},
created(){
this.getUid(this.id, this.typeId);
const missingparamsmsgs = [];
if(!this.typeId)
{
// TODO(bh) Phrase
missingparamsmsgs.push('Fehlender oder ungültiger Parameter Empfänger-Id-Typ.');
}
if (['person_id', 'mitarbeiter_uid'].includes(this.typeId)){
const params = {
id: this.id,
type_id: this.typeId
};
if(!this.id || this.id.length < 1)
{
// TODO(bh) Phrase
missingparamsmsgs.push('Fehlender oder ungültiger Parameter Empfänger-Id(s).');
}
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 +261,7 @@ export default {
}
this.$api
.call(this.endpoint.getMsgVarsLoggedInUser())
.call(ApiMessages.getMsgVarsLoggedInUser())
.then(result => {
this.fieldsUser = result.data;
const user = this.fieldsUser;
@@ -295,21 +273,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 != null) {
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;
@@ -343,7 +318,7 @@ export default {
type="text"
name="recipient"
:label="$p.t('messages/recipient')"
v-model="defaultRecipient"
v-model="defaultRecipientString"
disabled
>
</form-input>
@@ -472,18 +447,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>
@@ -19,7 +19,7 @@ export default {
},
typeId: String,
id: {
type: [Number, String],
type: Array,
required: true
},
messageLayout: String,
@@ -38,12 +38,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 +56,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 +86,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 +103,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);
}
},
{
@@ -347,7 +372,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
+46 -21
View File
@@ -31,7 +31,7 @@ export default {
}
},
id: {
type: [Number, String],
type: Array,
required: true
},
showTable: Boolean,
@@ -65,15 +65,20 @@ export default {
}
},
methods: {
getControllerUrl() {
return FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/NeueNachricht';
},
reloadTable(){
this.$refs.templateTableMessage.reload();
},
handleMessage(id, typeId, messageId){
this.messageId = messageId;
if (this.openMode == "window") {
//this.$refs['newMsgForm'].submit();
this.openInNewWindow(id, typeId, messageId);
}
else if (this.openMode == "newTab"){
//this.$refs['newMsgForm'].submit();
this.openInNewTab(id, typeId, messageId);
}
else if (this.openMode == "modal"){
@@ -85,36 +90,48 @@ export default {
else
console.log("no valid openMode");
},
openInNewTab(id, typeId, messageId= null){
openInNewTab(id, typeId, messageId=null){
if(id.length > 1)
{
this.$refs['newMsgForm'].submit();
return;
}
let path = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router;
let path = this.getControllerUrl();
if (messageId){
path += "/NeueNachricht/" + id + "/" + typeId + "/" + messageId;
path += "/" + encodeURIComponent(id) + "/" + encodeURIComponent(typeId) + "/" + encodeURIComponent(messageId);
}
else {
path += "/NeueNachricht/" + id + "/" + typeId;
path += "/" + encodeURIComponent(id) + "/" + encodeURIComponent(typeId);
}
const newTab = window.open(path, "_blank");
},
openInNewWindow(id, typeId, messageId){
let path = FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router;
if (messageId){
path += "/NeueNachricht/" + id + "/" + typeId + "/" + messageId;
}
else {
path += "/NeueNachricht/" + id + "/" + typeId;
}
const width = Math.round(window.innerWidth * 0.75);
const height = Math.round(window.innerHeight * 0.75);
const left = Math.round((window.innerWidth - width) / 2);
const top = Math.round((window.innerHeight - height) / 2);
if(id.length > 1)
{
const newWindow = window.open('', "NewMsgWindow", `width=${width},height=${height},left=${left},top=${top}`);
this.$refs['newMsgForm'].submit();
return;
}
let path = this.getControllerUrl();
if (messageId){
path += "/" + encodeURIComponent(id) + "/" + encodeURIComponent(typeId) + "/" + encodeURIComponent(messageId);
}
else {
path += "/" + encodeURIComponent(id) + "/" + encodeURIComponent(typeId);
}
const newWindow = window.open(path, "_blank", `width=${width},height=${height},left=${left},top=${top}`);
},
resetMessageId(){
@@ -124,6 +141,15 @@ export default {
},
template: `
<div class="core-messages h-100 pb-3">
<!-- TODO(bh) set target _self for debugging post but _blank for newTab -->
<form ref="newMsgForm"
method="post"
:action="getControllerUrl()"
:target="(openMode === 'window') ? 'NewMsgWindow' : '_blank'"
>
<input type="hidden" name="typeid" :value="typeId">
<input type="hidden" name="ids" :value="id">
</form>
<message-modal
ref="modalMsg"
@@ -141,18 +167,17 @@ export default {
<div v-if="isVisibleDiv" class="overflow-auto m-3" style="max-height: 500px; border: 1px solid #ccc;">
<form-only
ref="templateNewMessage"
:temp-type-id="typeId"
:temp-id="id"
:temp-message-id="messageId"
:type-id="typeId"
:id="id"
:message-id="messageId"
:endpoint="endpoint"
:openMode="openMode"
@reloadTable="reloadTable"
>
</form-only>
</div>
<div v-if="showTable">
<div v-if="showTable && id.length==1">
<table-messages
ref="templateTableMessage"
:type-id="typeId"
@@ -14,26 +14,49 @@ 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>
`
};