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)}}
+ + diff --git a/public/js/components/Cis/Profil/EditProfilSelect.js b/public/js/components/Cis/Profil/EditProfilSelect.js index 1323455c7..f438100d7 100644 --- a/public/js/components/Cis/Profil/EditProfilSelect.js +++ b/public/js/components/Cis/Profil/EditProfilSelect.js @@ -34,6 +34,7 @@ export default { ['update:profilUpdate']:null, ['update:topic']:null, ['update:breadcrumb']:null, + submit:null, select:null, }, @@ -46,6 +47,16 @@ export default { }, methods: { + + deleteItem: function(item){ + let data = item.data; + data.delete = true; + this.$emit('update:profilUpdate',item.data); + //? updates the topic when a Kontakt or an Address should be deleted + this.$emit('update:topic',item.data.kontakt?"Delete Kontakte":"Delete Adressen"); + this.$emit('submit'); + }, + profilUpdateEmit: function(event){ console.log(event); //? passes the updated profil information to the parent component @@ -92,11 +103,15 @@ export default {
-
diff --git a/public/js/components/Cis/Profil/MitarbeiterProfil.js b/public/js/components/Cis/Profil/MitarbeiterProfil.js index 062e9280e..e31d817f9 100644 --- a/public/js/components/Cis/Profil/MitarbeiterProfil.js +++ b/public/js/components/Cis/Profil/MitarbeiterProfil.js @@ -325,6 +325,9 @@ export default { }; + + console.log(JSON.stringify(this.data.editData,null,2)); + }, mounted() { diff --git a/public/js/components/Cis/Profil/ProfilComponents.js b/public/js/components/Cis/Profil/ProfilComponents.js index 6e8fdabce..7234044c9 100644 --- a/public/js/components/Cis/Profil/ProfilComponents.js +++ b/public/js/components/Cis/Profil/ProfilComponents.js @@ -10,7 +10,7 @@ const Adresse = { }, template:` -
+
@@ -166,6 +166,9 @@ const Kontakt = {
+ + +
@@ -344,13 +347,14 @@ const FetchProfilUpdates = { }, template:` +
{{JSON.stringify(data,null,2)}}
- + @@ -358,7 +362,8 @@ const FetchProfilUpdates = { - + + diff --git a/system/dbupdate_3.4/25999_C4_ma0594.php b/system/dbupdate_3.4/25999_C4_ma0594.php index eea45c0f1..4d694c4c2 100644 --- a/system/dbupdate_3.4/25999_C4_ma0594.php +++ b/system/dbupdate_3.4/25999_C4_ma0594.php @@ -19,7 +19,7 @@ CACHE 1; ALTER TABLE public.tbl_cis_profil_update ALTER COLUMN profil_update_id SET DEFAULT nextval('public.tbl_cis_profil_update_id_seq'); - ALTER TABLE public.tbl_cis_profil_update ADD CONSTRAINT cis_profil_udpate_topic_uid_unique UNIQUE (uid,topic); + --ALTER TABLE public.tbl_cis_profil_update ADD CONSTRAINT cis_profil_udpate_topic_uid_unique UNIQUE (uid,topic); GRANT SELECT, INSERT, UPDATE, DELETE ON public.tbl_cis_profil_update TO vilesci; GRANT SELECT, INSERT, UPDATE, DELETE ON public.tbl_cis_profil_update TO web;
Topic Date of RequestBearbeitenBearbeiten Löschen
{{item.topic}} {{item.change_timestamp}}{{item.requested_change.adr_typ?item.requested_change.adr_typ:item.requested_change.kontakt}}