diff --git a/application/config/stv.php b/application/config/stv.php index 84b148362..0e18be220 100644 --- a/application/config/stv.php +++ b/application/config/stv.php @@ -119,6 +119,7 @@ $config['student_tab_order'] = [ $config['students_tab_order'] = [ 'banking', 'status', + 'messages', 'groups', 'finalexam', 'combinePeople', diff --git a/application/controllers/NeueNachricht.php b/application/controllers/NeueNachricht.php index 9b61b78ef..b0ff5c554 100644 --- a/application/controllers/NeueNachricht.php +++ b/application/controllers/NeueNachricht.php @@ -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 ]); } } diff --git a/application/controllers/api/frontend/v1/messages/Messages.php b/application/controllers/api/frontend/v1/messages/Messages.php index 355fe79a4..714492203 100644 --- a/application/controllers/api/frontend/v1/messages/Messages.php +++ b/application/controllers/api/frontend/v1/messages/Messages.php @@ -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') diff --git a/application/controllers/api/frontend/v1/stv/Aufnahmetermine.php b/application/controllers/api/frontend/v1/stv/Aufnahmetermine.php index 86b739c90..26033908d 100644 --- a/application/controllers/api/frontend/v1/stv/Aufnahmetermine.php +++ b/application/controllers/api/frontend/v1/stv/Aufnahmetermine.php @@ -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'] diff --git a/application/controllers/api/frontend/v1/stv/Config.php b/application/controllers/api/frontend/v1/stv/Config.php index 3bf48bf5b..8a2f86b5f 100644 --- a/application/controllers/api/frontend/v1/stv/Config.php +++ b/application/controllers/api/frontend/v1/stv/Config.php @@ -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; }); diff --git a/application/controllers/api/frontend/v1/stv/GemeinsameStudien.php b/application/controllers/api/frontend/v1/stv/GemeinsameStudien.php index 97dad48fd..8f3d6419a 100644 --- a/application/controllers/api/frontend/v1/stv/GemeinsameStudien.php +++ b/application/controllers/api/frontend/v1/stv/GemeinsameStudien.php @@ -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); diff --git a/application/controllers/api/frontend/v1/stv/Gruppen.php b/application/controllers/api/frontend/v1/stv/Gruppen.php index c45165b41..b10cfb328 100644 --- a/application/controllers/api/frontend/v1/stv/Gruppen.php +++ b/application/controllers/api/frontend/v1/stv/Gruppen.php @@ -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); diff --git a/application/views/Nachrichten.php b/application/views/Nachrichten.php index cf34bfd53..0d0e8e707 100644 --- a/application/views/Nachrichten.php +++ b/application/views/Nachrichten.php @@ -40,6 +40,10 @@ $configArray = [ cis-root="= CIS_ROOT; ?>" :permissions="= htmlspecialchars(json_encode($permissions)); ?>" :config="= htmlspecialchars(json_encode($configArray)); ?>" + + :id ="= htmlspecialchars(json_encode($ids)); ?>" + type-id ="= htmlspecialchars($typeid); ?>" + > diff --git a/public/js/api/factory/messages/messages.js b/public/js/api/factory/messages/messages.js index c6d4b67b6..c3542308a 100644 --- a/public/js/api/factory/messages/messages.js +++ b/public/js/api/factory/messages/messages.js @@ -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 }; }, diff --git a/public/js/apps/Nachrichten.js b/public/js/apps/Nachrichten.js index 84b9ddee5..ab9baf084 100644 --- a/public/js/apps/Nachrichten.js +++ b/public/js/apps/Nachrichten.js @@ -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 }, ] }); diff --git a/public/js/components/Messages/Details/NewMessage/Modal.js b/public/js/components/Messages/Details/NewMessage/Modal.js index ce9235617..d173bc7d0 100644 --- a/public/js/components/Messages/Details/NewMessage/Modal.js +++ b/public/js/components/Messages/Details/NewMessage/Modal.js @@ -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 > @@ -502,17 +474,17 @@ export default { >