mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-29 11:44:21 +08:00 
			
		
		
		
	close currently active dialog if a different one is activated
This commit is contained in:
		
							parent
							
								
									27659805f6
								
							
						
					
					
						commit
						4cde65d171
					
				| @ -1,4 +1,5 @@ | ||||
| import server from "../services/server.js"; | ||||
| import utils from "../services/utils.js"; | ||||
| 
 | ||||
| const $dialog = $("#about-dialog"); | ||||
| const $appVersion = $("#app-version"); | ||||
| @ -9,6 +10,8 @@ const $buildRevision = $("#build-revision"); | ||||
| const $dataDirectory = $("#data-directory"); | ||||
| 
 | ||||
| async function showDialog() { | ||||
|     utils.closeActiveDialog(); | ||||
| 
 | ||||
|     const appInfo = await server.get('app-info'); | ||||
| 
 | ||||
|     $appVersion.text(appInfo.appVersion); | ||||
|  | ||||
| @ -3,6 +3,7 @@ import linkService from '../services/link.js'; | ||||
| import noteDetailService from '../services/note_detail.js'; | ||||
| import treeUtils from '../services/tree_utils.js'; | ||||
| import noteAutocompleteService from "../services/note_autocomplete.js"; | ||||
| import utils from "../services/utils.js"; | ||||
| 
 | ||||
| const $dialog = $("#add-link-dialog"); | ||||
| const $form = $("#add-link-form"); | ||||
| @ -28,6 +29,8 @@ async function showDialogForClone() { | ||||
| } | ||||
| 
 | ||||
| async function showDialog(linkType) { | ||||
|     utils.closeActiveDialog(); | ||||
| 
 | ||||
|     glob.activeDialog = $dialog; | ||||
| 
 | ||||
|     if (noteDetailService.getActiveNoteType() === 'text') { | ||||
|  | ||||
| @ -3,6 +3,7 @@ import server from '../services/server.js'; | ||||
| import infoService from "../services/info.js"; | ||||
| import treeUtils from "../services/tree_utils.js"; | ||||
| import attributeAutocompleteService from "../services/attribute_autocomplete.js"; | ||||
| import utils from "../services/utils.js"; | ||||
| 
 | ||||
| const $dialog = $("#attributes-dialog"); | ||||
| const $saveAttributesButton = $("#save-attributes-button"); | ||||
| @ -254,6 +255,8 @@ function AttributesModel() { | ||||
| } | ||||
| 
 | ||||
| async function showDialog() { | ||||
|     utils.closeActiveDialog(); | ||||
| 
 | ||||
|     // lazily apply bindings on first use
 | ||||
|     if (!ko.dataFor($dialog[0])) { | ||||
|         ko.applyBindings(attributesModel, $dialog[0]); | ||||
|  | ||||
| @ -3,6 +3,7 @@ import server from '../services/server.js'; | ||||
| import treeCache from "../services/tree_cache.js"; | ||||
| import treeUtils from "../services/tree_utils.js"; | ||||
| import infoService from "../services/info.js"; | ||||
| import utils from "../services/utils.js"; | ||||
| 
 | ||||
| const $dialog = $("#branch-prefix-dialog"); | ||||
| const $form = $("#branch-prefix-form"); | ||||
| @ -12,6 +13,8 @@ const $noteTitle = $('#branch-prefix-note-title'); | ||||
| let branchId; | ||||
| 
 | ||||
| async function showDialog() { | ||||
|     utils.closeActiveDialog(); | ||||
| 
 | ||||
|     glob.activeDialog = $dialog; | ||||
| 
 | ||||
|     $dialog.modal(); | ||||
|  | ||||
| @ -6,6 +6,8 @@ const $dialog = $("#event-log-dialog"); | ||||
| const $list = $("#event-log-list"); | ||||
| 
 | ||||
| async function showDialog() { | ||||
|     utils.closeActiveDialog(); | ||||
| 
 | ||||
|     glob.activeDialog = $dialog; | ||||
| 
 | ||||
|     $dialog.modal(); | ||||
|  | ||||
| @ -1,7 +1,6 @@ | ||||
| import treeService from '../services/tree.js'; | ||||
| import treeUtils from "../services/tree_utils.js"; | ||||
| import utils from "../services/utils.js"; | ||||
| import protectedSessionHolder from "../services/protected_session_holder.js"; | ||||
| import messagingService from "../services/messaging.js"; | ||||
| import infoService from "../services/info.js"; | ||||
| 
 | ||||
| @ -20,6 +19,8 @@ const $opmlVersions = $("#opml-versions"); | ||||
| let exportId = ''; | ||||
| 
 | ||||
| async function showDialog(defaultType) { | ||||
|     utils.closeActiveDialog(); | ||||
| 
 | ||||
|     // each opening of the dialog resets the exportId so we don't associate it with previous exports anymore
 | ||||
|     exportId = ''; | ||||
|     $exportButton.removeAttr("disabled"); | ||||
|  | ||||
| @ -1,6 +1,10 @@ | ||||
| import utils from "../services/utils.js"; | ||||
| 
 | ||||
| const $dialog = $("#help-dialog"); | ||||
| 
 | ||||
| async function showDialog() { | ||||
|     utils.closeActiveDialog(); | ||||
| 
 | ||||
|     glob.activeDialog = $dialog; | ||||
| 
 | ||||
|     $dialog.modal(); | ||||
|  | ||||
| @ -21,6 +21,8 @@ const $explodeArchivesCheckbox = $("#explode-archives-checkbox"); | ||||
| let importId; | ||||
| 
 | ||||
| async function showDialog() { | ||||
|     utils.closeActiveDialog(); | ||||
| 
 | ||||
|     // each opening of the dialog resets the importId so we don't associate it with previous imports anymore
 | ||||
|     importId = ''; | ||||
|     $importProgressCountWrapper.hide(); | ||||
|  | ||||
| @ -1,3 +1,5 @@ | ||||
| import utils from "../services/utils.js"; | ||||
| 
 | ||||
| const $dialog = $("#info-dialog"); | ||||
| const $infoContent = $("#info-dialog-content"); | ||||
| const $okButton = $("#info-dialog-ok-button"); | ||||
| @ -5,6 +7,8 @@ const $okButton = $("#info-dialog-ok-button"); | ||||
| let resolve; | ||||
| 
 | ||||
| function info(message) { | ||||
|     utils.closeActiveDialog(); | ||||
| 
 | ||||
|     glob.activeDialog = $dialog; | ||||
| 
 | ||||
|     $infoContent.text(message); | ||||
|  | ||||
| @ -1,12 +1,15 @@ | ||||
| import treeService from '../services/tree.js'; | ||||
| import searchNotesService from '../services/search_notes.js'; | ||||
| import noteAutocompleteService from '../services/note_autocomplete.js'; | ||||
| import utils from "../services/utils.js"; | ||||
| 
 | ||||
| const $dialog = $("#jump-to-note-dialog"); | ||||
| const $autoComplete = $("#jump-to-note-autocomplete"); | ||||
| const $showInFullTextButton = $("#show-in-full-text-button"); | ||||
| 
 | ||||
| async function showDialog() { | ||||
|     utils.closeActiveDialog(); | ||||
| 
 | ||||
|     glob.activeDialog = $dialog; | ||||
| 
 | ||||
|     $autoComplete.val(''); | ||||
|  | ||||
| @ -3,6 +3,7 @@ import noteDetailService from "../services/note_detail.js"; | ||||
| import libraryLoader from "../services/library_loader.js"; | ||||
| import treeCache from "../services/tree_cache.js"; | ||||
| import linkService from "../services/link.js"; | ||||
| import utils from "../services/utils.js"; | ||||
| 
 | ||||
| const $linkMapContainer = $("#link-map-container"); | ||||
| 
 | ||||
| @ -26,6 +27,8 @@ let pzInstance = null; | ||||
| let renderer = null; | ||||
| 
 | ||||
| async function showDialog() { | ||||
|     utils.closeActiveDialog(); | ||||
| 
 | ||||
|     glob.activeDialog = $dialog; | ||||
| 
 | ||||
|     // set default settings
 | ||||
|  | ||||
| @ -1,4 +1,5 @@ | ||||
| import noteDetailService from '../services/note_detail.js'; | ||||
| import utils from "../services/utils.js"; | ||||
| 
 | ||||
| const $dialog = $("#note-info-dialog"); | ||||
| const $noteId = $("#note-info-note-id"); | ||||
| @ -9,6 +10,8 @@ const $mime = $("#note-info-mime"); | ||||
| const $okButton = $("#note-info-ok-button"); | ||||
| 
 | ||||
| function showDialog() { | ||||
|     utils.closeActiveDialog(); | ||||
| 
 | ||||
|     glob.activeDialog = $dialog; | ||||
| 
 | ||||
|     $dialog.modal(); | ||||
|  | ||||
| @ -15,6 +15,8 @@ async function showCurrentNoteRevisions() { | ||||
| } | ||||
| 
 | ||||
| async function showNoteRevisionsDialog(noteId, noteRevisionId) { | ||||
|     utils.closeActiveDialog(); | ||||
| 
 | ||||
|     glob.activeDialog = $dialog; | ||||
| 
 | ||||
|     $dialog.modal(); | ||||
|  | ||||
| @ -1,9 +1,12 @@ | ||||
| import noteDetailService from '../services/note_detail.js'; | ||||
| import utils from "../services/utils.js"; | ||||
| 
 | ||||
| const $dialog = $("#note-source-dialog"); | ||||
| const $noteSource = $("#note-source"); | ||||
| 
 | ||||
| function showDialog() { | ||||
|     utils.closeActiveDialog(); | ||||
| 
 | ||||
|     glob.activeDialog = $dialog; | ||||
| 
 | ||||
|     $dialog.modal(); | ||||
|  | ||||
| @ -17,6 +17,8 @@ function addTabHandler(handler) { | ||||
| } | ||||
| 
 | ||||
| async function showDialog() { | ||||
|     utils.closeActiveDialog(); | ||||
| 
 | ||||
|     glob.activeDialog = $dialog; | ||||
| 
 | ||||
|     const options = await server.get('options'); | ||||
|  | ||||
| @ -1,3 +1,5 @@ | ||||
| import utils from "../services/utils.js"; | ||||
| 
 | ||||
| const $dialog = $("#prompt-dialog"); | ||||
| const $dialogBody = $dialog.find(".modal-body"); | ||||
| 
 | ||||
| @ -10,6 +12,8 @@ let resolve; | ||||
| let shownCb; | ||||
| 
 | ||||
| function ask({ message, defaultValue, shown }) { | ||||
|     utils.closeActiveDialog(); | ||||
| 
 | ||||
|     glob.activeDialog = $dialog; | ||||
| 
 | ||||
|     shownCb = shown; | ||||
|  | ||||
| @ -6,6 +6,8 @@ const $dialog = $("#recent-changes-dialog"); | ||||
| const $content = $("#recent-changes-content"); | ||||
| 
 | ||||
| async function showDialog() { | ||||
|     utils.closeActiveDialog(); | ||||
| 
 | ||||
|     glob.activeDialog = $dialog; | ||||
| 
 | ||||
|     $dialog.modal(); | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| import libraryLoader from '../services/library_loader.js'; | ||||
| import server from '../services/server.js'; | ||||
| import infoService from "../services/info.js"; | ||||
| import utils from "../services/utils.js"; | ||||
| 
 | ||||
| const $dialog = $("#sql-console-dialog"); | ||||
| const $query = $('#sql-console-query'); | ||||
| @ -14,6 +15,8 @@ let codeEditor; | ||||
| $dialog.on("shown.bs.modal", e => initEditor()); | ||||
| 
 | ||||
| async function showDialog() { | ||||
|     utils.closeActiveDialog(); | ||||
| 
 | ||||
|     glob.activeDialog = $dialog; | ||||
| 
 | ||||
|     await showTables(); | ||||
|  | ||||
| @ -162,9 +162,7 @@ async function activateNote(notePath, noteLoadedListener) { | ||||
|         await hoistedNoteService.unhoist(); | ||||
|     } | ||||
| 
 | ||||
|     if (glob.activeDialog) { | ||||
|         glob.activeDialog.modal('hide'); | ||||
|     } | ||||
|     utils.closeActiveDialog(); | ||||
| 
 | ||||
|     const node = await expandToNote(notePath); | ||||
| 
 | ||||
|  | ||||
| @ -194,6 +194,12 @@ function getMimeTypeClass(mime) { | ||||
|     return 'mime-' + mime.toLowerCase().replace(/[\W_]+/g,"-"); | ||||
| } | ||||
| 
 | ||||
| function closeActiveDialog() { | ||||
|     if (glob.activeDialog) { | ||||
|         glob.activeDialog.modal('hide'); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| export default { | ||||
|     reloadApp, | ||||
|     parseDate, | ||||
| @ -223,5 +229,6 @@ export default { | ||||
|     setSessionCookie, | ||||
|     getCookie, | ||||
|     getNoteTypeClass, | ||||
|     getMimeTypeClass | ||||
|     getMimeTypeClass, | ||||
|     closeActiveDialog | ||||
| }; | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 zadam
						zadam