Merge pull request #2859 from edx/waheed/stud1404-accidental-click-can-lose-work-on-adding-new-update

Don't close modal on click outside new course update modal.
This commit is contained in:
Waheed Ahmed
2014-03-11 18:39:28 +05:00
2 changed files with 16 additions and 3 deletions

View File

@@ -65,6 +65,19 @@ define ["js/views/course_info_handout", "js/views/course_info_update", "js/model
previewContents = @courseInfoEdit.$el.find('.update-contents').html()
expect(previewContents).not.toEqual('unsaved changes')
@doNotCloseNewCourseInfo = () ->
@courseInfoEdit.onNew(@event)
spyOn(@courseInfoEdit.$modalCover, 'hide').andCallThrough()
spyOn(@courseInfoEdit.$codeMirror, 'getValue').andReturn('unsaved changes')
model = @collection.at(0)
spyOn(model, "save").andCallThrough()
cancelEditingUpdate(@courseInfoEdit, @courseInfoEdit.$modalCover, false)
expect(model.save).not.toHaveBeenCalled()
expect(@courseInfoEdit.$modalCover.hide).not.toHaveBeenCalled()
@cancelExistingCourseInfo = (useCancelButton) ->
@createNewUpdate('existing update')
@courseInfoEdit.$el.find('.edit-button').click()
@@ -125,8 +138,8 @@ define ["js/views/course_info_handout", "js/views/course_info_update", "js/model
it "removes newly created course info on cancel", ->
@cancelNewCourseInfo(true)
it "removes newly created course info on click outside modal", ->
@cancelNewCourseInfo(false)
it "do not close new course info on click outside modal", ->
@doNotCloseNewCourseInfo()
it "does not remove existing course info on cancel", ->
@cancelExistingCourseInfo(true)

View File

@@ -64,7 +64,7 @@ define(["js/views/baseview", "underscore", "codemirror", "js/models/course_updat
// Variable stored for unit test.
this.$modalCover = ModalUtils.showModalCover(false, function() {
self.closeEditor(true)
// Binding empty function to prevent default hideModal.
});
$('.date').datepicker('destroy');