diff --git a/src/UI/AddMovies/AddMoviesView.js b/src/UI/AddMovies/AddMoviesView.js index 1694a9ffc..e83aad42f 100644 --- a/src/UI/AddMovies/AddMoviesView.js +++ b/src/UI/AddMovies/AddMoviesView.js @@ -120,16 +120,17 @@ module.exports = Marionette.Layout.extend({ }, _onMoviesAdded : function(options) { - if (this.isExisting && options.movies.get('path') === this.model.get('folder').path) { + if (this.isExisting && options.movie.get('path') === this.model.get('folder').path) { this.close(); } else if (!this.isExisting) { - this.collection.term = ''; + this.resultCollectionView.setExisting(options.movie.get('imdbId')) + /*this.collection.term = ''; this.collection.reset(); this._clearResults(); this.ui.moviesSearch.val(''); - this.ui.moviesSearch.focus(); + this.ui.moviesSearch.focus();*/ //TODO: Maybe add option wheter to clear search result. } }, @@ -143,6 +144,7 @@ module.exports = Marionette.Layout.extend({ }, _clearResults : function() { + if (!this.isExisting) { this.searchResult.show(new EmptyView()); } else { diff --git a/src/UI/AddMovies/SearchResultCollectionView.js b/src/UI/AddMovies/SearchResultCollectionView.js index e533085ac..ac1257697 100644 --- a/src/UI/AddMovies/SearchResultCollectionView.js +++ b/src/UI/AddMovies/SearchResultCollectionView.js @@ -21,9 +21,21 @@ module.exports = Marionette.CollectionView.extend({ return this.showing >= this.collection.length; }, + setExisting : function(imdbid) { + var movies = this.collection.where({ imdbId : imdbid }); + console.warn(movies) + //debugger; + if (movies.length > 0) { + this.children.findByModel(movies[0])._configureTemplateHelpers(); + //this.children.findByModel(movies[0])._configureTemplateHelpers(); + this.children.findByModel(movies[0]).render(); + //this.templateHelpers.existing = existingMovies[0].toJSON(); + } + }, + appendHtml : function(collectionView, itemView, index) { if (!this.isExisting || index < this.showing || index === 0) { collectionView.$el.append(itemView.el); } } -}); \ No newline at end of file +}); diff --git a/src/UI/AddMovies/SearchResultViewTemplate.hbs b/src/UI/AddMovies/SearchResultViewTemplate.hbs index 41845cdee..87e1167da 100644 --- a/src/UI/AddMovies/SearchResultViewTemplate.hbs +++ b/src/UI/AddMovies/SearchResultViewTemplate.hbs @@ -2,7 +2,11 @@