Skip to content

Commit

Permalink
Merge pull request #366 from claudetete/master
Browse files Browse the repository at this point in the history
Add watched filter to movies list
  • Loading branch information
enen92 authored Jul 14, 2020
2 parents 426b586 + c67e31b commit b7a224a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/js/apps/filter/filter_app.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@
sortOrder: 'asc',
filterCallback: 'unwatched'
}
{
alias: 'watched'
type: "boolean"
key: 'watched'
sortOrder: 'asc',
filterCallback: 'watched'
}
{
alias: 'in progress'
type: "boolean"
Expand Down Expand Up @@ -343,6 +350,8 @@
collection.filterByMultiple(key, vals) ## data is not array
when 'unwatched'
collection.filterByUnwatched()
when 'watched'
collection.filterByWatched()
when 'inprogress'
collection.filterByInProgress()
when 'thumbsup'
Expand Down
2 changes: 1 addition & 1 deletion src/js/apps/movie/list/list_controller.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
## See filter_app.js for available options
getAvailableFilters: ->
sort: ['title', 'year', 'dateadded', 'rating', 'random']
filter: ['year', 'genre', 'writer', 'director', 'cast', 'set', 'unwatched', 'inprogress', 'mpaa', 'studio', 'thumbsUp']
filter: ['year', 'genre', 'writer', 'director', 'cast', 'set', 'unwatched', 'watched', 'inprogress', 'mpaa', 'studio', 'thumbsUp']

## Apply filter view and provide a handler for applying changes
getFiltersView: (collection) ->
Expand Down
9 changes: 9 additions & 0 deletions src/js/entities/_base/filtered.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@
unwatched = if model.get('playcount') > 0 then 0 else 1
unwatched > 0

filterByWatched: ->
@filterBy 'watched', (model) ->
watched = 1
if model.get('type') is 'tvshow'
watched = model.get('watchedepisodes')
else if model.get('type') is 'movie' or model.get('type') is 'episode'
watched = if model.get('playcount') > 0 then 1 else 0
watched > 0

filterByThumbsUp: (key) ->
@filterBy key, (model) ->
App.request "thumbsup:check", model
Expand Down

0 comments on commit b7a224a

Please sign in to comment.