2013-03-09 01:55:47 +00:00
|
|
|
|
'use strict';
|
|
|
|
|
|
2013-06-25 07:21:10 +00:00
|
|
|
|
define(['app',
|
|
|
|
|
'marionette',
|
|
|
|
|
'Settings/Quality/Profile/QualityProfileView',
|
|
|
|
|
'Settings/Quality/Profile/EditQualityProfileView',
|
|
|
|
|
'Settings/Quality/Profile/QualityProfileSchemaCollection'],
|
|
|
|
|
function (App, Marionette, QualityProfileView, EditProfileView, ProfileCollection) {
|
|
|
|
|
|
2013-06-19 01:02:23 +00:00
|
|
|
|
return Marionette.CompositeView.extend({
|
|
|
|
|
itemView : QualityProfileView,
|
2013-06-25 00:41:32 +00:00
|
|
|
|
itemViewContainer: '.quality-profiles',
|
2013-06-25 07:21:10 +00:00
|
|
|
|
template : 'Settings/Quality/Profile/QualityProfileCollectionTemplate',
|
|
|
|
|
|
|
|
|
|
events: {
|
2013-07-26 07:04:25 +00:00
|
|
|
|
'click .x-add-card': '_addProfile'
|
|
|
|
|
},
|
|
|
|
|
|
2013-07-26 07:46:24 +00:00
|
|
|
|
onRender: function () {
|
|
|
|
|
this.listenTo(this.collection, 'add', this.render);
|
2013-07-26 07:04:25 +00:00
|
|
|
|
|
|
|
|
|
this.templateFunction = Marionette.TemplateCache.get('Settings/Quality/Profile/AddCardTemplate');
|
|
|
|
|
var html = this.templateFunction();
|
|
|
|
|
|
|
|
|
|
this.$itemViewContainer.append(html);
|
2013-06-25 07:21:10 +00: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-09 01:55:47 +00:00
|
|
|
|
});
|
2013-05-01 22:42:30 +00:00
|
|
|
|
});
|