From 7e074f1a7e2574690d814267b8df7e2f71fd8f23 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Thu, 21 Nov 2013 18:18:14 -0500 Subject: [PATCH] Add error recovery to inline discussion loading Now the interface will reset apropriately and allow a user to retry expanding the discussion or loading a new page, and the alert message will ask the user to retry. JIRA: FOR-300, FOR-301 --- CHANGELOG.rst | 3 ++ .../discussion/discussion_module_view.coffee | 35 +++++++++++++++---- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 16e3f7a789..5a722c44c9 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -9,6 +9,9 @@ Blades: Update the calculator hints tooltip with full information. BLD-400. Blades: Fix transcripts 500 error in studio (BLD-530) +LMS: Add error recovery when a user loads or switches pages in an +inline discussion. + Blades: Allow multiple strings as the correct answer to a string response question. BLD-474. Blades: a11y - Videos will alert screenreaders when the video is over. diff --git a/common/static/coffee/src/discussion/discussion_module_view.coffee b/common/static/coffee/src/discussion/discussion_module_view.coffee index 3dde9bf950..f99eba3872 100644 --- a/common/static/coffee/src/discussion/discussion_module_view.coffee +++ b/common/static/coffee/src/discussion/discussion_module_view.coffee @@ -36,12 +36,15 @@ if Backbone? event.preventDefault() @newPostForm.slideUp(300) + hideDiscussion: -> + @$("section.discussion").slideUp() + @toggleDiscussionBtn.removeClass('shown') + @toggleDiscussionBtn.find('.button-text').html("Show Discussion") + @showed = false + toggleDiscussion: (event) -> if @showed - @$("section.discussion").slideUp() - @toggleDiscussionBtn.removeClass('shown') - @toggleDiscussionBtn.find('.button-text').html("Show Discussion") - @showed = false + @hideDiscussion() else @toggleDiscussionBtn.addClass('shown') @toggleDiscussionBtn.find('.button-text').html("Hide Discussion") @@ -51,9 +54,17 @@ if Backbone? @showed = true else $elem = @toggleDiscussionBtn - @loadPage $elem + @loadPage( + $elem, + => + @hideDiscussion() + DiscussionUtil.discussionAlert( + "Sorry", + "We had some trouble loading the discussion. Please try again." + ) + ) - loadPage: ($elem)=> + loadPage: ($elem, error) => discussionId = @$el.data("discussion-id") url = DiscussionUtil.urlFor('retrieve_discussion', discussionId) + "?page=#{@page}" DiscussionUtil.safeAjax @@ -63,6 +74,7 @@ if Backbone? type: "GET" dataType: 'json' success: (response, textStatus, jqXHR) => @renderDiscussion($elem, response, textStatus, discussionId) + error: error renderDiscussion: ($elem, response, textStatus, discussionId) => window.user = new DiscussionUser(response.user_info) @@ -131,5 +143,14 @@ if Backbone? navigateToPage: (event) => event.preventDefault() window.history.pushState({}, window.document.title, event.target.href) + currPage = @page @page = $(event.target).data('page-number') - @loadPage($(event.target)) + @loadPage( + $(event.target), + => + @page = currPage + DiscussionUtil.discussionAlert( + "Sorry", + "We had some trouble loading the threads you requested. Please try again." + ) + )