2013-02-14 02:28:56 +00:00
|
|
|
|
'use strict;'
|
|
|
|
|
|
2013-02-14 17:18:29 +00:00
|
|
|
|
define(['app', 'AddSeries/RootFolders/RootFolderCollection', 'Shared/AutoComplete'], function (app,rootFolders) {
|
2013-02-14 02:28:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NzbDrone.AddSeries.RootFolderItemView = Backbone.Marionette.ItemView.extend({
|
|
|
|
|
|
|
|
|
|
template: 'AddSeries/RootFolders/RootFolderItemTemplate',
|
|
|
|
|
tagName: 'tr',
|
|
|
|
|
|
|
|
|
|
events: {
|
2013-02-15 02:40:29 +00:00
|
|
|
|
'click .x-remove': 'removeFolder'
|
2013-02-14 02:28:56 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onRender: function () {
|
|
|
|
|
NzbDrone.ModelBinder.bind(this.model, this.el);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
removeFolder: function () {
|
|
|
|
|
this.model.destroy({ wait: true });
|
|
|
|
|
this.model.collection.remove(this.model);
|
2013-02-15 02:40:29 +00:00
|
|
|
|
}
|
2013-02-14 02:28:56 +00:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
NzbDrone.AddSeries.RootDirListView = Backbone.Marionette.CollectionView.extend({
|
|
|
|
|
itemView: NzbDrone.AddSeries.RootFolderItemView,
|
|
|
|
|
|
|
|
|
|
tagName: 'table',
|
2013-02-15 08:18:42 +00:00
|
|
|
|
className: 'table table-hover'
|
2013-02-14 02:28:56 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
NzbDrone.AddSeries.RootDirView = Backbone.Marionette.Layout.extend({
|
|
|
|
|
template: 'AddSeries/RootFolders/RootFolderTemplate',
|
|
|
|
|
route: 'series/add/rootdir',
|
|
|
|
|
|
|
|
|
|
ui: {
|
|
|
|
|
pathInput: '.x-path input'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
regions: {
|
2013-02-15 08:18:42 +00:00
|
|
|
|
currentDirs: '#current-dirs'
|
2013-02-14 02:28:56 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
events: {
|
2013-02-15 08:18:42 +00:00
|
|
|
|
'click .x-add': 'addFolder'
|
2013-02-14 02:28:56 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onRender: function () {
|
|
|
|
|
|
2013-02-15 08:18:42 +00:00
|
|
|
|
this.collection = rootFolders;
|
2013-02-14 02:28:56 +00:00
|
|
|
|
this.currentDirs.show(new NzbDrone.AddSeries.RootDirListView({ collection: this.collection }));
|
|
|
|
|
this.ui.pathInput.folderAutoComplete();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
addFolder: function () {
|
|
|
|
|
var newDir = new NzbDrone.AddSeries.RootFolders.RootFolderModel(
|
|
|
|
|
{
|
|
|
|
|
Path: this.ui.pathInput.val()
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
this.collection.create(newDir, {
|
|
|
|
|
wait: true, success: function () {
|
|
|
|
|
self.collection.fetch();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
search: function (context) {
|
|
|
|
|
|
|
|
|
|
var term = context.ui.seriesSearch.val();
|
|
|
|
|
|
|
|
|
|
if (term === "") {
|
|
|
|
|
context.collection.reset();
|
|
|
|
|
} else {
|
|
|
|
|
console.log(term);
|
2013-02-15 08:18:42 +00:00
|
|
|
|
context.collection.fetch({ data: { term: term } });
|
2013-02-14 02:28:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2013-02-15 08:18:42 +00:00
|
|
|
|
}
|
2013-02-14 02:28:56 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
});
|