improved query handling
This commit is contained in:
@@ -17,15 +17,17 @@ export default [
|
|||||||
options: TextOptions
|
options: TextOptions
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
default: ({ query }) => ({
|
default: ({ query }) => {
|
||||||
mode: query.mode || 'tree-map',
|
let { mode = 'tree-map', texts = [] } = query
|
||||||
|
if (typeof texts === 'string') texts = [texts]
|
||||||
// In case of a reload or direct link, vue-router doesn't turn the query string into an array.
|
// In case of a reload or direct link, vue-router doesn't turn the query string into an array.
|
||||||
texts: query.texts && query.texts.length && typeof query.texts[0] === 'string'
|
if (texts && texts.length && typeof texts[0] === 'string') {
|
||||||
? query.texts.map(text => text.split(',').map(id => parseInt(id)))
|
texts = texts.map(text => text.split(',').map(id => parseInt(id)))
|
||||||
: query.texts
|
}
|
||||||
}),
|
return { mode, texts }
|
||||||
|
},
|
||||||
options: ({ query }) => ({
|
options: ({ query }) => ({
|
||||||
show: !('texts' in query)
|
show: !('texts' in query && query.texts.length)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user