2013-03-09 04:55:47 +03:00
|
|
|
'use strict';
|
|
|
|
|
2013-06-25 10:21:10 +03:00
|
|
|
define(['app',
|
|
|
|
'marionette',
|
|
|
|
'Settings/Quality/Profile/QualityProfileView',
|
|
|
|
'Settings/Quality/Profile/EditQualityProfileView',
|
2013-08-21 02:35:19 +03:00
|
|
|
'Settings/Quality/Profile/QualityProfileSchemaCollection'
|
|
|
|
], function (App, Marionette, QualityProfileView, EditProfileView, ProfileCollection) {
|
2013-06-25 10:21:10 +03:00
|
|
|
|
2013-06-19 04:02:23 +03:00
|
|
|
return Marionette.CompositeView.extend({
|
|
|
|
itemView : QualityProfileView,
|
2013-06-25 03:41:32 +03:00
|
|
|
itemViewContainer: '.quality-profiles',
|
2013-06-25 10:21:10 +03:00
|
|
|
template : 'Settings/Quality/Profile/QualityProfileCollectionTemplate',
|
|
|
|
|
2013-07-27 01:07:51 +03:00
|
|
|
ui: {
|
|
|
|
'addCard': '.x-add-card'
|
|
|
|
},
|
|
|
|
|
2013-06-25 10:21:10 +03:00
|
|
|
events: {
|
2013-07-26 10:04:25 +03:00
|
|
|
'click .x-add-card': '_addProfile'
|
|
|
|
},
|
|
|
|
|
2013-07-27 01:07:51 +03:00
|
|
|
appendHtml: function(collectionView, itemView, index){
|
|
|
|
collectionView.ui.addCard.parent('li').before(itemView.el);
|
2013-06-25 10:21:10 +03: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 04:55:47 +03:00
|
|
|
});
|
2013-05-02 01:42:30 +03:00
|
|
|
});
|