From 45ff06737911a23e8ca1b96c07a3b3efea517561 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Tue, 8 Oct 2024 13:47:48 +0200 Subject: [PATCH] makes the url match to the Menu entries better --- public/js/components/Cis/Menu.js | 42 ++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/public/js/components/Cis/Menu.js b/public/js/components/Cis/Menu.js index 92e189af3..9608bc9de 100755 --- a/public/js/components/Cis/Menu.js +++ b/public/js/components/Cis/Menu.js @@ -21,15 +21,25 @@ export default { entries: [], activeEntry:null, url:null, - highestMatchingUrlCount:0, + urlMatchRankings:[], }; }, - methods:{ - checkHighestMatchingUrlCount(count){ - if(count > this.highestMatchingUrlCount) - { - this.highestMatchingUrlCount = count; + computed:{ + highestMatchingUrlCount(){ + // gets the hightest ranking inside the array + let highestMatch = Math.max(...this.urlMatchRankings); + + if(this.urlMatchRankings.length > 0){ + // if more than one entry has the same ranking, none should be active + return this.urlMatchRankings.filter((value)=>value == highestMatch).length > 1 ? null : highestMatch; } + + return null; + }, + }, + methods:{ + addUrlCount(count){ + this.urlMatchRankings.push(count); }, setActiveEntry(content_id){ @@ -51,6 +61,15 @@ export default { + +