now editAdressen shows a warning message if a new adresse is marked as zustelladresse

This commit is contained in:
SimonGschnell
2024-02-13 15:30:23 +01:00
parent 409221434a
commit 5ee241d914
4 changed files with 69 additions and 22 deletions
+33 -20
View File
@@ -22,6 +22,7 @@ class Profil extends Auth_Controller
'View' => ['student/anrechnung_beantragen:r', 'user:r'],
'isMitarbeiter' => ['student/anrechnung_beantragen:r', 'user:r'],
'isStudent' => ['student/anrechnung_beantragen:r', 'user:r'],
'getZustellAdresse' => ['student/anrechnung_beantragen:r', 'user:r'],
]);
@@ -70,6 +71,36 @@ class Profil extends Auth_Controller
}
//? foreward declaration of the function isStudent in Student_model.php
public function isStudent($uid){
$result = $this->StudentModel->isStudent($uid);
if(!isSuccess($result)){
show_error("error when calling Student_model function isStudent with uid ".$uid);
}
$result = getData($result);
echo json_encode($result);
}
//? foreward declaration of the function isMitarbeiter in Mitarbeiter_model.php
public function isMitarbeiter($uid){
$result = $this->MitarbeiterModel->isMitarbeiter($uid);
if(!isSuccess($result)){
show_error("error when calling Mitarbeiter_model function isMitarbeiter with uid ".$uid);
}
$result = getData($result);
echo json_encode($result);
}
public function getZustellAdresse(){
$this->AdresseModel->addSelect(["adresse_id"]);
$adressen_res = $this->AdresseModel->loadWhere(['person_id'=>$this->pid, 'zustelladresse'=>true]);
$adressen_res = hasData($adressen_res) ? getData($adressen_res): null;
$adressen_res = array_map(function($item){
return $item->adresse_id;
},$adressen_res);
echo json_encode($adressen_res);
}
private function viewMitarbeiterProfil($uid)
{
@@ -557,7 +588,7 @@ class Profil extends Auth_Controller
private function getAdressenInfo($pid){
$adresse_res = null;
if (
isSuccess($adresse_res = $this->AdresseModel->addSelect(["adresse_id","strasse", "tbl_adressentyp.bezeichnung as typ", "plz", "ort","zustelladresse"])) &&
isSuccess($adresse_res = $this->AdresseModel->addOrder("zustelladresse", "DESC")) &&
isSuccess($adresse_res = $this->AdresseModel->addJoin("tbl_adressentyp", "typ=adressentyp_kurzbz"))
@@ -613,24 +644,6 @@ class Profil extends Auth_Controller
return $zutrittskarte_ausgegebenam;
}
//? foreward declaration of the function isStudent in Student_model.php
public function isStudent($uid){
$result = $this->StudentModel->isStudent($uid);
if(!isSuccess($result)){
show_error("error when calling Student_model function isStudent with uid ".$uid);
}
$result = getData($result);
echo json_encode($result);
}
//? foreward declaration of the function isMitarbeiter in Mitarbeiter_model.php
public function isMitarbeiter($uid){
$result = $this->MitarbeiterModel->isMitarbeiter($uid);
if(!isSuccess($result)){
show_error("error when calling Mitarbeiter_model function isMitarbeiter with uid ".$uid);
}
$result = getData($result);
echo json_encode($result);
}
}
+7
View File
@@ -36,4 +36,11 @@ export default {
`cis.php/Cis/Profil/isMitarbeiter/${uid}`;
return axios.get(url);
},
getZustellAdresse: function () {
const url =
FHC_JS_DATA_STORAGE_OBJECT.app_root +
`cis.php/Cis/Profil/getZustellAdresse`;
return axios.get(url);
},
};
@@ -71,7 +71,7 @@ export default {
typ: null,
plz: null,
ort: null,
zustelladresse:null,
zustelladresse:false,
}
: {
//? add flag
@@ -9,6 +9,7 @@ export default {
data(){
return{
originalValue:null,
zustellAdressenCount:null,
}
},
methods:{
@@ -24,6 +25,20 @@ export default {
},
},
computed:{
showZustellAdressenWarning: function(){
if(this.zustellAdressenCount){
if(this.zustellAdressenCount.includes(this.data.adresse_id)){
//? if the adresse was already saved
return false;
}
return this.zustellAdressenCount > 0 && this.data.zustelladresse;
}
//? if this.zustellAdressenCount is still not set by the api call and is still null
return false;
},
ortLayoutClasses: function(){
return this.showKontaktTyp?[
'col-12',
@@ -45,13 +60,25 @@ export default {
},
},
created(){
Vue.$fhcapi.UserData.getZustellAdresse().then(res => {
this.zustellAdressenCount = res.data;
})
this.originalValue = JSON.stringify(this.data);
},
template:`
<div class="gy-3 row justify-content-center align-items-center">
<div v-if="showZustellAdressenWarning" class="col-12 ">
<div class="card bg-danger mx-2">
<div class="card-body text-white ">
<span>!Achtung: Eine deiner Adressen ist bereits als Zustelladresse gespeichert, sind sie sicher, dass sie die aktuelle Adresse stattdessen als Zustelladresse speichern wollen?</span>
</div>
</div>
</div>
<div class="col-12 ">