Skip to content

Commit

Permalink
add watched filter to movies list
Browse files Browse the repository at this point in the history
  • Loading branch information
claudetete committed Jul 4, 2019
1 parent d0f8e36 commit 5513cc7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
13 changes: 11 additions & 2 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 @@ -178,7 +185,7 @@
sortOrder: 'asc',
filterCallback: 'multiple'
}
]
]

## Wrapper for returning the available fields for sort/filter
## Available fields are defined in the entity controller and passed
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 Expand Up @@ -476,4 +485,4 @@

## Get a sort, fallback to default
App.reqres.setHandler 'filter:sort:store:get', ->
API.getStoreSort()
API.getStoreSort()
4 changes: 2 additions & 2 deletions 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 All @@ -75,4 +75,4 @@

## handler for other modules to get a list view.
App.reqres.setHandler "movie:list:view", (collection) ->
API.getMoviesView collection, true
API.getMoviesView collection, true
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 5513cc7

Please sign in to comment.