95% done with hiding existing movies

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

@ -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 }));
},

@ -9,6 +9,31 @@
</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="col-md-12">
<div id="add-movies-workspace"></div>

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

@ -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,

@ -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);

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

@ -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);
}
}
}
});

@ -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);

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

Loading…
Cancel
Save