1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-29 11:05:44 +00:00
Lidarr/UI/Settings/Indexers/CollectionView.js
2013-06-25 00:25:33 -07:00

35 lines
1.3 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',
events: {
'click .x-add': 'openSchemaModal'
},
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);
model.set('name', '');
var view = new IndexerEditView({ model: model, indexerCollection: self.collection});
App.modalRegion.show(view);
}
});
}
});
});