Skip to content

Commit

Permalink
Allow setting register from query param
Browse files Browse the repository at this point in the history
  • Loading branch information
avillar committed Jan 3, 2024
1 parent 7942b68 commit f0c46f8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/components/BuildingBlockFilters.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<v-expansion-panels v-model="expanded">
<v-expansion-panel title="Filters" value="expanded">
<v-expansion-panels v-model="expanded" :class="{ 'no-animate': noAnimate }">
<v-expansion-panel title="Filters" value="expanded" eager>
<v-expansion-panel-text>
<div
class="d-flex flex-wrap flex-md-nowrap filter-wrapper"
Expand Down Expand Up @@ -86,6 +86,7 @@ export default {
groups: [],
groupFilter: [],
expanded: false,
noAnimate: true,
};
},
mounted() {
Expand All @@ -99,6 +100,7 @@ export default {
}
});
this.expanded = this.$vuetify.display.mdAndUp ? 'expanded' : null;
setTimeout(() => this.noAnimate = false, 350);
this.debouncedTextFilter = debounce(v => {
this.emitFilter();
Expand Down Expand Up @@ -171,4 +173,9 @@ export default {
}
}
.no-animate {
.v-expansion-panel, .v-expansion-panel-title, .v-expansion-panel-text {
transition: none !important;
}
}
</style>
13 changes: 12 additions & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,22 @@ const routes = [
},
],
},
]
];

export const persistQuery = (to, from, next) => {
const registerQueryParam = from.query.register;
if (registerQueryParam && !to.query.register) {
next({ ...to, query: { register: registerQueryParam }});
} else {
next();
}
}

const router = createRouter({
history: createWebHistory(import.meta.env.BASE_URL),
routes,
})

router.beforeEach(persistQuery);

export default router
12 changes: 11 additions & 1 deletion src/services/config.service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
const config = window.bblocksViewer || {};
let registers;

let registers = window.bblocksRegisters;
const urlParams = new URLSearchParams(window.location.search);
const registerParam = urlParams.getAll('register');
if (registerParam) {
registers = [];
registerParam.forEach(r => r.split(',').forEach(rr => registers.push(rr)));
}

if (!registers) {
registers = window.bblocksRegisters;
}
if (!registers && import.meta.env.VITE_BBLOCK_REGISTERS) {
registers = import.meta.env.VITE_BBLOCK_REGISTERS.split(',');
}
Expand Down

0 comments on commit f0c46f8

Please sign in to comment.