From 97daff730bcf3a7b888c65766499d1da48597511 Mon Sep 17 00:00:00 2001 From: Bruno Besson Date: Mon, 12 Apr 2021 16:25:48 +0200 Subject: [PATCH] Fix disappearing method from $screen plugin Also fix some issues with active menu --- src/views/SideMenu.vue | 123 ++++++++++++++++++++++++++--------------- 1 file changed, 79 insertions(+), 44 deletions(-) diff --git a/src/views/SideMenu.vue b/src/views/SideMenu.vue index 6d8434dcd5..b184ec48c3 100644 --- a/src/views/SideMenu.vue +++ b/src/views/SideMenu.vue @@ -4,18 +4,60 @@ Camptocamp.org - + - - {{ item.text | uppercaseFirstLetter }} + + {{ $gettext('Topoguide') | uppercaseFirstLetter }} + + + + + + {{ $gettext('outings') | uppercaseFirstLetter }} + + + + + + {{ $gettext('Forum') | uppercaseFirstLetter }} + + + + + + {{ $gettext('Accident database') | uppercaseFirstLetter }} + + + + + + {{ $gettext('articles') | uppercaseFirstLetter }} + + + + + + {{ $gettext('Help') | uppercaseFirstLetter }} @@ -65,47 +107,40 @@ import Advertisement from './Advertisement'; export default { components: { Advertisement }, - computed: { - // This must be computed, because it needs $gettext() function - menuItems() { - return [ - { - name: 'topoguide', - icon: 'icon-topoguide', - text: this.$gettext('Topoguide'), - activeFor: ['routes', 'waypoints', 'route', 'waypoint', 'area', 'areas'], - }, - { - name: 'outings', - icon: 'icon-outing', - text: this.$gettext('outings'), - activeFor: ['outing'], - query: { qa: 'draft,great', bbox: '-431698,3115462,1931123,8442818' }, - }, - { name: 'forum', icon: 'icon-forum', text: this.$gettext('Forum'), activeFor: [] }, - { - name: 'serac', - icon: 'icon-xreport', - text: this.$gettext('Accident database'), - activeFor: ['xreports', 'xreport', 'xreport-add'], - }, - { name: 'articles', icon: 'icon-article', text: this.$gettext('articles'), activeFor: ['article'] }, - { - name: 'article', - icon: 'icon-help', - text: this.$gettext('Help'), - activeFor: [], - minScreenHeight: 715, - params: { id: 106732 }, - }, - ]; - }, + data() { + return { + isTall: false, + }; + }, + + created() { + this.mediaQueryList = window.matchMedia('only screen and (min-height: 715px)'); + if (this.mediaQueryList.addEventListener) { + this.mediaQueryList.addEventListener('change', this.onHeightBreakpointChange); + } else { + // Safari < 14 support + this.mediaQueryList.addListener(this.onHeightBreakpointChange); + } + this.onHeightBreakpointChange(); + }, + + beforeDestroy() { + if (this.mediaQueryList.removeEventListener) { + this.mediaQueryList.removeEventListener('change', this.onHeightBreakpointChange); + } else { + // Safari < 14 support + this.mediaQueryList.removeListener(this.onHeightBreakpointChange); + } }, methods: { showGdpr() { this.$root.$emit('showGdpr'); }, + + onHeightBreakpointChange() { + this.isTall = this.mediaQueryList.matches; + }, }, };