Radarr/UI/AddSeries/RootFolders/RootFolderView.js

84 lines
2.1 KiB
JavaScript
Raw Normal View History

2013-03-29 19:17:03 +00:00
"use strict";
define(['app', 'AddSeries/RootFolders/RootFolderCollection', 'Mixins/AutoComplete'], function (app, rootFolders) {
NzbDrone.AddSeries.RootFolderItemView = Backbone.Marionette.ItemView.extend({
template: 'AddSeries/RootFolders/RootFolderItemTemplate',
tagName : 'tr',
events: {
'click .x-remove': 'removeFolder'
},
removeFolder: function () {
this.model.destroy({ wait: true });
this.model.collection.remove(this.model);
}
});
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'
});
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'
},
events: {
2013-02-15 08:18:42 +00:00
'click .x-add': 'addFolder'
},
onRender: function () {
2013-02-15 08:18:42 +00:00
this.collection = rootFolders;
this.currentDirs.show(new NzbDrone.AddSeries.RootDirListView({ collection: this.collection }));
2013-02-15 23:38:53 +00:00
this.ui.pathInput.autoComplete('/directories');
},
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-15 08:18:42 +00:00
}
});
});