2013-03-08 17:55:47 -08:00
|
|
|
|
'use strict';
|
|
|
|
|
|
2013-06-25 00:21:10 -07:00
|
|
|
|
define(['app',
|
|
|
|
|
'marionette',
|
|
|
|
|
'Settings/Quality/Profile/QualityProfileView',
|
|
|
|
|
'Settings/Quality/Profile/EditQualityProfileView',
|
2013-08-20 16:35:19 -07:00
|
|
|
|
'Settings/Quality/Profile/QualityProfileSchemaCollection'
|
|
|
|
|
], function (App, Marionette, QualityProfileView, EditProfileView, ProfileCollection) {
|
2013-06-25 00:21:10 -07:00
|
|
|
|
|
2013-06-18 18:02:23 -07:00
|
|
|
|
return Marionette.CompositeView.extend({
|
|
|
|
|
itemView : QualityProfileView,
|
2013-06-24 17:41:32 -07:00
|
|
|
|
itemViewContainer: '.quality-profiles',
|
2013-06-25 00:21:10 -07:00
|
|
|
|
template : 'Settings/Quality/Profile/QualityProfileCollectionTemplate',
|
|
|
|
|
|
2013-07-26 15:07:51 -07:00
|
|
|
|
ui: {
|
|
|
|
|
'addCard': '.x-add-card'
|
|
|
|
|
},
|
|
|
|
|
|
2013-06-25 00:21:10 -07:00
|
|
|
|
events: {
|
2013-07-26 00:04:25 -07:00
|
|
|
|
'click .x-add-card': '_addProfile'
|
|
|
|
|
},
|
|
|
|
|
|
2013-07-26 15:07:51 -07:00
|
|
|
|
appendHtml: function(collectionView, itemView, index){
|
|
|
|
|
collectionView.ui.addCard.parent('li').before(itemView.el);
|
2013-06-25 00:21:10 -07:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_addProfile: function () {
|
|
|
|
|
var self = this;
|
|
|
|
|
var schemaCollection = new ProfileCollection();
|
|
|
|
|
schemaCollection.fetch({
|
|
|
|
|
success: function (collection) {
|
|
|
|
|
var model = _.first(collection.models);
|
|
|
|
|
model.set('id', undefined);
|
|
|
|
|
model.set('name', '');
|
|
|
|
|
model.collection = self.collection;
|
|
|
|
|
|
|
|
|
|
var view = new EditProfileView({ model: model, profileCollection: self.collection});
|
|
|
|
|
App.modalRegion.show(view);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2013-03-08 17:55:47 -08:00
|
|
|
|
});
|
2013-05-01 15:42:30 -07:00
|
|
|
|
});
|