2013-01-31 22:40:51 +00:00
|
|
|
|
'use strict';
|
|
|
|
|
/// <reference path="../../app.js" />
|
|
|
|
|
/// <reference path="UnmappedFolderModel.js" />
|
|
|
|
|
/// <reference path="../../Series/SeriesModel.js" />
|
|
|
|
|
/// <reference path="../SearchResultCollection.js" />
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
NzbDrone.AddSeries.Existing.FolderMatchResultView = Backbone.Marionette.ItemView.extend({
|
2013-02-02 03:33:23 +00:00
|
|
|
|
template: 'AddSeries/Existing/FolderMatchResultViewTemplatate',
|
2013-01-31 22:40:51 +00:00
|
|
|
|
|
2013-02-02 03:33:23 +00:00
|
|
|
|
events: {
|
|
|
|
|
'click .x-btn-add': 'addSeries'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
addSeries: function () {
|
|
|
|
|
|
|
|
|
|
var seriesId = this.model.get('id');
|
|
|
|
|
var title = this.model.get('seriesName');
|
|
|
|
|
var quality = this.options.qualityProfile.val();
|
|
|
|
|
var path = this.options.rootFolder + "\\" + title;
|
|
|
|
|
|
|
|
|
|
var model = new NzbDrone.Series.SeriesModel({
|
|
|
|
|
seriesId: seriesId,
|
|
|
|
|
title: title,
|
|
|
|
|
qualityProfileId: quality,
|
|
|
|
|
path: path
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
|
|
model.save(undefined, {
|
|
|
|
|
success: function () {
|
|
|
|
|
var notificationModel = new NzbDrone.Shared.NotificationModel({
|
|
|
|
|
title: 'Added',
|
|
|
|
|
message: title,
|
|
|
|
|
level: 'success'
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
NzbDrone.Shared.NotificationCollectionView.Instance.collection.add(notificationModel);
|
|
|
|
|
self.close();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-01-31 22:40:51 +00:00
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
NzbDrone.AddSeries.Existing.UnmappedFolderCompositeView = Backbone.Marionette.CompositeView.extend({
|
|
|
|
|
|
2013-02-02 03:33:23 +00:00
|
|
|
|
template: 'AddSeries/Existing/UnmappedFolderCompositeViewTemplatate',
|
|
|
|
|
itemViewContainer: '.x-folder-name-match-results',
|
2013-01-31 22:40:51 +00:00
|
|
|
|
itemView: NzbDrone.AddSeries.Existing.FolderMatchResultView,
|
|
|
|
|
|
|
|
|
|
events: {
|
2013-02-02 03:33:23 +00:00
|
|
|
|
'click .x-btn-search': 'search'
|
2013-01-31 22:40:51 +00:00
|
|
|
|
},
|
|
|
|
|
|
2013-02-01 03:15:19 +00:00
|
|
|
|
ui: {
|
2013-02-02 03:33:23 +00:00
|
|
|
|
searchButton: '.x-btn-search',
|
|
|
|
|
searchText: '.x-txt-search',
|
|
|
|
|
profileList: '.x-lst-quality-profile'
|
2013-02-01 03:15:19 +00:00
|
|
|
|
},
|
|
|
|
|
|
2013-01-31 22:40:51 +00:00
|
|
|
|
initialize: function () {
|
|
|
|
|
this.collection = new NzbDrone.AddSeries.SearchResultCollection();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
search: function () {
|
|
|
|
|
|
2013-02-01 03:15:19 +00:00
|
|
|
|
var icon = this.ui.searchButton.find('icon');
|
|
|
|
|
|
|
|
|
|
icon.removeClass('icon-search').addClass('icon-spin icon-spinner disabled');
|
|
|
|
|
|
2013-02-02 03:33:23 +00:00
|
|
|
|
var self = this;
|
2013-02-01 03:15:19 +00:00
|
|
|
|
|
2013-01-31 22:40:51 +00:00
|
|
|
|
this.collection.fetch({
|
2013-02-02 03:33:23 +00:00
|
|
|
|
data: $.param({ term: this.ui.searchText.val() }),
|
|
|
|
|
success: function (model) {
|
2013-02-01 03:15:19 +00:00
|
|
|
|
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
|
2013-02-02 03:33:23 +00:00
|
|
|
|
|
2013-02-01 03:15:19 +00:00
|
|
|
|
},
|
2013-02-02 03:33:23 +00:00
|
|
|
|
fail: function () {
|
2013-02-01 03:15:19 +00:00
|
|
|
|
icon.removeClass('icon-spin icon-spinner disabled').addClass('icon-search');
|
|
|
|
|
}
|
2013-01-31 22:40:51 +00:00
|
|
|
|
});
|
2013-02-02 03:33:23 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
itemViewOptions: function () {
|
|
|
|
|
return {
|
|
|
|
|
qualityProfile: this.ui.profileList,
|
|
|
|
|
rootFolder: this.model.get('rootFolder')
|
|
|
|
|
};
|
2013-01-31 22:40:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-02-02 03:33:23 +00:00
|
|
|
|
|
|
|
|
|
|
2013-01-31 22:40:51 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
NzbDrone.AddSeries.Existing.RootFolderCompositeView = Backbone.Marionette.CompositeView.extend({
|
|
|
|
|
|
|
|
|
|
template: "AddSeries/Existing/RootFolderCompositeViewTemplate",
|
|
|
|
|
itemViewContainer: ".x-existing-folder-container",
|
|
|
|
|
itemView: NzbDrone.AddSeries.Existing.UnmappedFolderCompositeView,
|
|
|
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
|
|
|
|
|
|
if (!this.model) {
|
|
|
|
|
throw "model is required.";
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-02 03:33:23 +00:00
|
|
|
|
if (!this.options.quality) {
|
|
|
|
|
throw "quality collection is required.";
|
|
|
|
|
}
|
|
|
|
|
|
2013-01-31 22:40:51 +00:00
|
|
|
|
this.collection = new NzbDrone.AddSeries.Existing.UnmappedFolderCollection();
|
2013-02-02 03:33:23 +00:00
|
|
|
|
this.refreshItems();
|
|
|
|
|
this.listenTo(this.options.quality, 'reset', this.refreshItems, this);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
refreshItems: function () {
|
|
|
|
|
this.collection.importItems(this.model, this.options.quality);
|
2013-01-31 22:40:51 +00:00
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
2013-02-02 03:33:23 +00:00
|
|
|
|
|
|
|
|
|
|
2013-01-31 22:40:51 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
NzbDrone.AddSeries.Existing.ImportSeriesView = Backbone.Marionette.CollectionView.extend({
|
|
|
|
|
|
|
|
|
|
itemView: NzbDrone.AddSeries.Existing.RootFolderCompositeView,
|
|
|
|
|
|
2013-02-02 03:33:23 +00:00
|
|
|
|
|
|
|
|
|
|
2013-01-31 22:40:51 +00:00
|
|
|
|
initialize: function () {
|
2013-02-02 03:33:23 +00:00
|
|
|
|
|
2013-01-31 22:40:51 +00:00
|
|
|
|
if (!this.collection) {
|
|
|
|
|
throw "root folder collection is required.";
|
|
|
|
|
}
|
2013-02-02 03:33:23 +00:00
|
|
|
|
|
|
|
|
|
if (!this.options.quality) {
|
|
|
|
|
throw "quality collection is required.";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.itemViewOptions = {
|
|
|
|
|
quality: this.options.quality
|
|
|
|
|
};
|
|
|
|
|
|
2013-01-31 22:40:51 +00:00
|
|
|
|
}
|
2013-02-02 03:33:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-01-31 22:40:51 +00:00
|
|
|
|
});
|