Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add watched filter to movies list #366

Merged
merged 1 commit into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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