95% done with hiding existing movies

pull/282/head
Tim Turner 8 years ago
parent 8c8c7a99e3
commit 7c5f2ca54e

@ -17,7 +17,8 @@ module.exports = Marionette.Layout.extend({
events : { events : {
'click .x-import' : '_importMovies', 'click .x-import' : '_importMovies',
'click .x-add-new' : '_addMovies' 'click .x-add-new' : '_addMovies',
'click .x-show-existing' : '_toggleExisting'
}, },
attributes : { 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() { onShow : function() {
this.workspace.show(new AddMoviesView()); this.workspace.show(new AddMoviesView());
}, },
_folderSelected : function(options) { _folderSelected : function(options) {
vent.trigger(vent.Commands.CloseModalCommand); vent.trigger(vent.Commands.CloseModalCommand);
//TODO: Fix this shit.
this.workspace.show(new ExistingMoviesCollectionView({ model : options.model })); this.workspace.show(new ExistingMoviesCollectionView({ model : options.model }));
}, },

@ -9,6 +9,31 @@
</div> </div>
</div> </div>
</div> </div>
<div class="row">
<div class="col-md-12">
<div class="form-group" style="display: inline-block; float: left; margin-bottom: 0;">
<label class="col-sm-3 control-label">Show Existing</label>
<div class="col-sm-9">
<div class="input-group">
<label class="checkbox toggle well">
<input class="x-show-existing" type="checkbox" checked="checked" name="showExisting"/>
<p>
<span>Yes</span>
<span>No</span>
</p>
<div class="btn btn-primary slide-button"/>
</label>
<span class="help-inline-checkbox">
<i class="icon-sonarr-form-info" title="Should Radarr display movies already in your collection?"/>
</span>
</div>
</div>
</div>
</div>
</div>
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<div id="add-movies-workspace"></div> <div id="add-movies-workspace"></div>

@ -27,6 +27,7 @@ module.exports = Marionette.Layout.extend({
initialize : function(options) { initialize : function(options) {
console.log(options); console.log(options);
this.isExisting = options.isExisting; this.isExisting = options.isExisting;
this.collection = new AddMoviesCollection(); this.collection = new AddMoviesCollection();

@ -1,6 +1,7 @@
var Marionette = require('marionette'); var Marionette = require('marionette');
var AddMoviesView = require('../AddMoviesView'); var AddMoviesView = require('../AddMoviesView');
var UnmappedFolderCollection = require('./UnmappedFolderCollection'); var UnmappedFolderCollection = require('./UnmappedFolderCollection');
var vent = require('vent');
module.exports = Marionette.CompositeView.extend({ module.exports = Marionette.CompositeView.extend({
itemView : AddMoviesView, itemView : AddMoviesView,

@ -48,7 +48,7 @@ var Layout = Marionette.Layout.extend({
var self = this; var self = this;
var newDir = new RootFolderModel({ var newDir = new RootFolderModel({
Path : this.ui.pathInput.val() Path : this.ui.pathInput.val(),
}); });
this.bindToModelValidation(newDir); this.bindToModelValidation(newDir);

@ -31,6 +31,8 @@
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button class="btn" data-dismiss="modal">Close</button> <button class="btn" data-dismiss="modal">Close</button>
</div> </div>
</div> </div>

@ -1,12 +1,21 @@
var Marionette = require('marionette'); var Marionette = require('marionette');
var SearchResultView = require('./SearchResultView'); var SearchResultView = require('./SearchResultView');
var vent = require('vent');
module.exports = Marionette.CollectionView.extend({ module.exports = Marionette.CollectionView.extend({
itemView : SearchResultView, itemView : SearchResultView,
initialize : function(options) { initialize : function(options) {
this.showExisting = true;
this.isExisting = options.isExisting; this.isExisting = options.isExisting;
this.showing = 1; this.showing = 1;
vent.on(vent.Commands.ShowExistingCommand, this._onExistingToggle.bind(this));
},
_onExistingToggle : function(data) {
this.showExisting = data.showExisting;
this.render();
}, },
showAll : function() { showAll : function() {
@ -34,8 +43,17 @@ module.exports = Marionette.CollectionView.extend({
}, },
appendHtml : function(collectionView, itemView, index) { appendHtml : function(collectionView, itemView, index) {
if (!this.isExisting || index < this.showing || index === 0) { if(this.isExisting) {
collectionView.$el.append(itemView.el); 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);
}
} }
} }
}); });

@ -43,7 +43,7 @@ var view = Marionette.ItemView.extend({
throw 'model is required'; throw 'model is required';
} }
console.log(this.route); //console.log(this.route);
this.templateHelpers = {}; this.templateHelpers = {};
this._configureTemplateHelpers(); this._configureTemplateHelpers();
@ -92,14 +92,12 @@ var view = Marionette.ItemView.extend({
_configureTemplateHelpers : function() { _configureTemplateHelpers : function() {
var existingMovies = MoviesCollection.where({ tmdbId : this.model.get('tmdbId') }); var existingMovies = MoviesCollection.where({ tmdbId : this.model.get('tmdbId') });
console.log(existingMovies);
if (existingMovies.length > 0) { if (existingMovies.length > 0) {
this.templateHelpers.existing = existingMovies[0].toJSON(); this.templateHelpers.existing = existingMovies[0].toJSON();
} }
this.templateHelpers.profiles = Profiles.toJSON(); this.templateHelpers.profiles = Profiles.toJSON();
console.log(this.model); //console.log(this.templateHelpers.isExisting);
console.log(this.templateHelpers.existing);
if (!this.model.get('isExisting')) { if (!this.model.get('isExisting')) {
this.templateHelpers.rootFolders = RootFolders.toJSON(); this.templateHelpers.rootFolders = RootFolders.toJSON();
} }
@ -185,8 +183,8 @@ var view = Marionette.ItemView.extend({
var self = this; var self = this;
var promise = this.model.save(); var promise = this.model.save();
console.log(this.model.save); //console.log(this.model.save);
console.log(promise); //console.log(promise);
if (searchForMovie) { if (searchForMovie) {
this.ui.addSearchButton.spinForPromise(promise); this.ui.addSearchButton.spinForPromise(promise);

@ -29,7 +29,8 @@ vent.Commands = {
ShowFileBrowser : 'showFileBrowser', ShowFileBrowser : 'showFileBrowser',
CloseFileBrowser : 'closeFileBrowser', CloseFileBrowser : 'closeFileBrowser',
OpenControlPanelCommand : 'OpenControlPanelCommand', OpenControlPanelCommand : 'OpenControlPanelCommand',
CloseControlPanelCommand : 'CloseControlPanelCommand' CloseControlPanelCommand : 'CloseControlPanelCommand',
ShowExistingCommand : 'ShowExistingCommand'
}; };
vent.Hotkeys = { vent.Hotkeys = {

Loading…
Cancel
Save