New: options when adding series, including the ability to search for all missing episodes

This commit is contained in:
Mark McDowall
2014-12-09 18:20:50 -08:00
parent 7b7f7ac56b
commit 05ee57a972
21 changed files with 594 additions and 65 deletions

View File

@@ -0,0 +1,14 @@
<dl class="monitor-tooltip-contents">
<dt>All</dt>
<dd>Monitor all episodes except specials</dd>
<dt>Future</dt>
<dd>Monitor episodes that have not aired yet</dd>
<dt>Missing</dt>
<dd>Monitor episodes that do not have files or have not aired yet</dd>
<dt>Existing</dt>
<dd>Monitor episodes that have files or have not aired yet</dd>
<dt>First Season</dt>
<dd>Monitor all episodes of the first season. All other seasons will be ignored</dd>
<!--<dt>Latest Season</dt>-->
<!--<dd>Monitor all episodes the latest season only, previous seasons will be ignored</dd>-->
</dl>

View File

@@ -36,17 +36,20 @@ define(
rootFolder : '.x-root-folder',
seasonFolder : '.x-season-folder',
seriesType : '.x-series-type',
startingSeason : '.x-starting-season',
monitor : '.x-monitor',
monitorTooltip : '.x-monitor-tooltip',
addButton : '.x-add',
overview : '.x-overview'
},
events: {
'click .x-add' : '_addSeries',
'click .x-add' : '_addWithoutSearch',
'click .x-add-search' : '_addAndSearch',
'change .x-profile' : '_profileChanged',
'change .x-root-folder' : '_rootFolderChanged',
'change .x-season-folder' : '_seasonFolderChanged',
'change .x-series-type' : '_seriesTypeChanged'
'change .x-series-type' : '_seriesTypeChanged',
'change .x-monitor' : '_monitorChanged'
},
initialize: function () {
@@ -69,6 +72,7 @@ define(
var defaultRoot = Config.getValue(Config.Keys.DefaultRootFolderId);
var useSeasonFolder = Config.getValueBoolean(Config.Keys.UseSeasonFolder, true);
var defaultSeriesType = Config.getValue(Config.Keys.DefaultSeriesType, 'standard');
var defaultMonitorEpisodes = Config.getValue(Config.Keys.MonitorEpisodes, 'missing');
if (Profiles.get(defaultProfile)) {
this.ui.profile.val(defaultProfile);
@@ -80,18 +84,25 @@ define(
this.ui.seasonFolder.prop('checked', useSeasonFolder);
this.ui.seriesType.val(defaultSeriesType);
var minSeasonNotZero = _.min(_.reject(this.model.get('seasons'), { seasonNumber: 0 }), 'seasonNumber');
if (minSeasonNotZero) {
this.ui.startingSeason.val(minSeasonNotZero.seasonNumber);
}
this.ui.monitor.val(defaultMonitorEpisodes);
//TODO: make this work via onRender, FM?
//works with onShow, but stops working after the first render
this.ui.overview.dotdotdot({
height: 120
});
this.templateFunction = Marionette.TemplateCache.get('AddSeries/MonitoringTooltipTemplate');
var content = this.templateFunction();
this.ui.monitorTooltip.popover({
content : content,
html : true,
trigger : 'hover',
title : 'Episode Monitoring Options',
placement: 'right',
container: this.$el
});
},
_configureTemplateHelpers: function () {
@@ -124,6 +135,10 @@ define(
else if (options.key === Config.Keys.DefaultSeriesType) {
this.ui.seriesType.val(options.value);
}
else if (options.key === Config.Keys.MonitorEpisodes) {
this.ui.monitor.val(options.value);
}
},
_profileChanged: function () {
@@ -150,30 +165,43 @@ define(
Config.setValue(Config.Keys.DefaultSeriesType, this.ui.seriesType.val());
},
_monitorChanged: function () {
Config.setValue(Config.Keys.MonitorEpisodes, this.ui.monitor.val());
},
_setRootFolder: function (options) {
vent.trigger(vent.Commands.CloseModalCommand);
this.ui.rootFolder.val(options.model.id);
this._rootFolderChanged();
},
_addSeries: function () {
_addWithoutSearch: function () {
this._addSeries(false);
},
_addAndSearch: function() {
this._addSeries(true);
},
_addSeries: function (searchForMissingEpisodes) {
var icon = this.ui.addButton.find('icon');
icon.removeClass('icon-plus').addClass('icon-spin icon-spinner disabled');
var profile = this.ui.profile.val();
var rootFolderPath = this.ui.rootFolder.children(':selected').text();
var startingSeason = this.ui.startingSeason.val();
var seriesType = this.ui.seriesType.val();
var seasonFolder = this.ui.seasonFolder.prop('checked');
this.model.set({
profileId: profile,
rootFolderPath: rootFolderPath,
seasonFolder: seasonFolder,
seriesType: seriesType
}, { silent: true });
var options = this._getAddSeriesOptions();
options.searchForMissingEpisodes = searchForMissingEpisodes;
this.model.setSeasonPass(startingSeason);
this.model.set({
profileId : profile,
rootFolderPath : rootFolderPath,
seasonFolder : seasonFolder,
seriesType : seriesType,
addOptions : options
}, { silent: true });
var self = this;
var promise = this.model.save();
@@ -209,6 +237,48 @@ define(
_rootFoldersUpdated: function () {
this._configureTemplateHelpers();
this.render();
},
_getAddSeriesOptions: function () {
var monitor = this.ui.monitor.val();
var lastSeason = _.max(this.model.get('seasons'), 'seasonNumber');
var firstSeason = _.min(_.reject(this.model.get('seasons'), { seasonNumber: 0 }), 'seasonNumber');
this.model.setSeasonPass(firstSeason.seasonNumber);
var options = {
ignoreEpisodesWithFiles: false,
ignoreEpisodesWithoutFiles: false
};
if (monitor === 'all') {
return options;
}
else if (monitor === 'future') {
options.ignoreEpisodesWithFiles = true;
options.ignoreEpisodesWithoutFiles = true;
}
else if (monitor === 'latest') {
this.model.setSeasonPass(lastSeason.seasonNumber);
}
else if (monitor === 'first') {
this.model.setSeasonPass(lastSeason + 1);
firstSeason.monitor = true;
}
else if (monitor === 'missing') {
options.ignoreEpisodesWithFiles = true;
}
else if (monitor === 'existing') {
options.ignoreEpisodesWithoutFiles = true;
}
return options;
}
});

View File

@@ -35,8 +35,15 @@
{{/unless}}
<div class="form-group col-md-2">
<label>Starting Season</label>
{{> StartingSeasonSelectionPartial seasons}}
<label>Monitor <i class="icon-nd-form-info monitor-tooltip x-monitor-tooltip"></i></label>
<select class="form-control col-md-2 x-monitor">
<option value="all">All</option>
<option value="future">Future</option>
<option value="missing">Missing</option>
<option value="existing">Existing</option>
<!--<option value="latest">Latest Season</option>-->
<option value="first">First Season</option>
</select>
</div>
<div class="form-group col-md-2">
@@ -70,10 +77,16 @@
{{#if title}}
<div class="form-group col-md-2 col-md-offset-10">
<!--Uncomment if we need to add even more controls to add series-->
<!--<label>&nbsp;</label>-->
<button class="btn btn-success x-add"> Add
<i class="icon-plus"></i>
</button>
<!--<label style="visibility: hidden">Add</label>-->
<div class="btn-group">
<button class="btn btn-success add x-add">
<i class="icon-plus" title="Add"></i>
</button>
<button class="btn btn-success add x-add-search">
<i class="icon-search" title="Add and Search for missing episodes"></i>
</button>
</div>
</div>
{{else}}
<div class="col-md-2 col-md-offset-10" title="Series requires an English title">

View File

@@ -84,18 +84,24 @@
}
select {
font-size : 16px;
font-size : 14px;
}
.checkbox {
margin-top : 0px;
}
i {
&:before {
color : #ffffff;
.add {
i {
&:before {
color : #ffffff;
}
}
}
.monitor-tooltip {
margin-left : 5px;
}
}
.loading-folders {
@@ -107,6 +113,14 @@
color : #999999;
font-style : italic;
}
.monitor-tooltip-contents {
padding-bottom : 0px;
dd {
padding-bottom : 8px;
}
}
}
li.add-new {

View File

@@ -10,10 +10,11 @@ define(
Keys : {
DefaultProfileId : 'DefaultProfileId',
DefaultRootFolderId : 'DefaultRootFolderId',
UseSeasonFolder : 'UseSeasonFolder',
DefaultSeriesType : 'DefaultSeriesType',
AdvancedSettings : 'advancedSettings'
DefaultRootFolderId : 'DefaultRootFolderId',
UseSeasonFolder : 'UseSeasonFolder',
DefaultSeriesType : 'DefaultSeriesType',
MonitorEpisodes : 'MonitorEpisodes',
AdvancedSettings : 'advancedSettings'
},
getValueBoolean: function (key, defaultValue) {

View File

@@ -26,6 +26,13 @@
}
}
.btn {
i {
margin-right : 0px;
color : inherit;
}
}
i {
font-size : 16px;
color : #595959;