Notes/src/public/app/widgets/buttons/attachments_actions.js

48 lines
1.6 KiB
JavaScript
Raw Normal View History

2023-03-24 10:57:32 +01:00
import BasicWidget from "../basic_widget.js";
2023-03-30 23:48:26 +02:00
import server from "../../services/server.js";
2023-03-24 10:57:32 +01:00
const TPL = `
<div class="dropdown attachment-actions">
<style>
.attachment-actions {
width: 35px;
height: 35px;
}
.attachment-actions .dropdown-menu {
width: 15em;
}
.attachment-actions .dropdown-item[disabled], .attachment-actions .dropdown-item[disabled]:hover {
color: var(--muted-text-color) !important;
background-color: transparent !important;
pointer-events: none; /* makes it unclickable */
}
</style>
<button type="button" data-toggle="dropdown" aria-haspopup="true"
aria-expanded="false" class="icon-action icon-action-always-border bx bx-dots-vertical-rounded"></button>
<div class="dropdown-menu dropdown-menu-right">
<a data-trigger-command="deleteAttachment" class="dropdown-item delete-attachment-button">Delete attachment</a>
<a data-trigger-command="pullAttachmentIntoNote" class="dropdown-item pull-attachment-into-note-button">Pull attachment into note</a>
<a data-trigger-command="pullAttachmentIntoNote" class="dropdown-item pull-attachment-into-note-button">Copy into clipboard</a>
</div>
</div>`;
export default class AttachmentActionsWidget extends BasicWidget {
constructor(attachment) {
super();
this.attachment = attachment;
}
doRender() {
this.$widget = $(TPL);
}
2023-03-30 23:48:26 +02:00
async deleteAttachmentCommand() {
await server.remove(`notes/${this.attachment.parentId}/attachments/${this.attachment.attachmentId}`);
2023-03-24 10:57:32 +01:00
}
}