From b05ce12e7b16fc2a403cf107b781325ada6ef4e9 Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 7 May 2023 23:32:30 +0200 Subject: [PATCH] adding links to owning note and list to attachments --- src/public/app/services/link.js | 2 +- .../widgets/type_widgets/attachment_detail.js | 18 +++++++++++++++++- .../widgets/type_widgets/attachment_list.js | 14 ++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/public/app/services/link.js b/src/public/app/services/link.js index 0233aec82..c35025f99 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 0e09e6cda..de35ee6a4 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; + } @@ -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 1604ea313..4399a43ee 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 = `
@@ -8,7 +9,14 @@ const TPL = ` .attachment-list { padding: 15px; } + + .attachment-list .links-wrapper { + font-size: larger; + margin-bottom: 15px; + } + +
`; @@ -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();