1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-27 10:17:47 +00:00
Sonarr/UI/Settings/Indexers/CollectionView.js
Mark McDowall e1272b4f34 Notification and Indexer settings are enabled by default on add
NzbClub and omgwtfnzbs are off by default
2013-08-01 08:25:09 -07:00

47 lines
1.7 KiB
JavaScript

'use strict';
define(['app',
'marionette',
'Settings/Indexers/ItemView',
'Settings/Indexers/EditView',
'Settings/Indexers/Collection'],
function (App, Marionette, IndexerItemView, IndexerEditView, IndexerCollection) {
return Marionette.CompositeView.extend({
itemView : IndexerItemView,
itemViewContainer: '#x-indexers',
template : 'Settings/Indexers/CollectionTemplate',
ui: {
'addCard': '.x-add-card'
},
events: {
'click .x-add-card': '_openSchemaModal'
},
appendHtml: function(collectionView, itemView, index){
collectionView.ui.addCard.parent('li').before(itemView.el);
},
_openSchemaModal: function () {
var self = this;
//TODO: Is there a better way to deal with changing URLs?
var schemaCollection = new IndexerCollection();
schemaCollection.url = '/api/indexer/schema';
schemaCollection.fetch({
success: function (collection) {
collection.url = '/api/indexer';
var model = _.first(collection.models);
model.set({
id: undefined,
name: '',
enable: true
});
var view = new IndexerEditView({ model: model, indexerCollection: self.collection});
App.modalRegion.show(view);
}
});
}
});
});