Fixed selecting a new folder on add new series.
This commit is contained in:
parent
b7c569d30d
commit
f3194279e4
|
@ -10,6 +10,11 @@ define(
|
||||||
template: 'AddSeries/RootFolders/ItemViewTemplate',
|
template: 'AddSeries/RootFolders/ItemViewTemplate',
|
||||||
tagName : 'tr',
|
tagName : 'tr',
|
||||||
|
|
||||||
|
initialize: function () {
|
||||||
|
this.listenTo(this.model, 'change', this.render);
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
'click .x-delete': 'removeFolder',
|
'click .x-delete': 'removeFolder',
|
||||||
'click .x-folder': 'folderSelected'
|
'click .x-folder': 'folderSelected'
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
<span>{{Bytes freeSpace}}</span>
|
<span>{{Bytes freeSpace}}</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="span1 nz-row-action">
|
<td class="span1 nz-row-action">
|
||||||
<div class="btn btn-small btn-icon-only btn-danger icon-minus x-delete">
|
<div class="btn btn-small btn-icon-only icon-nd-delete x-delete">
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -27,7 +27,8 @@ define(
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
this.collection = RootFolderCollection;
|
this.collection = RootFolderCollection;
|
||||||
this.rootfolderListView = new RootFolderCollectionView({ collection: RootFolderCollection });
|
this.rootfolderListView = new RootFolderCollectionView({ collection: RootFolderCollection });
|
||||||
this.rootfolderListView.on('itemview:folderSelected', this._onFolderSelected, this);
|
|
||||||
|
this.listenTo(this.rootfolderListView, 'itemview:folderSelected', this._onFolderSelected);
|
||||||
},
|
},
|
||||||
|
|
||||||
onRender: function () {
|
onRender: function () {
|
||||||
|
@ -41,14 +42,17 @@ define(
|
||||||
},
|
},
|
||||||
|
|
||||||
_addFolder: function () {
|
_addFolder: function () {
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
|
||||||
var newDir = new RootFolderModel({
|
var newDir = new RootFolderModel({
|
||||||
Path: this.ui.pathInput.val()
|
Path: this.ui.pathInput.val()
|
||||||
});
|
});
|
||||||
|
|
||||||
RootFolderCollection.create(newDir, {
|
RootFolderCollection.add(newDir);
|
||||||
wait: true, success: function () {
|
|
||||||
RootFolderCollection.fetch();
|
newDir.save().done(function () {
|
||||||
}
|
self.trigger('folderSelected', {model: newDir});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,13 +1,16 @@
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
<i class="icon-hdd"/>
|
<h3>Select Folder</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body root-folders-modal">
|
<div class="modal-body root-folders-modal">
|
||||||
<div class="input-prepend input-append x-path">
|
<div class="input-prepend input-append x-path">
|
||||||
<span class="add-on"> <i class="icon-folder-open"></i></span>
|
<span class="add-on"> <i class="icon-folder-open"></i></span>
|
||||||
<input class="span5" type="text" placeholder="Path of the folder to add ...">
|
<input class="span9" type="text" placeholder="Start Typing Folder Path...">
|
||||||
<button class="btn btn-success x-add"><i class="icon-plus"/></button>
|
<button class="btn btn-success x-add"><i class="icon-ok"/></button>
|
||||||
</div>
|
</div>
|
||||||
|
{{#if items}}
|
||||||
|
<h4>Recent Folders</h4>
|
||||||
|
{{/if}}
|
||||||
<div id="current-dirs"/>
|
<div id="current-dirs"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
<select class="span6 x-root-folder">
|
<select class="span6 x-root-folder">
|
||||||
|
{{#if this}}
|
||||||
{{#each this}}
|
{{#each this}}
|
||||||
<option value="{{id}}">{{path}}</option>
|
<option value="{{id}}">{{path}}</option>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
|
{{else}}
|
||||||
|
<option value="">Select Path</option>
|
||||||
|
{{/if}}
|
||||||
<option value="addNew">Add a different path</option>
|
<option value="addNew">Add a different path</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -5,10 +5,11 @@ define(
|
||||||
'marionette',
|
'marionette',
|
||||||
'Quality/QualityProfileCollection',
|
'Quality/QualityProfileCollection',
|
||||||
'AddSeries/RootFolders/Collection',
|
'AddSeries/RootFolders/Collection',
|
||||||
|
'AddSeries/RootFolders/Layout',
|
||||||
'Series/SeriesCollection',
|
'Series/SeriesCollection',
|
||||||
'Config',
|
'Config',
|
||||||
'Shared/Messenger'
|
'Shared/Messenger'
|
||||||
], function (App, Marionette, QualityProfiles, RootFolders, SeriesCollection, Config, Messenger) {
|
], function (App, Marionette, QualityProfiles, RootFolders, RootFolderLayout, SeriesCollection, Config, Messenger) {
|
||||||
|
|
||||||
return Marionette.ItemView.extend({
|
return Marionette.ItemView.extend({
|
||||||
|
|
||||||
|
@ -23,7 +24,8 @@ define(
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
'click .x-add' : '_addSeries',
|
'click .x-add' : '_addSeries',
|
||||||
'change .x-quality-profile': '_qualityProfileChanged'
|
'change .x-quality-profile': '_qualityProfileChanged',
|
||||||
|
'change .x-root-folder' : '_rootFolderChanged'
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function () {
|
initialize: function () {
|
||||||
|
@ -34,15 +36,24 @@ define(
|
||||||
|
|
||||||
this.listenTo(App.vent, Config.Events.ConfigUpdatedEvent, this._onConfigUpdated);
|
this.listenTo(App.vent, Config.Events.ConfigUpdatedEvent, this._onConfigUpdated);
|
||||||
this.listenTo(this.model, 'change', this.render);
|
this.listenTo(this.model, 'change', this.render);
|
||||||
|
this.listenTo(RootFolders, 'change', this.render);
|
||||||
|
|
||||||
|
this.rootFolderLayout = new RootFolderLayout();
|
||||||
|
this.listenTo(this.rootFolderLayout, 'folderSelected', this._setRootFolder);
|
||||||
},
|
},
|
||||||
|
|
||||||
onRender: function () {
|
onRender: function () {
|
||||||
|
|
||||||
var defaultQuality = Config.GetValue(Config.Keys.DefaultQualityProfileId);
|
var defaultQuality = Config.GetValue(Config.Keys.DefaultQualityProfileId);
|
||||||
|
var defaultRoot = Config.GetValue(Config.Keys.DefaultRootFolderId);
|
||||||
|
|
||||||
if (QualityProfiles.get(defaultQuality)) {
|
if (QualityProfiles.get(defaultQuality)) {
|
||||||
this.ui.qualityProfile.val(defaultQuality);
|
this.ui.qualityProfile.val(defaultQuality);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (RootFolders.get(defaultRoot)) {
|
||||||
|
this.ui.rootFolder.val(defaultRoot);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
serializeData: function () {
|
serializeData: function () {
|
||||||
|
@ -64,9 +75,11 @@ define(
|
||||||
},
|
},
|
||||||
|
|
||||||
_onConfigUpdated: function (options) {
|
_onConfigUpdated: function (options) {
|
||||||
|
|
||||||
if (options.key === Config.Keys.DefaultQualityProfileId) {
|
if (options.key === Config.Keys.DefaultQualityProfileId) {
|
||||||
this.$('.x-quality-profile').val(options.value);
|
this.ui.qualityProfile.val(options.value);
|
||||||
|
}
|
||||||
|
else if (options.key === Config.Keys.DefaultRootFolderId) {
|
||||||
|
this.ui.rootFolder.val(options.value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -74,6 +87,21 @@ define(
|
||||||
Config.SetValue(Config.Keys.DefaultQualityProfileId, this.ui.qualityProfile.val());
|
Config.SetValue(Config.Keys.DefaultQualityProfileId, this.ui.qualityProfile.val());
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_rootFolderChanged: function () {
|
||||||
|
var rootFolderValue = this.ui.rootFolder.val();
|
||||||
|
if (rootFolderValue === 'addNew') {
|
||||||
|
App.modalRegion.show(this.rootFolderLayout);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Config.SetValue(Config.Keys.DefaultRootFolderId, rootFolderValue);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_setRootFolder: function (options) {
|
||||||
|
App.modalRegion.closeModal();
|
||||||
|
this.ui.rootFolder.val(options.model.id);
|
||||||
|
},
|
||||||
|
|
||||||
_addSeries: function () {
|
_addSeries: function () {
|
||||||
var icon = this.ui.addButton.find('icon');
|
var icon = this.ui.addButton.find('icon');
|
||||||
icon.removeClass('icon-plus').addClass('icon-spin icon-spinner disabled');
|
icon.removeClass('icon-plus').addClass('icon-spin icon-spinner disabled');
|
||||||
|
|
|
@ -8,7 +8,8 @@ define(
|
||||||
ConfigUpdatedEvent: 'ConfigUpdatedEvent'
|
ConfigUpdatedEvent: 'ConfigUpdatedEvent'
|
||||||
},
|
},
|
||||||
Keys : {
|
Keys : {
|
||||||
DefaultQualityProfileId: 'DefaultQualityProfileId'
|
DefaultQualityProfileId: 'DefaultQualityProfileId',
|
||||||
|
DefaultRootFolderId: 'DefaultRootFolderId'
|
||||||
},
|
},
|
||||||
|
|
||||||
GetValue: function (key, defaultValue) {
|
GetValue: function (key, defaultValue) {
|
||||||
|
|
Loading…
Reference in New Issue