adding links to owning note and list to attachments

This commit is contained in:
zadam 2023-05-07 23:32:30 +02:00
parent 274505188b
commit b05ce12e7b
3 changed files with 32 additions and 2 deletions

View File

@ -83,7 +83,7 @@ function calculateHash({notePath, ntxId, hoistedNoteId, viewScope = {}}) {
const params = [
ntxId ? { ntxId: ntxId } : null,
(hoistedNoteId && hoistedNoteId !== 'root') ? { hoistedNoteId: hoistedNoteId } : null,
viewScope.viewMode !== 'default' ? { viewMode: viewScope.viewMode } : null,
viewScope.viewMode && viewScope.viewMode !== 'default' ? { viewMode: viewScope.viewMode } : null,
viewScope.attachmentId ? { attachmentId: viewScope.attachmentId } : null
].filter(p => !!p);

View File

@ -9,6 +9,11 @@ const TPL = `
.attachment-detail {
padding: 15px;
}
.attachment-detail .links-wrapper {
padding: 16px;
font-size: larger;
}
</style>
<div class="links-wrapper"></div>
@ -24,6 +29,7 @@ export default class AttachmentDetailTypeWidget extends TypeWidget {
doRender() {
this.$widget = $(TPL);
this.$wrapper = this.$widget.find('.attachment-wrapper');
this.$linksWrapper = this.$widget.find('.links-wrapper');
super.doRender();
}
@ -32,7 +38,17 @@ export default class AttachmentDetailTypeWidget extends TypeWidget {
this.$wrapper.empty();
this.children = [];
linkService.createNoteLink(this.noteId, {});
this.$linksWrapper.append(
"Owning note: ",
await linkService.createNoteLink(this.noteId),
", you can also open the ",
await linkService.createNoteLink(this.noteId, {
title: 'List of all attachments',
viewScope: {
viewMode: 'attachments'
}
})
);
const attachment = await server.get(`attachments/${this.attachmentId}/?includeContent=true`);

View File

@ -1,6 +1,7 @@
import TypeWidget from "./type_widget.js";
import server from "../../services/server.js";
import AttachmentDetailWidget from "../attachment_detail.js";
import linkService from "../../services/link.js";
const TPL = `
<div class="attachment-list note-detail-printable">
@ -8,7 +9,14 @@ const TPL = `
.attachment-list {
padding: 15px;
}
.attachment-list .links-wrapper {
font-size: larger;
margin-bottom: 15px;
}
</style>
<div class="links-wrapper"></div>
<div class="attachment-list-wrapper"></div>
</div>`;
@ -21,11 +29,17 @@ export default class AttachmentListTypeWidget extends TypeWidget {
doRender() {
this.$widget = $(TPL);
this.$list = this.$widget.find('.attachment-list-wrapper');
this.$linksWrapper = this.$widget.find('.links-wrapper');
super.doRender();
}
async doRefresh(note) {
this.$linksWrapper.append(
"Owning note: ",
await linkService.createNoteLink(this.noteId)
);
this.$list.empty();
this.children = [];
this.renderedAttachmentIds = new Set();