Commit 48bec75b by Asad Azam

Fixed Course handouts rejects deletion of all text

parent 28e3b1cb
......@@ -232,6 +232,20 @@ define ["js/views/course_info_handout", "js/views/course_info_update", "js/model
@handoutsEdit.render()
it "saves <ol></ol> when content left empty", ->
requests = AjaxHelpers["requests"](this)
# Enter empty string in the handouts section, verifying that the model
# is saved with '<ol></ol>' instead of the empty string
@handoutsEdit.$el.find('.edit-button').click()
spyOn(@handoutsEdit.$codeMirror, 'getValue').and.returnValue('')
spyOn(@model, "save").and.callThrough()
@handoutsEdit.$el.find('.save-button').click()
expect(@model.save).toHaveBeenCalled()
contentSaved = JSON.parse(requests[requests.length - 1].requestBody).data
expect(contentSaved).toEqual('<ol></ol>')
it "does not rewrite links on save", ->
requests = AjaxHelpers["requests"](this)
......
......@@ -50,10 +50,14 @@ define(['js/views/baseview', 'codemirror', 'common/js/components/views/feedback_
},
onSave: function(event) {
var handoutsContent = this.$codeMirror.getValue();
$('#handout_error').removeClass('is-shown');
$('.save-button').removeClass('is-disabled').attr('aria-disabled', false);
if ($('.CodeMirror-lines').find('.cm-error').length == 0) {
this.model.set('data', this.$codeMirror.getValue());
if (handoutsContent === '') {
handoutsContent = '<ol></ol>';
}
this.model.set('data', handoutsContent);
var saving = new NotificationView.Mini({
title: gettext('Saving')
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment