2013-02-14 05:28:56 +03:00
|
|
|
'use strict;'
|
|
|
|
|
2013-02-14 20:18:29 +03:00
|
|
|
define(['app', 'AddSeries/RootFolders/RootFolderCollection', 'Shared/AutoComplete'], function (app,rootFolders) {
|
2013-02-14 05:28:56 +03:00
|
|
|
|
|
|
|
|
|
|
|
NzbDrone.AddSeries.RootFolderItemView = Backbone.Marionette.ItemView.extend({
|
|
|
|
|
|
|
|
template: 'AddSeries/RootFolders/RootFolderItemTemplate',
|
|
|
|
tagName: 'tr',
|
|
|
|
|
|
|
|
events: {
|
2013-02-15 05:40:29 +03:00
|
|
|
'click .x-remove': 'removeFolder'
|
2013-02-14 05:28:56 +03: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 05:40:29 +03:00
|
|
|
}
|
2013-02-14 05:28:56 +03:00
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
NzbDrone.AddSeries.RootDirListView = Backbone.Marionette.CollectionView.extend({
|
|
|
|
itemView: NzbDrone.AddSeries.RootFolderItemView,
|
|
|
|
|
|
|
|
tagName: 'table',
|
|
|
|
className: 'table table-hover',
|
|
|
|
});
|
|
|
|
|
|
|
|
NzbDrone.AddSeries.RootDirView = Backbone.Marionette.Layout.extend({
|
|
|
|
template: 'AddSeries/RootFolders/RootFolderTemplate',
|
|
|
|
route: 'series/add/rootdir',
|
|
|
|
|
|
|
|
ui: {
|
|
|
|
pathInput: '.x-path input'
|
|
|
|
},
|
|
|
|
|
|
|
|
regions: {
|
|
|
|
currentDirs: '#current-dirs',
|
|
|
|
},
|
|
|
|
|
|
|
|
events: {
|
|
|
|
'click .x-add': 'addFolder',
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
onRender: function () {
|
|
|
|
|
2013-02-14 20:18:29 +03:00
|
|
|
this.collection = rootFolders,
|
2013-02-14 05:28:56 +03: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);
|
|
|
|
context.collection.fetch({ data: $.param({ term: term }) });
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|