1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-27 10:19:41 +00:00
Radarr/UI/AddSeries/RootFolders/Layout.js

72 lines
2 KiB
JavaScript
Raw Normal View History

2013-06-22 06:24:24 +00:00
'use strict';
2013-06-21 01:43:58 +00:00
define(
[
'marionette',
'AddSeries/RootFolders/CollectionView',
'AddSeries/RootFolders/Collection',
2013-06-21 05:19:41 +00:00
'AddSeries/RootFolders/Model',
2013-08-22 04:04:03 +00:00
'Shared/LoadingView',
'Mixins/AsValidatedView',
2013-06-21 01:43:58 +00:00
'Mixins/AutoComplete'
], function (Marionette, RootFolderCollectionView, RootFolderCollection, RootFolderModel, LoadingView, AsValidatedView) {
2013-06-21 01:43:58 +00:00
var layout = Marionette.Layout.extend({
2013-06-21 01:43:58 +00:00
template: 'AddSeries/RootFolders/LayoutTemplate',
ui: {
pathInput: '.x-path input'
},
regions: {
currentDirs: '#current-dirs'
},
events: {
2013-06-28 00:00:55 +00:00
'click .x-add': '_addFolder'
2013-06-21 01:43:58 +00:00
},
initialize: function () {
this.collection = RootFolderCollection;
this.rootfolderListView = new RootFolderCollectionView({ collection: RootFolderCollection });
this.listenTo(this.rootfolderListView, 'itemview:folderSelected', this._onFolderSelected);
2013-06-21 01:43:58 +00:00
},
onRender: function () {
2013-08-21 05:48:25 +00:00
var self = this;
2013-08-22 04:04:03 +00:00
this.currentDirs.show(new LoadingView());
2013-08-21 05:48:25 +00:00
RootFolderCollection.promise.done(function () {
self.currentDirs.show(self.rootfolderListView);
});
2013-06-21 01:43:58 +00:00
this.ui.pathInput.autoComplete('/directories');
},
_onFolderSelected: function (options) {
this.trigger('folderSelected', options);
},
2013-06-28 00:00:55 +00:00
_addFolder: function () {
var self = this;
2013-06-21 01:43:58 +00:00
var newDir = new RootFolderModel({
Path: this.ui.pathInput.val()
});
this.bindToModelValidation(newDir);
newDir.save().done(function () {
RootFolderCollection.add(newDir);
self.trigger('folderSelected', {model: newDir});
2013-06-21 01:43:58 +00:00
});
}
});
return AsValidatedView.apply(layout);
2013-06-21 01:43:58 +00:00
});