')) // spacer
- .append(attachmentActionsWidget.render())
- )
- .append(
- $('
')
- .append(this.renderContent(attachment))
- )
- );
- }
- }
-
- renderContent(attachment) {
- if (attachment.content) {
- return $("
").text(attachment.content);
- } else if (attachment.role === 'image') {
- return `
`;
+ renderContent() {
+ if (this.attachment.content) {
+ return $("").text(this.attachment.content);
+ } else if (this.attachment.role === 'image') {
+ return `
`;
} else {
return '';
}
diff --git a/src/public/app/widgets/buttons/attachments_actions.js b/src/public/app/widgets/buttons/attachments_actions.js
index 6d6121862..bfae9cec3 100644
--- a/src/public/app/widgets/buttons/attachments_actions.js
+++ b/src/public/app/widgets/buttons/attachments_actions.js
@@ -1,5 +1,6 @@
import BasicWidget from "../basic_widget.js";
import server from "../../services/server.js";
+import dialogService from "../../services/dialog.js";
const TPL = `
@@ -39,9 +40,12 @@ export default class AttachmentActionsWidget extends BasicWidget {
doRender() {
this.$widget = $(TPL);
+ this.$widget.on('click', '.dropdown-item', () => this.$widget.find("[data-toggle='dropdown']").dropdown('toggle'));
}
async deleteAttachmentCommand() {
- await server.remove(`notes/${this.attachment.parentId}/attachments/${this.attachment.attachmentId}`);
+ 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}`);
+ }
}
}
diff --git a/src/public/app/widgets/dialogs/note_revisions.js b/src/public/app/widgets/dialogs/note_revisions.js
index 9eb224891..226bc3f1c 100644
--- a/src/public/app/widgets/dialogs/note_revisions.js
+++ b/src/public/app/widgets/dialogs/note_revisions.js
@@ -234,8 +234,6 @@ export default class NoteRevisionsDialog extends BasicWidget {
const fullNoteRevision = await server.get(`notes/${revisionItem.noteId}/revisions/${revisionItem.noteRevisionId}`);
- console.log(fullNoteRevision);
-
if (revisionItem.type === 'text') {
this.$content.html(fullNoteRevision.content);
diff --git a/src/public/app/widgets/type_widgets/attachments.js b/src/public/app/widgets/type_widgets/attachments.js
index 06a54873e..f0a6afcc4 100644
--- a/src/public/app/widgets/type_widgets/attachments.js
+++ b/src/public/app/widgets/type_widgets/attachments.js
@@ -2,6 +2,7 @@ import TypeWidget from "./type_widget.js";
import server from "../../services/server.js";
import utils from "../../services/utils.js";
import AttachmentActionsWidget from "../buttons/attachments_actions.js";
+import AttachmentDetailWidget from "../attachment_detail.js";
const TPL = `
@@ -9,34 +10,6 @@ const TPL = `
.attachments {
padding: 15px;
}
-
- .attachment-wrapper {
- margin-bottom: 20px;
- }
-
- .attachment-title-line {
- display: flex;
- align-items: baseline;
- }
-
- .attachment-details {
- margin-left: 10px;
- }
-
- .attachment-content pre {
- max-height: 400px;
- background: var(--accented-background-color);
- padding: 10px;
- margin-top: 10px;
- margin-bottom: 10px;
- }
-
- .attachment-content img {
- margin: 10px;
- max-height: 300px;
- max-width: 90%;
- object-fit: contain;
- }
@@ -65,36 +38,10 @@ export default class AttachmentsTypeWidget extends TypeWidget {
}
for (const attachment of attachments) {
- const attachmentActionsWidget = new AttachmentActionsWidget(attachment);
- this.child(attachmentActionsWidget);
+ const attachmentDetailWidget = new AttachmentDetailWidget(attachment);
+ this.child(attachmentDetailWidget);
- this.$list.append(
- $('
')
- .append(
- $('
')
- .append($('
').append($('').text(attachment.title)))
- .append(
- $('')
- .text(`Role: ${attachment.role}, Size: ${utils.formatSize(attachment.contentLength)}`)
- )
- .append($('
')) // spacer
- .append(attachmentActionsWidget.render())
- )
- .append(
- $('
')
- .append(this.renderContent(attachment))
- )
- );
- }
- }
-
- renderContent(attachment) {
- if (attachment.content) {
- return $("
").text(attachment.content);
- } else if (attachment.role === 'image') {
- return `
`;
- } else {
- return '';
+ this.$list.append(attachmentDetailWidget.render());
}
}
}