mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-18 23:42:17 +00:00
fixes some data handling errors in controller functions
This commit is contained in:
@@ -206,22 +206,22 @@ class ProfilUpdate extends Auth_Controller
|
||||
|
||||
//? loops over all updateRequests from a user to validate if the new request is valid
|
||||
$res = $this->ProfilUpdateModel->getProfilUpdatesWhere(["uid"=>$this->uid]);
|
||||
$res = hasData($res) ? getData($res) : null;
|
||||
|
||||
if($res){
|
||||
$pending_changes = array_filter($res, function($element) {
|
||||
return $element->status == 'pending';
|
||||
});
|
||||
foreach($pending_changes as $update_request){
|
||||
$existing_change = json_decode($update_request->requested_change);
|
||||
$existing_change = $update_request->requested_change;
|
||||
|
||||
//? the user can add as many new kontakt/adresse as he likes
|
||||
if( !isset($payload->add) && property_exists($existing_change,$identifier) && property_exists($payload,$identifier) && $existing_change->$identifier == $payload->$identifier){
|
||||
|
||||
if( !isset($payload->add) && property_exists($existing_change,$identifier) && property_exists($payload,$identifier) && $existing_change->$identifier == $payload->$identifier){
|
||||
//? the kontakt_id / adresse_id of a change has to be unique
|
||||
echo json_encode(error("cannot change the same resource twice"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
elseif(!$identifier && $update_request->topic == $json->topic ){
|
||||
//? if it is not a delete or add request than the topic has to be unique
|
||||
echo json_encode(error("A request to change " . $json->topic . " is already open"));
|
||||
|
||||
@@ -51,6 +51,7 @@ class Profil_update_model extends DB_Model
|
||||
|
||||
//? queries the tbl_profil_updates without permissions of the user
|
||||
public function getProfilUpdatesWhere($whereClause){
|
||||
|
||||
$res = $this->loadWhere($whereClause);
|
||||
if(isError($res)){
|
||||
return error("Could not load public.tbl_profil_update with whereClause");
|
||||
|
||||
@@ -149,7 +149,7 @@ export default {
|
||||
Vue.$fhcapi.ProfilUpdate.selectProfilRequest().then((res)=>{
|
||||
|
||||
if(!res.error){
|
||||
this.data.profilUpdates = res.data.retval?.length ? res.data.retval.sort(this.sortProfilUpdates) : null ;
|
||||
this.data.profilUpdates = res.data?.length ? res.data.sort(this.sortProfilUpdates) : null ;
|
||||
}
|
||||
});
|
||||
},
|
||||
@@ -164,14 +164,16 @@ export default {
|
||||
Vue.$fhcapi.ProfilUpdate.selectProfilRequest()
|
||||
.then((res) =>{
|
||||
if(!res.error){
|
||||
this.data.profilUpdates = res.data.retval;
|
||||
this.data.profilUpdates = res.data;
|
||||
this.data.profilUpdates.sort(this.sortProfilUpdates);
|
||||
|
||||
}else{
|
||||
alert("Error when fetching profile updates: " +res.data.retval);
|
||||
console.log("Error when fetching profile updates: " +res.data);
|
||||
}
|
||||
})
|
||||
.catch(err=>alert(err));
|
||||
.catch(err=>{
|
||||
console.log(err);
|
||||
});
|
||||
}
|
||||
}).catch((e) => {
|
||||
// Wenn der User das Modal abbricht ohne Änderungen
|
||||
|
||||
Reference in New Issue
Block a user