mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-15 22:12:16 +00:00
instead of calculating how many zustelladressen or zustellkontakte a user has in the backend, it is calculated in the client side to prevent an extra api call
This commit is contained in:
@@ -23,6 +23,8 @@ class ProfilUpdate extends Auth_Controller
|
||||
'selectProfilRequest' => ['student/anrechnung_beantragen:r', 'user:r'],
|
||||
'insertFile' => ['student/anrechnung_beantragen:r', 'user:r'],
|
||||
'getProfilRequestFiles' => ['student/anrechnung_beantragen:r', 'user:r'],
|
||||
'handleDupplicateZustellKontakte' => ['student/anrechnung_beantragen:r', 'user:r'],
|
||||
|
||||
|
||||
]);
|
||||
|
||||
@@ -332,6 +334,7 @@ class ProfilUpdate extends Auth_Controller
|
||||
|
||||
|
||||
public function acceptProfilRequest(){
|
||||
|
||||
|
||||
$_POST = json_decode($this->input->raw_input_stream,true);
|
||||
$id = $this->input->post('profil_update_id',true);
|
||||
@@ -455,6 +458,8 @@ class ProfilUpdate extends Auth_Controller
|
||||
$requested_change['insertamum'] = "NOW()";
|
||||
$requested_change['insertvon'] = getAuthUID();
|
||||
$insertID = $this->KontaktModel->insert($requested_change);
|
||||
//TODO: check if the user has two zustelladressen or zustellkontakte
|
||||
$this->handleDupplicateZustellKontakte($requested_change['zustellung']);
|
||||
|
||||
}
|
||||
//! DELETE
|
||||
@@ -485,6 +490,7 @@ class ProfilUpdate extends Auth_Controller
|
||||
|
||||
//! ADD
|
||||
if(array_key_exists('add',$requested_change) && $requested_change['add']){
|
||||
|
||||
//? removes add flag
|
||||
unset($requested_change['add']);
|
||||
$requested_change['insertamum']="NOW()";
|
||||
@@ -492,6 +498,7 @@ class ProfilUpdate extends Auth_Controller
|
||||
$requested_change['person_id'] = $personID;
|
||||
//TODO: zustelladresse, heimatadresse, rechnungsadresse und nation werden nicht beachtet
|
||||
$insertID = $this->AdresseModel->insert($requested_change);
|
||||
|
||||
}
|
||||
//! DELETE
|
||||
elseif(array_key_exists('delete',$requested_change) && $requested_change['delete']){
|
||||
@@ -505,4 +512,29 @@ class ProfilUpdate extends Auth_Controller
|
||||
}
|
||||
return isset($insertID)? $insertID : null;
|
||||
}
|
||||
|
||||
|
||||
public function handleDupplicateZustellKontakte($zustellung){
|
||||
|
||||
$this->PersonModel->addSelect("public.tbl_kontakt.kontakt_id");
|
||||
$this->PersonModel->addJoin("public.tbl_kontakt","public.tbl_kontakt.person_id = public.tbl_person.person_id");
|
||||
$zustellKontakteCount = $this->PersonModel->loadWhere(["public.tbl_person.person_id"=>$this->pid, "zustellung"=>TRUE]);
|
||||
if(!isSuccess($zustellKontakteCount)){
|
||||
return error("error in the query");
|
||||
}
|
||||
$zustellKontakteCount = hasData($zustellKontakteCount) ? getData($zustellKontakteCount) : null;
|
||||
|
||||
|
||||
if($zustellung && count($zustellKontakteCount)>0){
|
||||
echo $zustellKontakteCount[0];
|
||||
}
|
||||
}
|
||||
|
||||
private function getZustelladressenCount(){
|
||||
|
||||
}
|
||||
|
||||
public function getZustellkontakteCount(){
|
||||
|
||||
}
|
||||
}
|
||||
@@ -57,8 +57,9 @@ const app = Vue.createApp({
|
||||
//? use function syntax for provide so that we can access `this`
|
||||
provide() {
|
||||
return {
|
||||
|
||||
|
||||
|
||||
getZustellkontakteCount: this.zustellKontakteCount,
|
||||
getZustelladressenCount: this.zustellAdressenCount,
|
||||
collapseFunction: (e, column)=> {
|
||||
|
||||
//* check if property doesn't exist already and add it to the reactive this properties
|
||||
@@ -121,7 +122,36 @@ const app = Vue.createApp({
|
||||
}
|
||||
|
||||
},
|
||||
methods:{
|
||||
zustellAdressenCount(){
|
||||
if(!this.data || !this.data.adressen){
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.data.adressen.filter(adresse => {
|
||||
return adresse.zustelladresse;
|
||||
}).map(adr => {
|
||||
|
||||
return adr.adresse_id;
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
zustellKontakteCount(){
|
||||
if(!this.data || !this.data.kontakte){
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.data.kontakte.filter(kontakt => {
|
||||
return kontakt.zustellung;
|
||||
}).map(kon =>{
|
||||
return kon.kontakt_id;
|
||||
});
|
||||
},
|
||||
},
|
||||
computed:{
|
||||
|
||||
|
||||
filteredEditData(){
|
||||
if(!this.data){
|
||||
@@ -218,13 +248,9 @@ const app = Vue.createApp({
|
||||
this.notFoundUID=uid;
|
||||
}else{
|
||||
this.view = res.data?.view;
|
||||
|
||||
this.data = res.data?.data;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
},
|
||||
template:`
|
||||
|
||||
@@ -12,6 +12,8 @@ export default {
|
||||
props: {
|
||||
value: Object,
|
||||
title: String,
|
||||
zustelladressenCount: Function,
|
||||
zustellkontakteCount: Function,
|
||||
/*
|
||||
* NOTE(chris):
|
||||
* Hack to expose in "emits" declared events to $props which we use
|
||||
@@ -41,6 +43,8 @@ export default {
|
||||
provide(){
|
||||
return {
|
||||
updateFileID: this.updateFileIDFunction,
|
||||
zustellAdresseCount:this.zustelladressenCount,
|
||||
zustellKontaktCount:this.zustellkontakteCount,
|
||||
}
|
||||
},
|
||||
|
||||
@@ -144,6 +148,7 @@ export default {
|
||||
return BsModal.popup.bind(this)(null, options);
|
||||
},
|
||||
template: `
|
||||
|
||||
<bs-modal ref="modalContainer" v-bind="$props" body-class="" dialog-class="modal-lg" class="bootstrap-alert" backdrop="false" >
|
||||
|
||||
<template v-if="title" v-slot:title>
|
||||
@@ -158,7 +163,6 @@ export default {
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
|
||||
<edit-profil-select @submit="submitProfilChange" v-model:breadcrumb="breadcrumb" v-model:topic="topic" v-model:profilUpdate="profilUpdate" ariaLabel="test" :list="editData"></edit-profil-select>
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ export default {
|
||||
RoleInformation,
|
||||
ProfilInformation,
|
||||
},
|
||||
inject: ['sortProfilUpdates','collapseFunction'],
|
||||
inject: ['sortProfilUpdates','collapseFunction','getZustellkontakteCount','getZustelladressenCount'],
|
||||
data() {
|
||||
return {
|
||||
|
||||
@@ -158,6 +158,8 @@ export default {
|
||||
|
||||
EditProfil.popup({
|
||||
value:JSON.parse(JSON.stringify(this.editData)),
|
||||
zustelladressenCount:this.getZustelladressenCount,
|
||||
zustellkontakteCount:this.getZustellkontakteCount,
|
||||
title:"Profil bearbeiten",
|
||||
}).then((popup_result) => {
|
||||
if(popup_result){
|
||||
@@ -241,7 +243,7 @@ export default {
|
||||
},
|
||||
|
||||
template: `
|
||||
|
||||
|
||||
<div class="container-fluid text-break fhc-form" >
|
||||
|
||||
<div class="row">
|
||||
@@ -273,7 +275,7 @@ export default {
|
||||
<div v-if="data.profilUpdates" class="row mb-3">
|
||||
<div class="col">
|
||||
<!-- MOBILE PROFIL UPDATES -->
|
||||
<fetch-profil-updates v-if="data.profilUpdates && data.profilUpdates.length" @fetchUpdates="fetchProfilUpdates" :data="data.profilUpdates"></fetch-profil-updates>
|
||||
<fetch-profil-updates v-if="data.profilUpdates && data.profilUpdates.length" @fetchUpdates="fetchProfilUpdates" :data="data.profilUpdates" ></fetch-profil-updates>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ export default {
|
||||
ProfilEmails,
|
||||
ProfilInformation,
|
||||
},
|
||||
inject: ['collapseFunction'],
|
||||
data() {
|
||||
return {
|
||||
collapseIconFunktionen: true,
|
||||
@@ -45,7 +46,7 @@ export default {
|
||||
headerFilter: false,
|
||||
formatter: "responsiveCollapse",
|
||||
maxWidth: 40,
|
||||
headerClick: this.$parent.collapseFunction,
|
||||
headerClick: this.collapseFunction,
|
||||
},
|
||||
{
|
||||
title: "Bezeichnung",
|
||||
|
||||
@@ -6,6 +6,7 @@ export default {
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
inject:["zustellAdresseCount"],
|
||||
data(){
|
||||
return{
|
||||
originalValue:null,
|
||||
@@ -60,15 +61,12 @@ export default {
|
||||
},
|
||||
},
|
||||
created(){
|
||||
Vue.$fhcapi.UserData.getZustellAdresse().then(res => {
|
||||
|
||||
this.zustellAdressenCount = res.data;
|
||||
})
|
||||
console.log(this.getZustelladressenCount)
|
||||
this.originalValue = JSON.stringify(this.data);
|
||||
this.zustellAdressenCount = this.zustellAdresseCount();
|
||||
|
||||
},
|
||||
template:`
|
||||
|
||||
<div class="gy-3 row justify-content-center align-items-center">
|
||||
|
||||
|
||||
|
||||
@@ -8,9 +8,11 @@ export default {
|
||||
return{
|
||||
|
||||
originalValue:null,
|
||||
zustellKontaktCount:null,
|
||||
zustellKontakteCount:null,
|
||||
|
||||
}
|
||||
},
|
||||
inject:["zustellKontaktCount"],
|
||||
methods:{
|
||||
updateValue: function(event,bind){
|
||||
|
||||
@@ -29,13 +31,13 @@ export default {
|
||||
},
|
||||
computed:{
|
||||
showZustellKontakteWarning: function(){
|
||||
if(this.zustellKontaktCount){
|
||||
if(this.zustellKontakteCount){
|
||||
|
||||
if(this.zustellKontaktCount.includes(this.data.kontakt_id)){
|
||||
if(this.zustellKontakteCount.includes(this.data.kontakt_id)){
|
||||
//? if the adresse was already saved
|
||||
return false;
|
||||
}
|
||||
return this.zustellKontaktCount.length && this.data.zustellung;
|
||||
return this.zustellKontakteCount.length && this.data.zustellung;
|
||||
}
|
||||
//? if this.zustellAdressenCount is still not set by the api call and is still null
|
||||
return false;
|
||||
@@ -50,13 +52,9 @@ export default {
|
||||
},
|
||||
created(){
|
||||
|
||||
Vue.$fhcapi.UserData.getZustellKontakt().then(res => {
|
||||
|
||||
this.zustellKontaktCount = res.data;
|
||||
})
|
||||
|
||||
this.originalValue = JSON.stringify(this.data);
|
||||
|
||||
this.zustellKontakteCount = this.zustellKontaktCount();
|
||||
},
|
||||
template:
|
||||
`
|
||||
|
||||
@@ -6,9 +6,9 @@ export default {
|
||||
type: Object,
|
||||
},
|
||||
},
|
||||
inject:['getZustellkontakteCount','getZustelladressenCount'],
|
||||
|
||||
emits: ["fetchUpdates"],
|
||||
|
||||
data() {
|
||||
return {};
|
||||
},
|
||||
@@ -88,13 +88,13 @@ export default {
|
||||
withFiles: withFiles,
|
||||
topic: updateRequest.topic,
|
||||
files: files,
|
||||
|
||||
};
|
||||
|
||||
//?TODO: check if updateRequest.uid is a mitarbeiter, if so add the flag isMitarbeiter:true
|
||||
if(view === "EditAdresse"){
|
||||
console.log("uid",updateRequest.uid);
|
||||
const isMitarbeiter = await Vue.$fhcapi.UserData.isMitarbeiter(updateRequest.uid).then(res => res.data);
|
||||
console.log(typeof(isMitarbeiter));
|
||||
|
||||
if(isMitarbeiter){
|
||||
content['isMitarbeiter']=isMitarbeiter;
|
||||
}
|
||||
@@ -112,6 +112,8 @@ export default {
|
||||
EditProfil.popup({
|
||||
value: content,
|
||||
title: updateRequest.topic,
|
||||
zustellkontakteCount:this.getZustellkontakteCount,
|
||||
zustelladressenCount:this.getZustelladressenCount,
|
||||
})
|
||||
.then((res) => {
|
||||
if (res === true) {
|
||||
@@ -127,7 +129,6 @@ export default {
|
||||
created() {},
|
||||
computed: {},
|
||||
template: `
|
||||
|
||||
<div class="card text-nowrap" >
|
||||
<div class="card-header">
|
||||
Profil Updates
|
||||
|
||||
@@ -24,7 +24,7 @@ export default {
|
||||
FetchProfilUpdates,
|
||||
|
||||
},
|
||||
inject:['sortProfilUpdates'],
|
||||
inject:['sortProfilUpdates','collapseFunction','getZustellkontakteCount','getZustelladressenCount'],
|
||||
data() {
|
||||
return {
|
||||
|
||||
@@ -51,7 +51,7 @@ export default {
|
||||
headerFilter: false,
|
||||
formatter: "responsiveCollapse",
|
||||
maxWidth: 40,
|
||||
headerClick: this.$parent.collapseFunction,
|
||||
headerClick: this.collapseFunction,
|
||||
},
|
||||
{
|
||||
title: "Betriebsmittel",
|
||||
@@ -97,6 +97,8 @@ export default {
|
||||
EditProfil.popup({
|
||||
value:JSON.parse(JSON.stringify(this.editData)),
|
||||
title:"Profil bearbeiten",
|
||||
zustelladressenCount:this.getZustelladressenCount,
|
||||
zustellkontakteCount:this.getZustellkontakteCount,
|
||||
}).then((popup_result) => {
|
||||
if(popup_result){
|
||||
Vue.$fhcapi.ProfilUpdate.selectProfilRequest()
|
||||
@@ -212,7 +214,7 @@ export default {
|
||||
<div v-if="data.profilUpdates" class="row mb-3">
|
||||
<div class="col">
|
||||
<!-- MOBILE PROFIL UPDATES -->
|
||||
<fetch-profil-updates v-if="data.profilUpdates && data.profilUpdates.length" @fetchUpdates="fetchProfilUpdates" :data="data.profilUpdates"></fetch-profil-updates>
|
||||
<fetch-profil-updates v-if="data.profilUpdates && data.profilUpdates.length" @fetchUpdates="fetchProfilUpdates" :data="data.profilUpdates"></fetch-profil-updates>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -398,7 +400,7 @@ export default {
|
||||
<div v-if="data.profilUpdates" class="row d-none d-md-block mb-3">
|
||||
<div class="col mb-3">
|
||||
<!-- PROFIL UPDATES -->
|
||||
<fetch-profil-updates v-if="data.profilUpdates && data.profilUpdates.length" @fetchUpdates="fetchProfilUpdates" :data="data.profilUpdates"></fetch-profil-updates>
|
||||
<fetch-profil-updates v-if="data.profilUpdates && data.profilUpdates.length" @fetchUpdates="fetchProfilUpdates" :data="data.profilUpdates"></fetch-profil-updates>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user