From 19a97f35db6c1cdafda7e51c09de0f4d0d4780cd Mon Sep 17 00:00:00 2001 From: Marty Date: Wed, 28 Nov 2018 19:25:37 +0000 Subject: [PATCH] Fix Zettel Dialog Selection Now works with a backing array of IDs. This is inefficient but works for the moment. And it is better than having to put the ids into the selection. --- zettel.qml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/zettel.qml b/zettel.qml index d364774..e87a05c 100644 --- a/zettel.qml +++ b/zettel.qml @@ -124,22 +124,22 @@ QtObject { // ---- Internal Functions ---- // ---------------------------- - function zettelSelectorDialog(editableTextBox, zettelArray) { - if (zettelArray == null) { - zettelArray = []; - fetchZettelIDs().forEach(function (noteId){ - let note = script.fetchNoteById(noteId); - zettelArray.push(note.name + " --id:"+note.id); - }); - } + function zettelSelectorDialog(isEditableTextBox) { + let backingIDs = []; + let zettelArray = []; + fetchZettelIDs().forEach(function (noteId){ + let note = script.fetchNoteById(noteId); + zettelArray.push(note.name); + backingIDs.push(note.id); + }); if (zettelArray.length == 0) { script.informationMessageBox("No valid Zettel found."); } - let selected = script.inputDialogGetItem("Zettel", "Select a Zettel", zettelArray, 0, editableTextBox); - // FIXME dont display id in names - rather, go getNotebyName(name) -> (get its id) -> set note to it - return script.fetchNoteById(selected.substring(selected.search(/--id:/)+5)); + let selected = script.inputDialogGetItem("Zettel", "Select a Zettel", zettelArray, 0, isEditableTextBox); + + return script.fetchNoteById(backingIDs[zettelArray.indexOf(selected)]); } function extractAnchorFromString(text) {