From 69a1e945b3a3b50bda35f3a1b934575c181470a4 Mon Sep 17 00:00:00 2001 From: ma0048 Date: Tue, 16 Sep 2025 08:36:12 +0200 Subject: [PATCH] bug beim laden des messages tab ohne oe zuordnung --- .../api/frontend/v1/messages/Messages.php | 41 ++++++++----------- .../api/frontend/v1/vorlagen/Vorlagen.php | 14 ++++--- .../Messages/Details/TableMessages.js | 5 +++ 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/application/controllers/api/frontend/v1/messages/Messages.php b/application/controllers/api/frontend/v1/messages/Messages.php index fa6748f6a..006fe296b 100644 --- a/application/controllers/api/frontend/v1/messages/Messages.php +++ b/application/controllers/api/frontend/v1/messages/Messages.php @@ -52,11 +52,14 @@ class Messages extends FHCAPI_Controller $result = $this->MessageModel->getMessagesForTable($id, $offset, $limit); - $data = $this->getDataOrTerminateWithError($result); + if (hasData($result)) + { + $data = getData($result); + $this->addMeta('count', $data['count']); + $this->terminateWithSuccess($data['data']); + } - $this->addMeta('count', $data['count']); - - $this->terminateWithSuccess($data['data']); + $this->terminateWithSuccess(array()); } public function getVorlagen() @@ -66,32 +69,23 @@ class Messages extends FHCAPI_Controller $this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); $result = $this->BenutzerfunktionModel->getBenutzerfunktionByUid($uid, 'oezuordnung'); - $data = $this->getDataOrTerminateWithError($result); - $oe_kurzbz = current($data); + if (hasData($result)) + { + $this->load->model('system/Vorlage_model', 'VorlageModel'); - $this->load->model('system/Vorlage_model', 'VorlageModel'); + $data = getData($result); - $result = $this->VorlageModel->getAllVorlagenByOe($oe_kurzbz->oe_kurzbz); - $data = $this->getDataOrTerminateWithError($result); + $oe_kurzbz = array_column($data, 'oe_kurzbz'); + $result = $this->VorlageModel->getAllVorlagenByOe($oe_kurzbz); - $this->terminateWithSuccess($data); + $this->terminateWithSuccess(hasData($result) ? getData($result) : array()); + } - //If admin - $this->VorlageModel->addOrder('vorlage_kurzbz', 'ASC'); - $result = $this->VorlageModel->loadWhere( - array( - 'mimetype' => 'text/html' - )); - - - $data = $this->getDataOrTerminateWithError($result); - - $this->terminateWithSuccess($data); + $this->terminateWithSuccess(array()); } public function getVorlagentext($vorlage_kurzbz) { - //$this->terminateWithError("vor " . $vorlage_kurzbz, self::ERROR_TYPE_GENERAL); //$studiengang_kz = 227; //TODO(Manu) dynamisieren NULL $studiengang_kz = 0; $this->load->model('system/Vorlagestudiengang_model', 'VorlagestudiengangModel'); @@ -108,7 +102,6 @@ class Messages extends FHCAPI_Controller //not correct with Vorlage $vorlage = current($data); - //$this->terminateWithSuccess($data); $this->terminateWithSuccess($vorlage->text); } @@ -223,8 +216,6 @@ class Messages extends FHCAPI_Controller } elseif($typeId == 'prestudent_id') { - // $this->terminateWithError("prestudent_id ", self::ERROR_TYPE_GENERAL); - $result = $this->MessagesModel->parseMessageTextPrestudent($id, $body); $bodyParsed = $this->getDataOrTerminateWithError($result); } diff --git a/application/controllers/api/frontend/v1/vorlagen/Vorlagen.php b/application/controllers/api/frontend/v1/vorlagen/Vorlagen.php index 01edb33d1..cf76746ef 100644 --- a/application/controllers/api/frontend/v1/vorlagen/Vorlagen.php +++ b/application/controllers/api/frontend/v1/vorlagen/Vorlagen.php @@ -51,13 +51,17 @@ class Vorlagen extends FHCAPI_Controller $this->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); $result = $this->BenutzerfunktionModel->getBenutzerfunktionByUid($uid, 'oezuordnung'); - $data = $this->getDataOrTerminateWithError($result); - $oe_kurzbz = current($data); + if (hasData($result)) + { + $data = getData($result); - $result = $this->VorlageModel->getAllVorlagenByOe($oe_kurzbz->oe_kurzbz); - $data = $this->getDataOrTerminateWithError($result); + $oe_kurzbz = array_column($data, 'oe_kurzbz'); + $result = $this->VorlageModel->getAllVorlagenByOe($oe_kurzbz); + + $this->terminateWithSuccess(hasData($result) ? getData($result) : array()); + } + $this->terminateWithSuccess(array()); - $this->terminateWithSuccess($data); } } \ No newline at end of file diff --git a/public/js/components/Messages/Details/TableMessages.js b/public/js/components/Messages/Details/TableMessages.js index 5095f4223..2a12128eb 100644 --- a/public/js/components/Messages/Details/TableMessages.js +++ b/public/js/components/Messages/Details/TableMessages.js @@ -274,6 +274,11 @@ export default { this.$refs.table.reloadTable(); }, buildTreemap(messages) { + if (!messages || !messages.data || messages.data.length === 0) + { + return {data: [], last_page: 0}; + } + const last_page = messages.meta.count; messages = messages.data; const messageMap = new Map();