mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-20 00:12:15 +00:00
fixes an error where the payload i treated like an object but is an associative array in the controller
This commit is contained in:
@@ -160,13 +160,13 @@ class ProfilUpdate extends FHCAPI_Controller
|
||||
$res = $this->getDataOrTerminateWithError($res);
|
||||
|
||||
//? the user cannot delete a zustelladresse/kontakt
|
||||
if (isset($payload->delete) && $payload->{$identifier == "kontakt_id" ? "zustellung" : "zustelladresse"}) {
|
||||
if (isset($payload["delete"]) && $payload-[$identifier == "kontakt_id" ? "zustellung" : "zustelladresse"]) {
|
||||
$this->terminateWithError($this->p->t('profilUpdate', 'profilUpdate_deleteZustellung_error'));
|
||||
}
|
||||
|
||||
//? if the user tries to delete a adresse, checks whether the adresse is a heimatadresse, if so an error is raised
|
||||
if (isset($payload->delete) && $identifier == "adresse_id") {
|
||||
$adr = $this->AdresseModel->load($payload->$identifier);
|
||||
if (isset($payload["delete"]) && $identifier == "adresse_id") {
|
||||
$adr = $this->AdresseModel->load($payload[$identifier]);
|
||||
$adr = $this->getDataOrTerminateWithError($adr)[0];
|
||||
if ($adr->heimatadresse) {
|
||||
$this->terminateWithError($this->p->t('profilUpdate', 'profilUpdate_deleteZustellung_error'));
|
||||
@@ -177,12 +177,15 @@ class ProfilUpdate extends FHCAPI_Controller
|
||||
$pending_changes = array_filter($res, function ($element) {
|
||||
return $element->status == (self::$STATUS_PENDING ?: "Pending");
|
||||
});
|
||||
|
||||
$test = array();
|
||||
foreach ($pending_changes as $update_request) {
|
||||
$existing_change = $update_request->requested_change;
|
||||
|
||||
$this->addMeta("paylaod",$payload);
|
||||
$this->addMeta("object style", $payload[$identifier]);
|
||||
$this->addMeta("array style", $payload[$identifier]);
|
||||
|
||||
//? the user can add as many new kontakte/adressen 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) && array_key_exists($identifier,$payload) && $existing_change->$identifier == $payload[$identifier]) {
|
||||
//? the kontakt_id / adresse_id of a change has to be unique
|
||||
$this->terminateWithError($this->p->t('profilUpdate', 'profilUpdate_changeTwice_error'));
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ export default {
|
||||
async submitProfilChange() {
|
||||
|
||||
//? check if data is valid before making a request
|
||||
if (this.topic && this.profilUpdate) {
|
||||
if (this.topic && this.profilUpdate) {
|
||||
//? if profil update contains any attachment
|
||||
if (this.fileID) {
|
||||
const fileData = await this.uploadFiles(this.fileID);
|
||||
|
||||
@@ -45,7 +45,7 @@ export default {
|
||||
view: null,
|
||||
data: null,
|
||||
breadcrumbItems: [],
|
||||
topic: this.topic,
|
||||
modal_topic: this.topic,
|
||||
properties: null,
|
||||
};
|
||||
},
|
||||
@@ -53,17 +53,17 @@ export default {
|
||||
methods: {
|
||||
addItem: function () {
|
||||
this.view =
|
||||
this.topic == this.profilUpdateTopic["Private Kontakte"]
|
||||
this.modal_topic == this.profilUpdateTopic["Private Kontakte"]
|
||||
? "EditKontakt"
|
||||
: "EditAdresse";
|
||||
|
||||
//? updates the topic when a Kontakt or an Address should be added
|
||||
this.topic =
|
||||
this.topic == this.profilUpdateTopic["Private Kontakte"]
|
||||
this.modal_topic =
|
||||
this.modal_topic == this.profilUpdateTopic["Private Kontakte"]
|
||||
? this.profilUpdateTopic["Add Kontakt"]
|
||||
: this.profilUpdateTopic["Add Adresse"];
|
||||
this.$emit("update:topic", this.topic);
|
||||
this.breadcrumbItems.push(this.topic);
|
||||
this.$emit("update:topic", this.modal_topic);
|
||||
this.breadcrumbItems.push(this.modal_topic);
|
||||
this.$emit("update:breadcrumb", this.breadcrumbItems);
|
||||
|
||||
this.data =
|
||||
@@ -108,13 +108,13 @@ export default {
|
||||
},
|
||||
|
||||
updateOptions: function (event, item) {
|
||||
this.properties = item;
|
||||
this.properties = item;
|
||||
this.data = item.data;
|
||||
this.view = item.view;
|
||||
if (item.title) {
|
||||
//? emits the selected topic to the parent component
|
||||
this.topic = item.topic;
|
||||
this.$emit("update:topic", this.topic);
|
||||
this.modal_topic = item.topic;
|
||||
this.$emit("update:topic", this.modal_topic);
|
||||
|
||||
//? emits the new item for the breadcrumb in the parent component
|
||||
this.breadcrumbItems.push(item.title);
|
||||
|
||||
Reference in New Issue
Block a user