From 629ea3716ebeadba3dea204d3c0541941800c21b Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Wed, 19 Jun 2024 11:15:06 +0200 Subject: [PATCH] changes how the content and the news are displayed and also modifies the modals for the roominformation which now get their data from props instead of passing them directly via refs --- application/controllers/CisHmvc/Cms.php | 11 +-- application/controllers/CisHtml/Cms.php | 11 +-- application/controllers/CisVue/Cms.php | 11 +-- .../controllers/api/frontend/v1/Cms.php | 98 +++++++++++++++++++ application/views/CisHmvc/Cms/Content.php | 5 +- application/views/CisHtml/Cms/Content.php | 3 +- application/views/CisVue/Cms/Content.php | 4 +- public/js/api/cms.js | 15 +++ public/js/api/fhcapifactory.js | 2 + public/js/api/ort.js | 12 +-- public/js/apps/Cis/Cms.js | 10 +- public/js/components/Bootstrap/Modal.js | 2 +- public/js/components/Cis/Cms/Content.js | 48 +++++---- public/js/components/Cis/Cms/ContentModal.js | 38 +++++-- public/js/components/Cis/Cms/News.js | 34 +++++++ .../components/DashboardWidget/Stundenplan.js | 34 +++---- 16 files changed, 249 insertions(+), 89 deletions(-) create mode 100644 application/controllers/api/frontend/v1/Cms.php create mode 100644 public/js/api/cms.js create mode 100644 public/js/components/Cis/Cms/News.js diff --git a/application/controllers/CisHmvc/Cms.php b/application/controllers/CisHmvc/Cms.php index eed1a5fea..544e3d6bb 100755 --- a/application/controllers/CisHmvc/Cms.php +++ b/application/controllers/CisHmvc/Cms.php @@ -69,12 +69,11 @@ class Cms extends Auth_Controller */ public function content($content_id, $version = null, $sprache = null, $sichtbar = true) { - $content = $this->cmslib->getContent($content_id, $version, $sprache, $sichtbar); - - if (isError($content)) - return $this->load->view('CisHmvc/Error', ['error' => getError($content)]); - - $this->load->view('CisHmvc/Cms/Content', ['content' => getData($content)]); + // return early if the content_id for the content is missing + if(!isset($content_id)) + $this->terminateWithError("content_id is missing"); + + $this->load->view('CisHtml/Cms/Content', ['content_id' => $content_id, 'version' => $version, 'sprache' => $sprache, 'sichtbar' => $sichtbar]); } /** diff --git a/application/controllers/CisHtml/Cms.php b/application/controllers/CisHtml/Cms.php index f56b3eea3..5223fd4e5 100755 --- a/application/controllers/CisHtml/Cms.php +++ b/application/controllers/CisHtml/Cms.php @@ -45,12 +45,11 @@ class Cms extends FHC_Controller */ public function content($content_id, $version = null, $sprache = null, $sichtbar = true) { - $content = $this->cmslib->getContent($content_id, $version, $sprache, $sichtbar); - - if (isError($content)) - return $this->load->view('CisHtml/Error', ['error' => getError($content)]); - - $this->load->view('CisHtml/Cms/Content', ['content' => getData($content)]); + // return early if the content_id for the content is missing + if(!isset($content_id)) + $this->terminateWithError("content_id is missing"); + + $this->load->view('CisHtml/Cms/Content', ['content_id' => $content_id, 'version' => $version, 'sprache' => $sprache, 'sichtbar' => $sichtbar]); } /** diff --git a/application/controllers/CisVue/Cms.php b/application/controllers/CisVue/Cms.php index 2c1fa1fc6..74b8d19ee 100755 --- a/application/controllers/CisVue/Cms.php +++ b/application/controllers/CisVue/Cms.php @@ -39,12 +39,11 @@ class Cms extends FHC_Controller */ public function content($content_id, $version = null, $sprache = null, $sichtbar = true) { - $content = $this->cmslib->getContent($content_id, $version, $sprache, $sichtbar); - - if (isError($content)) - return $this->load->view('CisHtml/Error', ['error' => getError($content)]); - - $this->load->view('CisHtml/Cms/Content', ['content' => getData($content)]); + // return early if the content_id for the content is missing + if(!isset($content_id)) + $this->terminateWithError("content_id is missing"); + + $this->load->view('CisHtml/Cms/Content', ['content_id' => $content_id, 'version' => $version, 'sprache' => $sprache, 'sichtbar' => $sichtbar]); } /** diff --git a/application/controllers/api/frontend/v1/Cms.php b/application/controllers/api/frontend/v1/Cms.php new file mode 100644 index 000000000..f54353e28 --- /dev/null +++ b/application/controllers/api/frontend/v1/Cms.php @@ -0,0 +1,98 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the SearchBarLib (back-end) + * Provides data to the ajax get calls about the searchbar component + * This controller works with JSON calls on the HTTP GET and the output is always JSON + */ +class Cms extends FHCAPI_Controller +{ + + /** + * Object initialization + */ + public function __construct() + { + // NOTE(chris): additional permission checks will be done in SearchBarLib + parent::__construct([ + 'ContentID' => self::PERM_LOGGED, + 'getOrtKurzbzContent' => self::PERM_LOGGED, + 'content' => self::PERM_LOGGED, + ]); + + $this->load->library('CmsLib'); + + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Gets a JSON body via HTTP POST and provides the parameters + */ + public function content() + { + // getting the get parameters + $content_id = $this->input->get("content_id",TRUE); + $version = $this->input->get("version",TRUE); + $sprache = $this->input->get("sprache",TRUE); + $sichtbar = $this->input->get("sichtbar",TRUE); + + // return early if the content_id is missing + if(!isset($content_id)) + $this->terminateWithError("content_id is missing", self::ERROR_TYPE_GENERAL); + + $content = $this->cmslib->getContent($content_id, $version, $sprache, $sichtbar); + + if (isError($content)) + $this->terminateWithError(getError($content), self::ERROR_TYPE_GENERAL); + + $this->terminateWithSuccess(getData($content)); + } + + /** + * Gets a JSON body via HTTP POST and provides the parameters + */ + public function ContentID() + { + // if error + //$this->terminateWithError(SearchBarLib::ERROR_WRONG_JSON, self::ERROR_TYPE_GENERAL); + + $ort_kurzbz = $this->input->get('ort_kurzbz',TRUE); + + if(!$ort_kurzbz){ + $this->terminateWithError("missing ort_kurzbz parameter", self::ERROR_TYPE_GENERAL); + } + + $result = $this->OrtModel->getContentID($ort_kurzbz); + + if(isError($result)){ + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + + $result = hasData($result) ? current(getData($result)) : null; + + $this->terminateWithSuccess($result->content_id ?? NULL); + } + + +} + diff --git a/application/views/CisHmvc/Cms/Content.php b/application/views/CisHmvc/Cms/Content.php index 7ca1347d3..f56c45eb6 100755 --- a/application/views/CisHmvc/Cms/Content.php +++ b/application/views/CisHmvc/Cms/Content.php @@ -10,11 +10,10 @@ $includesArray = array( $this->load->view('templates/FHC-Header', $includesArray); ?> -
-'); ?> + +' : ''); ?>
- load->view('templates/FHC-Footer', $includesArray); ?> diff --git a/application/views/CisHtml/Cms/Content.php b/application/views/CisHtml/Cms/Content.php index ac62c985a..d3e03ea04 100755 --- a/application/views/CisHtml/Cms/Content.php +++ b/application/views/CisHtml/Cms/Content.php @@ -12,8 +12,9 @@ $this->load->view('templates/CISHTML-Header', $includesArray); ?>
-'); ?> +' : ''); ?> +
load->view('templates/CISHTML-Footer', $includesArray); ?> \ No newline at end of file diff --git a/application/views/CisVue/Cms/Content.php b/application/views/CisVue/Cms/Content.php index 02aa42b57..ed9d90ef2 100755 --- a/application/views/CisVue/Cms/Content.php +++ b/application/views/CisVue/Cms/Content.php @@ -11,7 +11,9 @@ $this->load->view('templates/CISVUE-Header', $includesArray); ?>
-'); ?> + +' : ''); ?> +
load->view('templates/CISVUE-Footer', $includesArray); ?> diff --git a/public/js/api/cms.js b/public/js/api/cms.js new file mode 100644 index 000000000..5602c7bf8 --- /dev/null +++ b/public/js/api/cms.js @@ -0,0 +1,15 @@ +export default { + content(content_id, version=null, sprache=null, sichtbar=null) { + return this.$fhcApi.get( + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + "/api/frontend/v1/Cms/content", + { content_id: content_id, + ...(version?{version}:{}), + ...(sprache?{sprache}:{}), + ...(sichtbar?{sichtbar}:{}), + } + ); + }, + + } \ No newline at end of file diff --git a/public/js/api/fhcapifactory.js b/public/js/api/fhcapifactory.js index a41730548..31c6fe9ab 100644 --- a/public/js/api/fhcapifactory.js +++ b/public/js/api/fhcapifactory.js @@ -21,6 +21,7 @@ import navigation from "./navigation.js"; import filter from "./filter.js"; import studstatus from "./studstatus.js"; import ort from "./ort.js"; +import cms from "./cms.js"; export default { search, @@ -29,4 +30,5 @@ export default { filter, studstatus, ort, + cms, }; diff --git a/public/js/api/ort.js b/public/js/api/ort.js index c92ac0be0..4c8e2ce73 100644 --- a/public/js/api/ort.js +++ b/public/js/api/ort.js @@ -1,18 +1,10 @@ export default { - getContentID($ort_kurbz) { + getContentID(ort_kurbz) { return this.$fhcApi.get( FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + "/api/frontend/v1/Ort/ContentID", - { ort_kurzbz: $ort_kurbz } - ); - }, - getOrtKuzbzContent($ort_kurzbz_content_id) { - return this.$fhcApi.get( - FHC_JS_DATA_STORAGE_OBJECT.app_root + - FHC_JS_DATA_STORAGE_OBJECT.ci_router + - "/api/frontend/v1/Ort/getOrtKurzbzContent", - { content_id: $ort_kurzbz_content_id } + { ort_kurzbz: ort_kurbz } ); }, } \ No newline at end of file diff --git a/public/js/apps/Cis/Cms.js b/public/js/apps/Cis/Cms.js index cd2b5f6e9..dd059fb92 100755 --- a/public/js/apps/Cis/Cms.js +++ b/public/js/apps/Cis/Cms.js @@ -1,13 +1,14 @@ import BsConfirm from "../../components/Bootstrap/Confirm.js"; //import Pagination from "../../components/Pagination/Pagination.js"; -import Content from "../../components/Cis/Cms/Content.js"; -import Fhcapi from "../api/fhcapifactory.js"; +import CmsNews from "../../components/Cis/Cms/News.js"; +import CmsContent from "../../components/Cis/Cms/Content.js"; +import Fhcapi from "../../plugin/FhcApi.js"; -Vue.$fhcapi = Fhcapi; const app = Vue.createApp({ components: { - Content, + CmsNews, + CmsContent, }, mounted() { document.querySelectorAll("#cms [data-confirm]").forEach((el) => { @@ -34,5 +35,6 @@ const app = Vue.createApp({ }, }); app.use(primevue.config.default, { zIndex: { overlay: 9999 } }); +app.use(Fhcapi); app.mount("#cms"); //#cms [data-confirm], #cms [data-href] diff --git a/public/js/components/Bootstrap/Modal.js b/public/js/components/Bootstrap/Modal.js index 734a3bdb9..e390319e8 100755 --- a/public/js/components/Bootstrap/Modal.js +++ b/public/js/components/Bootstrap/Modal.js @@ -109,7 +109,7 @@ export default { document.body.appendChild(wrapper); }); }, - template: `