diff --git a/application/controllers/Cis/ProfilUpdate.php b/application/controllers/Cis/ProfilUpdate.php index 98d9e3224..1ea04716e 100755 --- a/application/controllers/Cis/ProfilUpdate.php +++ b/application/controllers/Cis/ProfilUpdate.php @@ -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"]]); diff --git a/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js b/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js index 8650f2b55..76a2e2b6a 100755 --- a/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js +++ b/public/js/components/Cis/ProfilUpdate/AcceptDenyUpdate.js @@ -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 {