Sonarr/UI/Settings/Quality/Profile/QualityProfileCollectionVie...

45 lines
1.6 KiB
JavaScript
Raw Normal View History

'use strict';
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',
template : 'Settings/Quality/Profile/QualityProfileCollectionTemplate',
events: {
2013-07-26 07:04:25 +00:00
'click .x-add-card': '_addProfile'
},
onAfterItemAdded: function () {
2013-07-26 07:19:44 +00:00
this.$itemViewContainer.find('.x-add-card').parent('li').remove();
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);
},
_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-05-01 22:42:30 +00:00
});