Skip to content

Build your personal knowledge base with Trilium Notes

adding links to owning note and list to attachments

zadamb05ce12e7b16
diff --git a/src/public/app/services/link.js b/src/public/app/services/link.js
index 0233aec820..c35025f99e 100644
--- a/src/public/app/services/link.js
+++ b/src/public/app/services/link.js
@@ -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);
diff --git a/src/public/app/widgets/type_widgets/attachment_detail.js b/src/public/app/widgets/type_widgets/attachment_detail.js
index 0e09e6cda8..de35ee6a47 100644
--- a/src/public/app/widgets/type_widgets/attachment_detail.js
+++ b/src/public/app/widgets/type_widgets/attachment_detail.js
@@ -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`);
diff --git a/src/public/app/widgets/type_widgets/attachment_list.js b/src/public/app/widgets/type_widgets/attachment_list.js
index 1604ea313c..4399a43eec 100644
--- a/src/public/app/widgets/type_widgets/attachment_list.js
+++ b/src/public/app/widgets/type_widgets/attachment_list.js
@@ -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();