From 6d7da9b8eb55d42e2f78ba6efc35917fd53c48bf Mon Sep 17 00:00:00 2001 From: chriscauley Date: Mon, 23 Aug 2021 19:07:26 +0000 Subject: [PATCH 1/2] Explore pane now set from route --- resources/js/Pages/Explore.vue | 31 ++--------------------------- resources/js/Pages/Explore/panes.js | 27 +++++++++++++++++++++++++ resources/js/store/index.js | 8 +++++++- 3 files changed, 36 insertions(+), 30 deletions(-) create mode 100644 resources/js/Pages/Explore/panes.js diff --git a/resources/js/Pages/Explore.vue b/resources/js/Pages/Explore.vue index ee41fa9..c2ac977 100644 --- a/resources/js/Pages/Explore.vue +++ b/resources/js/Pages/Explore.vue @@ -64,12 +64,7 @@ import Layout from '../Shared/Layouts/Layout.vue'; import MapSheetLayout from '../Shared/Layouts/MapSheetLayout.vue'; import LPBottomSheet from '../Shared/LPBottomSheet.vue'; -// panes -import Alteration from './Explore/Alteration.vue'; -import NewConstruction from './Explore/NewConstruction.vue'; -import SalePrices from './Explore/SalePrices.vue'; -import Zoning from './Explore/Zoning.vue'; -import Layers from './Explore/Layers.vue'; +import panes from './Explore/panes'; export default { components: { @@ -79,29 +74,7 @@ export default { layout: [Layout, MapSheetLayout], data() { - return { - panes: [{ - title: 'Sale Prices', - component: SalePrices, - route: 'sales', - }, { - title: 'Zoning', - component: Zoning, - route: 'zoning', - }, { - title: 'New Construction Permits', - component: NewConstruction, - route: 'construction', - }, { - title: 'Alteration Permits', - component: Alteration, - route: 'alteration', - }, { - title: 'Planning Overlays', - component: Layers, - route: 'layers', - }], - }; + return { panes }; }, computed: { diff --git a/resources/js/Pages/Explore/panes.js b/resources/js/Pages/Explore/panes.js new file mode 100644 index 0000000..4d2f544 --- /dev/null +++ b/resources/js/Pages/Explore/panes.js @@ -0,0 +1,27 @@ +import Alteration from './Alteration.vue'; +import NewConstruction from './NewConstruction.vue'; +import SalePrices from './SalePrices.vue'; +import Zoning from './Zoning.vue'; +import Layers from './Layers.vue'; + +export default [{ + title: 'Sale Prices', + component: SalePrices, + route: 'sales', +}, { + title: 'Zoning', + component: Zoning, + route: 'zoning', +}, { + title: 'New Construction Permits', + component: NewConstruction, + route: 'construction', +}, { + title: 'Alteration Permits', + component: Alteration, + route: 'alteration', +}, { + title: 'Planning Overlays', + component: Layers, + route: 'layers', +}]; diff --git a/resources/js/store/index.js b/resources/js/store/index.js index 88958d2..3e080ad 100644 --- a/resources/js/store/index.js +++ b/resources/js/store/index.js @@ -2,9 +2,15 @@ import Vue from 'vue'; import Vuex from 'vuex'; import { getField, updateField } from 'vuex-map-fields'; import { parse } from 'papaparse'; +import panes from '../Pages/Explore/panes'; Vue.use(Vuex); +const getInitialPane = () => { + const { pane } = route().params; + return panes.findIndex((p) => p.route === pane); +}; + export default new Vuex.Store({ strict: true, state: { @@ -28,7 +34,7 @@ export default new Vuex.Store({ // from letsplanorg exploreIsExpanded: false, layersIsExpanded: true, - exploreCurrentPane: 0, + exploreCurrentPane: getInitialPane(), tourShown: false, }, mutations: { From 2f13a3869e2ec0a6e2a0c703aec7591f566f5048 Mon Sep 17 00:00:00 2001 From: chriscauley Date: Mon, 23 Aug 2021 20:07:00 +0000 Subject: [PATCH 2/2] using inertia route as sole source of truth for which pane is visible via route().params.pane --- resources/js/Pages/Explore.vue | 92 ++++++++++--------- .../js/Shared/Layouts/MapSheetLayout.vue | 15 ++- resources/js/store/index.js | 7 -- 3 files changed, 56 insertions(+), 58 deletions(-) diff --git a/resources/js/Pages/Explore.vue b/resources/js/Pages/Explore.vue index c2ac977..eb21a3b 100644 --- a/resources/js/Pages/Explore.vue +++ b/resources/js/Pages/Explore.vue @@ -6,7 +6,7 @@ Previous data mdi-chevron-left @@ -16,7 +16,7 @@ style="flex: 1 1 0" > Next data mdi-chevron-right @@ -41,7 +41,7 @@