Commit b1daf0b3 by David Baumgold

Merge pull request #211 from edx/db/fix-assets-page-notifications

Clean up assets page notifications
parents 24bee17d 687779ba
...@@ -9,7 +9,7 @@ function removeAsset(e){ ...@@ -9,7 +9,7 @@ function removeAsset(e){
e.preventDefault(); e.preventDefault();
var that = this; var that = this;
var msg = new CMS.Models.ConfirmAssetDeleteMessage({ var msg = new CMS.Views.Prompt.Confirmation({
title: gettext("Delete File Confirmation"), title: gettext("Delete File Confirmation"),
message: gettext("Are you sure you wish to delete this item. It cannot be reversed!\n\nAlso any content that links/refers to this item will no longer work (e.g. broken images and/or links)"), message: gettext("Are you sure you wish to delete this item. It cannot be reversed!\n\nAlso any content that links/refers to this item will no longer work (e.g. broken images and/or links)"),
actions: { actions: {
...@@ -17,15 +17,17 @@ function removeAsset(e){ ...@@ -17,15 +17,17 @@ function removeAsset(e){
text: gettext("OK"), text: gettext("OK"),
click: function(view) { click: function(view) {
// call the back-end to actually remove the asset // call the back-end to actually remove the asset
$.post(view.model.get('remove_asset_url'), var url = $('.asset-library').data('remove-asset-callback-url');
{ 'location': view.model.get('asset_location') }, var row = $(that).closest('tr');
$.post(url,
{ 'location': row.data('id') },
function() { function() {
// show the post-commit confirmation // show the post-commit confirmation
$(".wrapper-alert-confirmation").addClass("is-shown").attr('aria-hidden','false'); $(".wrapper-alert-confirmation").addClass("is-shown").attr('aria-hidden','false');
view.model.get('row_to_remove').remove(); row.remove();
analytics.track('Deleted Asset', { analytics.track('Deleted Asset', {
'course': course_location_analytics, 'course': course_location_analytics,
'id': view.model.get('asset_location') 'id': row.data('id')
}); });
} }
); );
...@@ -38,24 +40,9 @@ function removeAsset(e){ ...@@ -38,24 +40,9 @@ function removeAsset(e){
view.hide(); view.hide();
} }
}] }]
}, }
remove_asset_url: $('.asset-library').data('remove-asset-callback-url'),
asset_location: $(this).closest('tr').data('id'),
row_to_remove: $(this).closest('tr')
}); });
return msg.show();
// workaround for now. We can't spawn multiple instances of the Prompt View
// so for now, a bit of hackery to just make sure we have a single instance
// note: confirm_delete_prompt is in asset_index.html
if (confirm_delete_prompt === null)
confirm_delete_prompt = new CMS.Views.Prompt({model: msg});
else
{
confirm_delete_prompt.model = msg;
confirm_delete_prompt.show();
}
return;
} }
function showUploadModal(e) { function showUploadModal(e) {
...@@ -125,4 +112,4 @@ function displayFinishedUpload(xhr) { ...@@ -125,4 +112,4 @@ function displayFinishedUpload(xhr) {
'course': course_location_analytics, 'course': course_location_analytics,
'asset_url': resp.url 'asset_url': resp.url
}); });
} }
\ No newline at end of file
...@@ -90,6 +90,7 @@ CMS.Views.SystemFeedback = Backbone.View.extend({ ...@@ -90,6 +90,7 @@ CMS.Views.SystemFeedback = Backbone.View.extend({
var parent = CMS.Views[_.str.capitalize(this.options.type)]; var parent = CMS.Views[_.str.capitalize(this.options.type)];
if(parent && parent.active && parent.active !== this) { if(parent && parent.active && parent.active !== this) {
parent.active.stopListening(); parent.active.stopListening();
parent.active.undelegateEvents();
} }
this.$el.html(this.template(this.options)); this.$el.html(this.template(this.options));
parent.active = this; parent.active = this;
......
...@@ -8,11 +8,6 @@ ...@@ -8,11 +8,6 @@
<%block name="jsextra"> <%block name="jsextra">
<script src="${static.url('js/vendor/mustache.js')}"></script> <script src="${static.url('js/vendor/mustache.js')}"></script>
<script type='text/javascript'>
// we just want a singleton
confirm_delete_prompt = null;
</script>
</%block> </%block>
<%block name="content"> <%block name="content">
...@@ -98,7 +93,7 @@ ...@@ -98,7 +93,7 @@
</td> </td>
<td class="delete-col"> <td class="delete-col">
<a href="#" data-tooltip="${_('Delete this asset')}" class="remove-asset-button"><span class="delete-icon"></span></a> <a href="#" data-tooltip="${_('Delete this asset')}" class="remove-asset-button"><span class="delete-icon"></span></a>
</td> </td>
</tr> </tr>
% endfor % endfor
</tbody> </tbody>
......
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