| 
									
										
										
										
											2019-06-10 22:45:03 +02:00
										 |  |  | import utils from "../services/utils.js"; | 
					
						
							| 
									
										
										
										
											2019-08-27 21:24:31 +02:00
										 |  |  | import LinkMapService from "../services/link_map.js"; | 
					
						
							|  |  |  | import noteDetailService from "../services/note_detail.js"; | 
					
						
							| 
									
										
										
										
											2019-06-03 22:55:59 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | const $linkMapContainer = $("#link-map-container"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-10 14:33:59 +02:00
										 |  |  | const LINK_TYPES = [ "hyper", "image", "relation", "relation-map" ]; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-02 15:35:57 +02:00
										 |  |  | const $dialog = $("#link-map-dialog"); | 
					
						
							| 
									
										
										
										
											2019-06-10 14:33:59 +02:00
										 |  |  | const $maxNotesInput = $("#link-map-max-notes"); | 
					
						
							| 
									
										
										
										
											2019-06-02 15:35:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-27 21:24:31 +02:00
										 |  |  | let linkMapService; | 
					
						
							| 
									
										
										
										
											2019-06-03 22:55:59 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-20 21:40:47 +02:00
										 |  |  | export async function showDialog() { | 
					
						
							| 
									
										
										
										
											2019-06-10 22:45:03 +02:00
										 |  |  |     utils.closeActiveDialog(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-02 15:35:57 +02:00
										 |  |  |     glob.activeDialog = $dialog; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-10 14:33:59 +02:00
										 |  |  |     // set default settings
 | 
					
						
							| 
									
										
										
										
											2019-06-12 19:59:52 +02:00
										 |  |  |     $maxNotesInput.val(10); | 
					
						
							| 
									
										
										
										
											2019-06-11 21:52:00 +02:00
										 |  |  |     LINK_TYPES.forEach(lt => $("#link-map-" + lt).prop('checked', true)); | 
					
						
							| 
									
										
										
										
											2019-06-10 14:33:59 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-27 21:24:31 +02:00
										 |  |  |     const note = noteDetailService.getActiveNoteId(); | 
					
						
							| 
									
										
										
										
											2019-06-03 22:55:59 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-27 21:24:31 +02:00
										 |  |  |     if (!note) { | 
					
						
							| 
									
										
										
										
											2019-06-03 22:55:59 +02:00
										 |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-27 21:24:31 +02:00
										 |  |  |     linkMapService = new LinkMapService(note, $linkMapContainer); | 
					
						
							|  |  |  |     linkMapService.render(); | 
					
						
							| 
									
										
										
										
											2019-06-03 22:55:59 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-27 21:24:31 +02:00
										 |  |  |     $dialog.modal(); | 
					
						
							| 
									
										
										
										
											2019-06-03 22:55:59 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-27 21:24:31 +02:00
										 |  |  | $(".link-map-settings").change(() => linkMapService.loadNotesAndRelations()); | 
					
						
							| 
									
										
										
										
											2019-06-10 14:33:59 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-08-27 21:24:31 +02:00
										 |  |  | $maxNotesInput.on("input", () => linkMapService.loadNotesAndRelations()); |