2017-11-26 22:34:25 -05:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const editTreePrefix = (function() {
|
2018-02-10 08:44:34 -05: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-26 22:34:25 -05:00
|
|
|
|
2018-03-24 21:39:15 -04:00
|
|
|
let branchId;
|
2017-11-28 10:17:30 -05:00
|
|
|
|
2017-11-26 23:10:23 -05:00
|
|
|
async function showDialog() {
|
2018-02-10 08:44:34 -05:00
|
|
|
glob.activeDialog = $dialog;
|
2017-11-26 22:34:25 -05:00
|
|
|
|
2018-02-10 08:44:34 -05:00
|
|
|
await $dialog.dialog({
|
2017-11-26 22:34:25 -05:00
|
|
|
modal: true,
|
2017-12-26 19:54:43 -05:00
|
|
|
width: 500
|
2017-11-26 22:34:25 -05:00
|
|
|
});
|
|
|
|
|
2018-03-24 21:39:15 -04:00
|
|
|
const currentNode = treeService.getCurrentNode();
|
2017-11-26 22:34:25 -05:00
|
|
|
|
2018-03-24 21:39:15 -04:00
|
|
|
branchId = currentNode.data.branchId;
|
|
|
|
const nt = treeService.getBranch(branchId);
|
2017-11-28 10:17:30 -05:00
|
|
|
|
2018-03-12 23:14:09 -04:00
|
|
|
$treePrefixInput.val(nt.prefix).focus();
|
2017-11-26 22:34:25 -05:00
|
|
|
|
2018-03-24 21:39:15 -04:00
|
|
|
const noteTitle = treeService.getNoteTitle(currentNode.data.noteId);
|
2017-11-26 22:34:25 -05:00
|
|
|
|
2018-02-10 08:44:34 -05:00
|
|
|
$noteTitle.html(noteTitle);
|
2017-11-26 22:34:25 -05:00
|
|
|
}
|
|
|
|
|
2018-02-10 08:44:34 -05:00
|
|
|
$form.submit(() => {
|
|
|
|
const prefix = $treePrefixInput.val();
|
2017-11-26 22:34:25 -05:00
|
|
|
|
2018-03-24 21:39:15 -04:00
|
|
|
server.put('tree/' + branchId + '/set-prefix', {
|
2017-11-28 20:52:38 -05:00
|
|
|
prefix: prefix
|
2018-03-24 21:39:15 -04:00
|
|
|
}).then(() => treeService.setPrefix(branchId, prefix));
|
2017-11-26 22:34:25 -05:00
|
|
|
|
2018-02-10 08:44:34 -05:00
|
|
|
$dialog.dialog("close");
|
2017-11-26 22:34:25 -05:00
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
showDialog
|
|
|
|
};
|
|
|
|
})();
|