{% load i18n %} /* globals makeIconButton, renderLink, */ /* exported addAttachmentButtonCallbacks, loadAttachmentTable, reloadAttachmentTable, */ /* * Add callbacks to buttons for creating new attachments. * * Note: Attachments can also be external links! */ function addAttachmentButtonCallbacks(url, fields={}) { // Callback for 'new attachment' button $('#new-attachment').click(function() { var file_fields = { attachment: {}, comment: {}, }; Object.assign(file_fields, fields); constructForm(url, { fields: file_fields, method: 'POST', onSuccess: reloadAttachmentTable, title: '{% trans "Add Attachment" %}', }); }); // Callback for 'new link' button $('#new-attachment-link').click(function() { var link_fields = { link: {}, comment: {}, }; Object.assign(link_fields, fields); constructForm(url, { fields: link_fields, method: 'POST', onSuccess: reloadAttachmentTable, title: '{% trans "Add Link" %}', }); }); } /* * Construct a form to delete attachment files */ function deleteAttachments(attachments, url, options={}) { if (attachments.length == 0) { console.warn('deleteAttachments function called with zero attachments provided'); return; } function renderAttachment(attachment, opts={}) { var icon = ''; if (attachment.filename) { icon = ``; } else if (attachment.link) { icon = ``; } return `
{% trans "Attachment" %} | {% trans "Comment" %} |
---|