From 7ed7ce1bb99069356c6eb7304fa0c3cc92c4c617 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Tue, 24 Sep 2024 14:57:41 +0200 Subject: [PATCH] active Menu Entry logic for CISVUE --- application/controllers/CisVue/Cms.php | 20 ++- application/views/Cis/Profil.php | 4 +- application/views/lehre/Antrag/Create.php | 32 +++-- .../views/lehre/Antrag/Student/List.php | 4 +- public/js/components/Cis/Menu.js | 16 ++- public/js/components/Cis/Menu/Entry.js | 129 ++++++++++++++---- 6 files changed, 159 insertions(+), 46 deletions(-) diff --git a/application/controllers/CisVue/Cms.php b/application/controllers/CisVue/Cms.php index 7eb810476..d1ab3c23b 100755 --- a/application/controllers/CisVue/Cms.php +++ b/application/controllers/CisVue/Cms.php @@ -40,13 +40,21 @@ class Cms extends FHC_Controller */ public function content($content_id, $version = null, $sprache = null, $sichtbar = true) { - $content = $this->ContentModel->load($content_id); - - $content = $this->getDataOrTerminateWithError($content); - + // return early if the content_id for the content is missing + if (!isset($content_id)) + $this->terminateWithError("content_id is missing"); + + $content = $this->ContentModel->load($content_id); + if (isError($content)) + $this->terminateWithError(getError($content)); + + $content = getData($content); + if (NULL === $content) + $this->terminateWithError("Content not found"); + $content = current($content); - $this->load->view('CisVue/Cms/Content', ['content_id' => $content_id, 'template_kurzbz'=>$content->template_kurzbz , 'version' => $version, 'sprache' => $sprache, 'sichtbar' => $sichtbar]); + $this->load->view('CisVue/Cms/Content', ['content_id' => $content_id, 'template_kurzbz' => $content->template_kurzbz, 'version' => $version, 'sprache' => $sprache, 'sichtbar' => $sichtbar]); } /** @@ -62,7 +70,7 @@ class Cms extends FHC_Controller */ public function news($infoscreen = false, $studiengang_kz = null, $semester = null, $mischen = true, $titel = '', $edit = false, $sichtbar = true) { - $this->load->view('CisHtml/Cms/Content', ['infoscreen' => $infoscreen, 'studiengang_kz' => $studiengang_kz, 'semester' => $semester, 'mischen' => $mischen, 'titel' => $titel, 'edit' => $edit, 'sichtbar' => $sichtbar]); + $this->load->view('CisVue/Cms/Content', ['infoscreen' => $infoscreen, 'studiengang_kz' => $studiengang_kz, 'semester' => $semester, 'mischen' => $mischen, 'titel' => $titel, 'edit' => $edit, 'sichtbar' => $sichtbar]); } public function getNews($infoscreen = false, $studiengang_kz = null, $semester = null, $mischen = true, $titel = '', $edit = false, $sichtbar = true) diff --git a/application/views/Cis/Profil.php b/application/views/Cis/Profil.php index cb3d28711..788d44360 100755 --- a/application/views/Cis/Profil.php +++ b/application/views/Cis/Profil.php @@ -8,11 +8,11 @@ $includesArray = array( ); -$this->load->view('templates/CISHTML-Header', $includesArray); +$this->load->view('templates/CISVUE-Header', $includesArray); ?>
-load->view('templates/CISHTML-Footer', $includesArray); ?> +load->view('templates/CISVUE-Footer', $includesArray); ?> diff --git a/application/views/lehre/Antrag/Create.php b/application/views/lehre/Antrag/Create.php index dcfd29e42..00e41d1cd 100755 --- a/application/views/lehre/Antrag/Create.php +++ b/application/views/lehre/Antrag/Create.php @@ -18,10 +18,18 @@ $sitesettings = array( ) ); -$this->load->view( - 'templates/CISHTML-Header', - $sitesettings -); +if(defined('CIS4')){ + $this->load->view( + 'templates/CISVUE-Header', + $sitesettings + ); +}else{ + $this->load->view( + 'templates/FHC-Header', + $sitesettings + ); +} + ?>
@@ -49,7 +57,15 @@ $this->load->view(
load->view( - 'templates/CISHTML-Footer', - $sitesettings -); + +if (defined('CIS4')) { + $this->load->view( + 'templates/CISVUE-Footer', + $sitesettings + ); +} else { + $this->load->view( + 'templates/FHC-Footer', + $sitesettings + ); +} diff --git a/application/views/lehre/Antrag/Student/List.php b/application/views/lehre/Antrag/Student/List.php index 2be4f63d7..c2e3060d1 100755 --- a/application/views/lehre/Antrag/Student/List.php +++ b/application/views/lehre/Antrag/Student/List.php @@ -18,7 +18,7 @@ $sitesettings = array( ); $this->load->view( - 'templates/CISHTML-Header', + 'templates/CISVUE-Header', $sitesettings ); ?> @@ -222,6 +222,6 @@ $this->load->view( load->view( - 'templates/CISHTML-Footer', + 'templates/CISVUE-Footer', $sitesettings ); diff --git a/public/js/components/Cis/Menu.js b/public/js/components/Cis/Menu.js index 71400b3b5..b5f265e3b 100755 --- a/public/js/components/Cis/Menu.js +++ b/public/js/components/Cis/Menu.js @@ -16,19 +16,27 @@ export default { }, data: () => { return { - entries: [] + entries: [], + activeEntry:null, + url:null, }; }, + methods:{ + setActiveEntry(content_id){ + this.activeEntry = content_id; + } + }, created() { axios.get(FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/components/CisVue/Menu').then(res => { this.entries = res.data.retval.childs; }); + }, - template: ` + template: /*html*/` +

CISVUE HEADER

- @@ -51,7 +59,7 @@ export default { diff --git a/public/js/components/Cis/Menu/Entry.js b/public/js/components/Cis/Menu/Entry.js index 93bfc2819..8d2469887 100755 --- a/public/js/components/Cis/Menu/Entry.js +++ b/public/js/components/Cis/Menu/Entry.js @@ -5,14 +5,53 @@ export default { level: { type: Number, default: 1 - } + }, + activeContent: String }, data: () => { return { - collapse: null + collapse: null, + url:null, } }, + emits: ["activeEntry"], + watch:{ + activeContent: function(newValue){ + if(newValue == this.entry.content_id){ + this.entry.menu_open = true; + }else{ + if(this.entry.childs instanceof Array){ + for(let child of this.entry.childs){ + child.menu_open = false; + + } + } + if (this.searchRecursiveChild(this.entry,newValue)){ + this.entry.menu_open = true; + }else{ + this.entry.menu_open = false; + } + } + }, + 'entry.menu_open': function (newValue,oldValue) { + if (newValue) { + console.log(this.entry.titel,"open") + this.collapse && this.collapse.show(); + } else { + console.log(this.entry.titel,"close") + this.collapse && this.collapse.hide(); + } + } + }, + computed: { + active: function () { + if (this.activeContent) { + return this.activeContent == this.entry.content_id; + } else { + return false; + } + }, link() { if (this.entry.template_kurzbz == 'redirect') { if (!this.entry.content) @@ -23,9 +62,19 @@ export default { return ''; // TODO(chris): replace get params url = url.childNodes[0].nodeValue + ""; - url = url.replace(/^\.\.\/cms\/news\.php/, FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/CisVue/Cms/news'); - url = url.replace(/^\.\.\//, FHC_JS_DATA_STORAGE_OBJECT.app_root); - return url; + if (url.includes("../cms/news.php")) { + let news_regex = new RegExp("^\.\./cms/news\.php"); + url = url.replace(news_regex, FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/CisVue/Cms/news'); + } + else if(url.includes("../index.ci.php")){ + let index_regex = new RegExp("^\.\./index\.ci\.php"); + url = url.replace(index_regex, FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router); + } + else if (url.includes("../")) { + let relative_regex = new RegExp("^\.\./"); + url = url.replace(relative_regex, FHC_JS_DATA_STORAGE_OBJECT.app_root); + } + return url; } return FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/CisVue/Cms/content/' + this.entry.content_id; }, @@ -50,11 +99,33 @@ export default { } }, methods: { + searchRecursiveChild(entry,child_content_id){ + if (entry.childs instanceof Array) { + for (let child of entry.childs) { + if (child.content_id == child_content_id){ + return true; + } + if (this.searchRecursiveChild(child, child_content_id)){ + return true; + } + } + } + return false; + }, + resendEmit(event){ + console.log(this.entry.titel); + this.entry.menu_open = true; + this.$emit('activeEntry',event); + }, toggleCollapse(evt) { - if (this.collapse !== null) { + if (this.level > 1 && this.collapse !== null) { this.entry.menu_open = !this.entry.menu_open; this.collapse.toggle(evt.target); - } + }else{ + this.active ? + this.$emit("activeEntry", null): + this.$emit("activeEntry", this.entry.content_id); + } } }, mounted() { @@ -63,33 +134,42 @@ export default { this.$refs.children.className += ' show'; this.collapse = new bootstrap.Collapse(this.$refs.children, { toggle: false }); } + + this.url = window.location.href; + if (window.location.href == this.link) { + this.$emit("activeEntry", this.entry.content_id); + } }, - template: ` -
+ template: /*html*/` + +
INCLUDE