From 66b73c861fe7440eb023b517e63d4ef34cd72d88 Mon Sep 17 00:00:00 2001 From: Peter Fogg Date: Wed, 10 Jul 2013 15:50:01 -0400 Subject: [PATCH 1/4] Use new feedback notification when changing section release dates. --- .../contentstore/features/section.feature | 1 + .../contentstore/features/section.py | 6 ++ .../coffee/spec/views/overview_spec.coffee | 64 +++++++++++++++++++ cms/static/js/base.js | 15 ++--- 4 files changed, 76 insertions(+), 10 deletions(-) create mode 100644 cms/static/coffee/spec/views/overview_spec.coffee diff --git a/cms/djangoapps/contentstore/features/section.feature b/cms/djangoapps/contentstore/features/section.feature index a91960cd2a..84a9bb991d 100644 --- a/cms/djangoapps/contentstore/features/section.feature +++ b/cms/djangoapps/contentstore/features/section.feature @@ -26,6 +26,7 @@ Feature: Create Section When I click the Edit link for the release date And I save a new section release date Then the section release date is updated + And I see a "saving" notification Scenario: Delete section Given I have opened a new course in Studio diff --git a/cms/djangoapps/contentstore/features/section.py b/cms/djangoapps/contentstore/features/section.py index 989c73e010..f41b2dbcd0 100644 --- a/cms/djangoapps/contentstore/features/section.py +++ b/cms/djangoapps/contentstore/features/section.py @@ -42,6 +42,12 @@ 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): + saving_css = '.wrapper-notification-saving' + assert world.is_css_present(saving_css) + + ############ ASSERTIONS ################### diff --git a/cms/static/coffee/spec/views/overview_spec.coffee b/cms/static/coffee/spec/views/overview_spec.coffee new file mode 100644 index 0000000000..3ddc962cb3 --- /dev/null +++ b/cms/static/coffee/spec/views/overview_spec.coffee @@ -0,0 +1,64 @@ +describe "Course Overview", -> + + beforeEach -> + appendSetFixtures """ + + """ + + appendSetFixtures """ + + """ + + appendSetFixtures """ +
+ + Will Release: 06/12/2013 at 04:00 UTC + + Edit +
+ """#" + + appendSetFixtures """ +
+
+

Section Release Date

+
+
+ + +
+
+ + +
+
+

On the date set above, this section – – will be released to students. Any units marked private will only be visible to admins.

