1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/UI/AddSeries/RootFolders/Layout.js

58 lines
1.6 KiB
JavaScript
Raw Normal View History

2013-06-21 04:43:58 +03:00
"use strict";
define(
[
'marionette',
'AddSeries/RootFolders/CollectionView',
'AddSeries/RootFolders/Collection',
2013-06-21 08:19:41 +03:00
'AddSeries/RootFolders/Model',
2013-06-21 04:43:58 +03:00
'Mixins/AutoComplete'
], function (Marionette, RootFolderCollectionView, RootFolderCollection, RootFolderModel) {
return Marionette.Layout.extend({
template: 'AddSeries/RootFolders/LayoutTemplate',
ui: {
pathInput: '.x-path input'
},
regions: {
currentDirs: '#current-dirs'
},
events: {
'click .x-add': 'addFolder'
},
initialize: function () {
this.collection = RootFolderCollection;
this.rootfolderListView = new RootFolderCollectionView({ collection: RootFolderCollection });
this.rootfolderListView.on('itemview:folderSelected', this._onFolderSelected, this);
},
onRender: function () {
this.currentDirs.show(this.rootfolderListView);
this.ui.pathInput.autoComplete('/directories');
},
_onFolderSelected: function (options) {
this.trigger('folderSelected', options);
},
addFolder: function () {
var newDir = new RootFolderModel({
Path: this.ui.pathInput.val()
});
RootFolderCollection.create(newDir, {
wait: true, success: function () {
RootFolderCollection.fetch();
}
});
}
});
});