2017-11-27 11:34:25 +08:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const editTreePrefix = (function() {
|
2018-02-10 21:44:34 +08:00
|
|
|
const $dialog = $("#edit-tree-prefix-dialog");
|
|
|
|
const $form = $("#edit-tree-prefix-form");
|
|
|
|
const $treePrefixInput = $("#tree-prefix-input");
|
|
|
|
const $noteTitle = $('#tree-prefix-note-title');
|
2017-11-27 11:34:25 +08:00
|
|
|
|
2017-11-28 23:17:30 +08:00
|
|
|
let noteTreeId;
|
|
|
|
|
2017-11-27 12:10:23 +08:00
|
|
|
async function showDialog() {
|
2018-02-10 21:44:34 +08:00
|
|
|
glob.activeDialog = $dialog;
|
2017-11-27 11:34:25 +08:00
|
|
|
|
2018-02-10 21:44:34 +08:00
|
|
|
await $dialog.dialog({
|
2017-11-27 11:34:25 +08:00
|
|
|
modal: true,
|
2017-12-27 08:54:43 +08:00
|
|
|
width: 500
|
2017-11-27 11:34:25 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
const currentNode = noteTree.getCurrentNode();
|
|
|
|
|
2018-01-29 08:30:14 +08:00
|
|
|
noteTreeId = currentNode.data.noteTreeId;
|
2017-11-28 23:17:30 +08:00
|
|
|
|
2018-02-10 21:44:34 +08:00
|
|
|
$treePrefixInput.val(currentNode.data.prefix).focus();
|
2017-11-27 11:34:25 +08:00
|
|
|
|
2018-01-29 08:30:14 +08:00
|
|
|
const noteTitle = noteTree.getNoteTitle(currentNode.data.noteId);
|
2017-11-27 11:34:25 +08:00
|
|
|
|
2018-02-10 21:44:34 +08:00
|
|
|
$noteTitle.html(noteTitle);
|
2017-11-27 11:34:25 +08:00
|
|
|
}
|
|
|
|
|
2018-02-10 21:44:34 +08:00
|
|
|
$form.submit(() => {
|
|
|
|
const prefix = $treePrefixInput.val();
|
2017-11-27 11:34:25 +08:00
|
|
|
|
2017-12-02 11:47:23 +08:00
|
|
|
server.put('tree/' + noteTreeId + '/set-prefix', {
|
2017-11-29 09:52:38 +08:00
|
|
|
prefix: prefix
|
|
|
|
}).then(() => noteTree.setPrefix(noteTreeId, prefix));
|
2017-11-27 11:34:25 +08:00
|
|
|
|
2018-02-10 21:44:34 +08:00
|
|
|
$dialog.dialog("close");
|
2017-11-27 11:34:25 +08:00
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
showDialog
|
|
|
|
};
|
|
|
|
})();
|