From d2194b22110317c846efb5911e7ddffde13c42bb Mon Sep 17 00:00:00 2001 From: Peter Fogg Date: Thu, 1 Aug 2013 13:21:59 -0400 Subject: [PATCH] Notifications for course updates. --- .../features/course-updates.feature | 8 +- .../contentstore/features/section.py | 4 +- cms/static/js/views/course_info_edit.js | 79 +++++++++++++------ 3 files changed, 65 insertions(+), 26 deletions(-) diff --git a/cms/djangoapps/contentstore/features/course-updates.feature b/cms/djangoapps/contentstore/features/course-updates.feature index 81714c43ae..fb18e51f2d 100644 --- a/cms/djangoapps/contentstore/features/course-updates.feature +++ b/cms/djangoapps/contentstore/features/course-updates.feature @@ -6,6 +6,7 @@ Feature: Course updates And I go to the course updates page When I add a new update with the text "Hello" Then I should see the update "Hello" + And I see a "saving" notification Scenario: Users can edit updates Given I have opened a new course in Studio @@ -13,15 +14,16 @@ Feature: Course updates When I add a new update with the text "Hello" And I modify the text to "Goodbye" Then I should see the update "Goodbye" + And I see a "saving" notification Scenario: Users can delete updates Given I have opened a new course in Studio And I go to the course updates page And I add a new update with the text "Hello" - When I will confirm all alerts And I delete the update + And I confirm the prompt Then I should not see the update "Hello" - + And I see a "deleting" notification Scenario: Users can edit update dates Given I have opened a new course in Studio @@ -29,9 +31,11 @@ Feature: Course updates And I add a new update with the text "Hello" When I edit the date to "June 1, 2013" Then I should see the date "June 1, 2013" + And I see a "saving" notification Scenario: Users can change handouts Given I have opened a new course in Studio And I go to the course updates page When I modify the handout to "
    Test
" Then I see the handout "Test" + And I see a "saving" notification diff --git a/cms/djangoapps/contentstore/features/section.py b/cms/djangoapps/contentstore/features/section.py index 4b69b9b37e..955c6a8f4e 100644 --- a/cms/djangoapps/contentstore/features/section.py +++ b/cms/djangoapps/contentstore/features/section.py @@ -42,8 +42,8 @@ def i_save_a_new_section_release_date(_step): world.browser.click_link_by_text('Save') -@step('I see a "saving" notification') -def i_see_a_saving_notification(step): +@step('I see a "(saving|deleting)" notification') +def i_see_a_mini_notification(_step, _type): saving_css = '.wrapper-notification-mini' assert world.is_css_present(saving_css) diff --git a/cms/static/js/views/course_info_edit.js b/cms/static/js/views/course_info_edit.js index 38d2c78576..949baee0aa 100644 --- a/cms/static/js/views/course_info_edit.js +++ b/cms/static/js/views/course_info_edit.js @@ -97,7 +97,15 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({ var targetModel = this.eventModel(event); targetModel.set({ date : this.dateEntry(event).val(), content : this.$codeMirror.getValue() }); // push change to display, hide the editor, submit the change - targetModel.save({}); + var saving = new CMS.Views.Notification.Mini({ + title: gettext('Saving') + '…' + }); + saving.show(); + targetModel.save({}, { + success: function() { + saving.hide(); + } + }); this.closeEditor(this); analytics.track('Saved Course Update', { @@ -140,29 +148,48 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({ onDelete: function(event) { event.preventDefault(); - if (!confirm('Are you sure you want to delete this update? This action cannot be undone.')) { - return; - } - - analytics.track('Deleted Course Update', { - 'course': course_location_analytics, - 'date': this.dateEntry(event).val() - }); - + var self = this; var targetModel = this.eventModel(event); - this.modelDom(event).remove(); - var cacheThis = this; - targetModel.destroy({ - success: function (model, response) { - cacheThis.collection.fetch({ - success: function() { - cacheThis.render(); - }, - reset: true - }); + var confirm = new CMS.Views.Prompt.Warning({ + title: gettext('Are you sure you want to delete this update?'), + message: gettext('This action cannot be undone.'), + actions: { + primary: { + text: gettext('OK'), + click: function () { + analytics.track('Deleted Course Update', { + 'course': course_location_analytics, + 'date': self.dateEntry(event).val() + }); + self.modelDom(event).remove(); + var deleting = new CMS.Views.Notification.Mini({ + title: gettext('Deleting') + '…' + }); + deleting.show(); + targetModel.destroy({ + success: function (model, response) { + self.collection.fetch({ + success: function() { + self.render(); + deleting.hide(); + }, + reset: true + }); + } + }); + confirm.hide(); + } + }, + secondary: { + text: gettext('Cancel'), + click: function() { + confirm.hide(); + } + } } }); - }, + confirm.show(); +}, closeEditor: function(self, removePost) { var targetModel = self.collection.get(self.$currentPost.attr('name')); @@ -280,7 +307,15 @@ CMS.Views.ClassInfoHandoutsView = Backbone.View.extend({ onSave: function(event) { this.model.set('data', this.$codeMirror.getValue()); this.render(); - this.model.save({}); + var saving = new CMS.Views.Notification.Mini({ + title: gettext('Saving') + '…' + }); + saving.show(); + this.model.save({}, { + success: function() { + saving.hide(); + } + }); this.$form.hide(); this.closeEditor(this);