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.
This commit is contained in:
Marty 2018-11-28 19:25:37 +00:00
parent 1eb6703a57
commit 19a97f35db
1 changed files with 11 additions and 11 deletions

View File

@ -124,22 +124,22 @@ QtObject {
// ---- Internal Functions ---- // ---- Internal Functions ----
// ---------------------------- // ----------------------------
function zettelSelectorDialog(editableTextBox, zettelArray) { function zettelSelectorDialog(isEditableTextBox) {
if (zettelArray == null) { let backingIDs = [];
zettelArray = []; let zettelArray = [];
fetchZettelIDs().forEach(function (noteId){ fetchZettelIDs().forEach(function (noteId){
let note = script.fetchNoteById(noteId); let note = script.fetchNoteById(noteId);
zettelArray.push(note.name + " --id:"+note.id); zettelArray.push(note.name);
}); backingIDs.push(note.id);
} });
if (zettelArray.length == 0) { if (zettelArray.length == 0) {
script.informationMessageBox("No valid Zettel found."); script.informationMessageBox("No valid Zettel found.");
} }
let selected = script.inputDialogGetItem("Zettel", "Select a Zettel", zettelArray, 0, editableTextBox); let selected = script.inputDialogGetItem("Zettel", "Select a Zettel", zettelArray, 0, isEditableTextBox);
// 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)); return script.fetchNoteById(backingIDs[zettelArray.indexOf(selected)]);
} }
function extractAnchorFromString(text) { function extractAnchorFromString(text) {