mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-30 18:05:55 +01:00 
			
		
		
		
	search note fixes
This commit is contained in:
		
							
								
								
									
										
											BIN
										
									
								
								src/public/images/icons/save.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/public/images/icons/save.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 388 B | 
| @@ -114,13 +114,14 @@ const contextMenuOptions = { | ||||
|         // Modify menu entries depending on node status | ||||
|         $tree.contextmenu("enableEntry", "insertNoteHere", isNotRoot && parentNote.type !== 'search'); | ||||
|         $tree.contextmenu("enableEntry", "insertChildNote", note.type !== 'search'); | ||||
|         $tree.contextmenu("enableEntry", "delete", isNotRoot); | ||||
|         $tree.contextmenu("enableEntry", "delete", isNotRoot && parentNote.type !== 'search'); | ||||
|         $tree.contextmenu("enableEntry", "copy", isNotRoot); | ||||
|         $tree.contextmenu("enableEntry", "cut", isNotRoot); | ||||
|         $tree.contextmenu("enableEntry", "pasteAfter", clipboardIds.length > 0 && isNotRoot && parentNote.type !== 'search'); | ||||
|         $tree.contextmenu("enableEntry", "pasteInto", clipboardIds.length > 0 && note.type !== 'search'); | ||||
|         $tree.contextmenu("enableEntry", "importBranch", note.type !== 'search'); | ||||
|         $tree.contextmenu("enableEntry", "exportBranch", note.type !== 'search'); | ||||
|         $tree.contextmenu("enableEntry", "editBranchPrefix", parentNote.type !== 'search'); | ||||
|  | ||||
|         // Activate node on right-click | ||||
|         node.setActive(); | ||||
|   | ||||
| @@ -74,14 +74,14 @@ async function prepareRealBranch(parentNote) { | ||||
|  | ||||
| async function prepareSearchBranch(note) { | ||||
|     const fullNote = await noteDetailService.loadNote(note.noteId); | ||||
|     const noteIds = await server.get('search/' + encodeURIComponent(fullNote.jsonContent.searchString)); | ||||
|     const results = await server.get('search/' + encodeURIComponent(fullNote.jsonContent.searchString)); | ||||
|  | ||||
|     for (const noteId of noteIds) { | ||||
|     for (const result of results) { | ||||
|         const branch = new Branch(treeCache, { | ||||
|             branchId: "virt" + utils.randomString(10), | ||||
|             noteId: noteId, | ||||
|             noteId: result.noteId, | ||||
|             parentNoteId: note.noteId, | ||||
|             prefix: '', | ||||
|             prefix: result.prefix, | ||||
|             virtual: true | ||||
|         }); | ||||
|  | ||||
|   | ||||
| @@ -8,6 +8,7 @@ const utils = require('./utils'); | ||||
| let noteTitles; | ||||
| let protectedNoteTitles; | ||||
| let noteIds; | ||||
| let childParentToBranchId = {}; | ||||
| const childToParent = {}; | ||||
| const hideInAutocomplete = {}; | ||||
|  | ||||
| @@ -20,11 +21,12 @@ async function load() { | ||||
|  | ||||
|     prefixes = await sql.getMap(`SELECT noteId || '-' || parentNoteId, prefix FROM branches WHERE prefix IS NOT NULL AND prefix != ''`); | ||||
|  | ||||
|     const relations = await sql.getRows(`SELECT noteId, parentNoteId FROM branches WHERE isDeleted = 0`); | ||||
|     const relations = await sql.getRows(`SELECT branchId, noteId, parentNoteId FROM branches WHERE isDeleted = 0`); | ||||
|  | ||||
|     for (const rel of relations) { | ||||
|         childToParent[rel.noteId] = childToParent[rel.noteId] || []; | ||||
|         childToParent[rel.noteId].push(rel.parentNoteId); | ||||
|         childParentToBranchId[`${rel.noteId}-${rel.parentNoteId}`] = rel.branchId; | ||||
|     } | ||||
|  | ||||
|     const hiddenLabels = await sql.getColumn(`SELECT noteId FROM labels WHERE isDeleted = 0 AND name = 'hideInAutocomplete'`); | ||||
| @@ -91,11 +93,15 @@ function search(noteId, tokens, path, results) { | ||||
|  | ||||
|         if (retPath) { | ||||
|             const noteTitle = getNoteTitleForPath(retPath); | ||||
|             const thisNoteId = retPath[retPath.length - 1]; | ||||
|             const thisParentNoteId = retPath[retPath.length - 2]; | ||||
|  | ||||
|             results.push({ | ||||
|                 noteId: noteId, | ||||
|                 noteId: thisNoteId, | ||||
|                 branchId: childParentToBranchId[`${thisNoteId}-${thisParentNoteId}`], | ||||
|                 title: noteTitle, | ||||
|                 path: retPath.join('/') | ||||
|                 path: retPath.join('/'), | ||||
|                 prefix: prefixes[`${thisNoteId}-${thisParentNoteId}`] | ||||
|             }); | ||||
|         } | ||||
|  | ||||
| @@ -230,6 +236,7 @@ eventService.subscribe(eventService.ENTITY_CHANGED, async ({entityName, entityId | ||||
|  | ||||
|         if (branch.isDeleted) { | ||||
|             delete prefixes[branch.noteId + '-' + branch.parentNoteId]; | ||||
|             delete childParentToBranchId[branch.noteId + '-' + branch.parentNoteId]; | ||||
|         } | ||||
|         else { | ||||
|             if (branch.prefix) { | ||||
| @@ -238,6 +245,7 @@ eventService.subscribe(eventService.ENTITY_CHANGED, async ({entityName, entityId | ||||
|  | ||||
|             childToParent[branch.noteId] = childToParent[branch.noteId] || []; | ||||
|             childToParent[branch.noteId].push(branch.parentNoteId); | ||||
|             childParentToBranchId[branch.noteId + '-' + branch.parentNoteId] = branch.branchId; | ||||
|         } | ||||
|     } | ||||
|     else if (entityName === 'labels') { | ||||
|   | ||||
| @@ -77,7 +77,12 @@ | ||||
|           <div style="display: flex; align-items: center;"> | ||||
|             <input name="search-text" placeholder="Search text, labels" style="flex-grow: 100; margin-left: 5px; margin-right: 5px;" autocomplete="off"> | ||||
|             <button id="do-search-button" class="btn btn-sm" title="Search">Search</button> | ||||
|             <button id="save-search-button" class="btn btn-sm" title="Save search">Save</button> | ||||
|  | ||||
|               | ||||
|  | ||||
|             <button id="save-search-button" class="btn btn-sm" title="Save search" style="padding: 4px;"> | ||||
|               <img src="/images/icons/save.png" alt="Save search"/> | ||||
|             </button> | ||||
|           </div> | ||||
|         </div> | ||||
|  | ||||
| @@ -115,10 +120,10 @@ | ||||
|  | ||||
|             <div class="btn-group btn-group-xs"> | ||||
|               <button type="button" class="btn" id="protect-button" title="Protected note can be viewed and edited only after entering password"> | ||||
|                 <img src="images/icons/shield.png"/> | ||||
|                 <img src="/images/icons/shield.png"/> | ||||
|               </button> | ||||
|               <button type="button" class="btn" id="unprotect-button" title="Not protected note can be viewed without entering password"> | ||||
|                 <img src="images/icons/shield-off.png"/> | ||||
|                 <img src="/images/icons/shield-off.png"/> | ||||
|               </button> | ||||
|             </div> | ||||
|           </div> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user