Skip to content
Snippets Groups Projects
Commit cf9a44b4 authored by Erwan Rouchet's avatar Erwan Rouchet Committed by Bastien Abadie
Browse files

Add explicit top-level filters

parent 44388bf9
No related branches found
No related tags found
1 merge request!1019Add explicit top-level filters
......@@ -311,16 +311,26 @@ export default {
// We cannot use the normal vue-router navigation guards because those only work on the main component of a route
$route: {
immediate: true,
handler ({ query }, oldValue) {
async handler ({ query }, oldValue) {
this.parseQuery(query)
/*
* When the handler is run due to `immediate: true`, `oldValue` will be undefined.
* We can use this to detect when the component first loads, and when there are no filters at all
* we can add default filters for top-level elements on projects.
*/
if (oldValue === undefined && !query.page && !Object.keys(this.selectedFilters).length && !this.useSelection && this.corpusId) {
// TODO: Also include folder=yes / top level type once those are removed from the backend
if (
oldValue === undefined &&
!query.page &&
!Object.keys(this.selectedFilters).length &&
!this.useSelection &&
this.corpusId &&
!this.elementId
) {
// Ensure we have a corpus available
const corpus = await this.$store.dispatch('corpora/get', { id: this.corpusId })
this.selectedFilters = { top_level: true }
if (corpus.top_level_type) this.selectedFilters.type = corpus.top_level_type
else this.selectedFilters.folder = true
}
this.onFilterUpdate()
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment