Files
edx-platform/cms/static/js/views/content_group_editor.js
Eric Fischer 5bc6b31e29 eslint --fix
2017-12-08 14:38:41 -05:00

47 lines
1.3 KiB
JavaScript

/**
* This class defines an editing view for content groups.
* It is expected to be backed by a Group model.
*/
define([
'js/views/list_item_editor', 'underscore'
],
function(ListItemEditorView, _) {
'use strict';
var ContentGroupEditorView = ListItemEditorView.extend({
tagName: 'div',
className: 'content-group-edit collection-edit',
events: {
submit: 'setAndClose',
'click .action-cancel': 'cancel'
},
initialize: function() {
ListItemEditorView.prototype.initialize.call(this);
this.template = this.loadTemplate('content-group-editor');
},
getTemplateOptions: function() {
return {
id: this.model.get('id'),
name: this.model.get('name'),
index: this.model.collection.indexOf(this.model),
isNew: this.model.isNew(),
usage: this.model.get('usage'),
uniqueId: _.uniqueId()
};
},
setValues: function() {
this.model.set({name: this.$('input').val().trim()});
return this;
},
getSaveableModel: function() {
return this.model.collection.parents[0];
}
});
return ContentGroupEditorView;
});