|
|
@ -15,9 +15,9 @@ require('jquery.dotdotdot');
|
|
|
|
|
|
|
|
|
|
|
|
var view = Marionette.ItemView.extend({
|
|
|
|
var view = Marionette.ItemView.extend({
|
|
|
|
|
|
|
|
|
|
|
|
template: 'AddSeries/SearchResultViewTemplate',
|
|
|
|
template : 'AddSeries/SearchResultViewTemplate',
|
|
|
|
|
|
|
|
|
|
|
|
ui: {
|
|
|
|
ui : {
|
|
|
|
profile : '.x-profile',
|
|
|
|
profile : '.x-profile',
|
|
|
|
rootFolder : '.x-root-folder',
|
|
|
|
rootFolder : '.x-root-folder',
|
|
|
|
seasonFolder : '.x-season-folder',
|
|
|
|
seasonFolder : '.x-season-folder',
|
|
|
@ -29,7 +29,7 @@ var view = Marionette.ItemView.extend({
|
|
|
|
overview : '.x-overview'
|
|
|
|
overview : '.x-overview'
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
events: {
|
|
|
|
events : {
|
|
|
|
'click .x-add' : '_addWithoutSearch',
|
|
|
|
'click .x-add' : '_addWithoutSearch',
|
|
|
|
'click .x-add-search' : '_addAndSearch',
|
|
|
|
'click .x-add-search' : '_addAndSearch',
|
|
|
|
'change .x-profile' : '_profileChanged',
|
|
|
|
'change .x-profile' : '_profileChanged',
|
|
|
@ -39,7 +39,7 @@ var view = Marionette.ItemView.extend({
|
|
|
|
'change .x-monitor' : '_monitorChanged'
|
|
|
|
'change .x-monitor' : '_monitorChanged'
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
initialize : function() {
|
|
|
|
|
|
|
|
|
|
|
|
if (!this.model) {
|
|
|
|
if (!this.model) {
|
|
|
|
throw 'model is required';
|
|
|
|
throw 'model is required';
|
|
|
@ -53,7 +53,7 @@ var view = Marionette.ItemView.extend({
|
|
|
|
this.listenTo(RootFolders, 'all', this._rootFoldersUpdated);
|
|
|
|
this.listenTo(RootFolders, 'all', this._rootFoldersUpdated);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
onRender: function () {
|
|
|
|
onRender : function() {
|
|
|
|
|
|
|
|
|
|
|
|
var defaultProfile = Config.getValue(Config.Keys.DefaultProfileId);
|
|
|
|
var defaultProfile = Config.getValue(Config.Keys.DefaultProfileId);
|
|
|
|
var defaultRoot = Config.getValue(Config.Keys.DefaultRootFolderId);
|
|
|
|
var defaultRoot = Config.getValue(Config.Keys.DefaultRootFolderId);
|
|
|
@ -76,7 +76,7 @@ var view = Marionette.ItemView.extend({
|
|
|
|
//TODO: make this work via onRender, FM?
|
|
|
|
//TODO: make this work via onRender, FM?
|
|
|
|
//works with onShow, but stops working after the first render
|
|
|
|
//works with onShow, but stops working after the first render
|
|
|
|
this.ui.overview.dotdotdot({
|
|
|
|
this.ui.overview.dotdotdot({
|
|
|
|
height: 120
|
|
|
|
height : 120
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this.templateFunction = Marionette.TemplateCache.get('AddSeries/MonitoringTooltipTemplate');
|
|
|
|
this.templateFunction = Marionette.TemplateCache.get('AddSeries/MonitoringTooltipTemplate');
|
|
|
@ -87,13 +87,13 @@ var view = Marionette.ItemView.extend({
|
|
|
|
html : true,
|
|
|
|
html : true,
|
|
|
|
trigger : 'hover',
|
|
|
|
trigger : 'hover',
|
|
|
|
title : 'Episode Monitoring Options',
|
|
|
|
title : 'Episode Monitoring Options',
|
|
|
|
placement: 'right',
|
|
|
|
placement : 'right',
|
|
|
|
container: this.$el
|
|
|
|
container : this.$el
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_configureTemplateHelpers: function () {
|
|
|
|
_configureTemplateHelpers : function() {
|
|
|
|
var existingSeries = SeriesCollection.where({tvdbId: this.model.get('tvdbId')});
|
|
|
|
var existingSeries = SeriesCollection.where({ tvdbId : this.model.get('tvdbId') });
|
|
|
|
|
|
|
|
|
|
|
|
if (existingSeries.length > 0) {
|
|
|
|
if (existingSeries.length > 0) {
|
|
|
|
this.templateHelpers.existing = existingSeries[0].toJSON();
|
|
|
|
this.templateHelpers.existing = existingSeries[0].toJSON();
|
|
|
@ -106,7 +106,7 @@ var view = Marionette.ItemView.extend({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_onConfigUpdated: function (options) {
|
|
|
|
_onConfigUpdated : function(options) {
|
|
|
|
if (options.key === Config.Keys.DefaultProfileId) {
|
|
|
|
if (options.key === Config.Keys.DefaultProfileId) {
|
|
|
|
this.ui.profile.val(options.value);
|
|
|
|
this.ui.profile.val(options.value);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -128,49 +128,48 @@ var view = Marionette.ItemView.extend({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_profileChanged: function () {
|
|
|
|
_profileChanged : function() {
|
|
|
|
Config.setValue(Config.Keys.DefaultProfileId, this.ui.profile.val());
|
|
|
|
Config.setValue(Config.Keys.DefaultProfileId, this.ui.profile.val());
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_seasonFolderChanged: function () {
|
|
|
|
_seasonFolderChanged : function() {
|
|
|
|
Config.setValue(Config.Keys.UseSeasonFolder, this.ui.seasonFolder.prop('checked'));
|
|
|
|
Config.setValue(Config.Keys.UseSeasonFolder, this.ui.seasonFolder.prop('checked'));
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_rootFolderChanged: function () {
|
|
|
|
_rootFolderChanged : function() {
|
|
|
|
var rootFolderValue = this.ui.rootFolder.val();
|
|
|
|
var rootFolderValue = this.ui.rootFolder.val();
|
|
|
|
if (rootFolderValue === 'addNew') {
|
|
|
|
if (rootFolderValue === 'addNew') {
|
|
|
|
var rootFolderLayout = new RootFolderLayout();
|
|
|
|
var rootFolderLayout = new RootFolderLayout();
|
|
|
|
this.listenToOnce(rootFolderLayout, 'folderSelected', this._setRootFolder);
|
|
|
|
this.listenToOnce(rootFolderLayout, 'folderSelected', this._setRootFolder);
|
|
|
|
AppLayout.modalRegion.show(rootFolderLayout);
|
|
|
|
AppLayout.modalRegion.show(rootFolderLayout);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else {
|
|
|
|
|
|
|
|
Config.setValue(Config.Keys.DefaultRootFolderId, rootFolderValue);
|
|
|
|
Config.setValue(Config.Keys.DefaultRootFolderId, rootFolderValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_seriesTypeChanged: function () {
|
|
|
|
_seriesTypeChanged : function() {
|
|
|
|
Config.setValue(Config.Keys.DefaultSeriesType, this.ui.seriesType.val());
|
|
|
|
Config.setValue(Config.Keys.DefaultSeriesType, this.ui.seriesType.val());
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_monitorChanged: function () {
|
|
|
|
_monitorChanged : function() {
|
|
|
|
Config.setValue(Config.Keys.MonitorEpisodes, this.ui.monitor.val());
|
|
|
|
Config.setValue(Config.Keys.MonitorEpisodes, this.ui.monitor.val());
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_setRootFolder: function (options) {
|
|
|
|
_setRootFolder : function(options) {
|
|
|
|
vent.trigger(vent.Commands.CloseModalCommand);
|
|
|
|
vent.trigger(vent.Commands.CloseModalCommand);
|
|
|
|
this.ui.rootFolder.val(options.model.id);
|
|
|
|
this.ui.rootFolder.val(options.model.id);
|
|
|
|
this._rootFolderChanged();
|
|
|
|
this._rootFolderChanged();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_addWithoutSearch: function () {
|
|
|
|
_addWithoutSearch : function() {
|
|
|
|
this._addSeries(false);
|
|
|
|
this._addSeries(false);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_addAndSearch: function() {
|
|
|
|
_addAndSearch : function() {
|
|
|
|
this._addSeries(true);
|
|
|
|
this._addSeries(true);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_addSeries: function (searchForMissingEpisodes) {
|
|
|
|
_addSeries : function(searchForMissingEpisodes) {
|
|
|
|
var addButton = this.ui.addButton;
|
|
|
|
var addButton = this.ui.addButton;
|
|
|
|
var addSearchButton = this.ui.addSearchButton;
|
|
|
|
var addSearchButton = this.ui.addSearchButton;
|
|
|
|
|
|
|
|
|
|
|
@ -191,7 +190,7 @@ var view = Marionette.ItemView.extend({
|
|
|
|
seasonFolder : seasonFolder,
|
|
|
|
seasonFolder : seasonFolder,
|
|
|
|
seriesType : seriesType,
|
|
|
|
seriesType : seriesType,
|
|
|
|
addOptions : options
|
|
|
|
addOptions : options
|
|
|
|
}, { silent: true });
|
|
|
|
}, { silent : true });
|
|
|
|
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
var self = this;
|
|
|
|
var promise = this.model.save();
|
|
|
|
var promise = this.model.save();
|
|
|
@ -204,49 +203,49 @@ var view = Marionette.ItemView.extend({
|
|
|
|
this.ui.addButton.spinForPromise(promise);
|
|
|
|
this.ui.addButton.spinForPromise(promise);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
promise.always(function () {
|
|
|
|
promise.always(function() {
|
|
|
|
addButton.removeClass('disabled');
|
|
|
|
addButton.removeClass('disabled');
|
|
|
|
addSearchButton.removeClass('disabled');
|
|
|
|
addSearchButton.removeClass('disabled');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
promise.done(function () {
|
|
|
|
promise.done(function() {
|
|
|
|
SeriesCollection.add(self.model);
|
|
|
|
SeriesCollection.add(self.model);
|
|
|
|
|
|
|
|
|
|
|
|
self.close();
|
|
|
|
self.close();
|
|
|
|
|
|
|
|
|
|
|
|
Messenger.show({
|
|
|
|
Messenger.show({
|
|
|
|
message: 'Added: ' + self.model.get('title'),
|
|
|
|
message : 'Added: ' + self.model.get('title'),
|
|
|
|
actions : {
|
|
|
|
actions : {
|
|
|
|
goToSeries: {
|
|
|
|
goToSeries : {
|
|
|
|
label: 'Go to Series',
|
|
|
|
label : 'Go to Series',
|
|
|
|
action: function() {
|
|
|
|
action : function() {
|
|
|
|
Backbone.history.navigate('/series/' + self.model.get('titleSlug'), { trigger: true });
|
|
|
|
Backbone.history.navigate('/series/' + self.model.get('titleSlug'), { trigger : true });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
hideAfter: 8,
|
|
|
|
hideAfter : 8,
|
|
|
|
hideOnNavigate: true
|
|
|
|
hideOnNavigate : true
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
vent.trigger(vent.Events.SeriesAdded, { series: self.model });
|
|
|
|
vent.trigger(vent.Events.SeriesAdded, { series : self.model });
|
|
|
|
});
|
|
|
|
});
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_rootFoldersUpdated: function () {
|
|
|
|
_rootFoldersUpdated : function() {
|
|
|
|
this._configureTemplateHelpers();
|
|
|
|
this._configureTemplateHelpers();
|
|
|
|
this.render();
|
|
|
|
this.render();
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
_getAddSeriesOptions: function () {
|
|
|
|
_getAddSeriesOptions : function() {
|
|
|
|
var monitor = this.ui.monitor.val();
|
|
|
|
var monitor = this.ui.monitor.val();
|
|
|
|
var lastSeason = _.max(this.model.get('seasons'), 'seasonNumber');
|
|
|
|
var lastSeason = _.max(this.model.get('seasons'), 'seasonNumber');
|
|
|
|
var firstSeason = _.min(_.reject(this.model.get('seasons'), { seasonNumber: 0 }), 'seasonNumber');
|
|
|
|
var firstSeason = _.min(_.reject(this.model.get('seasons'), { seasonNumber : 0 }), 'seasonNumber');
|
|
|
|
|
|
|
|
|
|
|
|
this.model.setSeasonPass(firstSeason.seasonNumber);
|
|
|
|
this.model.setSeasonPass(firstSeason.seasonNumber);
|
|
|
|
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
var options = {
|
|
|
|
ignoreEpisodesWithFiles: false,
|
|
|
|
ignoreEpisodesWithFiles : false,
|
|
|
|
ignoreEpisodesWithoutFiles: false
|
|
|
|
ignoreEpisodesWithoutFiles : false
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (monitor === 'all') {
|
|
|
|
if (monitor === 'all') {
|
|
|
|