2013-01-30 06:52:31 +00:00
|
|
|
|
'use strict;'
|
|
|
|
|
/// <reference path="../../app.js" />
|
2013-01-24 20:48:44 +00:00
|
|
|
|
/// <reference path="RootDirModel.js" />
|
|
|
|
|
/// <reference path="RootDirCollection.js" />
|
2013-02-06 06:28:56 +00:00
|
|
|
|
/// <reference path="../../Shared/AutoComplete.js" />
|
2013-01-24 20:48:44 +00:00
|
|
|
|
|
|
|
|
|
NzbDrone.AddSeries.RootDirItemView = Backbone.Marionette.ItemView.extend({
|
|
|
|
|
|
2013-01-31 22:40:51 +00:00
|
|
|
|
template: 'AddSeries/RootFolders/RootDirItemTemplate',
|
2013-01-25 00:02:53 +00:00
|
|
|
|
tagName: 'tr',
|
|
|
|
|
|
|
|
|
|
events: {
|
2013-01-29 07:44:07 +00:00
|
|
|
|
'click .x-remove': 'removeFolder',
|
2013-01-25 00:02:53 +00:00
|
|
|
|
},
|
2013-01-24 20:48:44 +00:00
|
|
|
|
|
|
|
|
|
onRender: function () {
|
|
|
|
|
NzbDrone.ModelBinder.bind(this.model, this.el);
|
2013-01-25 00:02:53 +00:00
|
|
|
|
},
|
|
|
|
|
|
2013-01-29 07:44:07 +00:00
|
|
|
|
removeFolder: function () {
|
2013-01-25 00:02:53 +00:00
|
|
|
|
this.model.destroy({ wait: true });
|
2013-01-25 01:22:14 +00:00
|
|
|
|
this.model.collection.remove(this.model);
|
2013-01-25 00:02:53 +00:00
|
|
|
|
},
|
2013-01-24 20:48:44 +00:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
NzbDrone.AddSeries.RootDirListView = Backbone.Marionette.CollectionView.extend({
|
|
|
|
|
itemView: NzbDrone.AddSeries.RootDirItemView,
|
2013-01-25 00:02:53 +00:00
|
|
|
|
|
|
|
|
|
tagName: 'table',
|
|
|
|
|
className: 'table table-hover',
|
2013-01-24 20:48:44 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
NzbDrone.AddSeries.RootDirView = Backbone.Marionette.Layout.extend({
|
2013-01-31 22:40:51 +00:00
|
|
|
|
template: 'AddSeries/RootFolders/RootDirTemplate',
|
2013-01-30 06:52:31 +00:00
|
|
|
|
route: 'series/add/rootdir',
|
2013-01-24 20:48:44 +00:00
|
|
|
|
|
|
|
|
|
ui: {
|
2013-01-29 07:44:07 +00:00
|
|
|
|
pathInput: '.x-path input'
|
2013-01-24 20:48:44 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
regions: {
|
2013-01-30 06:52:31 +00:00
|
|
|
|
currentDirs: '#current-dirs',
|
2013-01-24 20:48:44 +00:00
|
|
|
|
},
|
|
|
|
|
|
2013-01-25 00:02:53 +00:00
|
|
|
|
events: {
|
2013-01-29 07:44:07 +00:00
|
|
|
|
'click .x-add': 'addFolder',
|
2013-01-25 17:54:45 +00:00
|
|
|
|
},
|
|
|
|
|
|
2013-01-25 00:02:53 +00:00
|
|
|
|
|
2013-01-24 20:48:44 +00:00
|
|
|
|
collection: new NzbDrone.AddSeries.RootDirCollection(),
|
|
|
|
|
|
|
|
|
|
onRender: function () {
|
|
|
|
|
|
|
|
|
|
this.currentDirs.show(new NzbDrone.AddSeries.RootDirListView({ collection: this.collection }));
|
2013-01-25 00:02:53 +00:00
|
|
|
|
this.collection.fetch();
|
2013-02-06 06:28:56 +00:00
|
|
|
|
|
|
|
|
|
this.ui.pathInput.folderAutoComplete();
|
2013-01-25 00:02:53 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
2013-01-29 07:44:07 +00:00
|
|
|
|
addFolder: function () {
|
2013-01-25 00:02:53 +00:00
|
|
|
|
var newDir = new NzbDrone.AddSeries.RootDirModel(
|
|
|
|
|
{
|
|
|
|
|
Path: this.ui.pathInput.val()
|
|
|
|
|
});
|
|
|
|
|
|
2013-01-29 02:00:35 +00:00
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
this.collection.create(newDir, {
|
|
|
|
|
wait: true, success: function () {
|
|
|
|
|
self.collection.fetch();
|
|
|
|
|
}
|
|
|
|
|
});
|
2013-01-24 20:48:44 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
search: function (context) {
|
|
|
|
|
|
|
|
|
|
var term = context.ui.seriesSearch.val();
|
|
|
|
|
|
2013-01-30 06:52:31 +00:00
|
|
|
|
if (term === "") {
|
2013-01-24 20:48:44 +00:00
|
|
|
|
context.collection.reset();
|
|
|
|
|
} else {
|
|
|
|
|
console.log(term);
|
|
|
|
|
context.collection.fetch({ data: $.param({ term: term }) });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
});
|