| 
									
										
										
										
											2018-03-27 21:36:01 -04:00
										 |  |  | import noteDetailService from "./note_detail.js"; | 
					
						
							| 
									
										
										
										
											2019-03-30 00:12:32 +01:00
										 |  |  | import searchNotesService from "./search_notes.js"; | 
					
						
							| 
									
										
										
										
											2018-03-27 21:36:01 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-04 00:16:41 +02:00
										 |  |  | class NoteDetailSearch { | 
					
						
							|  |  |  |     /** | 
					
						
							| 
									
										
										
										
											2019-05-08 19:55:24 +02:00
										 |  |  |      * @param {TabContext} ctx | 
					
						
							| 
									
										
										
										
											2019-05-04 00:16:41 +02:00
										 |  |  |      */ | 
					
						
							|  |  |  |     constructor(ctx) { | 
					
						
							|  |  |  |         this.ctx = ctx; | 
					
						
							| 
									
										
										
										
											2019-05-08 19:55:24 +02:00
										 |  |  |         this.$searchString = ctx.$tabContent.find(".search-string"); | 
					
						
							|  |  |  |         this.$component = ctx.$tabContent.find('.note-detail-search'); | 
					
						
							|  |  |  |         this.$help = ctx.$tabContent.find(".note-detail-search-help"); | 
					
						
							|  |  |  |         this.$refreshButton = ctx.$tabContent.find('.note-detail-search-refresh-results-button'); | 
					
						
							| 
									
										
										
										
											2019-05-04 00:16:41 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         this.$refreshButton.click(async () => { | 
					
						
							|  |  |  |             await noteDetailService.saveNotesIfChanged(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             await searchNotesService.refreshSearch(); | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     show() { | 
					
						
							|  |  |  |         this.$help.html(searchNotesService.getHelpText()); | 
					
						
							| 
									
										
										
										
											2018-03-27 21:36:01 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-04 00:16:41 +02:00
										 |  |  |         this.$component.show(); | 
					
						
							| 
									
										
										
										
											2019-03-31 21:19:10 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-04 00:16:41 +02:00
										 |  |  |         try { | 
					
						
							|  |  |  |             const json = JSON.parse(this.ctx.note.content); | 
					
						
							| 
									
										
										
										
											2018-03-27 21:36:01 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-04 00:16:41 +02:00
										 |  |  |             this.$searchString.val(json.searchString); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         catch (e) { | 
					
						
							|  |  |  |             console.log(e); | 
					
						
							|  |  |  |             this.$searchString.val(''); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2018-03-27 21:36:01 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-04 00:16:41 +02:00
										 |  |  |         this.$searchString.on('input', noteDetailService.noteChanged); | 
					
						
							| 
									
										
										
										
											2018-03-27 21:36:01 -04:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-05-04 00:16:41 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     getContent() { | 
					
						
							|  |  |  |         return JSON.stringify({ | 
					
						
							|  |  |  |             searchString: this.$searchString.val() | 
					
						
							|  |  |  |         }); | 
					
						
							| 
									
										
										
										
											2018-03-27 21:36:01 -04:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-04 00:16:41 +02:00
										 |  |  |     focus() {} | 
					
						
							| 
									
										
										
										
											2018-03-27 21:36:01 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-04 00:16:41 +02:00
										 |  |  |     onNoteChange() {} | 
					
						
							| 
									
										
										
										
											2019-02-15 21:21:26 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-04 00:16:41 +02:00
										 |  |  |     cleanup() {} | 
					
						
							| 
									
										
										
										
											2019-01-09 19:54:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-04 00:16:41 +02:00
										 |  |  |     scrollToTop() {} | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-01-08 23:32:03 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-04 00:16:41 +02:00
										 |  |  | export default NoteDetailSearch; |