phrasen fix and bug where profilUpdates were only sorted when accepting the request and not denying

This commit is contained in:
SimonGschnell
2024-04-12 09:39:28 +02:00
parent 86504fd663
commit ea9bd93e73
4 changed files with 88 additions and 40 deletions
+12 -6
View File
@@ -415,7 +415,7 @@ class ProfilUpdate extends Auth_Controller
if ($res) {
$pending_changes = array_filter($res, function ($element) {
return $element->status == self::$STATUS_PENDING ?: "Pending";
return $element->status == (self::$STATUS_PENDING ?: "Pending");
});
foreach ($pending_changes as $update_request) {
@@ -565,7 +565,7 @@ class ProfilUpdate extends Auth_Controller
$requested_change['adresse_id'] = $insertID;
$update_res = $this->updateRequestedChange($id, $requested_change);
if (isError($update_res)) {
echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_address_error', [$insertID, $id])));
echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_address_error', [$insertID])));
return;
}
}
@@ -577,7 +577,7 @@ class ProfilUpdate extends Auth_Controller
$requested_change['kontakt_id'] = $insertID;
$update_res = $this->updateRequestedChange($id, $requested_change);
if (isError($update_res)) {
echo json_encode(error("was not able to add kontakt_id " . $insertID . " to profilRequest " . $id));
echo json_encode(error($this->p->t('profilUpdate', 'profilUpdate_kontakt_error', [$insertID])));
return;
}
}
@@ -586,15 +586,21 @@ class ProfilUpdate extends Auth_Controller
} else {
switch ($topic) {
// mapping phrasen to database columns to make the update with the correct column names
case $this->p->t('profilUpdate', 'title'):
case self::$TOPICS['Titel']:
$topic = "titelpre";
break;
case $this->p->t('profilUpdate', 'postnomen'):
case self::$TOPICS['Postnomen']:
$topic = "titelpost";
break;
case $this->p->t('profilUpdate', 'vorname'):
case self::$TOPICS['Vorname']:
$topic = "vorname";
break;
case self::$TOPICS['Nachname']:
$topic = "nachname";
break;
default:
show_error($this->p->t('profilUpdate', 'profilUpdate_topic_error',[$topic]));
return;
}
$result = $this->PersonModel->update($personID, [$topic => $requested_change["value"]]);
@@ -38,7 +38,6 @@ export default {
return {
data: this.value,
loading: false,
profilUpdateStates: {},
result: false,
info: null,
files: null,
@@ -60,10 +59,14 @@ export default {
`/Cis/ProfilUpdate/show/${dms_id}`
);
},
acceptRequest: function () {
handleRequest: function (type) {
this.loading = true;
this.setLoading(true);
Vue.$fhcapi.ProfilUpdate.acceptProfilRequest(this.data)
Vue.$fhcapi.ProfilUpdate[
type.toLowerCase() == "accept"
? "acceptProfilRequest"
: "denyProfilRequest"
](this.data)
.then((res) => {
this.setLoading(false);
this.loading = false;
@@ -76,22 +79,8 @@ export default {
this.hide();
});
},
denyRequest: async function () {
this.loading = true;
this.setLoading(true);
Vue.$fhcapi.ProfilUpdate.denyProfilRequest(this.data)
.then((res) => {
this.setLoading(false);
this.loading = false;
this.result = true;
})
.catch((e) => {
Alert.popup(Vue.h("div", { innerHTML: e.response.data }));
});
this.hide();
},
},
computed: {
getComponentView: function () {
if (this.data.topic.toLowerCase().includes("kontakt")) {
@@ -104,20 +93,14 @@ export default {
},
},
created() {
// fetching the different ProfilUpdateStates from the db
Vue.$fhcapi.ProfilUpdate.getStatus()
.then((result) => {
this.profilUpdateStates = result.data;
})
.catch((err) => {
console.error(err);
// only fetching the profilUpdate Attachemnts if the profilUpdate actually has attachments
if (this.value.attachment_id) {
Vue.$fhcapi.ProfilUpdate.getProfilRequestFiles(
this.data.profil_update_id
).then((res) => {
this.files = res.data;
});
Vue.$fhcapi.ProfilUpdate.getProfilRequestFiles(
this.data.profil_update_id
).then((res) => {
this.files = res.data;
});
}
},
mounted() {
this.modal = this.$refs.modalContainer.modal;
@@ -224,8 +207,8 @@ export default {
<div class="d-flex flex-row gap-2">
<input class="form-control " v-model="data.status_message" />
<button @click="acceptRequest" class="text-nowrap btn btn-success">{{$p.t('profilUpdate','accept')}} <i class="fa fa-check"></i></button>
<button @click="denyRequest" class="text-nowrap btn btn-danger">{{$p.t('profilUpdate','deny')}} <i class="fa fa-xmark"></i></button>
<button @click="handleRequest('accept')" class="text-nowrap btn btn-success">{{$p.t('profilUpdate','accept')}} <i class="fa fa-check"></i></button>
<button @click="handleRequest('deny')" class="text-nowrap btn btn-danger">{{$p.t('profilUpdate','deny')}} <i class="fa fa-xmark"></i></button>
</div>
</div>
@@ -263,7 +263,6 @@ export default {
},
hideAcceptDenyModal: function () {
//? checks the AcceptDenyModal component property result, if the user made a successful request or not
if (this.$refs.AcceptDenyModal.result) {
//? refetches the data, if any request was denied or accepted
//* setData will call the ajaxURL again to refresh the data
+60
View File
@@ -25780,6 +25780,66 @@ array(
)
)
),
array(
'app' => 'core',
'category' => 'profilUpdate',
'phrase' => 'profilUpdate_topic_error',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Ein Fehler ist aufgetreten, das Topic "{0}" existiert nicht',
'description' => 'Fehler der auftritt wenn es das Topic nicht in der Datenbank gibt',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'An error occurred, the topic "{0}" is not known',
'description' => 'error that occurrs when the used topic is not present in the database',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'profilUpdate',
'phrase' => 'profilUpdate_address_error',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Ein Fehler ist aufgetreten, Es war nicht möglich die Adresse mit ID {0} in der Datenbank anzulegen',
'description' => 'Fehler der auftritt wenn es nicht möglich war eine neue Adresse anzulegen',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'An error occurred, it wasn\'t possible to add new address with ID {0} to the database',
'description' => 'error that occurrs when it wasn\'t possible to add new address in db',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'profilUpdate',
'phrase' => 'profilUpdate_kontakt_error',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Ein Fehler ist aufgetreten, Es war nicht möglich den Kontakt mit ID {0} in der Datenbank anzulegen',
'description' => 'Fehler der auftritt wenn es nicht möglich war einen neuen Kontakt anzulegen',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'An error occurred, it wasn\'t possible to add new contact with ID {0} to the database',
'description' => 'error that occurrs when it wasn\'t possible to add new contact in db',
'insertvon' => 'system'
)
)
),