Adaptions

- bugfix personFields
- validation for sendmessage for openmode inSamePage, newTab, window
- restyling div for enable scrolling in openmode InSamePage
This commit is contained in:
ma0068
2025-03-13 09:05:53 +01:00
parent a0ce635c7e
commit 7b4f0f9dff
7 changed files with 37 additions and 67 deletions
@@ -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);
+3 -4
View File
@@ -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);
}
@@ -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 {
</div>
<div class="row">
<DropdownComponent
<dropdown-component
ref="dropdownComp"
:label="$p.t('global/vorlage')"
@change="handleSelectedVorlage"
useLoggedInUserOe
>
</DropdownComponent>
</dropdown-component>
</div>
</form-form>
@@ -528,7 +516,5 @@ export default {
</template>
</bs-modal>
</div>
`,
}
@@ -104,7 +104,6 @@ export default {
this.formData.body = value;
},
sendMessage() {
//TODO(Manu) check default recipient(s)
const data = new FormData();
const params = {
@@ -118,42 +117,34 @@ export default {
};
data.append('data', JSON.stringify(merged));
//this.uid is important for existing sendFunction
//this.uid is necessary for existing sendFunction
return this.$fhcApi.factory.messages.person.sendMessage(
this.$refs.formMessage,
this.uid,
data)
.then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSent'));
//this.hideModal('messageModal');
this.hideTemplate();
this.resetForm();
this.messageSent = true;
}).catch(this.$fhcAlert.handleSystemError)
.finally(() => {
//this.resetForm();
//closeModal
//closewindwo
this.messageSent = true;
//TODO(Manu) hier route definieren? ist kein child sondern mit route aufgerufen
//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"){
this.$emit('reloadTable');
}
}
);
},
getVorlagentext(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
});
},
getPreviewText(id, typeId){
@@ -168,8 +159,6 @@ export default {
}).catch(this.$fhcAlert.handleSystemError)
.finally(() => {
//this.resetForm();
//closeModal
//closewindwo
});
},
insertVariable(selectedItem){
@@ -275,9 +264,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);
@@ -345,9 +335,6 @@ export default {
template: `
<div class="messages-detail-newmessage-newdiv">
<!--passt für inSamePage-->
<!-- <div class="overflow-auto" style="max-height: 500px; border: 1px solid #ccc;">-->
<!--new page-->
<div v-if="!messageSent" class="overflow-auto m-3">
<h4>{{ $p.t('messages', 'neueNachricht') }}</h4>
@@ -356,7 +343,6 @@ export default {
<div class="col-sm-8">
<form-form class="row g-3 mt-2" ref="formMessage">
<!--TODO(Manu) ist eigentlich ein Array, hier werden alle Einträge angegeben als String-->
<div class="row mb-3">
<form-input
+1 -9
View File
@@ -1,18 +1,10 @@
import TableMessages from "./Details/TableMessages.js";
//import NewMessage from "./Details/NewMessage.js";
import FormOnly from "./Details/NewMessage/NewDiv.js";
import FhcApi from "../../../../public/js/plugin/FhcApi.js";
import Phrasen from "../../../../public/js/plugin/Phrasen.js";
//TODO(Manu) Only if openMode == modal
import MessageModal from "../Messages/Details/NewMessage/Modal.js";
export default {
components: {
TableMessages,
// NewMessage,
FormOnly,
FhcApi,
Phrasen,
MessageModal
},
inject: {
@@ -145,7 +137,7 @@ export default {
</message-modal>
<!--in same page-->
<div v-if="isVisibleDiv">
<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"
@@ -10,7 +10,8 @@ export default {
template: `
<div class="stv-details-messages h-100 pb-3 overflow-hidden">
<!--TODO(Manu) Delete Testdata-->
<!-- <h3>Test Dominik Schneider</h3>
<core-messages
ref="formc"
@@ -28,9 +29,19 @@ export default {
ref="formc"
endpoint="$fhcApi.factory.messages.person"
type-id="mitarbeiter_uid"
id="ma0130"
id="ma0158"
messageLayout="twoColumnsTableLeft"
show-table
open-mode="newTab"
>
</core-messages>-->
<!-- <h3>Test no table</h3>
<core-messages
ref="form2"
endpoint="$fhcApi.factory.messages.person"
type-id="prestudent_id"
:id="modelValue.prestudent_id"
open-mode="modal"
>
</core-messages>-->
@@ -23,11 +23,11 @@ export default {
}, */
isAdmin: {
type: Boolean,
required: true
required: false
},
useLoggedInUserOe: {
type: Boolean,
required: true
required: false
}
},
data() {