mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	introduction of refreshWithNote
This commit is contained in:
		| @@ -60,7 +60,7 @@ window.glob.noteChanged = noteDetailService.noteChanged; | ||||
| window.glob.refreshTree = treeService.reload; | ||||
|  | ||||
| // required for ESLint plugin | ||||
| window.glob.getActiveTabNote = appContext.getActiveTabNote; | ||||
| window.glob.getActiveTabNote = () => appContext.getActiveTabNote(); | ||||
| window.glob.requireLibrary = libraryLoader.requireLibrary; | ||||
| window.glob.ESLINT = libraryLoader.ESLINT; | ||||
|  | ||||
|   | ||||
| @@ -23,7 +23,7 @@ class AttributesWidget extends StandardWidget { | ||||
|         return [$showFullButton]; | ||||
|     } | ||||
|  | ||||
|     async refresh() { | ||||
|     async refreshWithNote() { | ||||
|         const attributes = await this.tabContext.attributes.getAttributes();console.log("attributes", attributes); | ||||
|         const ownedAttributes = attributes.filter(attr => attr.noteId === this.tabContext.note.noteId); | ||||
|  | ||||
|   | ||||
| @@ -17,6 +17,10 @@ class BasicWidget extends Component { | ||||
|     doRender() {} | ||||
|  | ||||
|     toggle(show) { | ||||
|         if (!this.$widget) { | ||||
|             console.log(this.componentId); | ||||
|         } | ||||
|  | ||||
|         this.$widget.toggle(show); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -38,7 +38,7 @@ class CalendarWidget extends StandardWidget { | ||||
|         this.$body.html(TPL); | ||||
|     } | ||||
|  | ||||
|     async refresh() { | ||||
|     async refreshWithNote() { | ||||
|         this.init(this.$body, await this.tabContext.note.getLabelValue("dateNote")); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -19,7 +19,7 @@ class EditedNotesWidget extends StandardWidget { | ||||
|             && await this.tabContext.note.hasLabel("dateNote"); | ||||
|     } | ||||
|  | ||||
|     async doRenderBody() { | ||||
|     async refreshWithNote() { | ||||
|         const note = this.tabContext.note; | ||||
|         // remember which title was when we found the similar notes | ||||
|         this.title = note.title; | ||||
|   | ||||
| @@ -28,7 +28,7 @@ class LinkMapWidget extends StandardWidget { | ||||
|         return [$showFullButton]; | ||||
|     } | ||||
|  | ||||
|     async refresh() { | ||||
|     async refreshWithNote() { | ||||
|         this.$body.css('opacity', 0); | ||||
|         this.$body.html(TPL); | ||||
|  | ||||
|   | ||||
| @@ -31,7 +31,7 @@ class NoteInfoWidget extends StandardWidget { | ||||
|         this.$body.html(TPL); | ||||
|     } | ||||
|  | ||||
|     refresh() { | ||||
|     refreshWithNote() { | ||||
|         const $noteId = this.$body.find(".note-info-note-id"); | ||||
|         const $dateCreated = this.$body.find(".note-info-date-created"); | ||||
|         const $dateModified = this.$body.find(".note-info-date-modified"); | ||||
|   | ||||
| @@ -30,7 +30,7 @@ export default class NotePathsWidget extends TabAwareWidget { | ||||
|         return this.$widget; | ||||
|     } | ||||
|  | ||||
|     async refresh() { | ||||
|     async refreshWithNote() { | ||||
|         const {note, notePath} = this.tabContext; | ||||
|  | ||||
|         if (note.noteId === 'root') { | ||||
|   | ||||
| @@ -26,7 +26,7 @@ class NoteRevisionsWidget extends StandardWidget { | ||||
|         return [$showFullButton]; | ||||
|     } | ||||
|  | ||||
|     async refresh() { | ||||
|     async refreshWithNote() { | ||||
|         const note = this.tabContext.note; | ||||
|         const revisionItems = await server.get(`notes/${note.noteId}/revisions`); | ||||
|  | ||||
|   | ||||
| @@ -130,17 +130,9 @@ export default class NoteTitleWidget extends TabAwareWidget { | ||||
|         return this.$widget; | ||||
|     } | ||||
|  | ||||
|     async refresh() { | ||||
|     async refreshWithNote() { | ||||
|         const note = this.tabContext.note; | ||||
|  | ||||
|         if (!note) { | ||||
|             this.toggle(false); | ||||
|             return; | ||||
|         } | ||||
|         else { | ||||
|             this.toggle(true); | ||||
|         } | ||||
|  | ||||
|         this.$noteTitle.val(note.title); | ||||
|  | ||||
|         if (note.isProtected && !protectedSessionHolder.isProtectedSessionAvailable()) { | ||||
|   | ||||
| @@ -17,15 +17,14 @@ const NOTE_TYPES = [ | ||||
| ]; | ||||
|  | ||||
| const TPL = ` | ||||
| <style> | ||||
| .note-type-dropdown { | ||||
|     max-height: 500px; | ||||
|     overflow-y: auto; | ||||
|     overflow-x: hidden; | ||||
| } | ||||
| </style> | ||||
|  | ||||
| <div class="dropdown note-type"> | ||||
|     <style> | ||||
|     .note-type-dropdown { | ||||
|         max-height: 500px; | ||||
|         overflow-y: auto; | ||||
|         overflow-x: hidden; | ||||
|     } | ||||
|     </style> | ||||
|     <button type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-sm dropdown-toggle note-type-button"> | ||||
|         Type: <span class="note-type-desc"></span> | ||||
|         <span class="caret"></span> | ||||
| @@ -36,20 +35,20 @@ const TPL = ` | ||||
|  | ||||
| export default class NoteTypeWidget extends TabAwareWidget { | ||||
|     doRender() { | ||||
|         const $widget = $(TPL); | ||||
|         this.$widget = $(TPL); | ||||
|  | ||||
|         $widget.on('show.bs.dropdown', () => this.renderDropdown()); | ||||
|         this.$widget.on('show.bs.dropdown', () => this.renderDropdown()); | ||||
|  | ||||
|         this.$noteTypeDropdown = $widget.find(".note-type-dropdown"); | ||||
|         this.$noteTypeButton = $widget.find(".note-type-button"); | ||||
|         this.$noteTypeDesc = $widget.find(".note-type-desc"); | ||||
|         this.$executeScriptButton = $widget.find(".execute-script-button"); | ||||
|         this.$renderButton = $widget.find('.render-button'); | ||||
|         this.$noteTypeDropdown = this.$widget.find(".note-type-dropdown"); | ||||
|         this.$noteTypeButton = this.$widget.find(".note-type-button"); | ||||
|         this.$noteTypeDesc = this.$widget.find(".note-type-desc"); | ||||
|         this.$executeScriptButton = this.$widget.find(".execute-script-button"); | ||||
|         this.$renderButton = this.$widget.find('.render-button'); | ||||
|  | ||||
|         return $widget; | ||||
|         return this.$widget; | ||||
|     } | ||||
|  | ||||
|     async refresh() { | ||||
|     async refreshWithNote() { | ||||
|         this.$noteTypeButton.prop("disabled", | ||||
|             () => ["file", "image", "search"].includes(this.tabContext.note.type)); | ||||
|  | ||||
|   | ||||
| @@ -35,14 +35,9 @@ export default class PromotedAttributesWidget extends TabAwareWidget { | ||||
|         return this.$widget; | ||||
|     } | ||||
|  | ||||
|     async refresh() { | ||||
|     async refreshWithNote() { | ||||
|         this.$container.empty(); | ||||
|  | ||||
|         if (!this.tabContext.note) { | ||||
|             this.toggle(false); | ||||
|             return; | ||||
|         } | ||||
|  | ||||
|         const attributes = await this.tabContext.attributes.getAttributes(); | ||||
|  | ||||
|         const promoted = attributes.filter(attr => | ||||
|   | ||||
| @@ -14,7 +14,7 @@ class SimilarNotesWidget extends StandardWidget { | ||||
|  | ||||
|     getMaxHeight() { return "200px"; } | ||||
|  | ||||
|     async refresh() { | ||||
|     async refreshWithNote() { | ||||
|         // remember which title was when we found the similar notes | ||||
|         this.title = this.tabContext.note.title; | ||||
|  | ||||
|   | ||||
| @@ -18,12 +18,21 @@ export default class TabAwareWidget extends BasicWidget { | ||||
|         this.refresh(); | ||||
|     } | ||||
|  | ||||
|     // to override | ||||
|     activeTabChanged() { | ||||
|         this.refresh(); | ||||
|     } | ||||
|  | ||||
|     refresh() {} | ||||
|     refresh() { | ||||
|         if (this.tabContext && this.tabContext.note) { | ||||
|             this.toggle(true); | ||||
|             this.refreshWithNote(); | ||||
|         } | ||||
|         else { | ||||
|             this.toggle(false); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     refreshWithNote() {} | ||||
|  | ||||
|     activeTabChangedListener() { | ||||
|         this.tabContext = this.appContext.getActiveTabContext(); | ||||
|   | ||||
| @@ -35,4 +35,10 @@ export default class TabCachingWidget extends TabAwareWidget { | ||||
|  | ||||
|         return false; // stop propagation to children | ||||
|     } | ||||
|  | ||||
|     toggle(show) { | ||||
|         for (const tabId in this.widgets) { | ||||
|             this.widgets[tabId].toggle(show && this.tabContext && tabId === this.tabContext.tabId); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -22,7 +22,7 @@ class WhatLinksHereWidget extends StandardWidget { | ||||
|         return [$showFullButton]; | ||||
|     } | ||||
|  | ||||
|     async refresh() { | ||||
|     async refreshWithNote() { | ||||
|         const targetRelations = await this.tabContext.note.getTargetRelations(); | ||||
|  | ||||
|         if (targetRelations.length === 0) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user