fix note export/import/branch prefix to use right-clicked note as opposed to current active

This commit is contained in:
zadam
2019-06-20 09:37:18 +02:00
parent a7cf3cdf05
commit fead3cd7ad
9 changed files with 74 additions and 108 deletions

View File

@@ -12,21 +12,19 @@ const $noteTitle = $('#branch-prefix-note-title');
let branchId;
async function showDialog() {
async function showDialog(node) {
utils.closeActiveDialog();
glob.activeDialog = $dialog;
$dialog.modal();
const currentNode = treeService.getActiveNode();
branchId = currentNode.data.branchId;
branchId = node.data.branchId;
const branch = await treeCache.getBranch(branchId);
$treePrefixInput.val(branch.prefix);
const noteTitle = await treeUtils.getNoteTitle(currentNode.data.noteId);
const noteTitle = await treeUtils.getNoteTitle(node.data.noteId);
$noteTitle.text(" - " + noteTitle);
}

View File

@@ -1,4 +1,3 @@
import treeService from '../services/tree.js';
import treeUtils from "../services/tree_utils.js";
import utils from "../services/utils.js";
import messagingService from "../services/messaging.js";
@@ -6,7 +5,7 @@ import infoService from "../services/info.js";
const $dialog = $("#export-dialog");
const $form = $("#export-form");
const $noteTitle = $dialog.find(".note-title");
const $noteTitle = $dialog.find(".export-note-title");
const $subtreeFormats = $("#export-subtree-formats");
const $singleFormats = $("#export-single-formats");
const $subtreeType = $("#export-type-subtree");
@@ -17,8 +16,9 @@ const $exportButton = $("#export-button");
const $opmlVersions = $("#opml-versions");
let exportId = '';
let branchId = null;
async function showDialog(defaultType) {
async function showDialog(node, defaultType) {
utils.closeActiveDialog();
// each opening of the dialog resets the exportId so we don't associate it with previous exports anymore
@@ -46,8 +46,9 @@ async function showDialog(defaultType) {
$dialog.modal();
const currentNode = treeService.getActiveNode();
const noteTitle = await treeUtils.getNoteTitle(currentNode.data.noteId);
branchId = node.data.branchId;
const noteTitle = await treeUtils.getNoteTitle(node.data.noteId);
$noteTitle.html(noteTitle);
}
@@ -70,9 +71,7 @@ $form.submit(() => {
const exportVersion = exportFormat === 'opml' ? $dialog.find("input[name='opml-version']:checked").val() : "1.0";
const currentNode = treeService.getActiveNode();
exportBranch(currentNode.data.branchId, exportType, exportFormat, exportVersion);
exportBranch(branchId, exportType, exportFormat, exportVersion);
return false;
});

View File

@@ -19,8 +19,9 @@ const $codeImportedAsCodeCheckbox = $("#code-imported-as-code-checkbox");
const $explodeArchivesCheckbox = $("#explode-archives-checkbox");
let importId;
let importIntoNoteId = null;
async function showDialog() {
async function showDialog(node) {
utils.closeActiveDialog();
// each opening of the dialog resets the importId so we don't associate it with previous imports anymore
@@ -37,19 +38,18 @@ async function showDialog() {
glob.activeDialog = $dialog;
const currentNode = treeService.getActiveNode();
$noteTitle.text(await treeUtils.getNoteTitle(currentNode.data.noteId));
importIntoNoteId = node.data.noteId;
$noteTitle.text(await treeUtils.getNoteTitle(importIntoNoteId));
$dialog.modal();
}
$form.submit(() => {
const currentNode = treeService.getActiveNode();
// disabling so that import is not triggered again.
$importButton.attr("disabled", "disabled");
importIntoNote(currentNode.data.noteId);
importIntoNote(importIntoNoteId);
return false;
});