1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-16 16:04:08 +01:00
Radarr/NzbDrone.Web/_backboneApp/AddSeries/RootFolders/RootDirView.js

87 lines
1.9 KiB
JavaScript
Raw Normal View History

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