mirror of
https://github.com/TriliumNext/Notes.git
synced 2026-05-01 09:49:52 -05:00
implemented mirror relations
This commit is contained in:
@@ -71,6 +71,7 @@ function AttributesModel() {
|
||||
|
||||
attr.relationDefinition = (attr.type === 'relation-definition' && attr.value) ? attr.value : {
|
||||
multiplicityType: "singlevalue",
|
||||
mirrorRelation: "",
|
||||
isPromoted: true
|
||||
};
|
||||
|
||||
@@ -189,6 +190,7 @@ function AttributesModel() {
|
||||
},
|
||||
relationDefinition: {
|
||||
multiplicityType: "singlevalue",
|
||||
mirrorRelation: "",
|
||||
isPromoted: true
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -60,7 +60,7 @@ async function showAttributes() {
|
||||
const $inputCell = $("<td>").append($("<div>").addClass("input-group").append($input));
|
||||
|
||||
const $actionCell = $("<td>");
|
||||
const $multiplicityCell = $("<td>");
|
||||
const $multiplicityCell = $("<td>").addClass("multiplicity");
|
||||
|
||||
$tr
|
||||
.append($labelCell)
|
||||
@@ -148,9 +148,14 @@ async function showAttributes() {
|
||||
// ideally we'd use link instead of button which would allow tooltip preview, but
|
||||
// we can't guarantee updating the link in the a element
|
||||
const $openButton = $("<button>").addClass("btn btn-sm").text("Open").click(() => {
|
||||
const notePath = $input.prop("data-selected-path");
|
||||
const notePath = $input.getSelectedPath();
|
||||
|
||||
treeService.activateNote(notePath);
|
||||
if (notePath) {
|
||||
treeService.activateNote(notePath);
|
||||
}
|
||||
else {
|
||||
console.log("Empty note path, nothing to open.");
|
||||
}
|
||||
});
|
||||
|
||||
$actionCell.append($openButton);
|
||||
@@ -162,7 +167,7 @@ async function showAttributes() {
|
||||
|
||||
if (definition.multiplicityType === "multivalue") {
|
||||
const addButton = $("<span>")
|
||||
.addClass("glyphicon glyphicon-plus pointer")
|
||||
.addClass("jam jam-plus pointer")
|
||||
.prop("title", "Add new attribute")
|
||||
.click(async () => {
|
||||
const $new = await createRow(definitionAttr, {
|
||||
@@ -178,7 +183,7 @@ async function showAttributes() {
|
||||
});
|
||||
|
||||
const removeButton = $("<span>")
|
||||
.addClass("glyphicon glyphicon-trash pointer")
|
||||
.addClass("jam jam-trash pointer")
|
||||
.prop("title", "Remove this attribute")
|
||||
.click(async () => {
|
||||
if (valueAttr.attributeId) {
|
||||
@@ -269,11 +274,9 @@ async function promotedAttributeChanged(event) {
|
||||
value = $attr.is(':checked') ? "true" : "false";
|
||||
}
|
||||
else if ($attr.prop("attribute-type") === "relation") {
|
||||
const selectedPath = $attr.prop("data-selected-path");
|
||||
const selectedPath = $attr.getSelectedPath();
|
||||
|
||||
if (selectedPath) {
|
||||
value = treeUtils.getNoteIdFromNotePath(selectedPath);
|
||||
}
|
||||
value = selectedPath ? treeUtils.getNoteIdFromNotePath(selectedPath) : "";
|
||||
}
|
||||
else {
|
||||
value = $attr.val();
|
||||
|
||||
@@ -54,24 +54,34 @@ function initNoteAutocomplete($el) {
|
||||
$el.prop("data-selected-path", suggestion.path);
|
||||
});
|
||||
|
||||
$el.getSelectedPath = () => $el.prop("data-selected-path");
|
||||
$el.on('autocomplete:closed', () => {
|
||||
$el.prop("data-selected-path", "");
|
||||
});
|
||||
}
|
||||
|
||||
return $el;
|
||||
}
|
||||
|
||||
$.fn.getSelectedPath = function() {
|
||||
if (!$(this).val().trim()) {
|
||||
return "";
|
||||
}
|
||||
else {
|
||||
return $(this).prop("data-selected-path");
|
||||
}
|
||||
};
|
||||
|
||||
ko.bindingHandlers.noteAutocomplete = {
|
||||
init: function(element, valueAccessor, allBindings, viewModel, bindingContext) {
|
||||
initNoteAutocomplete($(element));
|
||||
|
||||
$(element).on('autocomplete:selected', function(event, suggestion, dataset) {
|
||||
bindingContext.$data.selectedPath = suggestion.path;
|
||||
bindingContext.$data.selectedPath = $(element).val().trim() ? suggestion.path : '';
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
initNoteAutocomplete,
|
||||
autocompleteSource,
|
||||
showRecentNotes
|
||||
}
|
||||
@@ -152,6 +152,11 @@ async function getRunPath(notePath) {
|
||||
|
||||
if (childNoteId !== null) {
|
||||
const child = await treeCache.getNote(childNoteId);
|
||||
|
||||
if (!child) {
|
||||
console.log("Can't find " + childNoteId);
|
||||
}
|
||||
|
||||
const parents = await child.getParentNotes();
|
||||
|
||||
if (!parents) {
|
||||
@@ -609,7 +614,7 @@ $(window).bind('hashchange', function() {
|
||||
const notePath = getNotePathFromAddress();
|
||||
|
||||
if (getCurrentNotePath() !== notePath) {
|
||||
console.log("Switching to " + notePath + " because of hash change");
|
||||
console.debug("Switching to " + notePath + " because of hash change");
|
||||
|
||||
activateNote(notePath);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ class TreeCache {
|
||||
|
||||
return noteIds.map(noteId => {
|
||||
if (!this.notes[noteId] && !silentNotFoundError) {
|
||||
messagingService.logError(`Can't find note ${noteId}`);
|
||||
messagingService.logError(`Can't find note "${noteId}"`);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user