mirror of https://github.com/TriliumNext/Notes
added "include note" widget to text notes, WIP
parent
64f32ba38f
commit
2f711a12f8
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,40 @@
|
|||||||
|
import treeUtils from '../services/tree_utils.js';
|
||||||
|
import noteAutocompleteService from '../services/note_autocomplete.js';
|
||||||
|
import utils from "../services/utils.js";
|
||||||
|
|
||||||
|
const $dialog = $("#include-note-dialog");
|
||||||
|
const $form = $("#include-note-form");
|
||||||
|
const $autoComplete = $("#include-note-autocomplete");
|
||||||
|
let callback = null;
|
||||||
|
|
||||||
|
export async function showDialog(cb) {
|
||||||
|
callback = cb;
|
||||||
|
|
||||||
|
utils.closeActiveDialog();
|
||||||
|
|
||||||
|
glob.activeDialog = $dialog;
|
||||||
|
|
||||||
|
$autoComplete.val('');
|
||||||
|
|
||||||
|
$dialog.modal();
|
||||||
|
|
||||||
|
noteAutocompleteService.initNoteAutocomplete($autoComplete, { hideGoToSelectedNoteButton: true });
|
||||||
|
noteAutocompleteService.showRecentNotes($autoComplete);
|
||||||
|
}
|
||||||
|
|
||||||
|
$form.on('submit', () => {
|
||||||
|
const notePath = $autoComplete.getSelectedPath();
|
||||||
|
|
||||||
|
if (notePath) {
|
||||||
|
$dialog.modal('hide');
|
||||||
|
|
||||||
|
if (callback) {
|
||||||
|
callback(treeUtils.getNoteIdFromNotePath(notePath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.error("No noteId to include.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
<div id="include-note-dialog" class="modal mx-auto" tabindex="-1" role="dialog">
|
||||||
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Include note</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<form id="include-note-form">
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="include-note-autocomplete">Note</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<input id="include-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">Include note <kbd>enter</kbd></button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Loading…
Reference in New Issue