Fixed selecting a new folder on add new series.

pull/6/head
Keivan Beigi 11 years ago
parent b7c569d30d
commit f3194279e4

@ -10,6 +10,11 @@ define(
template: 'AddSeries/RootFolders/ItemViewTemplate',
tagName : 'tr',
initialize: function () {
this.listenTo(this.model, 'change', this.render);
},
events: {
'click .x-delete': 'removeFolder',
'click .x-folder': 'folderSelected'

@ -5,6 +5,6 @@
<span>{{Bytes freeSpace}}</span>
</td>
<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>
</td>

@ -27,7 +27,8 @@ define(
initialize: function () {
this.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 () {
@ -41,14 +42,17 @@ define(
},
_addFolder: function () {
var self = this;
var newDir = new RootFolderModel({
Path: this.ui.pathInput.val()
});
RootFolderCollection.create(newDir, {
wait: true, success: function () {
RootFolderCollection.fetch();
}
RootFolderCollection.add(newDir);
newDir.save().done(function () {
self.trigger('folderSelected', {model: newDir});
});
}
});

@ -1,13 +1,16 @@
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<i class="icon-hdd"/>
<h3>Select Folder</h3>
</div>
<div class="modal-body root-folders-modal">
<div class="input-prepend input-append x-path">
<span class="add-on">&nbsp;<i class="icon-folder-open"></i></span>
<input class="span5" type="text" placeholder="Path of the folder to add ...">
<button class="btn btn-success x-add"><i class="icon-plus"/></button>
<input class="span9" type="text" placeholder="Start Typing Folder Path...">
<button class="btn btn-success x-add"><i class="icon-ok"/></button>
</div>
{{#if items}}
<h4>Recent Folders</h4>
{{/if}}
<div id="current-dirs"/>
</div>
<div class="modal-footer">

@ -1,6 +1,10 @@
<select class="span6 x-root-folder">
{{#if this}}
{{#each this}}
<option value="{{id}}">{{path}}</option>
<option value="{{id}}">{{path}}</option>
{{/each}}
{{else}}
<option value="">Select Path</option>
{{/if}}
<option value="addNew">Add a different path</option>
</select>

@ -5,10 +5,11 @@ define(
'marionette',
'Quality/QualityProfileCollection',
'AddSeries/RootFolders/Collection',
'AddSeries/RootFolders/Layout',
'Series/SeriesCollection',
'Config',
'Shared/Messenger'
], function (App, Marionette, QualityProfiles, RootFolders, SeriesCollection, Config, Messenger) {
], function (App, Marionette, QualityProfiles, RootFolders, RootFolderLayout, SeriesCollection, Config, Messenger) {
return Marionette.ItemView.extend({
@ -23,7 +24,8 @@ define(
events: {
'click .x-add' : '_addSeries',
'change .x-quality-profile': '_qualityProfileChanged'
'change .x-quality-profile': '_qualityProfileChanged',
'change .x-root-folder' : '_rootFolderChanged'
},
initialize: function () {
@ -34,15 +36,24 @@ define(
this.listenTo(App.vent, Config.Events.ConfigUpdatedEvent, this._onConfigUpdated);
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 () {
var defaultQuality = Config.GetValue(Config.Keys.DefaultQualityProfileId);
var defaultRoot = Config.GetValue(Config.Keys.DefaultRootFolderId);
if (QualityProfiles.get(defaultQuality)) {
this.ui.qualityProfile.val(defaultQuality);
}
if (RootFolders.get(defaultRoot)) {
this.ui.rootFolder.val(defaultRoot);
}
},
serializeData: function () {
@ -64,9 +75,11 @@ define(
},
_onConfigUpdated: function (options) {
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());
},
_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 () {
var icon = this.ui.addButton.find('icon');
icon.removeClass('icon-plus').addClass('icon-spin icon-spinner disabled');

@ -8,7 +8,8 @@ define(
ConfigUpdatedEvent: 'ConfigUpdatedEvent'
},
Keys : {
DefaultQualityProfileId: 'DefaultQualityProfileId'
DefaultQualityProfileId: 'DefaultQualityProfileId',
DefaultRootFolderId: 'DefaultRootFolderId'
},
GetValue: function (key, defaultValue) {

Loading…
Cancel
Save