mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	continuing in API review
This commit is contained in:
		
							
								
								
									
										51
									
								
								src/public/javascripts/dialogs/branch_prefix.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								src/public/javascripts/dialogs/branch_prefix.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | ||||
| import treeService from '../services/tree.js'; | ||||
| import server from '../services/server.js'; | ||||
| import treeCache from "../services/tree_cache.js"; | ||||
| import treeUtils from "../services/tree_utils.js"; | ||||
|  | ||||
| const $dialog = $("#edit-tree-prefix-dialog"); | ||||
| const $form = $("#edit-tree-prefix-form"); | ||||
| const $treePrefixInput = $("#tree-prefix-input"); | ||||
| const $noteTitle = $('#tree-prefix-note-title'); | ||||
|  | ||||
| let branchId; | ||||
|  | ||||
| async function showDialog() { | ||||
|     glob.activeDialog = $dialog; | ||||
|  | ||||
|     await $dialog.dialog({ | ||||
|         modal: true, | ||||
|         width: 500 | ||||
|     }); | ||||
|  | ||||
|     const currentNode = treeService.getCurrentNode(); | ||||
|  | ||||
|     branchId = currentNode.data.branchId; | ||||
|     const branch = await treeCache.getBranch(branchId); | ||||
|  | ||||
|     $treePrefixInput.val(branch.prefix).focus(); | ||||
|  | ||||
|     const noteTitle = treeUtils.getNoteTitle(currentNode.data.noteId); | ||||
|  | ||||
|     $noteTitle.html(noteTitle); | ||||
| } | ||||
|  | ||||
| async function savePrefix() { | ||||
|     const prefix = $treePrefixInput.val(); | ||||
|  | ||||
|     await server.put('branches/' + branchId + '/set-prefix', { prefix: prefix }); | ||||
|  | ||||
|     await treeService.setPrefix(branchId, prefix); | ||||
|  | ||||
|     $dialog.dialog("close"); | ||||
| } | ||||
|  | ||||
| $form.submit(() => { | ||||
|     savePrefix(); | ||||
|  | ||||
|     return false; | ||||
| }); | ||||
|  | ||||
| export default { | ||||
|     showDialog | ||||
| }; | ||||
		Reference in New Issue
	
	Block a user