mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			50 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| 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";
 | |
| import toastService from "../services/toast.js";
 | |
| import utils from "../services/utils.js";
 | |
| 
 | |
| const $dialog = $("#branch-prefix-dialog");
 | |
| const $form = $("#branch-prefix-form");
 | |
| const $treePrefixInput = $("#branch-prefix-input");
 | |
| const $noteTitle = $('#branch-prefix-note-title');
 | |
| 
 | |
| let branchId;
 | |
| 
 | |
| export async function showDialog(node) {
 | |
|     utils.closeActiveDialog();
 | |
| 
 | |
|     glob.activeDialog = $dialog;
 | |
| 
 | |
|     $dialog.modal();
 | |
| 
 | |
|     branchId = node.data.branchId;
 | |
|     const branch = treeCache.getBranch(branchId);
 | |
| 
 | |
|     $treePrefixInput.val(branch.prefix);
 | |
| 
 | |
|     const noteTitle = await treeUtils.getNoteTitle(node.data.noteId);
 | |
| 
 | |
|     $noteTitle.text(" - " + noteTitle);
 | |
| }
 | |
| 
 | |
| async function savePrefix() {
 | |
|     const prefix = $treePrefixInput.val();
 | |
| 
 | |
|     await server.put('branches/' + branchId + '/set-prefix', { prefix: prefix });
 | |
| 
 | |
|     await treeService.setPrefix(branchId, prefix);
 | |
| 
 | |
|     $dialog.modal('hide');
 | |
| 
 | |
|     toastService.showMessage("Branch prefix has been saved.");
 | |
| }
 | |
| 
 | |
| $form.submit(() => {
 | |
|     savePrefix();
 | |
| 
 | |
|     return false;
 | |
| });
 | |
| 
 | |
| $dialog.on('shown.bs.modal', () => $treePrefixInput.focus()); |