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

39 lines
1.3 KiB
JavaScript

define(['backbone', 'gettext', 'common/js/components/views/feedback_notification', 'js/utils/module'],
function(Backbone, gettext, NotificationView, ModuleUtils) {
var Section = Backbone.Model.extend({
defaults: {
name: ''
},
validate: function(attrs, options) {
if (!attrs.name) {
return gettext('You must specify a name');
}
},
urlRoot: ModuleUtils.urlRoot,
toJSON: function() {
return {
metadata: {
display_name: this.get('name')
}
};
},
initialize: function() {
this.listenTo(this, 'request', this.showNotification);
this.listenTo(this, 'sync', this.hideNotification);
},
showNotification: function() {
if (!this.msg) {
this.msg = new NotificationView.Mini({
title: gettext('Saving')
});
}
this.msg.show();
},
hideNotification: function() {
if (!this.msg) { return; }
this.msg.hide();
}
});
return Section;
});