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