mirror of
https://github.com/zadam/trilium.git
synced 2025-11-17 18:50:41 +01:00
#126, relation list in note detail and fixes in saving
This commit is contained in:
@@ -79,7 +79,7 @@ async function showDialog() {
|
||||
return;
|
||||
}
|
||||
|
||||
const notePath = linkService.getNodePathFromLabel(ui.item.value);
|
||||
const notePath = linkService.getNotePathFromLabel(ui.item.value);
|
||||
|
||||
if (!notePath) {
|
||||
return;
|
||||
@@ -99,7 +99,7 @@ async function showDialog() {
|
||||
// this is called when user goes through autocomplete list with keyboard
|
||||
// at this point the item isn't selected yet so we use supplied ui.item to see WHERE the cursor is
|
||||
focus: async (event, ui) => {
|
||||
const notePath = linkService.getNodePathFromLabel(ui.item.value);
|
||||
const notePath = linkService.getNotePathFromLabel(ui.item.value);
|
||||
const noteId = treeUtils.getNoteIdFromNotePath(notePath);
|
||||
|
||||
await setDefaultLinkTitle(noteId);
|
||||
@@ -114,7 +114,7 @@ async function showDialog() {
|
||||
$form.submit(() => {
|
||||
const value = $autoComplete.val();
|
||||
|
||||
const notePath = linkService.getNodePathFromLabel(value);
|
||||
const notePath = linkService.getNotePathFromLabel(value);
|
||||
const noteId = treeUtils.getNoteIdFromNotePath(notePath);
|
||||
|
||||
if (notePath) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import noteDetailService from '../services/note_detail.js';
|
||||
import server from '../services/server.js';
|
||||
import infoService from "../services/info.js";
|
||||
import linkService from "../services/link.js";
|
||||
import treeUtils from "../services/tree_utils.js";
|
||||
|
||||
const $dialog = $("#relations-dialog");
|
||||
const $saveRelationsButton = $("#save-relations-button");
|
||||
@@ -26,12 +28,20 @@ function RelationsModel() {
|
||||
});
|
||||
};
|
||||
|
||||
async function showRelations(relations) {
|
||||
for (const relation of relations) {
|
||||
relation.targetNoteId = await treeUtils.getNoteTitle(relation.targetNoteId) + " (" + relation.targetNoteId + ")";
|
||||
}
|
||||
|
||||
self.relations(relations.map(ko.observable));
|
||||
}
|
||||
|
||||
this.loadRelations = async function() {
|
||||
const noteId = noteDetailService.getCurrentNoteId();
|
||||
|
||||
const relations = await server.get('notes/' + noteId + '/relations');
|
||||
|
||||
self.relations(relations.map(ko.observable));
|
||||
await showRelations(relations);
|
||||
|
||||
addLastEmptyRow();
|
||||
|
||||
@@ -89,19 +99,18 @@ function RelationsModel() {
|
||||
.map(relation => relation())
|
||||
.filter(relation => relation.relationId !== "" || relation.name !== "");
|
||||
|
||||
relationsToSave.forEach(relation => relation.targetNoteId = treeUtils.getNoteIdFromNotePath(linkService.getNotePathFromLabel(relation.targetNoteId)));
|
||||
|
||||
console.log(relationsToSave);
|
||||
|
||||
const relations = await server.put('notes/' + noteId + '/relations', relationsToSave);
|
||||
|
||||
self.relations(relations.map(ko.observable));
|
||||
await showRelations(relations);
|
||||
|
||||
addLastEmptyRow();
|
||||
|
||||
infoService.showMessage("Relations have been saved.");
|
||||
|
||||
// FIXME FIXME FIXME FIXME FIXME
|
||||
// FIXME FIXME FIXME FIXME FIXME
|
||||
// FIXME FIXME FIXME FIXME FIXME
|
||||
// FIXME FIXME FIXME FIXME FIXME
|
||||
// FIXME FIXME FIXME FIXME FIXME
|
||||
noteDetailService.loadRelationList();
|
||||
};
|
||||
|
||||
@@ -218,7 +227,7 @@ async function initAutocomplete($el) {
|
||||
if (ui.item.value === 'No results') {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user