mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 11:39:01 +01:00 
			
		
		
		
	chore(client/ts): port search_options
This commit is contained in:
		
							parent
							
								
									2c714afa21
								
							
						
					
					
						commit
						423037b9d6
					
				| @ -58,7 +58,7 @@ export default class Ancestor extends AbstractSearchOption { | |||||||
|         return "relation"; |         return "relation"; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     static async create(noteId) { |     static async create(noteId: string) { | ||||||
|         await AbstractSearchOption.setAttribute(noteId, "relation", "ancestor", "root"); |         await AbstractSearchOption.setAttribute(noteId, "relation", "ancestor", "root"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -77,7 +77,7 @@ export default class Ancestor extends AbstractSearchOption { | |||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         $ancestorDepth.on("change", async () => { |         $ancestorDepth.on("change", async () => { | ||||||
|             const ancestorDepth = $ancestorDepth.val(); |             const ancestorDepth = String($ancestorDepth.val()); | ||||||
| 
 | 
 | ||||||
|             if (ancestorDepth) { |             if (ancestorDepth) { | ||||||
|                 await this.setAttribute("label", "ancestorDepth", ancestorDepth); |                 await this.setAttribute("label", "ancestorDepth", ancestorDepth); | ||||||
| @ -88,7 +88,7 @@ export default class Ancestor extends AbstractSearchOption { | |||||||
| 
 | 
 | ||||||
|         const ancestorNoteId = this.note.getRelationValue("ancestor"); |         const ancestorNoteId = this.note.getRelationValue("ancestor"); | ||||||
| 
 | 
 | ||||||
|         if (ancestorNoteId !== "root") { |         if (ancestorNoteId && ancestorNoteId !== "root") { | ||||||
|             $ancestor.setNote(ancestorNoteId); |             $ancestor.setNote(ancestorNoteId); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -23,6 +23,9 @@ const TPL = ` | |||||||
| </tr>`;
 | </tr>`;
 | ||||||
| 
 | 
 | ||||||
| export default class Limit extends AbstractSearchOption { | export default class Limit extends AbstractSearchOption { | ||||||
|  | 
 | ||||||
|  |     private $limit!: JQuery<HTMLElement>; | ||||||
|  | 
 | ||||||
|     static get optionName() { |     static get optionName() { | ||||||
|         return "limit"; |         return "limit"; | ||||||
|     } |     } | ||||||
| @ -30,7 +33,7 @@ export default class Limit extends AbstractSearchOption { | |||||||
|         return "label"; |         return "label"; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     static async create(noteId) { |     static async create(noteId: string) { | ||||||
|         await AbstractSearchOption.setAttribute(noteId, "label", "limit", "10"); |         await AbstractSearchOption.setAttribute(noteId, "label", "limit", "10"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -40,13 +43,13 @@ export default class Limit extends AbstractSearchOption { | |||||||
|         this.$limit = $option.find("input[name=limit]"); |         this.$limit = $option.find("input[name=limit]"); | ||||||
|         this.$limit.on("change", () => this.update()); |         this.$limit.on("change", () => this.update()); | ||||||
|         this.$limit.on("input", () => this.update()); |         this.$limit.on("input", () => this.update()); | ||||||
|         this.$limit.val(this.note.getLabelValue("limit")); |         this.$limit.val(this.note.getLabelValue("limit") ?? ""); | ||||||
| 
 | 
 | ||||||
|         return $option; |         return $option; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     async update() { |     async update() { | ||||||
|         const limit = this.$limit.val(); |         const limit = String(this.$limit.val()); | ||||||
| 
 | 
 | ||||||
|         await this.setAttribute("label", "limit", limit); |         await this.setAttribute("label", "limit", limit); | ||||||
|     } |     } | ||||||
| @ -36,6 +36,7 @@ const TPL = ` | |||||||
| </tr>`;
 | </tr>`;
 | ||||||
| 
 | 
 | ||||||
| export default class OrderBy extends AbstractSearchOption { | export default class OrderBy extends AbstractSearchOption { | ||||||
|  | 
 | ||||||
|     static get optionName() { |     static get optionName() { | ||||||
|         return "orderBy"; |         return "orderBy"; | ||||||
|     } |     } | ||||||
| @ -43,7 +44,7 @@ export default class OrderBy extends AbstractSearchOption { | |||||||
|         return "label"; |         return "label"; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     static async create(noteId) { |     static async create(noteId: string) { | ||||||
|         await AbstractSearchOption.setAttribute(noteId, "label", "orderBy", "relevancy"); |         await AbstractSearchOption.setAttribute(noteId, "label", "orderBy", "relevancy"); | ||||||
|         await AbstractSearchOption.setAttribute(noteId, "label", "orderDirection", "asc"); |         await AbstractSearchOption.setAttribute(noteId, "label", "orderDirection", "asc"); | ||||||
|     } |     } | ||||||
| @ -53,15 +54,15 @@ export default class OrderBy extends AbstractSearchOption { | |||||||
| 
 | 
 | ||||||
|         const $orderBy = $option.find("select[name=orderBy]"); |         const $orderBy = $option.find("select[name=orderBy]"); | ||||||
|         $orderBy.on("change", async () => { |         $orderBy.on("change", async () => { | ||||||
|             const orderBy = $orderBy.val(); |             const orderBy = String($orderBy.val()); | ||||||
| 
 | 
 | ||||||
|             await this.setAttribute("label", "orderBy", orderBy); |             await this.setAttribute("label", "orderBy", orderBy); | ||||||
|         }); |         }); | ||||||
|         $orderBy.val(this.note.getLabelValue("orderBy")); |         $orderBy.val(this.note.getLabelValue("orderBy") ?? ""); | ||||||
| 
 | 
 | ||||||
|         const $orderDirection = $option.find("select[name=orderDirection]"); |         const $orderDirection = $option.find("select[name=orderDirection]"); | ||||||
|         $orderDirection.on("change", async () => { |         $orderDirection.on("change", async () => { | ||||||
|             const orderDirection = $orderDirection.val(); |             const orderDirection = String($orderDirection.val()); | ||||||
| 
 | 
 | ||||||
|             await this.setAttribute("label", "orderDirection", orderDirection); |             await this.setAttribute("label", "orderDirection", orderDirection); | ||||||
|         }); |         }); | ||||||
| @ -40,7 +40,7 @@ export default class SearchScript extends AbstractSearchOption { | |||||||
|         return "relation"; |         return "relation"; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     static async create(noteId) { |     static async create(noteId: string) { | ||||||
|         await AbstractSearchOption.setAttribute(noteId, "relation", "searchScript", "root"); |         await AbstractSearchOption.setAttribute(noteId, "relation", "searchScript", "root"); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -59,7 +59,7 @@ export default class SearchScript extends AbstractSearchOption { | |||||||
| 
 | 
 | ||||||
|         const searchScriptNoteId = this.note.getRelationValue("searchScript"); |         const searchScriptNoteId = this.note.getRelationValue("searchScript"); | ||||||
| 
 | 
 | ||||||
|         if (searchScriptNoteId !== "root") { |         if (searchScriptNoteId && searchScriptNoteId !== "root") { | ||||||
|             $searchScript.setNote(searchScriptNoteId); |             $searchScript.setNote(searchScriptNoteId); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran