Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
vue-shufflejs-plugin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dmstr
vue-shufflejs-plugin
Commits
3aec8a11
Commit
3aec8a11
authored
Sep 28, 2018
by
Marc Mautz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated filter presets handling
parent
cd41ba61
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
22 deletions
+31
-22
VueShuffleNavbar.vue
src/components/VueShuffleNavbar.vue
+31
-22
No files found.
src/components/VueShuffleNavbar.vue
View file @
3aec8a11
...
@@ -48,7 +48,7 @@
...
@@ -48,7 +48,7 @@
<multiselect
<multiselect
:id=
"index"
:id=
"index"
:ref=
"index"
:ref=
"index"
:value=
"
filterBy
[index]"
:value=
"
selectedFilters
[index]"
:options=
"getOptions(item.options)"
:options=
"getOptions(item.options)"
:multiple=
"true"
:multiple=
"true"
:hideSelected=
"true"
:hideSelected=
"true"
...
@@ -86,7 +86,6 @@
...
@@ -86,7 +86,6 @@
],
],
data
()
{
data
()
{
return
{
return
{
filterBy
:
[],
filtered
:
[],
filtered
:
[],
checked
:
(
this
.
filterMode
===
Shuffle
.
FilterMode
.
ALL
),
checked
:
(
this
.
filterMode
===
Shuffle
.
FilterMode
.
ALL
),
searchBy
:
null
,
searchBy
:
null
,
...
@@ -104,29 +103,43 @@
...
@@ -104,29 +103,43 @@
selectedFilters
:
{}
selectedFilters
:
{}
}
}
},
},
created
()
{},
mounted
()
{
mounted
()
{
const
qs
=
window
.
location
.
hash
.
split
(
'?'
)[
1
]
this
.
checkUrlQueryParams
()
this
.
queryStrings
=
this
.
parseQueryString
(
qs
)
},
console
.
log
(
'queryStrings'
,
this
.
queryStrings
)
methods
:
{
/**
setTimeout
(()
=>
{
* Check if url query params set & update filter selection
*/
checkUrlQueryParams
()
{
if
(
window
.
location
.
hash
.
length
&&
window
.
location
.
hash
.
indexOf
(
'?'
)
!==
-
1
)
{
const
qs
=
window
.
location
.
hash
.
split
(
'?'
)[
1
]
this
.
queryStrings
=
this
.
parseQueryString
(
qs
)
setTimeout
(()
=>
{
this
.
updateFilters
()
},
1500
)
}
},
/**
* Set filter presets & change filter selection
*/
updateFilters
()
{
const
refs
=
this
.
$refs
const
refs
=
this
.
$refs
for
(
const
prop
in
refs
)
{
for
(
const
prop
in
refs
)
{
this
.
set
SelectedFilter
s
(
prop
,
refs
[
prop
][
0
],
this
.
queryStrings
[
prop
])
this
.
set
FilterPreset
s
(
prop
,
refs
[
prop
][
0
],
this
.
queryStrings
[
prop
])
}
}
console
.
log
(
'selectedFilters'
,
this
.
selectedFilters
)
for
(
const
key
in
this
.
selectedFilters
)
{
},
500
)
if
(
this
.
selectedFilters
.
hasOwnProperty
(
key
))
{
},
this
.
filterChange
(
this
.
selectedFilters
[
key
],
key
)
computed
:
{},
}
methods
:
{
}
},
/**
/**
* Set
selected filters from url query
* Set
filter presets
* @param {String} key
* @param {String} key
* @param {String} ref
* @param {String} ref
* @param {String} qs
* @param {String} qs
*/
*/
set
SelectedFilter
s
(
key
,
ref
,
qs
)
{
set
FilterPreset
s
(
key
,
ref
,
qs
)
{
let
filters
=
[]
let
filters
=
[]
for
(
const
prop
in
qs
)
{
for
(
const
prop
in
qs
)
{
if
(
qs
.
hasOwnProperty
(
prop
))
{
if
(
qs
.
hasOwnProperty
(
prop
))
{
...
@@ -137,8 +150,7 @@
...
@@ -137,8 +150,7 @@
filters
.
push
(
found
)
filters
.
push
(
found
)
}
}
}
}
console
.
log
(
'filters'
,
filters
)
this
.
$set
(
this
.
selectedFilters
,
key
,
filters
)
this
.
selectedFilters
[
key
]
=
filters
},
},
/**
/**
* Parse query string and return as array
* Parse query string and return as array
...
@@ -177,7 +189,7 @@
...
@@ -177,7 +189,7 @@
return
result
return
result
},
},
/**
/**
* Get filter options
* Get
available
filter options
* @param options
* @param options
*/
*/
getOptions
(
options
)
{
getOptions
(
options
)
{
...
@@ -193,10 +205,7 @@
...
@@ -193,10 +205,7 @@
* @param id
* @param id
*/
*/
filterChange
(
value
,
id
)
{
filterChange
(
value
,
id
)
{
// this.filtered[id] = value.map(a => a.label)
this
.
filtered
[
id
]
=
value
this
.
filtered
[
id
]
=
value
console
.
log
(
'filtered'
,
this
.
filtered
)
console
.
log
(
'$refs'
,
this
.
$refs
)
this
.
$emit
(
'filterChange'
,
this
.
filtered
)
this
.
$emit
(
'filterChange'
,
this
.
filtered
)
},
},
/**
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment