mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	allow refreshing saved note, closes #304
This commit is contained in:
		| @@ -1,7 +1,9 @@ | ||||
| import noteDetailService from "./note_detail.js"; | ||||
| import treeService from "./tree.js"; | ||||
|  | ||||
| const $searchString = $("#search-string"); | ||||
| const $component = $('#note-detail-search'); | ||||
| const $refreshButton = $('#note-detail-search-refresh-results-button'); | ||||
|  | ||||
| function getContent() { | ||||
|     return JSON.stringify({ | ||||
| @@ -25,6 +27,8 @@ function show() { | ||||
|     $searchString.on('input', noteDetailService.noteChanged); | ||||
| } | ||||
|  | ||||
| $refreshButton.click(() => treeService.reload()); | ||||
|  | ||||
| export default { | ||||
|     getContent, | ||||
|     show, | ||||
|   | ||||
| @@ -352,6 +352,7 @@ function clearSelectedNodes() { | ||||
| } | ||||
|  | ||||
| async function treeInitialized() { | ||||
|     // - is used in mobile to indicate that we don't want to activate any note after load | ||||
|     if (startNotePath === '-') { | ||||
|         return; | ||||
|     } | ||||
| @@ -363,7 +364,6 @@ async function treeInitialized() { | ||||
|         startNotePath = null; | ||||
|     } | ||||
|  | ||||
|     // - is used in mobile to indicate that we don't want to activate any note after load | ||||
|     if (startNotePath) { | ||||
|         const node = await activateNote(startNotePath); | ||||
|  | ||||
| @@ -438,6 +438,16 @@ function initFancyTree(tree) { | ||||
|  | ||||
|                 $span.append(unhoistButton); | ||||
|             } | ||||
|         }, | ||||
|         // this is done to automatically lazy load all expanded search notes after tree load | ||||
|         loadChildren: function(event, data) { | ||||
|             data.node.visit(function(subNode){ | ||||
|                 // Load all lazy/unloaded child nodes | ||||
|                 // (which will trigger `loadChildren` recursively) | ||||
|                 if( subNode.isUndefined() && subNode.isExpanded() ) { | ||||
|                     subNode.load(); | ||||
|                 } | ||||
|             }); | ||||
|         } | ||||
|     }); | ||||
|  | ||||
|   | ||||
| @@ -86,7 +86,7 @@ async function prepareNode(branch) { | ||||
|         extraClasses: await getExtraClasses(note), | ||||
|         icon: await getIcon(note), | ||||
|         refKey: note.noteId, | ||||
|         expanded: (note.type !== 'search' && branch.isExpanded) || hoistedNoteId === note.noteId | ||||
|         expanded: branch.isExpanded || hoistedNoteId === note.noteId | ||||
|     }; | ||||
|  | ||||
|     if (note.hasChildren() || note.type === 'search') { | ||||
|   | ||||
| @@ -1,7 +1,12 @@ | ||||
| <div id="note-detail-search" class="note-detail-component"> | ||||
|     <div style="display: flex; align-items: center;"> | ||||
|         <strong>Search string:    </strong> | ||||
|         <textarea rows="4" cols="50" id="search-string"></textarea> | ||||
|         <textarea rows="4" cols="40" id="search-string"></textarea> | ||||
|  | ||||
|         <span> | ||||
|                 | ||||
|             <button type="button" class="btn btn-primary" id="note-detail-search-refresh-results-button">Refresh tree</button> | ||||
|         </span> | ||||
|     </div> | ||||
|  | ||||
|     <br /> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user