diff --git a/src/UI/AddMovies/AddMoviesLayout.js b/src/UI/AddMovies/AddMoviesLayout.js index 3dd299959..30cbc74b3 100644 --- a/src/UI/AddMovies/AddMoviesLayout.js +++ b/src/UI/AddMovies/AddMoviesLayout.js @@ -17,7 +17,8 @@ module.exports = Marionette.Layout.extend({ events : { 'click .x-import' : '_importMovies', - 'click .x-add-new' : '_addMovies' + 'click .x-add-new' : '_addMovies', + 'click .x-show-existing' : '_toggleExisting' }, attributes : { @@ -31,13 +32,20 @@ module.exports = Marionette.Layout.extend({ }); }, + _toggleExisting : function(e) { + var showExisting = e.target.checked; + + vent.trigger(vent.Commands.ShowExistingCommand, { + showExisting: showExisting + }); + }, + onShow : function() { this.workspace.show(new AddMoviesView()); }, _folderSelected : function(options) { vent.trigger(vent.Commands.CloseModalCommand); - //TODO: Fix this shit. this.workspace.show(new ExistingMoviesCollectionView({ model : options.model })); }, diff --git a/src/UI/AddMovies/AddMoviesLayoutTemplate.hbs b/src/UI/AddMovies/AddMoviesLayoutTemplate.hbs index 9eccf4d91..2ad44bee5 100644 --- a/src/UI/AddMovies/AddMoviesLayoutTemplate.hbs +++ b/src/UI/AddMovies/AddMoviesLayoutTemplate.hbs @@ -9,6 +9,31 @@ +
+
+
+ + +
+
+
+
+
+
diff --git a/src/UI/AddMovies/AddMoviesView.js b/src/UI/AddMovies/AddMoviesView.js index ca47d5368..57b6de239 100644 --- a/src/UI/AddMovies/AddMoviesView.js +++ b/src/UI/AddMovies/AddMoviesView.js @@ -27,6 +27,7 @@ module.exports = Marionette.Layout.extend({ initialize : function(options) { console.log(options); + this.isExisting = options.isExisting; this.collection = new AddMoviesCollection(); diff --git a/src/UI/AddMovies/Existing/AddExistingMovieCollectionView.js b/src/UI/AddMovies/Existing/AddExistingMovieCollectionView.js index 1e3d38b6a..8b556c812 100644 --- a/src/UI/AddMovies/Existing/AddExistingMovieCollectionView.js +++ b/src/UI/AddMovies/Existing/AddExistingMovieCollectionView.js @@ -1,6 +1,7 @@ var Marionette = require('marionette'); var AddMoviesView = require('../AddMoviesView'); var UnmappedFolderCollection = require('./UnmappedFolderCollection'); +var vent = require('vent'); module.exports = Marionette.CompositeView.extend({ itemView : AddMoviesView, diff --git a/src/UI/AddMovies/RootFolders/RootFolderLayout.js b/src/UI/AddMovies/RootFolders/RootFolderLayout.js index f48890076..f0d9f3614 100644 --- a/src/UI/AddMovies/RootFolders/RootFolderLayout.js +++ b/src/UI/AddMovies/RootFolders/RootFolderLayout.js @@ -48,7 +48,7 @@ var Layout = Marionette.Layout.extend({ var self = this; var newDir = new RootFolderModel({ - Path : this.ui.pathInput.val() + Path : this.ui.pathInput.val(), }); this.bindToModelValidation(newDir); diff --git a/src/UI/AddMovies/RootFolders/RootFolderLayoutTemplate.hbs b/src/UI/AddMovies/RootFolders/RootFolderLayoutTemplate.hbs index 1d6eae265..54bfc192d 100644 --- a/src/UI/AddMovies/RootFolders/RootFolderLayoutTemplate.hbs +++ b/src/UI/AddMovies/RootFolders/RootFolderLayoutTemplate.hbs @@ -31,6 +31,8 @@
diff --git a/src/UI/AddMovies/SearchResultCollectionView.js b/src/UI/AddMovies/SearchResultCollectionView.js index 02fe1fa41..08649436c 100644 --- a/src/UI/AddMovies/SearchResultCollectionView.js +++ b/src/UI/AddMovies/SearchResultCollectionView.js @@ -1,12 +1,21 @@ var Marionette = require('marionette'); var SearchResultView = require('./SearchResultView'); +var vent = require('vent'); module.exports = Marionette.CollectionView.extend({ itemView : SearchResultView, initialize : function(options) { + this.showExisting = true; this.isExisting = options.isExisting; this.showing = 1; + vent.on(vent.Commands.ShowExistingCommand, this._onExistingToggle.bind(this)); + }, + + _onExistingToggle : function(data) { + this.showExisting = data.showExisting; + + this.render(); }, showAll : function() { @@ -34,8 +43,17 @@ module.exports = Marionette.CollectionView.extend({ }, appendHtml : function(collectionView, itemView, index) { - if (!this.isExisting || index < this.showing || index === 0) { - collectionView.$el.append(itemView.el); + if(this.isExisting) { + if(this.showExisting) { + if (index < this.showing || index === 0) { + collectionView.$el.append(itemView.el); + } + } + } else if(!this.isExisting) { + if (index < this.showing || index === 0) { + collectionView.$el.append(itemView.el); + } } + } }); diff --git a/src/UI/AddMovies/SearchResultView.js b/src/UI/AddMovies/SearchResultView.js index f563e6f66..f4d3a18f6 100644 --- a/src/UI/AddMovies/SearchResultView.js +++ b/src/UI/AddMovies/SearchResultView.js @@ -43,7 +43,7 @@ var view = Marionette.ItemView.extend({ throw 'model is required'; } - console.log(this.route); + //console.log(this.route); this.templateHelpers = {}; this._configureTemplateHelpers(); @@ -92,14 +92,12 @@ var view = Marionette.ItemView.extend({ _configureTemplateHelpers : function() { var existingMovies = MoviesCollection.where({ tmdbId : this.model.get('tmdbId') }); - console.log(existingMovies); if (existingMovies.length > 0) { this.templateHelpers.existing = existingMovies[0].toJSON(); } this.templateHelpers.profiles = Profiles.toJSON(); - console.log(this.model); - console.log(this.templateHelpers.existing); + //console.log(this.templateHelpers.isExisting); if (!this.model.get('isExisting')) { this.templateHelpers.rootFolders = RootFolders.toJSON(); } @@ -185,8 +183,8 @@ var view = Marionette.ItemView.extend({ var self = this; var promise = this.model.save(); - console.log(this.model.save); - console.log(promise); + //console.log(this.model.save); + //console.log(promise); if (searchForMovie) { this.ui.addSearchButton.spinForPromise(promise); diff --git a/src/UI/vent.js b/src/UI/vent.js index a623f2dbc..1962f9d22 100644 --- a/src/UI/vent.js +++ b/src/UI/vent.js @@ -29,7 +29,8 @@ vent.Commands = { ShowFileBrowser : 'showFileBrowser', CloseFileBrowser : 'closeFileBrowser', OpenControlPanelCommand : 'OpenControlPanelCommand', - CloseControlPanelCommand : 'CloseControlPanelCommand' + CloseControlPanelCommand : 'CloseControlPanelCommand', + ShowExistingCommand : 'ShowExistingCommand' }; vent.Hotkeys = {