Validation, settings UI cleanup and different settings models, oh my

New: Download client UI matches other settings
Fixed: Prevent drone factory folder from being set to invalid paths/root path for series
Fixed: Switching pages in settings will not hide changes
Fixed: Test download clients
Fixed: Settings are validated before saving
This commit is contained in:
Mark McDowall
2014-02-16 01:56:12 -08:00
parent 606d78f5e1
commit 77b83b521e
57 changed files with 667 additions and 484 deletions
@@ -22,7 +22,7 @@ define(
},
_edit: function () {
var view = new EditView({ model: this.model});
var view = new EditView({ model: this.model, downloadClientCollection: this.model.collection });
AppLayout.modalRegion.show(view);
},
@@ -5,24 +5,17 @@ define(
'marionette',
'Settings/DownloadClient/DownloadClientCollection',
'Settings/DownloadClient/DownloadClientCollectionView',
'Mixins/AsModelBoundView',
'Mixins/AutoComplete',
'bootstrap'
], function (Marionette, DownloadClientCollection, DownloadClientCollectionView, AsModelBoundView) {
'Settings/DownloadClient/Options/DownloadClientOptionsView',
'Settings/DownloadClient/FailedDownloadHandling/FailedDownloadHandlingView'
], function (Marionette, DownloadClientCollection, DownloadClientCollectionView, DownloadClientOptionsView, FailedDownloadHandlingView) {
var view = Marionette.Layout.extend({
return Marionette.Layout.extend({
template : 'Settings/DownloadClient/DownloadClientLayoutTemplate',
regions: {
downloadClients: '#x-download-clients-region'
},
ui: {
droneFactory: '.x-path'
},
events: {
'change .x-download-client': 'downloadClientChanged'
downloadClients : '#x-download-clients-region',
downloadClientOptions : '#x-download-client-options-region',
failedDownloadHandling : '#x-failed-download-handling-region'
},
initialize: function () {
@@ -32,9 +25,8 @@ define(
onShow: function () {
this.downloadClients.show(new DownloadClientCollectionView({ collection: this.downloadClientCollection }));
this.ui.droneFactory.autoComplete('/directories');
this.downloadClientOptions.show(new DownloadClientOptionsView({ model: this.model }));
this.failedDownloadHandling.show(new FailedDownloadHandlingView({ model: this.model }));
}
});
return AsModelBoundView.call(view);
});
@@ -1,16 +1,6 @@
<div id="x-download-clients-region"></div>
<div class="form-horizontal">
<div id="x-download-client-options-region"></div>
<div id="x-failed-download-handling-region"></div>
</div>
<fieldset class="form-horizontal">
<legend>Options</legend>
<div class="control-group">
<label class="control-label">Drone Factory</label>
<div class="controls">
<input type="text" name="downloadedEpisodesFolder" class="x-path"/>
<span class="help-inline">
<i class="icon-nd-form-info" title="The folder where your download client downloads TV shows to (Completed Download Directory)"/>
<i class="icon-nd-form-warning" title="Do not use the folder that contains some or all of your sorted and named TV shows - doing so could cause data loss"></i>
</span>
</div>
</div>
</fieldset>
@@ -0,0 +1,11 @@
'use strict';
define(
[
'Settings/SettingsModelBase'
], function (SettingsModelBase) {
return SettingsModelBase.extend({
url : window.NzbDrone.ApiRoot + '/config/downloadclient',
successMessage: 'Download client settings saved',
errorMessage : 'Failed to save download client settings'
});
});
@@ -8,13 +8,14 @@ define(
'Settings/DownloadClient/Delete/DownloadClientDeleteView',
'Commands/CommandController',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView',
'underscore',
'Form/FormBuilder',
'Mixins/AutoComplete',
'bootstrap'
], function (vent, AppLayout, Marionette, DeleteView, CommandController, AsModelBoundView, _) {
], function (vent, AppLayout, Marionette, DeleteView, CommandController, AsModelBoundView, AsValidatedView, _) {
var model = Marionette.ItemView.extend({
var view = Marionette.ItemView.extend({
template: 'Settings/DownloadClient/Edit/DownloadClientEditViewTemplate',
ui: {
@@ -89,5 +90,8 @@ define(
}
});
return AsModelBoundView.call(model);
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
});
@@ -0,0 +1,37 @@
'use strict';
define(
[
'marionette',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView'
], function (Marionette, AsModelBoundView, AsValidatedView) {
var view = Marionette.ItemView.extend({
template: 'Settings/DownloadClient/FailedDownloadHandling/FailedDownloadHandlingViewTemplate',
ui: {
failedDownloadHandlingCheckbox: '.x-failed-download-handling',
failedDownloadOptions : '.x-failed-download-options'
},
events: {
'change .x-failed-download-handling': '_setFailedDownloadOptionsVisibility'
},
_setFailedDownloadOptionsVisibility: function () {
var checked = this.ui.failedDownloadHandlingCheckbox.prop('checked');
if (checked) {
this.ui.failedDownloadOptions.slideDown();
}
else {
this.ui.failedDownloadOptions.slideUp();
}
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
});
@@ -0,0 +1,65 @@
<fieldset class="advanced-setting">
<legend>Failed Download Handling</legend>
<div class="control-group">
<label class="control-label">Enable</label>
<div class="controls">
<label class="checkbox toggle well">
<input type="checkbox" name="enableFailedDownloadHandling" class="x-failed-download-handling"/>
<p>
<span>Yes</span>
<span>No</span>
</p>
<div class="btn btn-primary slide-button"/>
</label>
<span class="help-inline-checkbox">
<i class="icon-nd-form-info" title="Process failed downloads and blacklist the release"/>
</span>
</div>
</div>
<div class="x-failed-download-options">
<div class="control-group">
<label class="control-label">Redownload</label>
<div class="controls">
<label class="checkbox toggle well">
<input type="checkbox" name="autoRedownloadFailed"/>
<p>
<span>Yes</span>
<span>No</span>
</p>
<div class="btn btn-primary slide-button"/>
</label>
<span class="help-inline-checkbox">
<i class="icon-nd-form-info" title="Automatically search for and attempt to download another release when a download fails?"/>
</span>
</div>
</div>
<div class="control-group">
<label class="control-label">Remove</label>
<div class="controls">
<label class="checkbox toggle well">
<input type="checkbox" name="removeFailedDownloads"/>
<p>
<span>Yes</span>
<span>No</span>
</p>
<div class="btn btn-primary slide-button"/>
</label>
<span class="help-inline-checkbox">
<i class="icon-nd-form-info" title="Automatically remove failed downloads from history and encrypted downloads from queue?"/>
</span>
</div>
</div>
</div>
</fieldset>
@@ -0,0 +1,26 @@
'use strict';
define(
[
'marionette',
'Mixins/AsModelBoundView',
'Mixins/AsValidatedView',
'Mixins/AutoComplete'
], function (Marionette, AsModelBoundView, AsValidatedView) {
var view = Marionette.ItemView.extend({
template: 'Settings/DownloadClient/Options/DownloadClientOptionsViewTemplate',
ui: {
droneFactory : '.x-path'
},
onShow: function () {
this.ui.droneFactory.autoComplete('/directories');
}
});
AsModelBoundView.call(view);
AsValidatedView.call(view);
return view;
});
@@ -0,0 +1,14 @@
<fieldset">
<legend>Options</legend>
<div class="control-group">
<label class="control-label">Drone Factory</label>
<div class="controls">
<input type="text" name="downloadedEpisodesFolder" class="x-path"/>
<span class="help-inline">
<i class="icon-nd-form-info" title="The folder where your download client downloads TV shows to (Completed Download Directory)"/>
<i class="icon-nd-form-warning" title="Do not use the folder that contains some or all of your sorted and named TV shows - doing so could cause data loss"></i>
</span>
</div>
</div>
</fieldset>