2019-06-11 04:45:03 +08:00
|
|
|
import utils from "../services/utils.js";
|
2019-08-28 03:24:31 +08:00
|
|
|
import LinkMapService from "../services/link_map.js";
|
|
|
|
import noteDetailService from "../services/note_detail.js";
|
2019-06-04 04:55:59 +08:00
|
|
|
|
|
|
|
const $linkMapContainer = $("#link-map-container");
|
|
|
|
|
2019-06-02 21:35:57 +08:00
|
|
|
const $dialog = $("#link-map-dialog");
|
2019-06-10 20:33:59 +08:00
|
|
|
const $maxNotesInput = $("#link-map-max-notes");
|
2019-06-02 21:35:57 +08:00
|
|
|
|
2019-08-28 03:24:31 +08:00
|
|
|
let linkMapService;
|
2019-06-04 04:55:59 +08:00
|
|
|
|
2019-08-28 04:47:10 +08:00
|
|
|
function getOptions() {
|
|
|
|
return {
|
|
|
|
maxNotes: $maxNotesInput.val()
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-08-21 03:40:47 +08:00
|
|
|
export async function showDialog() {
|
2019-06-11 04:45:03 +08:00
|
|
|
utils.closeActiveDialog();
|
|
|
|
|
2019-06-02 21:35:57 +08:00
|
|
|
glob.activeDialog = $dialog;
|
|
|
|
|
2019-06-10 20:33:59 +08:00
|
|
|
// set default settings
|
2019-08-28 04:47:10 +08:00
|
|
|
$maxNotesInput.val(20);
|
2019-06-10 20:33:59 +08:00
|
|
|
|
2019-08-28 04:19:32 +08:00
|
|
|
const note = noteDetailService.getActiveNote();
|
2019-06-04 04:55:59 +08:00
|
|
|
|
2019-08-28 03:24:31 +08:00
|
|
|
if (!note) {
|
2019-06-04 04:55:59 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-28 04:19:32 +08:00
|
|
|
$linkMapContainer.css("height", $("body").height() - 150);
|
|
|
|
|
2019-08-28 04:47:10 +08:00
|
|
|
linkMapService = new LinkMapService(note, $linkMapContainer, getOptions());
|
|
|
|
|
2019-08-28 03:24:31 +08:00
|
|
|
linkMapService.render();
|
2019-06-04 04:55:59 +08:00
|
|
|
|
2019-08-28 03:24:31 +08:00
|
|
|
$dialog.modal();
|
2019-06-04 04:55:59 +08:00
|
|
|
}
|
|
|
|
|
2019-08-28 04:47:10 +08:00
|
|
|
$maxNotesInput.on("input", () => linkMapService.loadNotesAndRelations(getOptions()));
|