2017-11-27 11:34:25 +08:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const editTreePrefix = (function() {
|
|
|
|
const dialogEl = $("#edit-tree-prefix-dialog");
|
|
|
|
const formEl = $("#edit-tree-prefix-form");
|
|
|
|
const treePrefixInputEl = $("#tree-prefix-input");
|
|
|
|
const noteTitleEl = $('#tree-prefix-note-title');
|
|
|
|
|
2017-11-28 23:17:30 +08:00
|
|
|
let noteTreeId;
|
|
|
|
|
2017-11-27 12:10:23 +08:00
|
|
|
async function showDialog() {
|
2017-11-27 11:34:25 +08:00
|
|
|
glob.activeDialog = dialogEl;
|
|
|
|
|
2017-11-27 12:10:23 +08:00
|
|
|
await dialogEl.dialog({
|
2017-11-27 11:34:25 +08:00
|
|
|
modal: true,
|
|
|
|
width: 800
|
|
|
|
});
|
|
|
|
|
|
|
|
const currentNode = noteTree.getCurrentNode();
|
|
|
|
|
2017-11-28 23:17:30 +08:00
|
|
|
noteTreeId = currentNode.data.note_tree_id;
|
|
|
|
|
2017-11-27 11:34:25 +08:00
|
|
|
treePrefixInputEl.val(currentNode.data.prefix).focus();
|
|
|
|
|
|
|
|
const noteTitle = noteTree.getNoteTitle(currentNode.data.note_id);
|
|
|
|
|
|
|
|
noteTitleEl.html(noteTitle);
|
|
|
|
}
|
|
|
|
|
|
|
|
formEl.submit(() => {
|
|
|
|
const prefix = treePrefixInputEl.val();
|
|
|
|
|
2017-11-29 09:52:38 +08:00
|
|
|
server.put('tree/' + noteTreeId + '/setPrefix', {
|
|
|
|
prefix: prefix
|
|
|
|
}).then(() => noteTree.setPrefix(noteTreeId, prefix));
|
2017-11-27 11:34:25 +08:00
|
|
|
|
|
|
|
dialogEl.dialog("close");
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
showDialog
|
|
|
|
};
|
|
|
|
})();
|