diff --git a/notebook/static/base/js/dialog.js b/notebook/static/base/js/dialog.js index ac9885e84..f6877a935 100644 --- a/notebook/static/base/js/dialog.js +++ b/notebook/static/base/js/dialog.js @@ -80,6 +80,9 @@ define(function(require) { .addClass("btn btn-default btn-sm") .attr("data-dismiss", "modal") .text(label); + if (btn_opts.id) { + button.attr('id', btn_opts.id); + } if (btn_opts.click) { button.click($.proxy(btn_opts.click, dialog_content)); } @@ -207,11 +210,185 @@ define(function(require) { modal_obj.on('shown.bs.modal', function(){ editor.refresh(); }); }; + + var edit_attachments = function (options) { + // This shows the Edit Attachments dialog. This dialog allows the + // user to delete attachments. We show a list of attachments to + // the user and he can mark some of them for deletion. The deletion + // is applied when the 'Apply' button of this dialog is pressed. + var message; + var attachments_list; + if (Object.keys(options.attachments).length == 0) { + message = "There are no attachments for this cell."; + attachments_list = $('
'); + } else { + message = "Current cell attachments"; + + attachments_list = $('
') + .addClass('list_container') + .append( + $('
') + .addClass('row list_header') + .append( + $('
') + .text('Attachments') + ) + ); + + // This is a set containing keys of attachments to be deleted when + // the Apply button is clicked + var to_delete = {}; + + var refresh_attachments_list = function() { + $(attachments_list).find('.row').remove(); + for (var key in options.attachments) { + var mime = Object.keys(options.attachments[key])[0]; + var deleted = key in to_delete; + + // This ensures the current value of key is captured since + // javascript only has function scope + var btn; + // Trash/restore button + (function(){ + var _key = key; + btn = $('