Commit 0cf42edc by Peter Fogg

Merge pull request #552 from edx/peter-fogg/course-update-notifications

Notifications for course updates.
parents 042b7d5f 1ebedc9a
...@@ -6,6 +6,7 @@ Feature: Course updates ...@@ -6,6 +6,7 @@ Feature: Course updates
And I go to the course updates page And I go to the course updates page
When I add a new update with the text "Hello" When I add a new update with the text "Hello"
Then I should see the update "Hello" Then I should see the update "Hello"
And I see a "saving" notification
Scenario: Users can edit updates Scenario: Users can edit updates
Given I have opened a new course in Studio Given I have opened a new course in Studio
...@@ -13,15 +14,16 @@ Feature: Course updates ...@@ -13,15 +14,16 @@ Feature: Course updates
When I add a new update with the text "Hello" When I add a new update with the text "Hello"
And I modify the text to "Goodbye" And I modify the text to "Goodbye"
Then I should see the update "Goodbye" Then I should see the update "Goodbye"
And I see a "saving" notification
Scenario: Users can delete updates Scenario: Users can delete updates
Given I have opened a new course in Studio Given I have opened a new course in Studio
And I go to the course updates page And I go to the course updates page
And I add a new update with the text "Hello" And I add a new update with the text "Hello"
When I will confirm all alerts
And I delete the update And I delete the update
And I confirm the prompt
Then I should not see the update "Hello" Then I should not see the update "Hello"
And I see a "deleting" notification
Scenario: Users can edit update dates Scenario: Users can edit update dates
Given I have opened a new course in Studio Given I have opened a new course in Studio
...@@ -29,9 +31,11 @@ Feature: Course updates ...@@ -29,9 +31,11 @@ Feature: Course updates
And I add a new update with the text "Hello" And I add a new update with the text "Hello"
When I edit the date to "June 1, 2013" When I edit the date to "June 1, 2013"
Then I should see the date "June 1, 2013" Then I should see the date "June 1, 2013"
And I see a "saving" notification
Scenario: Users can change handouts Scenario: Users can change handouts
Given I have opened a new course in Studio Given I have opened a new course in Studio
And I go to the course updates page And I go to the course updates page
When I modify the handout to "<ol>Test</ol>" When I modify the handout to "<ol>Test</ol>"
Then I see the handout "Test" Then I see the handout "Test"
And I see a "saving" notification
...@@ -42,8 +42,8 @@ def i_save_a_new_section_release_date(_step): ...@@ -42,8 +42,8 @@ def i_save_a_new_section_release_date(_step):
world.browser.click_link_by_text('Save') world.browser.click_link_by_text('Save')
@step('I see a "saving" notification') @step('I see a "(saving|deleting)" notification')
def i_see_a_saving_notification(step): def i_see_a_mini_notification(_step, _type):
saving_css = '.wrapper-notification-mini' saving_css = '.wrapper-notification-mini'
assert world.is_css_present(saving_css) assert world.is_css_present(saving_css)
......
...@@ -97,7 +97,19 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({ ...@@ -97,7 +97,19 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({
var targetModel = this.eventModel(event); var targetModel = this.eventModel(event);
targetModel.set({ date : this.dateEntry(event).val(), content : this.$codeMirror.getValue() }); targetModel.set({ date : this.dateEntry(event).val(), content : this.$codeMirror.getValue() });
// push change to display, hide the editor, submit the change // push change to display, hide the editor, submit the change
targetModel.save({}); var saving = new CMS.Views.Notification.Mini({
title: gettext('Saving') + '&hellip;'
});
saving.show();
var ele = this.modelDom(event);
targetModel.save({}, {
success: function() {
saving.hide();
},
error: function() {
ele.remove();
}
});
this.closeEditor(this); this.closeEditor(this);
analytics.track('Saved Course Update', { analytics.track('Saved Course Update', {
...@@ -140,29 +152,48 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({ ...@@ -140,29 +152,48 @@ CMS.Views.ClassInfoUpdateView = Backbone.View.extend({
onDelete: function(event) { onDelete: function(event) {
event.preventDefault(); event.preventDefault();
if (!confirm('Are you sure you want to delete this update? This action cannot be undone.')) { var self = this;
return;
}
analytics.track('Deleted Course Update', {
'course': course_location_analytics,
'date': this.dateEntry(event).val()
});
var targetModel = this.eventModel(event); var targetModel = this.eventModel(event);
this.modelDom(event).remove(); var confirm = new CMS.Views.Prompt.Warning({
var cacheThis = this; title: gettext('Are you sure you want to delete this update?'),
targetModel.destroy({ message: gettext('This action cannot be undone.'),
success: function (model, response) { actions: {
cacheThis.collection.fetch({ primary: {
success: function() { text: gettext('OK'),
cacheThis.render(); click: function () {
}, analytics.track('Deleted Course Update', {
reset: true 'course': course_location_analytics,
}); 'date': self.dateEntry(event).val()
});
self.modelDom(event).remove();
var deleting = new CMS.Views.Notification.Mini({
title: gettext('Deleting') + '&hellip;'
});
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) { closeEditor: function(self, removePost) {
var targetModel = self.collection.get(self.$currentPost.attr('name')); var targetModel = self.collection.get(self.$currentPost.attr('name'));
...@@ -280,7 +311,15 @@ CMS.Views.ClassInfoHandoutsView = Backbone.View.extend({ ...@@ -280,7 +311,15 @@ CMS.Views.ClassInfoHandoutsView = Backbone.View.extend({
onSave: function(event) { onSave: function(event) {
this.model.set('data', this.$codeMirror.getValue()); this.model.set('data', this.$codeMirror.getValue());
this.render(); this.render();
this.model.save({}); var saving = new CMS.Views.Notification.Mini({
title: gettext('Saving') + '&hellip;'
});
saving.show();
this.model.save({}, {
success: function() {
saving.hide();
}
});
this.$form.hide(); this.$form.hide();
this.closeEditor(this); this.closeEditor(this);
......
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