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

48 lines
1.7 KiB
JavaScript
Raw Normal View History

2013-05-01 03:01:54 +03:00
'use strict';
2013-05-28 03:19:07 +03:00
define(['app',
2013-06-19 04:02:23 +03:00
'marionette',
'Settings/Indexers/ItemView',
'Settings/Indexers/EditView',
'Settings/Indexers/Collection'],
function (App, Marionette, IndexerItemView, IndexerEditView, IndexerCollection) {
2013-06-19 04:02:23 +03:00
return Marionette.CompositeView.extend({
itemView : IndexerItemView,
itemViewContainer: '#x-indexers',
template : 'Settings/Indexers/CollectionTemplate',
ui: {
'addCard': '.x-add-card'
},
2013-06-19 04:02:23 +03:00
events: {
2013-07-26 10:19:44 +03:00
'click .x-add-card': '_openSchemaModal'
2013-06-19 04:02:23 +03:00
},
appendHtml: function(collectionView, itemView, index){
collectionView.ui.addCard.parent('li').before(itemView.el);
2013-07-26 10:19:44 +03:00
},
_openSchemaModal: function () {
2013-06-19 04:02:23 +03:00
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
});
2013-06-19 04:02:23 +03:00
var view = new IndexerEditView({ model: model, indexerCollection: self.collection});
App.modalRegion.show(view);
}
});
}
});
2013-05-01 03:01:54 +03:00
});