From 1b29b89bf126e0c73e5ab36993ec4cf12fb86450 Mon Sep 17 00:00:00 2001 From: thejacer87 Date: Fri, 17 Mar 2017 21:53:09 -0700 Subject: [PATCH] New movie search (#1212) * add movie search empty template (#1149) * hooked up new route in controller (#1149) --- src/UI/AddMovies/AddMoviesLayout.js | 12 ++++++++---- src/UI/AddMovies/AddMoviesView.js | 6 +++++- src/UI/Content/navbar.less | 8 ++++++++ src/UI/Controller.js | 4 ++-- src/UI/Navbar/Search.js | 7 ++++++- 5 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/UI/AddMovies/AddMoviesLayout.js b/src/UI/AddMovies/AddMoviesLayout.js index 460be57e0..83bd2a673 100644 --- a/src/UI/AddMovies/AddMoviesLayout.js +++ b/src/UI/AddMovies/AddMoviesLayout.js @@ -33,11 +33,15 @@ module.exports = Marionette.Layout.extend({ id : 'add-movies-screen' }, - initialize : function() { + initialize : function(options) { ProfileCollection.fetch(); RootFolderCollection.fetch().done(function() { RootFolderCollection.synced = true; }); + + if (options.action == "search") { + this._addMovies(options); + } }, _toggleExisting : function(e) { @@ -50,7 +54,7 @@ module.exports = Marionette.Layout.extend({ onShow : function() { - this.workspace.show(new AddMoviesView()); + this.workspace.show(new AddMoviesView(this.options)); this.ui.$existing.hide(); }, @@ -72,8 +76,8 @@ module.exports = Marionette.Layout.extend({ AppLayout.modalRegion.show(this.rootFolderLayout); }, - _addMovies : function() { - this.workspace.show(new AddMoviesView()); + _addMovies : function(options) { + this.workspace.show(new AddMoviesView(options)); }, _addFromList : function() { diff --git a/src/UI/AddMovies/AddMoviesView.js b/src/UI/AddMovies/AddMoviesView.js index a871af517..7947a4792 100644 --- a/src/UI/AddMovies/AddMoviesView.js +++ b/src/UI/AddMovies/AddMoviesView.js @@ -26,7 +26,6 @@ module.exports = Marionette.Layout.extend({ }, initialize : function(options) { - this.isExisting = options.isExisting; this.collection = new AddMoviesCollection(); @@ -49,6 +48,11 @@ module.exports = Marionette.Layout.extend({ }); this.throttledSearch = _.debounce(this.search, 1000, { trailing : true }).bind(this); + + if (options.action == "search") { + this.search({term: options.query}); + } + }, onRender : function() { diff --git a/src/UI/Content/navbar.less b/src/UI/Content/navbar.less index 00bee18e5..83dc9cd41 100644 --- a/src/UI/Content/navbar.less +++ b/src/UI/Content/navbar.less @@ -213,6 +213,14 @@ } } + .no-movies-found { + color: #fff; + font-size: 1em; + &:hover { + text-decoration: none; + } + } + ::-webkit-input-placeholder { color: #cccccc; opacity: 0.25; diff --git a/src/UI/Controller.js b/src/UI/Controller.js index 89775a3ba..49d57c7be 100644 --- a/src/UI/Controller.js +++ b/src/UI/Controller.js @@ -19,9 +19,9 @@ module.exports = NzbDroneController.extend({ this.showMainRegion(new AddSeriesLayout({ action : action })); }, - addMovies : function(action) { + addMovies : function(action, query) { this.setTitle("Add Movie"); - this.showMainRegion(new AddMoviesLayout({action : action})); + this.showMainRegion(new AddMoviesLayout({ action : action, query : query })); }, calendar : function() { diff --git a/src/UI/Navbar/Search.js b/src/UI/Navbar/Search.js index 91d1bfaa8..e5a12e8bd 100644 --- a/src/UI/Navbar/Search.js +++ b/src/UI/Navbar/Search.js @@ -14,7 +14,7 @@ var substringMatcher = function() { var matches = _.select(FullMovieCollection.toJSON(), function(series) { return series.title.toLowerCase().indexOf(q.toLowerCase()) > -1; }); - cb(matches); + cb(matches); }; }; @@ -28,6 +28,11 @@ $.fn.bindSearch = function() { displayKey : function(series) { return series.title + ' (' + series.year + ')'; }, + templates : { + empty : function(input) { + return '
' + }, + }, source : substringMatcher() });