2020-01-25 09:56:08 +01:00
|
|
|
import treeService from '../services/tree.js';
|
2019-12-29 23:46:40 +01:00
|
|
|
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");
|
|
|
|
|
|
2020-02-16 10:50:48 +01:00
|
|
|
/** @var TextTypeWidget */
|
|
|
|
|
let textTypeWidget;
|
|
|
|
|
|
|
|
|
|
export async function showDialog(widget) {
|
|
|
|
|
textTypeWidget = widget;
|
2019-12-29 23:46:40 +01:00
|
|
|
|
|
|
|
|
$autoComplete.val('');
|
|
|
|
|
|
2020-02-09 10:00:13 +01:00
|
|
|
utils.openDialog($dialog);
|
2019-12-29 23:46:40 +01:00
|
|
|
|
|
|
|
|
noteAutocompleteService.initNoteAutocomplete($autoComplete, { hideGoToSelectedNoteButton: true });
|
|
|
|
|
noteAutocompleteService.showRecentNotes($autoComplete);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$form.on('submit', () => {
|
|
|
|
|
const notePath = $autoComplete.getSelectedPath();
|
|
|
|
|
|
|
|
|
|
if (notePath) {
|
|
|
|
|
$dialog.modal('hide');
|
|
|
|
|
|
2020-02-16 10:50:48 +01:00
|
|
|
const includedNoteId = treeService.getNoteIdFromNotePath(notePath);
|
|
|
|
|
|
|
|
|
|
textTypeWidget.addIncludeNote(includedNoteId);
|
2019-12-29 23:46:40 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
console.error("No noteId to include.");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
});
|