mirror of
https://github.com/Readarr/Readarr.git
synced 2026-04-24 22:35:39 -04:00
rjs -> webpack
This commit is contained in:
@@ -1,27 +1,18 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'Series/SeriesModel',
|
||||
'underscore'
|
||||
], function (Backbone, SeriesModel, _) {
|
||||
return Backbone.Collection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/series/lookup',
|
||||
model: SeriesModel,
|
||||
var Backbone = require('backbone');
|
||||
var SeriesModel = require('../Series/SeriesModel');
|
||||
var _ = require('underscore');
|
||||
|
||||
parse: function (response) {
|
||||
|
||||
var self = this;
|
||||
|
||||
_.each(response, function (model) {
|
||||
model.id = undefined;
|
||||
|
||||
if (self.unmappedFolderModel) {
|
||||
model.path = self.unmappedFolderModel.get('folder').path;
|
||||
}
|
||||
});
|
||||
|
||||
return response;
|
||||
module.exports = Backbone.Collection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/series/lookup',
|
||||
model : SeriesModel,
|
||||
parse : function(response){
|
||||
var self = this;
|
||||
_.each(response, function(model){
|
||||
model.id = undefined;
|
||||
if(self.unmappedFolderModel) {
|
||||
model.path = self.unmappedFolderModel.get('folder').path;
|
||||
}
|
||||
});
|
||||
});
|
||||
return response;
|
||||
}
|
||||
});
|
||||
@@ -1,67 +1,40 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'vent',
|
||||
'AppLayout',
|
||||
'marionette',
|
||||
'AddSeries/RootFolders/RootFolderLayout',
|
||||
'AddSeries/Existing/AddExistingSeriesCollectionView',
|
||||
'AddSeries/AddSeriesView',
|
||||
'Profile/ProfileCollection',
|
||||
'AddSeries/RootFolders/RootFolderCollection',
|
||||
'Series/SeriesCollection'
|
||||
], function (vent,
|
||||
AppLayout,
|
||||
Marionette,
|
||||
RootFolderLayout,
|
||||
ExistingSeriesCollectionView,
|
||||
AddSeriesView,
|
||||
ProfileCollection,
|
||||
RootFolderCollection) {
|
||||
var vent = require('../vent');
|
||||
var AppLayout = require('../AppLayout');
|
||||
var Marionette = require('marionette');
|
||||
var RootFolderLayout = require('./RootFolders/RootFolderLayout');
|
||||
var ExistingSeriesCollectionView = require('./Existing/AddExistingSeriesCollectionView');
|
||||
var AddSeriesView = require('./AddSeriesView');
|
||||
var ProfileCollection = require('../Profile/ProfileCollection');
|
||||
var RootFolderCollection = require('./RootFolders/RootFolderCollection');
|
||||
require('../Series/SeriesCollection');
|
||||
|
||||
return Marionette.Layout.extend({
|
||||
template: 'AddSeries/AddSeriesLayoutTemplate',
|
||||
|
||||
regions: {
|
||||
workspace: '#add-series-workspace'
|
||||
},
|
||||
|
||||
events: {
|
||||
'click .x-import': '_importSeries',
|
||||
'click .x-add-new': '_addSeries'
|
||||
},
|
||||
|
||||
attributes: {
|
||||
id: 'add-series-screen'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
ProfileCollection.fetch();
|
||||
RootFolderCollection.fetch()
|
||||
.done(function () {
|
||||
RootFolderCollection.synced = true;
|
||||
});
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
this.workspace.show(new AddSeriesView());
|
||||
},
|
||||
|
||||
_folderSelected: function (options) {
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
|
||||
this.workspace.show(new ExistingSeriesCollectionView({model: options.model}));
|
||||
},
|
||||
|
||||
_importSeries: function () {
|
||||
this.rootFolderLayout = new RootFolderLayout();
|
||||
this.listenTo(this.rootFolderLayout, 'folderSelected', this._folderSelected);
|
||||
AppLayout.modalRegion.show(this.rootFolderLayout);
|
||||
},
|
||||
|
||||
_addSeries: function () {
|
||||
this.workspace.show(new AddSeriesView());
|
||||
}
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'AddSeries/AddSeriesLayoutTemplate',
|
||||
regions : {workspace : '#add-series-workspace'},
|
||||
events : {
|
||||
'click .x-import' : '_importSeries',
|
||||
'click .x-add-new' : '_addSeries'
|
||||
},
|
||||
attributes : {id : 'add-series-screen'},
|
||||
initialize : function(){
|
||||
ProfileCollection.fetch();
|
||||
RootFolderCollection.fetch().done(function(){
|
||||
RootFolderCollection.synced = true;
|
||||
});
|
||||
});
|
||||
|
||||
},
|
||||
onShow : function(){
|
||||
this.workspace.show(new AddSeriesView());
|
||||
},
|
||||
_folderSelected : function(options){
|
||||
vent.trigger(vent.Commands.CloseModalCommand);
|
||||
this.workspace.show(new ExistingSeriesCollectionView({model : options.model}));
|
||||
},
|
||||
_importSeries : function(){
|
||||
this.rootFolderLayout = new RootFolderLayout();
|
||||
this.listenTo(this.rootFolderLayout, 'folderSelected', this._folderSelected);
|
||||
AppLayout.modalRegion.show(this.rootFolderLayout);
|
||||
},
|
||||
_addSeries : function(){
|
||||
this.workspace.show(new AddSeriesView());
|
||||
}
|
||||
});
|
||||
+125
-170
@@ -1,174 +1,129 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'underscore',
|
||||
'vent',
|
||||
'marionette',
|
||||
'AddSeries/AddSeriesCollection',
|
||||
'AddSeries/SearchResultCollectionView',
|
||||
'AddSeries/EmptyView',
|
||||
'AddSeries/NotFoundView',
|
||||
'AddSeries/ErrorView',
|
||||
'Shared/LoadingView'
|
||||
], function (_, vent, Marionette, AddSeriesCollection, SearchResultCollectionView, EmptyView, NotFoundView, ErrorView, LoadingView) {
|
||||
return Marionette.Layout.extend({
|
||||
template: 'AddSeries/AddSeriesViewTemplate',
|
||||
var _ = require('underscore');
|
||||
var vent = require('../vent');
|
||||
var Marionette = require('marionette');
|
||||
var AddSeriesCollection = require('./AddSeriesCollection');
|
||||
var SearchResultCollectionView = require('./SearchResultCollectionView');
|
||||
var EmptyView = require('./EmptyView');
|
||||
var NotFoundView = require('./NotFoundView');
|
||||
var ErrorView = require('./ErrorView');
|
||||
var LoadingView = require('../Shared/LoadingView');
|
||||
|
||||
regions: {
|
||||
searchResult: '#search-result'
|
||||
},
|
||||
|
||||
ui: {
|
||||
seriesSearch: '.x-series-search',
|
||||
searchBar : '.x-search-bar',
|
||||
loadMore : '.x-load-more'
|
||||
},
|
||||
|
||||
events: {
|
||||
'click .x-load-more': '_onLoadMore'
|
||||
},
|
||||
|
||||
initialize: function (options) {
|
||||
this.isExisting = options.isExisting;
|
||||
this.collection = new AddSeriesCollection();
|
||||
|
||||
if (this.isExisting) {
|
||||
this.collection.unmappedFolderModel = this.model;
|
||||
}
|
||||
|
||||
if (this.isExisting) {
|
||||
this.className = 'existing-series';
|
||||
}
|
||||
else {
|
||||
this.className = 'new-series';
|
||||
}
|
||||
|
||||
this.listenTo(vent, vent.Events.SeriesAdded, this._onSeriesAdded);
|
||||
this.listenTo(this.collection, 'sync', this._showResults);
|
||||
|
||||
this.resultCollectionView = new SearchResultCollectionView({
|
||||
collection: this.collection,
|
||||
isExisting: this.isExisting
|
||||
});
|
||||
|
||||
this.throttledSearch = _.debounce(this.search, 1000, {trailing: true}).bind(this);
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
var self = this;
|
||||
|
||||
this.$el.addClass(this.className);
|
||||
|
||||
this.ui.seriesSearch.keyup(function (e) {
|
||||
|
||||
//Ignore special keys: http://www.javascripter.net/faq/keycodes.htm
|
||||
if (_.contains([9, 16, 17, 18, 19, 20, 33, 34, 35, 36, 37, 38, 39, 40, 91, 92, 93 ], e.keyCode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
self._abortExistingSearch();
|
||||
self.throttledSearch({
|
||||
term: self.ui.seriesSearch.val()
|
||||
});
|
||||
});
|
||||
|
||||
this._clearResults();
|
||||
|
||||
if (this.isExisting) {
|
||||
this.ui.searchBar.hide();
|
||||
}
|
||||
},
|
||||
|
||||
onShow: function () {
|
||||
this.ui.seriesSearch.focus();
|
||||
},
|
||||
|
||||
search: function (options) {
|
||||
var self = this;
|
||||
|
||||
this.collection.reset();
|
||||
|
||||
if (!options.term || options.term === this.collection.term) {
|
||||
return Marionette.$.Deferred().resolve();
|
||||
}
|
||||
|
||||
this.searchResult.show(new LoadingView());
|
||||
this.collection.term = options.term;
|
||||
this.currentSearchPromise = this.collection.fetch({
|
||||
data: { term: options.term }
|
||||
});
|
||||
|
||||
this.currentSearchPromise.fail(function () {
|
||||
self._showError();
|
||||
});
|
||||
|
||||
return this.currentSearchPromise;
|
||||
},
|
||||
|
||||
_onSeriesAdded: function (options) {
|
||||
if (this.isExisting && options.series.get('path') === this.model.get('folder').path) {
|
||||
this.close();
|
||||
}
|
||||
|
||||
else if (!this.isExisting) {
|
||||
this.collection.term = '';
|
||||
this.collection.reset();
|
||||
this._clearResults();
|
||||
this.ui.seriesSearch.val('');
|
||||
this.ui.seriesSearch.focus();
|
||||
}
|
||||
},
|
||||
|
||||
_onLoadMore: function () {
|
||||
var showingAll = this.resultCollectionView.showMore();
|
||||
module.exports = Marionette.Layout.extend({
|
||||
template : 'AddSeries/AddSeriesViewTemplate',
|
||||
regions : {searchResult : '#search-result'},
|
||||
ui : {
|
||||
seriesSearch : '.x-series-search',
|
||||
searchBar : '.x-search-bar',
|
||||
loadMore : '.x-load-more'
|
||||
},
|
||||
events : {"click .x-load-more" : '_onLoadMore'},
|
||||
initialize : function(options){
|
||||
this.isExisting = options.isExisting;
|
||||
this.collection = new AddSeriesCollection();
|
||||
if(this.isExisting) {
|
||||
this.collection.unmappedFolderModel = this.model;
|
||||
}
|
||||
if(this.isExisting) {
|
||||
this.className = 'existing-series';
|
||||
}
|
||||
else {
|
||||
this.className = 'new-series';
|
||||
}
|
||||
this.listenTo(vent, vent.Events.SeriesAdded, this._onSeriesAdded);
|
||||
this.listenTo(this.collection, 'sync', this._showResults);
|
||||
this.resultCollectionView = new SearchResultCollectionView({
|
||||
collection : this.collection,
|
||||
isExisting : this.isExisting
|
||||
});
|
||||
this.throttledSearch = _.debounce(this.search, 1000, {trailing : true}).bind(this);
|
||||
},
|
||||
onRender : function(){
|
||||
var self = this;
|
||||
this.$el.addClass(this.className);
|
||||
this.ui.seriesSearch.keyup(function(e){
|
||||
if(_.contains([9, 16, 17, 18, 19, 20, 33, 34, 35, 36, 37, 38, 39, 40, 91, 92, 93], e.keyCode)) {
|
||||
return;
|
||||
}
|
||||
self._abortExistingSearch();
|
||||
self.throttledSearch({term : self.ui.seriesSearch.val()});
|
||||
});
|
||||
this._clearResults();
|
||||
if(this.isExisting) {
|
||||
this.ui.searchBar.hide();
|
||||
}
|
||||
},
|
||||
onShow : function(){
|
||||
this.ui.seriesSearch.focus();
|
||||
},
|
||||
search : function(options){
|
||||
var self = this;
|
||||
this.collection.reset();
|
||||
if(!options.term || options.term === this.collection.term) {
|
||||
return Marionette.$.Deferred().resolve();
|
||||
}
|
||||
this.searchResult.show(new LoadingView());
|
||||
this.collection.term = options.term;
|
||||
this.currentSearchPromise = this.collection.fetch({data : {term : options.term}});
|
||||
this.currentSearchPromise.fail(function(){
|
||||
self._showError();
|
||||
});
|
||||
return this.currentSearchPromise;
|
||||
},
|
||||
_onSeriesAdded : function(options){
|
||||
if(this.isExisting && options.series.get('path') === this.model.get('folder').path) {
|
||||
this.close();
|
||||
}
|
||||
else if(!this.isExisting) {
|
||||
this.collection.term = '';
|
||||
this.collection.reset();
|
||||
this._clearResults();
|
||||
this.ui.seriesSearch.val('');
|
||||
this.ui.seriesSearch.focus();
|
||||
}
|
||||
},
|
||||
_onLoadMore : function(){
|
||||
var showingAll = this.resultCollectionView.showMore();
|
||||
this.ui.searchBar.show();
|
||||
if(showingAll) {
|
||||
this.ui.loadMore.hide();
|
||||
}
|
||||
},
|
||||
_clearResults : function(){
|
||||
if(!this.isExisting) {
|
||||
this.searchResult.show(new EmptyView());
|
||||
}
|
||||
else {
|
||||
this.searchResult.close();
|
||||
}
|
||||
},
|
||||
_showResults : function(){
|
||||
if(!this.isClosed) {
|
||||
if(this.collection.length === 0) {
|
||||
this.ui.searchBar.show();
|
||||
|
||||
if (showingAll) {
|
||||
this.ui.loadMore.hide();
|
||||
}
|
||||
},
|
||||
|
||||
_clearResults: function () {
|
||||
if (!this.isExisting) {
|
||||
this.searchResult.show(new EmptyView());
|
||||
}
|
||||
else {
|
||||
this.searchResult.close();
|
||||
}
|
||||
},
|
||||
|
||||
_showResults: function () {
|
||||
if (!this.isClosed) {
|
||||
|
||||
if (this.collection.length === 0) {
|
||||
this.ui.searchBar.show();
|
||||
this.searchResult.show(new NotFoundView({term: this.collection.term}));
|
||||
}
|
||||
else {
|
||||
this.searchResult.show(this.resultCollectionView);
|
||||
if (!this.showingAll && this.isExisting) {
|
||||
this.ui.loadMore.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_abortExistingSearch: function () {
|
||||
if (this.currentSearchPromise && this.currentSearchPromise.readyState > 0 && this.currentSearchPromise.readyState < 4) {
|
||||
console.log('aborting previous pending search request.');
|
||||
this.currentSearchPromise.abort();
|
||||
}
|
||||
else {
|
||||
this._clearResults();
|
||||
}
|
||||
},
|
||||
|
||||
_showError: function () {
|
||||
if (!this.isClosed) {
|
||||
this.ui.searchBar.show();
|
||||
this.searchResult.show(new ErrorView({term: this.collection.term}));
|
||||
this.collection.term = '';
|
||||
this.searchResult.show(new NotFoundView({term : this.collection.term}));
|
||||
}
|
||||
else {
|
||||
this.searchResult.show(this.resultCollectionView);
|
||||
if(!this.showingAll && this.isExisting) {
|
||||
this.ui.loadMore.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
_abortExistingSearch : function(){
|
||||
if(this.currentSearchPromise && this.currentSearchPromise.readyState > 0 && this.currentSearchPromise.readyState < 4) {
|
||||
console.log('aborting previous pending search request.');
|
||||
this.currentSearchPromise.abort();
|
||||
}
|
||||
else {
|
||||
this._clearResults();
|
||||
}
|
||||
},
|
||||
_showError : function(){
|
||||
if(!this.isClosed) {
|
||||
this.ui.searchBar.show();
|
||||
this.searchResult.show(new ErrorView({term : this.collection.term}));
|
||||
this.collection.term = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,11 +1,3 @@
|
||||
'use strict';
|
||||
var Marionette = require('marionette');
|
||||
|
||||
define(
|
||||
[
|
||||
'marionette'
|
||||
], function (Marionette) {
|
||||
|
||||
return Marionette.CompositeView.extend({
|
||||
template: 'AddSeries/EmptyViewTemplate'
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.CompositeView.extend({template : 'AddSeries/EmptyViewTemplate'});
|
||||
@@ -1,20 +1,11 @@
|
||||
'use strict';
|
||||
var Marionette = require('marionette');
|
||||
|
||||
define(
|
||||
[
|
||||
'marionette'
|
||||
], function (Marionette) {
|
||||
|
||||
return Marionette.CompositeView.extend({
|
||||
template: 'AddSeries/ErrorViewTemplate',
|
||||
|
||||
initialize: function (options) {
|
||||
this.options = options;
|
||||
},
|
||||
|
||||
templateHelpers: function () {
|
||||
return this.options;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.CompositeView.extend({
|
||||
template : 'AddSeries/ErrorViewTemplate',
|
||||
initialize : function(options){
|
||||
this.options = options;
|
||||
},
|
||||
templateHelpers : function(){
|
||||
return this.options;
|
||||
}
|
||||
});
|
||||
@@ -1,59 +1,38 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'AddSeries/AddSeriesView',
|
||||
'AddSeries/Existing/UnmappedFolderCollection'
|
||||
], function (Marionette, AddSeriesView, UnmappedFolderCollection) {
|
||||
var Marionette = require('marionette');
|
||||
var AddSeriesView = require('../AddSeriesView');
|
||||
var UnmappedFolderCollection = require('./UnmappedFolderCollection');
|
||||
|
||||
return Marionette.CompositeView.extend({
|
||||
|
||||
itemView : AddSeriesView,
|
||||
itemViewContainer: '.x-loading-folders',
|
||||
template : 'AddSeries/Existing/AddExistingSeriesCollectionViewTemplate',
|
||||
|
||||
ui: {
|
||||
loadingFolders: '.x-loading-folders'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.collection = new UnmappedFolderCollection();
|
||||
this.collection.importItems(this.model);
|
||||
},
|
||||
|
||||
showCollection: function () {
|
||||
this._showAndSearch(0);
|
||||
},
|
||||
|
||||
appendHtml: function(collectionView, itemView, index){
|
||||
collectionView.ui.loadingFolders.before(itemView.el);
|
||||
},
|
||||
|
||||
_showAndSearch: function (index) {
|
||||
var self = this;
|
||||
var model = this.collection.at(index);
|
||||
|
||||
if (model) {
|
||||
var currentIndex = index;
|
||||
var folderName = model.get('folder').name;
|
||||
this.addItemView(model, this.getItemView(), index);
|
||||
this.children.findByModel(model)
|
||||
.search({term: folderName})
|
||||
.always(function () {
|
||||
if (!self.isClosed) {
|
||||
self._showAndSearch(currentIndex + 1);
|
||||
}
|
||||
});
|
||||
module.exports = Marionette.CompositeView.extend({
|
||||
itemView : AddSeriesView,
|
||||
itemViewContainer : '.x-loading-folders',
|
||||
template : 'AddSeries/Existing/AddExistingSeriesCollectionViewTemplate',
|
||||
ui : {loadingFolders : '.x-loading-folders'},
|
||||
initialize : function(){
|
||||
this.collection = new UnmappedFolderCollection();
|
||||
this.collection.importItems(this.model);
|
||||
},
|
||||
showCollection : function(){
|
||||
this._showAndSearch(0);
|
||||
},
|
||||
appendHtml : function(collectionView, itemView, index){
|
||||
collectionView.ui.loadingFolders.before(itemView.el);
|
||||
},
|
||||
_showAndSearch : function(index){
|
||||
var self = this;
|
||||
var model = this.collection.at(index);
|
||||
if(model) {
|
||||
var currentIndex = index;
|
||||
var folderName = model.get('folder').name;
|
||||
this.addItemView(model, this.getItemView(), index);
|
||||
this.children.findByModel(model).search({term : folderName}).always(function(){
|
||||
if(!self.isClosed) {
|
||||
self._showAndSearch(currentIndex + 1);
|
||||
}
|
||||
|
||||
else {
|
||||
this.ui.loadingFolders.hide();
|
||||
}
|
||||
},
|
||||
|
||||
itemViewOptions: {
|
||||
isExisting: true
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.ui.loadingFolders.hide();
|
||||
}
|
||||
},
|
||||
itemViewOptions : {isExisting : true}
|
||||
});
|
||||
@@ -1,24 +1,17 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'AddSeries/Existing/UnmappedFolderModel',
|
||||
'underscore'
|
||||
], function (Backbone, UnmappedFolderModel,_) {
|
||||
return Backbone.Collection.extend({
|
||||
model: UnmappedFolderModel,
|
||||
var Backbone = require('backbone');
|
||||
var UnmappedFolderModel = require('./UnmappedFolderModel');
|
||||
var _ = require('underscore');
|
||||
|
||||
importItems: function (rootFolderModel) {
|
||||
|
||||
this.reset();
|
||||
var rootFolder = rootFolderModel;
|
||||
|
||||
_.each(rootFolderModel.get('unmappedFolders'), function (folder) {
|
||||
this.push(new UnmappedFolderModel({
|
||||
rootFolder: rootFolder,
|
||||
folder : folder
|
||||
}));
|
||||
}, this);
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Backbone.Collection.extend({
|
||||
model : UnmappedFolderModel,
|
||||
importItems : function(rootFolderModel){
|
||||
this.reset();
|
||||
var rootFolder = rootFolderModel;
|
||||
_.each(rootFolderModel.get('unmappedFolders'), function(folder){
|
||||
this.push(new UnmappedFolderModel({
|
||||
rootFolder : rootFolder,
|
||||
folder : folder
|
||||
}));
|
||||
}, this);
|
||||
}
|
||||
});
|
||||
@@ -1,10 +1,3 @@
|
||||
'use strict';
|
||||
var Backbone = require('backbone');
|
||||
|
||||
define(
|
||||
[
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
|
||||
});
|
||||
});
|
||||
module.exports = Backbone.Model.extend({});
|
||||
@@ -1,20 +1,11 @@
|
||||
'use strict';
|
||||
var Marionette = require('marionette');
|
||||
|
||||
define(
|
||||
[
|
||||
'marionette'
|
||||
], function (Marionette) {
|
||||
|
||||
return Marionette.CompositeView.extend({
|
||||
template: 'AddSeries/NotFoundViewTemplate',
|
||||
|
||||
initialize: function (options) {
|
||||
this.options = options;
|
||||
},
|
||||
|
||||
templateHelpers: function () {
|
||||
return this.options;
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.CompositeView.extend({
|
||||
template : 'AddSeries/NotFoundViewTemplate',
|
||||
initialize : function(options){
|
||||
this.options = options;
|
||||
},
|
||||
templateHelpers : function(){
|
||||
return this.options;
|
||||
}
|
||||
});
|
||||
@@ -1,17 +1,11 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone',
|
||||
'AddSeries/RootFolders/RootFolderModel',
|
||||
'Mixins/backbone.signalr.mixin'
|
||||
], function (Backbone, RootFolderModel) {
|
||||
var Backbone = require('backbone');
|
||||
var RootFolderModel = require('./RootFolderModel');
|
||||
require('../../Mixins/backbone.signalr.mixin');
|
||||
|
||||
var RootFolderCollection = Backbone.Collection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/rootfolder',
|
||||
model: RootFolderModel
|
||||
});
|
||||
|
||||
//var collection = new RootFolderCollection().bindSignalR();
|
||||
|
||||
return new RootFolderCollection();
|
||||
module.exports = (function(){
|
||||
var RootFolderCollection = Backbone.Collection.extend({
|
||||
url : window.NzbDrone.ApiRoot + '/rootfolder',
|
||||
model : RootFolderModel
|
||||
});
|
||||
return new RootFolderCollection();
|
||||
}).call(this);
|
||||
@@ -1,15 +1,8 @@
|
||||
'use strict';
|
||||
var Marionette = require('marionette');
|
||||
var RootFolderItemView = require('./RootFolderItemView');
|
||||
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'AddSeries/RootFolders/RootFolderItemView'
|
||||
], function (Marionette, RootFolderItemView) {
|
||||
|
||||
|
||||
return Marionette.CompositeView.extend({
|
||||
template : 'AddSeries/RootFolders/RootFolderCollectionViewTemplate',
|
||||
itemViewContainer : '.x-root-folders',
|
||||
itemView : RootFolderItemView
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.CompositeView.extend({
|
||||
template : 'AddSeries/RootFolders/RootFolderCollectionViewTemplate',
|
||||
itemViewContainer : '.x-root-folders',
|
||||
itemView : RootFolderItemView
|
||||
});
|
||||
@@ -1,37 +1,22 @@
|
||||
'use strict';
|
||||
var Marionette = require('marionette');
|
||||
|
||||
define(
|
||||
[
|
||||
'marionette'
|
||||
], function (Marionette) {
|
||||
|
||||
return Marionette.ItemView.extend({
|
||||
|
||||
template: 'AddSeries/RootFolders/RootFolderItemViewTemplate',
|
||||
tagName : 'tr',
|
||||
|
||||
initialize: function () {
|
||||
this.listenTo(this.model, 'change', this.render);
|
||||
},
|
||||
|
||||
|
||||
events: {
|
||||
'click .x-delete': 'removeFolder',
|
||||
'click .x-folder': 'folderSelected'
|
||||
},
|
||||
|
||||
removeFolder: function () {
|
||||
|
||||
var self = this;
|
||||
|
||||
this.model.destroy()
|
||||
.success(function(){
|
||||
self.close();
|
||||
});
|
||||
},
|
||||
|
||||
folderSelected: function () {
|
||||
this.trigger('folderSelected', this.model);
|
||||
}
|
||||
module.exports = Marionette.ItemView.extend({
|
||||
template : 'AddSeries/RootFolders/RootFolderItemViewTemplate',
|
||||
tagName : 'tr',
|
||||
initialize : function(){
|
||||
this.listenTo(this.model, 'change', this.render);
|
||||
},
|
||||
events : {
|
||||
'click .x-delete' : 'removeFolder',
|
||||
'click .x-folder' : 'folderSelected'
|
||||
},
|
||||
removeFolder : function(){
|
||||
var self = this;
|
||||
this.model.destroy().success(function(){
|
||||
self.close();
|
||||
});
|
||||
});
|
||||
},
|
||||
folderSelected : function(){
|
||||
this.trigger('folderSelected', this.model);
|
||||
}
|
||||
});
|
||||
@@ -1,81 +1,54 @@
|
||||
'use strict';
|
||||
var Marionette = require('marionette');
|
||||
var RootFolderCollectionView = require('./RootFolderCollectionView');
|
||||
var RootFolderCollection = require('./RootFolderCollection');
|
||||
var RootFolderModel = require('./RootFolderModel');
|
||||
var LoadingView = require('../../Shared/LoadingView');
|
||||
var AsValidatedView = require('../../Mixins/AsValidatedView');
|
||||
require('../../Mixins/FileBrowser');
|
||||
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'AddSeries/RootFolders/RootFolderCollectionView',
|
||||
'AddSeries/RootFolders/RootFolderCollection',
|
||||
'AddSeries/RootFolders/RootFolderModel',
|
||||
'Shared/LoadingView',
|
||||
'Mixins/AsValidatedView',
|
||||
'Mixins/FileBrowser'
|
||||
], function (Marionette, RootFolderCollectionView, RootFolderCollection, RootFolderModel, LoadingView, AsValidatedView) {
|
||||
|
||||
var layout = Marionette.Layout.extend({
|
||||
template: 'AddSeries/RootFolders/RootFolderLayoutTemplate',
|
||||
|
||||
ui: {
|
||||
pathInput: '.x-path'
|
||||
},
|
||||
|
||||
regions: {
|
||||
currentDirs: '#current-dirs'
|
||||
},
|
||||
|
||||
events: {
|
||||
'click .x-add': '_addFolder',
|
||||
'keydown .x-path input': '_keydown'
|
||||
},
|
||||
|
||||
initialize: function () {
|
||||
this.collection = RootFolderCollection;
|
||||
this.rootfolderListView = new RootFolderCollectionView({ collection: RootFolderCollection });
|
||||
|
||||
this.listenTo(this.rootfolderListView, 'itemview:folderSelected', this._onFolderSelected);
|
||||
this.listenTo(RootFolderCollection, 'sync', this._showCurrentDirs);
|
||||
},
|
||||
|
||||
onRender: function () {
|
||||
this.currentDirs.show(new LoadingView());
|
||||
|
||||
if (RootFolderCollection.synced) {
|
||||
this._showCurrentDirs();
|
||||
}
|
||||
|
||||
this.ui.pathInput.fileBrowser();
|
||||
},
|
||||
|
||||
_onFolderSelected: function (options) {
|
||||
this.trigger('folderSelected', options);
|
||||
},
|
||||
|
||||
_addFolder: function () {
|
||||
var self = this;
|
||||
|
||||
var newDir = new RootFolderModel({
|
||||
Path: this.ui.pathInput.val()
|
||||
});
|
||||
|
||||
this.bindToModelValidation(newDir);
|
||||
|
||||
newDir.save().done(function () {
|
||||
RootFolderCollection.add(newDir);
|
||||
self.trigger('folderSelected', {model: newDir});
|
||||
});
|
||||
},
|
||||
|
||||
_showCurrentDirs: function () {
|
||||
this.currentDirs.show(this.rootfolderListView);
|
||||
},
|
||||
|
||||
_keydown: function (e) {
|
||||
if (e.keyCode !== 13) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._addFolder();
|
||||
module.exports = (function(){
|
||||
var layout = Marionette.Layout.extend({
|
||||
template : 'AddSeries/RootFolders/RootFolderLayoutTemplate',
|
||||
ui : {pathInput : '.x-path'},
|
||||
regions : {currentDirs : '#current-dirs'},
|
||||
events : {
|
||||
'click .x-add' : '_addFolder',
|
||||
'keydown .x-path input' : '_keydown'
|
||||
},
|
||||
initialize : function(){
|
||||
this.collection = RootFolderCollection;
|
||||
this.rootfolderListView = new RootFolderCollectionView({collection : RootFolderCollection});
|
||||
this.listenTo(this.rootfolderListView, 'itemview:folderSelected', this._onFolderSelected);
|
||||
this.listenTo(RootFolderCollection, 'sync', this._showCurrentDirs);
|
||||
},
|
||||
onRender : function(){
|
||||
this.currentDirs.show(new LoadingView());
|
||||
if(RootFolderCollection.synced) {
|
||||
this._showCurrentDirs();
|
||||
}
|
||||
});
|
||||
|
||||
return AsValidatedView.apply(layout);
|
||||
this.ui.pathInput.fileBrowser();
|
||||
},
|
||||
_onFolderSelected : function(options){
|
||||
this.trigger('folderSelected', options);
|
||||
},
|
||||
_addFolder : function(){
|
||||
var self = this;
|
||||
var newDir = new RootFolderModel({Path : this.ui.pathInput.val()});
|
||||
this.bindToModelValidation(newDir);
|
||||
newDir.save().done(function(){
|
||||
RootFolderCollection.add(newDir);
|
||||
self.trigger('folderSelected', {model : newDir});
|
||||
});
|
||||
},
|
||||
_showCurrentDirs : function(){
|
||||
this.currentDirs.show(this.rootfolderListView);
|
||||
},
|
||||
_keydown : function(e){
|
||||
if(e.keyCode !== 13) {
|
||||
return;
|
||||
}
|
||||
this._addFolder();
|
||||
}
|
||||
});
|
||||
return AsValidatedView.apply(layout);
|
||||
}).call(this);
|
||||
@@ -1,12 +1,6 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'backbone'
|
||||
], function (Backbone) {
|
||||
return Backbone.Model.extend({
|
||||
urlRoot : window.NzbDrone.ApiRoot + '/rootfolder',
|
||||
defaults: {
|
||||
freeSpace: 0
|
||||
}
|
||||
});
|
||||
});
|
||||
var Backbone = require('backbone');
|
||||
|
||||
module.exports = Backbone.Model.extend({
|
||||
urlRoot : window.NzbDrone.ApiRoot + '/rootfolder',
|
||||
defaults : {freeSpace : 0}
|
||||
});
|
||||
@@ -1,35 +1,24 @@
|
||||
'use strict';
|
||||
define(
|
||||
[
|
||||
'marionette',
|
||||
'AddSeries/SearchResultView'
|
||||
], function (Marionette, SearchResultView) {
|
||||
var Marionette = require('marionette');
|
||||
var SearchResultView = require('./SearchResultView');
|
||||
|
||||
return Marionette.CollectionView.extend({
|
||||
|
||||
itemView: SearchResultView,
|
||||
|
||||
initialize: function (options) {
|
||||
this.isExisting = options.isExisting;
|
||||
this.showing = 1;
|
||||
},
|
||||
|
||||
showAll: function () {
|
||||
this.showingAll = true;
|
||||
this.render();
|
||||
},
|
||||
|
||||
showMore: function () {
|
||||
this.showing += 5;
|
||||
this.render();
|
||||
|
||||
return this.showing >= this.collection.length;
|
||||
},
|
||||
|
||||
appendHtml: function (collectionView, itemView, index) {
|
||||
if (!this.isExisting || index < this.showing || index === 0) {
|
||||
collectionView.$el.append(itemView.el);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
module.exports = Marionette.CollectionView.extend({
|
||||
itemView : SearchResultView,
|
||||
initialize : function(options){
|
||||
this.isExisting = options.isExisting;
|
||||
this.showing = 1;
|
||||
},
|
||||
showAll : function(){
|
||||
this.showingAll = true;
|
||||
this.render();
|
||||
},
|
||||
showMore : function(){
|
||||
this.showing += 5;
|
||||
this.render();
|
||||
return this.showing >= this.collection.length;
|
||||
},
|
||||
appendHtml : function(collectionView, itemView, index){
|
||||
if(!this.isExisting || index < this.showing || index === 0) {
|
||||
collectionView.$el.append(itemView.el);
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user