diff --git a/application/controllers/api/frontend/v1/messages/Messages.php b/application/controllers/api/frontend/v1/messages/Messages.php index 7834ba5f7..101a47185 100644 --- a/application/controllers/api/frontend/v1/messages/Messages.php +++ b/application/controllers/api/frontend/v1/messages/Messages.php @@ -120,20 +120,16 @@ class Messages extends FHCAPI_Controller public function getMessageVarsPerson($id, $typeId) { $person_id = ($typeId == 'mitarbeiter_uid') ? $this->_getPersonId($id, $typeId) : $id; - $result = $this->MessageModel->getMessageVarsPerson($person_id); - + $result = $this->MessageModel->getMsgVarsDataByPersonId($person_id); $data = $this->getDataOrTerminateWithError($result); - $this->terminateWithSuccess($data); } public function getMsgVarsPrestudent($id, $typeId) { $prestudent_id = ($typeId == 'uid') ? $this->_getPrestudentIdFromUid($id) : $id; - $result = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id); - $data = $this->getDataOrTerminateWithError($result); $this->terminateWithSuccess($data); diff --git a/public/js/api/messages/person.js b/public/js/api/messages/person.js index 6fa39c6ba..9bfae6f38 100644 --- a/public/js/api/messages/person.js +++ b/public/js/api/messages/person.js @@ -34,15 +34,14 @@ export default { getReplyData(messageId){ return this.$fhcApi.get('api/frontend/v1/messages/messages/getReplyData/' + messageId); }, - sendMessage(form, id, data) { - console.log("id" + id); + sendMessageFromModalContext(form, id, data) { return this.$fhcApi.post(form,'api/frontend/v1/messages/messages/sendMessage/' + id, data); }, -/* sendMessage(id, data) { + sendMessage(id, data) { return this.$fhcApi.post('api/frontend/v1/messages/messages/sendMessage/' + id, data); - },*/ + }, deleteMessage(messageId){ return this.$fhcApi.post('api/frontend/v1/messages/messages/deleteMessage/' + messageId); } diff --git a/public/js/components/Messages/Details/NewMessage/Modal.js b/public/js/components/Messages/Details/NewMessage/Modal.js index c6d3e1210..03345e9d4 100644 --- a/public/js/components/Messages/Details/NewMessage/Modal.js +++ b/public/js/components/Messages/Details/NewMessage/Modal.js @@ -92,7 +92,6 @@ export default { this.formData.body = value; }, sendMessage() { - //TODO(Manu) check default recipient(s) const data = new FormData(); const params = { id: this.id, @@ -104,13 +103,10 @@ export default { }; data.append('data', JSON.stringify(merged)); - return this.$fhcApi.factory.messages.person.sendMessage( + return this.$fhcApi.factory.messages.person.sendMessageFromModalContext( this.$refs.formMessage, this.uid, data) -/* return this.$fhcApi.factory.messages.person.sendMessage( - this.uid, - data)*/ .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSent')); this.hideModal('modalNewMessage'); @@ -125,13 +121,8 @@ export default { ); }, 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('modalNewMessage'); - //this.resetForm(); - //TODO(Manu) CHECK this.formData.body = response.data; }).catch(this.$fhcAlert.handleSystemError) .finally(() => { @@ -234,8 +225,6 @@ export default { }, 'formData.vorlage_kurzbz': { handler(newVal){ - // console.log("Vorlage: " + newVal); - if (newVal && newVal != null) { this.formData.subject = newVal; return this.getVorlagentext(newVal); @@ -274,9 +263,10 @@ export default { this.$fhcApi.factory.messages.person.getMessageVarsPerson(params) .then(result => { this.fieldsPerson = result.data; - this.itemsPerson = Object.entries(this.fieldsPerson).map(([key, value]) => ({ - label: value, - value: '{' + value + '}' + const person = this.fieldsPerson[0]; + this.itemsPerson = Object.entries(person).map(([key, value]) => ({ + label: key.toLowerCase(), + value: '{' + key.toLowerCase() + '}' })); }) .catch(this.$fhcAlert.handleSystemError); @@ -315,11 +305,9 @@ export default { type_id: this.typeId}) .then(result => { this.defaultRecipient = result.data; - // console.log("check " + this.uid + "|" + this.defaultRecipient); this.recipientsArray.push({ 'uid': this.uid, 'details': this.defaultRecipient}); - // console.log(JSON.stringify(this.recipientsArray)); }) .catch(this.$fhcAlert.handleSystemError); @@ -399,13 +387,13 @@ export default {