import BasicWidget from "../basic_widget.js"; import server from "../../services/server.js"; import dialogService from "../../services/dialog.js"; const TPL = ` `; export default class AttachmentActionsWidget extends BasicWidget { constructor(attachment) { super(); this.attachment = attachment; } doRender() { this.$widget = $(TPL); this.$widget.on('click', '.dropdown-item', () => this.$widget.find("[data-toggle='dropdown']").dropdown('toggle')); } async deleteAttachmentCommand() { if (await dialogService.confirm(`Are you sure you want to delete attachment '${this.attachment.title}'?`)) { await server.remove(`notes/${this.attachment.parentId}/attachments/${this.attachment.attachmentId}`); } } }