mirror of
https://github.com/zadam/trilium.git
synced 2025-11-04 20:36:13 +01:00
recent notes now don't display current note, unification of autocomplete source handling
This commit is contained in:
@@ -2,8 +2,8 @@ import cloningService from '../services/cloning.js';
|
||||
import linkService from '../services/link.js';
|
||||
import noteDetailService from '../services/note_detail.js';
|
||||
import treeUtils from '../services/tree_utils.js';
|
||||
import server from "../services/server.js";
|
||||
import noteDetailText from "../services/note_detail_text.js";
|
||||
import noteAutocompleteService from "../services/note_autocomplete.js";
|
||||
|
||||
const $dialog = $("#add-link-dialog");
|
||||
const $form = $("#add-link-form");
|
||||
@@ -55,24 +55,7 @@ async function showDialog() {
|
||||
}
|
||||
|
||||
await $autoComplete.autocomplete({
|
||||
source: async function(request, response) {
|
||||
const result = await server.get('autocomplete?query=' + encodeURIComponent(request.term));
|
||||
|
||||
if (result.length > 0) {
|
||||
response(result.map(row => {
|
||||
return {
|
||||
label: row.label,
|
||||
value: row.label + ' (' + row.value + ')'
|
||||
}
|
||||
}));
|
||||
}
|
||||
else {
|
||||
response([{
|
||||
label: "No results",
|
||||
value: "No results"
|
||||
}]);
|
||||
}
|
||||
},
|
||||
source: noteAutocompleteService.autocompleteSource,
|
||||
minLength: 0,
|
||||
change: async (event, ui) => {
|
||||
if (!ui.item) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import treeService from '../services/tree.js';
|
||||
import server from '../services/server.js';
|
||||
import searchNotesService from '../services/search_notes.js';
|
||||
import noteautocompleteService from '../services/note_autocomplete.js';
|
||||
import linkService from "../services/link.js";
|
||||
|
||||
const $dialog = $("#jump-to-note-dialog");
|
||||
const $autoComplete = $("#jump-to-note-autocomplete");
|
||||
@@ -19,22 +20,8 @@ async function showDialog() {
|
||||
});
|
||||
|
||||
await $autoComplete.autocomplete({
|
||||
source: async function(request, response) {
|
||||
const result = await server.get('autocomplete?query=' + encodeURIComponent(request.term));
|
||||
|
||||
if (result.length > 0) {
|
||||
response(result);
|
||||
}
|
||||
else {
|
||||
response([{
|
||||
label: "No results",
|
||||
value: "No results"
|
||||
}]);
|
||||
}
|
||||
},
|
||||
focus: function(event, ui) {
|
||||
event.preventDefault();
|
||||
},
|
||||
source: noteautocompleteService.autocompleteSource,
|
||||
focus: event => event.preventDefault(),
|
||||
minLength: 0,
|
||||
autoFocus: true,
|
||||
select: function (event, ui) {
|
||||
@@ -42,7 +29,9 @@ async function showDialog() {
|
||||
return false;
|
||||
}
|
||||
|
||||
treeService.activateNode(ui.item.value);
|
||||
const notePath = linkService.getNotePathFromLabel(ui.item.value);
|
||||
|
||||
treeService.activateNode(notePath);
|
||||
|
||||
$dialog.dialog('close');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user