makes the send button in the profil update popup disabled instead of not showing it

This commit is contained in:
SimonGschnell
2024-02-08 13:47:03 +01:00
parent 89bc5a5d9d
commit cda13ac705
6 changed files with 42 additions and 32 deletions
+5 -16
View File
@@ -27,7 +27,7 @@ class Profil extends Auth_Controller
'insertFile' => ['student/anrechnung_beantragen:r', 'user:r'],
'getProfilRequestFiles' => ['student/anrechnung_beantragen:r', 'user:r'],
'deleteOldVersionFiles' => ['student/anrechnung_beantragen:r', 'user:r'],
'test' => ['student/anrechnung_beantragen:r', 'user:r'],
]);
@@ -63,17 +63,6 @@ class Profil extends Auth_Controller
* @return void
*/
public function test(){
// Loads permission lib
$this->load->library('PermissionLib');
$mit_daten =$this->permissionlib->isBerechtigt('mitarbeiter/stammdaten','suid');
var_dump($mit_daten);
$stud_daten = $this->permissionlib->isBerechtigt('student/stammdaten','suid');
var_dump($stud_daten);
}
public function index()
{
$this->load->view('Cis/Profil');
@@ -172,7 +161,7 @@ class Profil extends Auth_Controller
if(isset($uid)) $whereClause['uid'] = $uid;
if(isset($id)) $whereClause['id'] = $id;
$res= $this->ProfilUpdateModel->getProfilUpdate($whereClause);
$res= $this->ProfilUpdateModel->getProfilUpdatesWhere($whereClause);
echo json_encode($res);
@@ -201,7 +190,7 @@ class Profil extends Auth_Controller
$data = ["topic"=>$json->topic,"uid" => $this->uid, "name"=>getData($name), "requested_change" => json_encode($payload), "insertamum" => "NOW()", "insertvon"=>$this->uid,"status"=>"pending" ];
//? loops over all updateRequests from a user to validate if the new request is valid
$res = $this->ProfilUpdateModel->loadWhere(["uid"=>$this->uid]);
$res = $this->ProfilUpdateModel->getProfilUpdatesWhere(["uid"=>$this->uid]);
$res = hasData($res) ? getData($res) : null;
if($res){
@@ -659,7 +648,7 @@ class Profil extends Auth_Controller
//? querying if the user has profil update requests
$profilUpdates = $this->ProfilUpdateModel->getProfilUpdate(['uid'=>$this->uid]);
$profilUpdates = $this->ProfilUpdateModel->getProfilUpdatesWhere(['uid'=>$this->uid]);
if(isError($profilUpdates)){
//error handling
}else{
@@ -865,7 +854,7 @@ class Profil extends Auth_Controller
}
//? querying if the user has profil update requests
$profilUpdates = $this->ProfilUpdateModel->getProfilUpdate(['uid'=>$this->uid]);
$profilUpdates = $this->ProfilUpdateModel->getProfilUpdatesWhere(['uid'=>$this->uid]);
if(isError($profilUpdates)){
//error handling
}else{
+3 -3
View File
@@ -12,7 +12,7 @@ class ProfilUpdate extends Auth_Controller
public function __construct(){
parent::__construct([
'index' => ['student/stammdaten:r','mitarbeiter/stammdaten:r'],
'getProfilUpdates' => ['student/stammdaten:r','mitarbeiter/stammdaten:r'],
'getProfilUpdateWithPermission' => ['student/stammdaten:r','mitarbeiter/stammdaten:r'],
'acceptProfilRequest'=>['student/stammdaten:rw','mitarbeiter/stammdaten:rw'],
'denyProfilRequest'=>['student/stammdaten:rw','mitarbeiter/stammdaten:rw'],
'show'=>['student/stammdaten:r','mitarbeiter/stammdaten:r'],
@@ -45,10 +45,10 @@ class ProfilUpdate extends Auth_Controller
echo json_encode($res);
}
public function getProfilUpdates($status=null){
public function getProfilUpdateWithPermission($status=null){
$res = $this->ProfilUpdateModel->getProfilUpdate(isset($status)?['status'=>$status]:null);
$res = $this->ProfilUpdateModel->getProfilUpdateWithPermission(isset($status)?['status'=>$status]:null);
echo json_encode($res);
}
@@ -48,13 +48,30 @@ class Profil_update_model extends DB_Model
return json_decode($res->requested_change)->files?:[];
}
public function getProfilUpdatesWhere($whereClause){
$res = $this->loadWhere($whereClause);
if(isError($res)){
return error("Could not load public.tbl_profil_update with whereClause");
}
$res = hasData($res) ? getData($res) : [];
if($res){
foreach($res as $request){
$this->formatProfilRequest($request);
}
}
return $res;
}
/**
*
* getProfilUpdate
* returns a profil update with id
* returns all profil updates if id is set to null
*/
public function getProfilUpdate($whereClause=null){
public function getProfilUpdateWithPermission($whereClause=null){
$studentBerechtigung = $this->permissionlib->isBerechtigt('student/stammdaten','s');
$mitarbeiterBerechtigung = $this->permissionlib->isBerechtigt('mitarbeiter/stammdaten','s');
@@ -103,14 +120,8 @@ class Profil_update_model extends DB_Model
if($res){
foreach($res as $update){
$update->requested_change = json_decode($update->requested_change);
$update->insertamum = !is_null($update->insertamum)?date_create($update->insertamum)->format('d.m.Y'):null;
$update->updateamum = !is_null($update->updateamum)?date_create($update->updateamum)->format('d.m.Y'):null;
$update->status_timestamp = !is_null($update->status_timestamp)?date_create($update->status_timestamp)->format('d.m.Y'):null;
foreach($res as $request){
$this->formatProfilRequest($request);
}
}
@@ -118,4 +129,11 @@ class Profil_update_model extends DB_Model
}
private function formatProfilRequest($request){
$request->requested_change = json_decode($request->requested_change);
$request->insertamum = !is_null($request->insertamum)?date_create($request->insertamum)->format('d.m.Y'):null;
$request->updateamum = !is_null($request->updateamum)?date_create($request->updateamum)->format('d.m.Y'):null;
$request->status_timestamp = !is_null($request->status_timestamp)?date_create($request->status_timestamp)->format('d.m.Y'):null;
}
}
+2 -3
View File
@@ -38,11 +38,10 @@ const app = Vue.createApp({
ajaxURLGenerator: (url, config, params) => {
//? this function needs to be an array function in order to access the this properties of the Vue component
console.log("showAll printed here:", this.showAll);
if (this.showAll) {
return url + "getProfilUpdates";
return url + "getProfilUpdateWithPermission";
} else {
return url + "getProfilUpdates/pending";
return url + "getProfilUpdateWithPermission/pending";
}
},
ajaxResponse: function (url, params, response) {
@@ -43,6 +43,7 @@ export default {
methods: {
async submitProfilChange() {
//? check if data is valid before making a request
if (this.topic && this.profilUpdate) {
if (this.profilUpdate.files) {
const fileIDs = await this.uploadFiles(this.profilUpdate.files);
@@ -179,7 +180,7 @@ export default {
<template v-slot:footer>
<button class="btn btn-outline-danger " @click="hide">Abbrechen</button>
<button v-if="profilUpdate" @click="submitProfilChange" role="button" class="btn btn-primary">Senden</button>
<button :disabled="!profilUpdate" @click="submitProfilChange" role="button" class="btn btn-primary">Senden</button>
</template>
<!-- end of optional footer -->
</bs-modal>`,
@@ -158,6 +158,9 @@ export default {
},
created(){
//? sorts the profil Updates: pending -> accepted -> rejected
this.data.profilUpdates?.sort(this.sortProfilUpdates);
},
mounted() {