+
+
+ SaveCancel +
+
+ """#" + + spyOn(window, 'saveSetSectionScheduleDate').andCallThrough() + # Have to do this here, as it normally gets bound in document.ready() + $('a.save-button').click(saveSetSectionScheduleDate) + @notificationSpy = spyOn(CMS.Views.Notification.Saving.prototype, 'show').andCallThrough() + window.analytics = jasmine.createSpyObj('analytics', ['track']) + window.course_location_analytics = jasmine.createSpy() + sinon.useFakeXMLHttpRequest() + + afterEach -> + @xhr.restore() + delete window.analytics + delete window.course_location_analytics + + it "should save model when save is clicked", -> + $('a.edit-button').click() + $('a.save-button').click() + expect(saveSetSectionScheduleDate).toHaveBeenCalled() + + it "should show a confirmation on save", -> + $('a.edit-button').click() + $('a.save-button').click() + expect(@notificationSpy).toHaveBeenCalled() diff --git a/cms/static/js/base.js b/cms/static/js/base.js index c2f401c77e..f172775f3a 100644 --- a/cms/static/js/base.js +++ b/cms/static/js/base.js @@ -712,6 +712,11 @@ function saveSetSectionScheduleDate(e) { 'start': start }); + var saving = new CMS.Views.Notification.Saving({ + title: gettext("Saving…"), + maxShown: 1250 + }); + saving.show(); // call into server to commit the new order $.ajax({ url: "/save_item", @@ -738,16 +743,6 @@ function saveSetSectionScheduleDate(e) { '" data-date="' + input_date + '" data-time="' + input_time + '" data-id="' + id + '">' + gettext('Edit') + ''); - $thisSection.find('.section-published-date').animate({ - 'background-color': 'rgb(182,37,104)' - }, 300).animate({ - 'background-color': '#edf1f5' - }, 300).animate({ - 'background-color': 'rgb(182,37,104)' - }, 300).animate({ - 'background-color': '#edf1f5' - }, 300); - hideModal(); }); } From 975e28e9dccf0a1bfd705845c7e1179476c80a3b Mon Sep 17 00:00:00 2001 From: Peter Fogg Date: Wed, 10 Jul 2013 16:31:43 -0400 Subject: [PATCH 2/4] Remove undefined variable. --- cms/static/coffee/spec/views/overview_spec.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/cms/static/coffee/spec/views/overview_spec.coffee b/cms/static/coffee/spec/views/overview_spec.coffee index 3ddc962cb3..29f1e49926 100644 --- a/cms/static/coffee/spec/views/overview_spec.coffee +++ b/cms/static/coffee/spec/views/overview_spec.coffee @@ -49,7 +49,6 @@ describe "Course Overview", -> sinon.useFakeXMLHttpRequest() afterEach -> - @xhr.restore() delete window.analytics delete window.course_location_analytics From f3837009aff72e8214640e4eefa0ef4185b15de3 Mon Sep 17 00:00:00 2001 From: Peter Fogg Date: Thu, 11 Jul 2013 11:26:17 -0400 Subject: [PATCH 3/4] Remove ellipsis from internationalized notifications. --- cms/static/js/base.js | 2 +- cms/static/js/models/section.js | 2 +- cms/static/js/views/textbook.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cms/static/js/base.js b/cms/static/js/base.js index f172775f3a..c6645daef0 100644 --- a/cms/static/js/base.js +++ b/cms/static/js/base.js @@ -713,7 +713,7 @@ function saveSetSectionScheduleDate(e) { }); var saving = new CMS.Views.Notification.Saving({ - title: gettext("Saving…"), + title: gettext("Saving") + "…", maxShown: 1250 }); saving.show(); diff --git a/cms/static/js/models/section.js b/cms/static/js/models/section.js index f9b20f3244..38acceb76d 100644 --- a/cms/static/js/models/section.js +++ b/cms/static/js/models/section.js @@ -23,7 +23,7 @@ CMS.Models.Section = Backbone.Model.extend({ showNotification: function() { if(!this.msg) { this.msg = new CMS.Views.Notification.Saving({ - title: gettext("Saving…") + title: gettext("Saving") + "…" }); } this.msg.show(); diff --git a/cms/static/js/views/textbook.js b/cms/static/js/views/textbook.js index a5a5473915..3abf09230c 100644 --- a/cms/static/js/views/textbook.js +++ b/cms/static/js/views/textbook.js @@ -35,7 +35,7 @@ CMS.Views.ShowTextbook = Backbone.View.extend({ click: function(view) { view.hide(); var delmsg = new CMS.Views.Notification.Saving({ - title: gettext("Deleting…") + title: gettext("Deleting") + "…" }).show(); textbook.destroy({ complete: function() { @@ -122,7 +122,7 @@ CMS.Views.EditTextbook = Backbone.View.extend({ this.setValues(); if(!this.model.isValid()) { return; } var saving = new CMS.Views.Notification.Saving({ - title: gettext("Saving…") + title: gettext("Saving") + "…" }).show(); var that = this; this.model.save({}, { From 7c9648babdded4f4650a946e18f9dafa35020bd1 Mon Sep 17 00:00:00 2001 From: Peter Fogg Date: Thu, 11 Jul 2013 13:27:15 -0400 Subject: [PATCH 4/4] Hide saving notification only when AJAX request completes. --- cms/static/js/base.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cms/static/js/base.js b/cms/static/js/base.js index c6645daef0..16e1209767 100644 --- a/cms/static/js/base.js +++ b/cms/static/js/base.js @@ -714,7 +714,6 @@ function saveSetSectionScheduleDate(e) { var saving = new CMS.Views.Notification.Saving({ title: gettext("Saving") + "…", - maxShown: 1250 }); saving.show(); // call into server to commit the new order @@ -744,5 +743,6 @@ function saveSetSectionScheduleDate(e) { '" data-time="' + input_time + '" data-id="' + id + '">' + gettext('Edit') + ''); hideModal(); + saving.hide(); }); }