updates editAdressen in the Profil

This commit is contained in:
SimonGschnell
2024-07-08 15:15:08 +02:00
parent 92afdf71cd
commit 84029fc729
9 changed files with 194 additions and 131 deletions
+14 -14
View File
@@ -244,23 +244,23 @@ class Profil extends Auth_Controller
$this->GemeindeModel->addDistinct();
$this->GemeindeModel->addSelect(["name"]);
if ($nation == "A") {
if (isset($zip) && $zip > 999 && $zip < 32000) {
if (isset($zip) && $zip > 999 && $zip < 32000) {
$gemeinde_res = $this->GemeindeModel->loadWhere(['plz' => $zip]);
if (isError($gemeinde_res)) {
show_error("error while trying to query bis.tbl_gemeinde");
$gemeinde_res = $this->GemeindeModel->loadWhere(['plz' => $zip]);
if (isError($gemeinde_res)) {
show_error("error while trying to query bis.tbl_gemeinde");
}
$gemeinde_res = hasData($gemeinde_res) ? getData($gemeinde_res) : null;
$gemeinde_res = array_map(function ($obj) {
return $obj->name;
}, $gemeinde_res);
echo json_encode($gemeinde_res);
} else {
echo json_encode(error("ortschaftskennziffer code was not valid"));
}
$gemeinde_res = hasData($gemeinde_res) ? getData($gemeinde_res) : null;
$gemeinde_res = array_map(function ($obj) {
return $obj->name;
}, $gemeinde_res);
echo json_encode($gemeinde_res);
} else {
echo json_encode(error("ortschaftskennziffer code was not valid"));
}
} else {
echo json_encode(error("Nation was not 'A' (Austria)"));
echo json_encode(error("Nation was not 'A' (Austria)"));
}
}
@@ -34,6 +34,8 @@ class Profil extends FHCAPI_Controller
parent::__construct([
'getView' => self::PERM_LOGGED,
'fotoSperre' => self::PERM_LOGGED,
'getGemeinden' => self::PERM_LOGGED,
]);
@@ -143,6 +145,31 @@ class Profil extends FHCAPI_Controller
$this->terminateWithSuccess(current($res));
}
public function getGemeinden($nation, $zip)
{
if(!isset($nation) || !isset($zip)){
echo json_encode(error("Missing parameters"));
return;
}
$this->load->model('codex/Gemeinde_model', "GemeindeModel");
$gemeinde_res = $this->GemeindeModel->getGemeindeByPlz($zip);
if (isError($gemeinde_res)) {
$this->terminateWithError(getError($gemeinde_res),self::ERROR_TYPE_GENERAL);
}
$gemeinde_res = $this->getDataOrTerminateWithError($gemeinde_res);
/* $gemeinde_res = array_map(function ($obj) {
return $obj->ortschaftsname;
}, $gemeinde_res); */
$this->terminateWithSuccess($gemeinde_res);
}
// -----------------------------------------------------------------------------------------------------------------
// Private methods
@@ -19,4 +19,28 @@ class Gemeinde_model extends DB_Model
return $this->loadWhere(array("plz" => $plz));
}
public function getGemeindeByNation($nation, $zip){
$this->addSelect(["name"]);
if ($nation == "A") {
if (isset($zip) && $zip > 999 && $zip < 32000) {
$gemeinde_res = $this->GemeindeModel->loadWhere(['plz' => $zip]);
if (isError($gemeinde_res)) {
show_error("error while trying to query bis.tbl_gemeinde");
}
$gemeinde_res = hasData($gemeinde_res) ? getData($gemeinde_res) : null;
$gemeinde_res = array_map(function ($obj) {
return $obj->name;
}, $gemeinde_res);
echo json_encode($gemeinde_res);
} else {
echo json_encode(error("ortschaftskennziffer code was not valid"));
}
} else {}
}
}
+3 -4
View File
@@ -56,13 +56,12 @@ export default {
);
},
getGemeinden: function(nation,zip=null){
getGemeinden: function(nation,zip){
return this.$fhcApi.get(
FHC_JS_DATA_STORAGE_OBJECT.app_root +
FHC_JS_DATA_STORAGE_OBJECT.ci_router +
"/api/frontend/v1/Profil/getGemeinden",
{ nation: nation,
...(zip? {zip:zip}:{}) }
`/api/frontend/v1/Profil/getGemeinden/${nation}/${zip}`,
{}
);
},
+3 -3
View File
@@ -318,16 +318,16 @@ const profilApp = Vue.createApp({
?.filter((item) => {
return !this.data.profilUpdates?.some((update) => {
return (
update.status === "pending" &&
update.status === this.profilUpdateStates["Pending"] &&
update.requested_change?.adresse_id == item.adresse_id
);
});
})
.map((kontakt) => {
.map((adresse) => {
return {
listview: "Adresse",
view: "EditAdresse",
data: kontakt,
data: adresse,
};
}),
},
@@ -238,6 +238,7 @@ export default {
created() {
//? sorts the profil Updates: pending -> accepted -> rejected
this.data.profilUpdates?.sort(this.sortProfilUpdates);
},
template: /*html*/ `
@@ -20,11 +20,9 @@ export default {
if (!this.data) {
return;
}
Vue.$fhcapi.UserData.sperre_foto_function(!this.FotoSperre).then(
(res) => {
this.FotoSperre = res.data.foto_sperre;
}
);
this.$fhcApi.factory.profil.fotoSperre(!this.FotoSperre).then(res =>{
this.FotoSperre = res.data.foto_sperre;
})
},
},
computed: {
@@ -16,6 +16,7 @@ export default {
data() {
return {
gemeinden: [],
ortschaftnamen: [],
selectedNation: null,
nationenList: [],
originalValue: null,
@@ -27,13 +28,25 @@ export default {
"data.gemeinde": function (newValue, oldValue) {
this.$emit("profilUpdate", this.isChanged ? this.data : null);
},
"data.ort": function (newValue, oldValue) {
this.$emit("profilUpdate", this.isChanged ? this.data : null);
},
},
methods: {
autocompleteSearch: function (event) {
test: function () {
console.log(this.gemeinden, "this are the gemeinden");
console.log(this.ortschaftnamen, "this are the ortschaftsnamen");
},
autocompleteSearchGemeinden: function (event) {
this.gemeinden = this.gemeinden.map((gemeinde) => gemeinde);
},
autocompleteSearchOrtschaftsnamen: function (event) {
this.ortschaftnamen = this.ortschaftnamen.map((ortschaft) => ortschaft);
},
getGemeinde: function () {
//? only query the gemeinde is the nation is Austria and the PLZ is greater than 999 and less than 32000
if (
@@ -43,14 +56,27 @@ export default {
this.data.plz > 999 &&
this.data.plz < 32000
) {
Vue.$fhcapi.UserData.getGemeinden(this.data.nation, this.data.plz).then(
(res) => {
this.$fhcApi.factory.profil
.getGemeinden(this.data.nation, this.data.plz)
.then((res) => {
if (res.data.length) {
this.gemeinden = res.data;
console.log(res.data, "this is the data from the gemeinden");
this.gemeinden = [
...new Set(
res.data.map((element) => {
return element.name;
})
),
];
this.ortschaftnamen = [
...new Set(
res.data.map((element) => {
return element.ortschaftsname;
})
),
];
}
}
);
});
} else {
this.gemeinden = [];
}
@@ -87,13 +113,12 @@ export default {
) {
return false;
}
return this.originalValue !== JSON.stringify(this.data);
},
},
created() {
Vue.$fhcapi.UserData.getAllNationen().then((res) => {
this.nationenList = res.data;
this.getGemeinde();
@@ -104,103 +129,89 @@ export default {
},
template: /*html*/ `
<div class="gy-3 row justify-content-center align-items-center">
<!-- warning message for too many zustellungs Adressen -->
<div v-if="showZustellAdressenWarning" class="col-12 ">
<div class="card bg-danger mx-2">
<div class="card-body text-white ">
<span>{{$p.t('profilUpdate','zustelladresseWarning')}}</span>
</div>
</div>
</div>
<!-- End of warning -->
<div class="gy-3 row justify-content-center align-items-center">
<div class="col-12 ">
<div class="form-check mb-2">
<input class="form-check-input" type="checkbox" @change="updateValue($event,'zustelladresse')" :checked="data.zustelladresse" id="flexCheckDefault">
<label class="form-check-label" for="flexCheckDefault">
{{$p.t('person','zustelladresse')}}
</label>
</div>
</div>
<div class="col-12 col-sm-9 col-xl-12 col-xxl-9 order-1">
<div class="form-underline ">
<div class="form-underline-titel">{{$p.t('person','strasse')}}*</div>
<input class="form-control" :value="data.strasse" @input="updateValue($event,'strasse')" :placeholder="data.strasse">
</div>
</div>
<div class=" order-2 order-sm-4 order-xl-3 order-xxl-4 col-12 col-sm-5 col-xl-8 col-xxl-5 ">
<div class="form-underline">
<div class="form-underline-titel">{{$p.t('profilUpdate','kontaktTyp')}}*</div>
<select :value="data.typ" @change="updateValue($event,'typ')" class="form-select" aria-label="Select Kontakttyp">
<option selected></option>
<option value="Nebenwohnsitz">{{$p.t('profilUpdate','nebenwohnsitz')}}</option>
<option value="Hauptwohnsitz">{{$p.t('profilUpdate','hauptwohnsitz')}}</option>
<option v-if="isMitarbeiter" value="Homeoffice">{{$p.t('profilUpdate','homeoffice')}}</option>
<option v-if="isMitarbeiter" value="Rechnungsadresse">{{$p.t('profilUpdate','rechnungsadresse')}}</option>
</select>
</div>
</template>
</div>
<div class="order-3 order-sm-3 order-xl-2 order-xxl-3 col-12 col-sm-7 col-xl-12 col-xxl-7 " >
<div class="form-underline ">
<div class="form-underline-titel">{{$p.t('person','ort')}}*</div>
<input class="form-control" :value="data.ort" @input="updateValue($event,'ort')" :placeholder="data.ort">
</div>
</div>
<div class="order-4 order-sm-2 order-xl-4 order-xxl-2 col-12 col-sm-3 col-xl-4 col-xxl-3 ">
<div class="form-underline ">
<div class="form-underline-titel">{{$p.t('person','plz')}}*</div>
<input class="form-control" :value="data.plz" @input="updateValue($event,'plz')" @input="getGemeinde" :placeholder="data.plz">
</div>
</div>
<div class="col-6 order-5">
<div class="form-underline ">
<div class="form-underline-titel">{{$p.t('person','gemeinde')}}*</div>
<auto-complete class="w-100" v-model="data.gemeinde" dropdown :forceSelection="data.nation ==='A'?true:false" :suggestions="gemeinden" @complete="autocompleteSearch" ></auto-complete>
</div>
</div>
<div class="col-6 order-5 ">
<div class="form-underline ">
<div class="form-underline-titel">{{$p.t('person','nation')}}*</div>
<select :value="data.nation" @change="updateValue($event,'nation')" @change="getGemeinde" class="form-select" aria-label="Select Kontakttyp">
<option selected></option>
<option :value="nation.code" v-for="nation in nationenList">{{nation.langtext}}</option>
</select>
</div>
</div>
<!-- warning message for too many zustellungs Adressen -->
<div v-if="showZustellAdressenWarning" class="col-12 ">
<div class="card bg-danger mx-2">
<div class="card-body text-white ">
<span>{{$p.t('profilUpdate','zustelladresseWarning')}}</span>
</div>
</div>
</div>
<!-- End of warning -->
<div class="col-12 ">
<div class="form-check mb-2">
<input class="form-check-input" type="checkbox" @change="updateValue($event,'zustelladresse')" :checked="data.zustelladresse" id="flexCheckDefault">
<label class="form-check-label" for="flexCheckDefault">
{{$p.t('person','zustelladresse')}}
</label>
</div>
</div>
<!-- NATION -->
<div class="col-8">
<div class="form-underline ">
<div class="form-underline-titel">{{$p.t('person','nation')}}*</div>
<select :value="data.nation" @change="updateValue($event,'nation')" @change="getGemeinde" class="form-select" aria-label="Select Kontakttyp">
<option selected></option>
<option :value="nation.code" v-for="nation in nationenList">{{nation.langtext}}</option>
</select>
</div>
</div>
<!-- PLZ -->
<div class=" col-4">
<div class="form-underline">
<div class="form-underline-titel">{{$p.t('person','plz')}}*</div>
<input class="form-control" :value="data.plz" @input="updateValue($event,'plz')" @input="getGemeinde" :placeholder="data.plz">
</div>
</div>
<!-- GEMEINDE -->
<div class="col-lg-6">
<div class="form-underline ">
<div class="form-underline-titel">{{$p.t('person','gemeinde')}}*</div>
<auto-complete class="w-100" v-model="data.gemeinde" dropdown :forceSelection="data.nation ==='A'?true:false" :suggestions="gemeinden" @complete="autocompleteSearchGemeinden" ></auto-complete>
</div>
</div>
<!-- ORT -->
<div class="col-lg-6" >
<div class="form-underline ">
<div class="form-underline-titel">{{$p.t('person','ort')}}*</div>
<auto-complete class="w-100" v-model="data.ort" dropdown :forceSelection="data.nation ==='A'?true:false" :suggestions="ortschaftnamen" @complete="autocompleteSearchOrtschaftsnamen" ></auto-complete>
</div>
</div>
<!-- STRASSE -->
<div class="col-lg-8">
<div class="form-underline ">
<div class="form-underline-titel">{{$p.t('person','strasse')}}*</div>
<input class="form-control" :value="data.strasse" @input="updateValue($event,'strasse')" :placeholder="data.strasse">
</div>
</div>
<!-- ADRESSEN TYP -->
<div class="col-lg-4">
<div class="form-underline">
<div class="form-underline-titel">{{$p.t('profilUpdate','kontaktTyp')}}*</div>
<select :value="data.typ" @change="updateValue($event,'typ')" class="form-select" aria-label="Select Kontakttyp">
<option selected></option>
<option value="Nebenwohnsitz">{{$p.t('profilUpdate','nebenwohnsitz')}}</option>
<option value="Hauptwohnsitz">{{$p.t('profilUpdate','hauptwohnsitz')}}</option>
<option v-if="isMitarbeiter" value="Homeoffice">{{$p.t('profilUpdate','homeoffice')}}</option>
<option v-if="isMitarbeiter" value="Rechnungsadresse">{{$p.t('profilUpdate','rechnungsadresse')}}</option>
</select>
</div>
</div>
</div>
`,
};
@@ -85,6 +85,7 @@ export default {
editData: Object,
},
methods: {
betriebsmittelTableBuilt: function () {
this.$refs.betriebsmittelTable.tabulator.setData(this.data.mittel);
},
@@ -181,6 +182,7 @@ export default {
created() {
//? sorts the profil Updates: pending -> accepted -> rejected
this.data.profilUpdates?.sort(this.sortProfilUpdates);
},
@@ -205,6 +207,7 @@ export default {
<div class="row ">
<div class="col mb-3">
<button @click="showEditProfilModal" type="button" class="text-start w-100 btn btn-outline-secondary" >
<div class="row">
<div class="col-2">