diff --git a/application/controllers/Cis/Profil.php b/application/controllers/Cis/Profil.php
index a8c89f631..f0efb51e3 100644
--- a/application/controllers/Cis/Profil.php
+++ b/application/controllers/Cis/Profil.php
@@ -97,16 +97,33 @@ class Profil extends Auth_Controller
$res = $this->ProfilChangeModel->loadWhere(["uid"=>$this->uid]);
$res = hasData($res) ? getData($res) : null;
+
//? checks if the user already made a request to change a topic
- //! which is an constraint added to the public.tbl_cis_profil_update table
- if($res){
+ //* Exception: a user can have multiple delete or add requests
+
foreach($res as $update_request){
- if($update_request->topic == $json->topic && $update_request->uid == $this->uid){
+
+ //TODO: Check if a change request already exists before adding the delete request
+
+ if(property_exists($json->payload, "delete")){
+
+ if(json_decode($update_request->requested_change) == $json->payload){
+ //? Check if the delete request for this resource already exists before adding the new delete request
+
+ echo json_encode(error("this delete request already exists"));
+ return;
+ }
+ }elseif(property_exists($json->payload, "add")){
+
+ }elseif($update_request->topic == $json->topic && $update_request->uid == $this->uid){
echo json_encode(error("uid and topic combination exists already"));
return;
}
- }}
+ }
+
+
+
$insert_res = $this->ProfilChangeModel->insert($data);
diff --git a/public/js/components/Cis/Profil/EditProfil.js b/public/js/components/Cis/Profil/EditProfil.js
index 978ab1f67..4f2022b0f 100644
--- a/public/js/components/Cis/Profil/EditProfil.js
+++ b/public/js/components/Cis/Profil/EditProfil.js
@@ -38,17 +38,15 @@ export default {
},
methods: {
-
-
submitProfilChange(){
if(this.topic && this.profilUpdate){
//? inserts new row in public.tbl_cis_profil_update
- if(this.editData.update){
-
- Vue.$fhcapi.UserData.updateProfilRequest(this.topic,this.profilUpdate).then((res)=>{
-
+ //* calls the update api call if an update field is present in the data that was passed to the module
+ Vue.$fhcapi.UserData[this.editData.update?'updateProfilRequest':'insertProfilRequest'](this.topic,this.profilUpdate).then((res)=>{
+ console.log("topic",this.topic);
+ console.log("profilUpdate",this.profilUpdate);
if(res.data.error == 0){
this.result= true;
this.hide();
@@ -60,26 +58,6 @@ export default {
}
});
-
- }else{
-
- Vue.$fhcapi.UserData.insertProfilRequest(this.topic,this.profilUpdate).then((res)=>{
-
-
- if(res.data.error == 0){
- this.result= true;
- this.hide();
- Alert.popup("Ihre Anfrage wurde erfolgreich gesendet. Bitte warten Sie, während sich das Team um Ihre Anfrage kümmert.");
- }else{
- this.result= false;
- this.hide();
- Alert.popup("Ein Fehler ist aufgetreten: "+ JSON.stringify(res.data.retval));
- }
-
- });
-
- }
-
}
},
},
@@ -116,7 +94,10 @@ export default {
-
{{JSON.stringify(profilUpdate,null,2)}}
+ {{JSON.stringify(topic,null,2)}}
+
+ {{JSON.stringify(data,null,2)}}
| Topic | Date of Request | -Bearbeiten | +Bearbeiten | Löschen | |
|---|---|---|---|---|---|
| {{item.topic}} | {{item.change_timestamp}} | -+ | {{item.requested_change.adr_typ?item.requested_change.adr_typ:item.requested_change.kontakt}} | +