From 8525c823057f51ba30d064f3658b97d5cdf6e3bf Mon Sep 17 00:00:00 2001 From: Johann Hoffmann Date: Wed, 12 Feb 2025 11:56:12 +0100 Subject: [PATCH] set menuEntry href based on link form -> no href on menus without full url, hash links on menus dont trigger routing anymore; news widget check if carousel exists on mounted nextTick; --- public/js/apps/Dashboard/Fhc.js | 15 ++++++++++++--- public/js/components/Cis/Menu/Entry.js | 7 +++++-- public/js/components/DashboardWidget/News.js | 12 +++++++----- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/public/js/apps/Dashboard/Fhc.js b/public/js/apps/Dashboard/Fhc.js index 8d7f9888b..6a3f8c66d 100644 --- a/public/js/apps/Dashboard/Fhc.js +++ b/public/js/apps/Dashboard/Fhc.js @@ -98,11 +98,12 @@ const app = Vue.createApp({ const target = event.target.closest('a'); if (target && this.isInternalRoute(target.href)) { + const url = new URL(target.href) - const path = new URL(target.href).pathname + const path = url.pathname const base = this.$router.options.history.base const route = path.replace(base, '') || '/' - + // let click event propagate normally if we dont route internally const res = this.$router.resolve(route) if(!res?.matched?.length) return @@ -112,10 +113,13 @@ const app = Vue.createApp({ if(this.isMobile) { // toggle the menu const navMain = document.getElementById('nav-main'); // fix unwanted toggle from off to on for some links on mobile - if(navMain.classList.contains('show')) document.getElementById('nav-main-btn').click(); + if(navMain.classList.contains('show')){ + document.getElementById('nav-main-btn').click(); + } } this.$router.push(route); + } } }, @@ -127,6 +131,11 @@ const app = Vue.createApp({ }, }); +router.beforeEach((to,from) => { + console.log('to', to) + console.log('from', from) +}) + // kind of a bandaid for bad css on some pages to avoid horizontal scroll setScrollbarWidth(); app.use(router); diff --git a/public/js/components/Cis/Menu/Entry.js b/public/js/components/Cis/Menu/Entry.js index 982777e60..cc4ad2df5 100644 --- a/public/js/components/Cis/Menu/Entry.js +++ b/public/js/components/Cis/Menu/Entry.js @@ -74,7 +74,7 @@ export default { return ''; let xmlDoc = (new DOMParser()).parseFromString(this.entry.content,"text/xml"); let url = xmlDoc.getElementsByTagName('url')[0]; - + if (!url) return ''; // TODO(chris): replace get params @@ -101,6 +101,9 @@ export default { } return FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/CisVue/Cms/content/' + this.entry.content_id; }, + hasFullLink() { + return this.link.startsWith(FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router) + }, target() { if (this.entry.template_kurzbz == 'redirect') { if (!this.entry.content) @@ -201,7 +204,7 @@ export default {