mirror of https://github.com/TriliumNext/Notes
add move to dialog
parent
5b4a2bd71c
commit
4cda661c1b
@ -0,0 +1,62 @@
|
|||||||
|
import noteAutocompleteService from "../services/note_autocomplete.js";
|
||||||
|
import utils from "../services/utils.js";
|
||||||
|
import cloningService from "../services/cloning.js";
|
||||||
|
import treeUtils from "../services/tree_utils.js";
|
||||||
|
import toastService from "../services/toast.js";
|
||||||
|
import treeCache from "../services/tree_cache.js";
|
||||||
|
import treeChangesService from "../services/branches.js";
|
||||||
|
import treeService from "../services/tree.js";
|
||||||
|
|
||||||
|
const $dialog = $("#move-to-dialog");
|
||||||
|
const $form = $("#move-to-form");
|
||||||
|
const $noteAutoComplete = $("#move-to-note-autocomplete");
|
||||||
|
const $movePrefix = $("#move-prefix");
|
||||||
|
const $noteList = $("#move-to-note-list");
|
||||||
|
|
||||||
|
let movedNodes;
|
||||||
|
|
||||||
|
export async function showDialog(nodes) {
|
||||||
|
movedNodes = nodes;
|
||||||
|
|
||||||
|
utils.closeActiveDialog();
|
||||||
|
|
||||||
|
glob.activeDialog = $dialog;
|
||||||
|
|
||||||
|
$dialog.modal();
|
||||||
|
|
||||||
|
$noteAutoComplete.val('').trigger('focus');
|
||||||
|
|
||||||
|
$noteList.empty();
|
||||||
|
|
||||||
|
for (const node of movedNodes) {
|
||||||
|
const note = await treeCache.getNote(node.data.noteId);
|
||||||
|
|
||||||
|
$noteList.append($("<li>").text(note.title));
|
||||||
|
}
|
||||||
|
|
||||||
|
noteAutocompleteService.initNoteAutocomplete($noteAutoComplete);
|
||||||
|
noteAutocompleteService.showRecentNotes($noteAutoComplete);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function moveNotesTo(notePath) {
|
||||||
|
const targetNode = await treeService.getNodeFromPath(notePath);
|
||||||
|
|
||||||
|
await treeChangesService.moveToNode(movedNodes, targetNode);
|
||||||
|
|
||||||
|
toastService.showMessage(`Selected notes have been moved into ${targetNode.title}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
$form.on('submit', () => {
|
||||||
|
const notePath = $noteAutoComplete.getSelectedPath();
|
||||||
|
|
||||||
|
if (notePath) {
|
||||||
|
$dialog.modal('hide');
|
||||||
|
|
||||||
|
moveNotesTo(notePath);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.error("No path to move to.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
@ -0,0 +1,31 @@
|
|||||||
|
<div id="move-to-dialog" class="modal mx-auto" tabindex="-1" role="dialog">
|
||||||
|
<div class="modal-dialog modal-lg" style="max-width: 1000px" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title mr-auto">Move notes to ...</h5>
|
||||||
|
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close" style="margin-left: 0 !important;">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<form id="move-to-form">
|
||||||
|
<div class="modal-body">
|
||||||
|
<h5>Notes to move</h5>
|
||||||
|
|
||||||
|
<ul id="move-to-note-list" style="max-height: 200px; overflow: auto;"></ul>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="move-to-note-autocomplete">Target parent note</label>
|
||||||
|
|
||||||
|
<div class="input-group">
|
||||||
|
<input id="move-to-note-autocomplete" class="form-control" placeholder="search for note by its name">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="submit" class="btn btn-primary">Move to selected note <kbd>enter</kbd></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Loading…
Reference in New Issue