1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-23 22:25:14 -04:00

Add Ability to set RootFolderPath for Net Import List

Fixed other things. Finished command to automatically add a movie.
This commit is contained in:
Leonardo Galli
2017-01-23 15:21:49 +01:00
parent 93d6505f85
commit 82f29cdc70
13 changed files with 157 additions and 9 deletions
@@ -7,6 +7,9 @@ var Profiles = require('../../../Profile/ProfileCollection');
var AsModelBoundView = require('../../../Mixins/AsModelBoundView');
var AsValidatedView = require('../../../Mixins/AsValidatedView');
var AsEditModalView = require('../../../Mixins/AsEditModalView');
var RootFolders = require('../../../AddMovies/RootFolders/RootFolderCollection');
var RootFolderLayout = require('../../../AddMovies/RootFolders/RootFolderLayout');
var Config = require('../../../Config');
require('../../../Form/FormBuilder');
require('../../../Mixins/AutoComplete');
require('bootstrap');
@@ -14,9 +17,15 @@ require('bootstrap');
var view = Marionette.ItemView.extend({
template : 'Settings/NetImport/Edit/NetImportEditViewTemplate',
ui : {
profile : '.x-profile',
rootFolder : '.x-root-folder',
},
events : {
'click .x-back' : '_back',
'click .x-captcha-refresh' : '_onRefreshCaptcha'
'click .x-captcha-refresh' : '_onRefreshCaptcha',
'change .x-root-folder' : '_rootFolderChanged',
},
_deleteView : DeleteView,
@@ -24,7 +33,26 @@ var view = Marionette.ItemView.extend({
initialize : function(options) {
this.targetCollection = options.targetCollection;
this.templateHelpers = {};
this.templateHelpers.profiles = Profiles.toJSON();
this._configureTemplateHelpers();
this.listenTo(this.model, 'change', this.render);
this.listenTo(RootFolders, 'all', this._rootFoldersUpdated);
},
onRender : function() {
var defaultRoot = Config.getValue(Config.Keys.DefaultRootFolderId);
if (RootFolders.get(defaultRoot)) {
this.ui.rootFolder.val(defaultRoot);
}
},
_onBeforeSave : function() {
var profile = this.ui.profile.val();
var rootFolderPath = this.ui.rootFolder.children(':selected').text();
this.model.set({
profileId : profile,
rootFolderPath : rootFolderPath,
})
},
_onAfterSave : function() {
@@ -46,6 +74,28 @@ var view = Marionette.ItemView.extend({
require('../Add/NetImportSchemaModal').open(this.targetCollection);
},
_configureTemplateHelpers : function() {
this.templateHelpers.profiles = Profiles.toJSON();
this.templateHelpers.rootFolders = RootFolders.toJSON();
},
_rootFolderChanged : function() {
var rootFolderValue = this.ui.rootFolder.val();
if (rootFolderValue === 'addNew') {
var rootFolderLayout = new RootFolderLayout();
this.listenToOnce(rootFolderLayout, 'folderSelected', this._setRootFolder);
AppLayout.modalRegion.show(rootFolderLayout);
} else {
Config.setValue(Config.Keys.DefaultRootFolderId, rootFolderValue);
}
},
_rootFoldersUpdated : function() {
this._configureTemplateHelpers();
debugger;
this.render();
},
_onRefreshCaptcha : function(event) {
var self = this;
@@ -48,6 +48,14 @@
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Folder</label>
<div class="col-sm-5">
{{> RootFolderSelectionPartial rootFolders}}
</div>
</div>
{{formBuilder}}
</div>
</div>
@@ -2,6 +2,7 @@ var Marionette = require('marionette');
var NetImportCollection = require('./NetImportCollection');
var CollectionView = require('./NetImportCollectionView');
var OptionsView = require('./Options/NetImportOptionsView');
var RootFolderCollection = require('../../AddMovies/RootFolders/RootFolderCollection');
module.exports = Marionette.Layout.extend({
template : 'Settings/NetImport/NetImportLayoutTemplate',
@@ -14,6 +15,9 @@ module.exports = Marionette.Layout.extend({
initialize : function() {
this.indexersCollection = new NetImportCollection();
this.indexersCollection.fetch();
RootFolderCollection.fetch().done(function() {
RootFolderCollection.synced = true;
});
},
onShow : function() {