diff --git a/src/NzbDrone.Api/PagingResource.cs b/src/NzbDrone.Api/PagingResource.cs index 3398e6e1d..d05ea2906 100644 --- a/src/NzbDrone.Api/PagingResource.cs +++ b/src/NzbDrone.Api/PagingResource.cs @@ -13,6 +13,7 @@ public class PagingResource public SortDirection SortDirection { get; set; } public string FilterKey { get; set; } public string FilterValue { get; set; } + public string FilterType { get; set; } public int TotalRecords { get; set; } public List Records { get; set; } } diff --git a/src/NzbDrone.Api/REST/RestModule.cs b/src/NzbDrone.Api/REST/RestModule.cs index 5ab5c16e8..d4f2d647b 100644 --- a/src/NzbDrone.Api/REST/RestModule.cs +++ b/src/NzbDrone.Api/REST/RestModule.cs @@ -252,8 +252,15 @@ private PagingResource ReadPagingResourceFromRequest() { pagingResource.FilterValue = Request.Query.FilterValue.ToString(); } + + if (Request.Query.FilterType != null) + { + pagingResource.FilterType = Request.Query.FilterType.ToString(); + } } + + return pagingResource; } } diff --git a/src/NzbDrone.Api/Series/MovieModule.cs b/src/NzbDrone.Api/Series/MovieModule.cs index b08d90747..0f93619ba 100644 --- a/src/NzbDrone.Api/Series/MovieModule.cs +++ b/src/NzbDrone.Api/Series/MovieModule.cs @@ -140,6 +140,24 @@ private PagingResource GetMoviePaged(PagingResource v.MovieFileId == 0; } + if (pagingResource.FilterKey == "title") + { + if (pagingResource.FilterType == "contains") + { + if (pagingResource.FilterValue == string.Empty || pagingResource.FilterValue == null) + { + pagingSpec.FilterExpression = v => true; + } + else + { + pagingSpec.FilterExpression = v => v.CleanTitle.Contains(pagingResource.FilterValue); + } + } else + { + pagingSpec.FilterExpression = v => v.CleanTitle == pagingResource.FilterValue; + } + } + return ApplyToPage(_moviesService.Paged, pagingSpec, MovieResourceMapper.ToResource); } diff --git a/src/UI/ManualImport/Movie/SelectMovieLayout.js b/src/UI/ManualImport/Movie/SelectMovieLayout.js index d22818f21..c830acb72 100644 --- a/src/UI/ManualImport/Movie/SelectMovieLayout.js +++ b/src/UI/ManualImport/Movie/SelectMovieLayout.js @@ -4,6 +4,7 @@ var Marionette = require('marionette'); var Backgrid = require('backgrid'); var MoviesCollection = require('../../Movies/MoviesCollection'); var SelectRow = require('./SelectMovieRow'); +var FullMovieCollection = require('../../Movies/FullMovieCollection'); module.exports = Marionette.Layout.extend({ template : 'ManualImport/Movie/SelectMovieLayoutTemplate', @@ -32,7 +33,7 @@ module.exports = Marionette.Layout.extend({ ], initialize : function() { - this.movieCollection = MoviesCollection.clone(); + this.movieCollection = FullMovieCollection; this._setModelCollection(); this.listenTo(this.movieCollection, 'row:selected', this._onSelected); diff --git a/src/UI/Mixins/AsFilteredCollection.js b/src/UI/Mixins/AsFilteredCollection.js index 4b3fd3272..681ee8af4 100644 --- a/src/UI/Mixins/AsFilteredCollection.js +++ b/src/UI/Mixins/AsFilteredCollection.js @@ -67,12 +67,14 @@ module.exports = function() { _.extend(this.prototype.state, { filterKey : null, - filterValue : null + filterValue : null, + filterType : null }); _.extend(this.prototype.queryParams, { filterKey : 'filterKey', - filterValue : 'filterValue' + filterValue : 'filterValue', + filterType : 'filterType' }); return this;