From b0e96fbab18e193b0eae9ea2944a0d9b46a9d990 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Mon, 14 Oct 2024 11:42:30 +0200 Subject: [PATCH] replaces the emits to injections to avoid repassing the emits between intermediate parent elements --- public/js/components/Cis/Menu.js | 4 +++- public/js/components/Cis/Menu/Entry.js | 20 ++++++-------------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/public/js/components/Cis/Menu.js b/public/js/components/Cis/Menu.js index 1fd5fce96..8ef389c49 100755 --- a/public/js/components/Cis/Menu.js +++ b/public/js/components/Cis/Menu.js @@ -26,6 +26,8 @@ export default { }, provide(){ return{ + setActiveEntry: this.setActiveEntry, + addUrlCount: this.addUrlCount, makeParentContentActive: this.makeParentContentActive, } }, @@ -94,7 +96,7 @@ export default {
diff --git a/public/js/components/Cis/Menu/Entry.js b/public/js/components/Cis/Menu/Entry.js index b75d71918..aafe19521 100755 --- a/public/js/components/Cis/Menu/Entry.js +++ b/public/js/components/Cis/Menu/Entry.js @@ -15,15 +15,14 @@ export default { urlCount:0, } }, - emits: ["activeEntry", "UrlCount"], - inject: ['makeParentContentActive'], + inject: ['makeParentContentActive', 'setActiveEntry','addUrlCount'], watch:{ highestMatchingUrlCount: function(newValue) { // if this entry has the most matching url parts then it should be active if (this.activeContent == null && newValue == this.urlCount) { - this.$emit("activeEntry", this.entry.content_id); + this.setActiveEntry(this.entry.content_id); } }, activeContent: function(newValue){ @@ -119,9 +118,6 @@ export default { } }, methods: { - passUrlCount(count){ - this.$emit("UrlCount",count); - }, getUrlMatchPoints(url,link){ let splitted_link = link.split('/'); let splitted_url = url.href.split('/'); @@ -139,7 +135,7 @@ export default { } } this.urlCount = count; - this.$emit("UrlCount",count); + this.addUrlCount(count); }, checkActiveUrl(url){ this.getUrlMatchPoints(url,this.link); @@ -153,7 +149,7 @@ export default { // or if the url equals the link of a menu // then set the menu active if (url_hash == this.entry.titel || url.href == this.link) { - this.$emit("activeEntry", this.entry.content_id); + this.setActiveEntry(this.entry.content_id); } }, searchRecursiveChild(entry,child_content_id){ @@ -172,10 +168,6 @@ export default { } return false; }, - resendEmit(event){ - this.entry.menu_open = true; - this.$emit('activeEntry',event); - }, toggleCollapse(evt) { if (this.active) { @@ -184,7 +176,7 @@ export default { else { console.log("entered here to make the content active") - this.$emit("activeEntry", this.entry.content_id); + this.setActiveEntry(this.entry.content_id); } } }, @@ -227,7 +219,7 @@ export default {