Skip to content

Build your personal knowledge base with Trilium Notes

setting the relation target note

zadam62cacf85ed43
diff --git a/package-lock.json b/package-lock.json
index 1ba45bc9e6..f0c5cae9c2 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -573,9 +573,9 @@
"integrity": "sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ=="
},
"@types/estree": {
- "version": "0.0.42",
- "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.42.tgz",
- "integrity": "sha512-K1DPVvnBCPxzD+G51/cxVIoc2X8uUVl1zpJeE6iKcgHMj4+tbat5Xu4TjV7v2QSDbIeAfLi2hIk+u2+s0MlpUQ==",
+ "version": "0.0.45",
+ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.45.tgz",
+ "integrity": "sha512-jnqIUKDUqJbDIUxm0Uj7bnlMnRm1T/eZ9N+AVMqhPgzrba2GhGG5o/jCTwmdPK709nEZsGoMzXEDUjcXHa3W0g==",
"dev": true
},
"@types/events": {
@@ -2841,9 +2841,9 @@
}
},
"electron": {
- "version": "10.0.0-beta.9",
- "resolved": "https://registry.npmjs.org/electron/-/electron-10.0.0-beta.9.tgz",
- "integrity": "sha512-trK7AsHIr8+f5kfCVLM/IAiHhr0CVIpf6GEokvkUMqoi/6q3q2PAgeaPnQhb102AREwKruCiE/wVEXCZiY7spQ==",
+ "version": "10.0.0-beta.10",
+ "resolved": "https://registry.npmjs.org/electron/-/electron-10.0.0-beta.10.tgz",
+ "integrity": "sha512-ARJaqzKFjP3DSyv0G50Uo3JMvi+kMP6k4J2pJXPhWJt7BZkI/AV2aWlHqe4SxBYRKuiUtFW16dF/wMcIWU2sdA==",
"dev": true,
"requires": {
"@electron/get": "^1.0.1",
@@ -3470,9 +3470,9 @@
}
},
"enhanced-resolve": {
- "version": "5.0.0-beta.7",
- "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.0.0-beta.7.tgz",
- "integrity": "sha512-4r9mhIEedx7IsNgutSPyFtD0hKukbknr8Fuee36IXg9dYcAeDLb7l6LzBAeiDBgUKeFv+OgMSkCyp/SGCZ5Xag==",
+ "version": "5.0.0-beta.8",
+ "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.0.0-beta.8.tgz",
+ "integrity": "sha512-6MteIR5h29V8UAsBVXkW7P2cAf+5p/c+Gu79xNCpBPt+hgKcJ0vujcX4vAiMGJjyq3SCHaY5N64C8HXwwRS3gQ==",
"dev": true,
"requires": {
"graceful-fs": "^4.2.0",
@@ -5160,9 +5160,9 @@
}
},
"loader-runner": {
- "version": "3.1.0",
- "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-3.1.0.tgz",
- "integrity": "sha512-wE/bOCdTKMR2rm7Xxh+eirDOmN7Vx7hntWgiTayuFPtF8MgsFDo49SP8kkYz8IVlEBTOtR7P+XI7bE1xjo/IkA==",
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.0.0.tgz",
+ "integrity": "sha512-Rqf48ufrr48gFjnaqss04QesoXB7VenbpFFIV/0yOKGnpbejrVlOPqTsoX42FG5goXM5Ixekcs4DqDzHOX2z7Q==",
"dev": true
},
"locate-path": {
@@ -5608,9 +5608,9 @@
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
},
"neo-async": {
- "version": "2.6.1",
- "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz",
- "integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==",
+ "version": "2.6.2",
+ "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
+ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
"dev": true
},
"nocache": {
@@ -6901,9 +6901,9 @@
},
"dependencies": {
"ajv": {
- "version": "6.12.2",
- "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.2.tgz",
- "integrity": "sha512-k+V+hzjm5q/Mr8ef/1Y9goCmlsK4I6Sm74teeyGvFk1XrOsbsKLjEdrvny42CZ+a8sXbk8KWpY/bDwS+FLL2UQ==",
+ "version": "6.12.3",
+ "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.3.tgz",
+ "integrity": "sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA==",
"dev": true,
"requires": {
"fast-deep-equal": "^3.1.1",
@@ -8027,25 +8027,25 @@
"integrity": "sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA=="
},
"webpack": {
- "version": "5.0.0-beta.20",
- "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.0.0-beta.20.tgz",
- "integrity": "sha512-bIUAephArRkyWBzhLJ7OD5ys+jTNgANuJJy4+qhAWd5De4T0l/qKrVYdXZCbAj3PXUdxyEL5KsJHPQHacyfBGQ==",
+ "version": "5.0.0-beta.22",
+ "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.0.0-beta.22.tgz",
+ "integrity": "sha512-t3HnQPy88PASM2ur0rvUXau8vAz287BlH8DpiaHoWkjlLThLx7olzExtTsVJEFen/9uTfWOV21dWS8kiYmGLkA==",
"dev": true,
"requires": {
- "@types/estree": "0.0.42",
+ "@types/estree": "^0.0.45",
"@webassemblyjs/ast": "1.9.0",
"@webassemblyjs/helper-module-context": "1.9.0",
"@webassemblyjs/wasm-edit": "1.9.0",
"@webassemblyjs/wasm-parser": "1.9.0",
- "acorn": "^7.0.0",
+ "acorn": "^7.3.0",
"chrome-trace-event": "^1.0.2",
- "enhanced-resolve": "5.0.0-beta.7",
+ "enhanced-resolve": "5.0.0-beta.8",
"eslint-scope": "^5.0.0",
"events": "^3.0.0",
"glob-to-regexp": "^0.4.1",
"graceful-fs": "^4.1.15",
"json-parse-better-errors": "^1.0.2",
- "loader-runner": "^3.1.0",
+ "loader-runner": "^4.0.0",
"mime-types": "^2.1.26",
"neo-async": "^2.6.1",
"pkg-dir": "^4.2.0",
@@ -8054,6 +8054,14 @@
"terser-webpack-plugin": "^3.0.2",
"watchpack": "2.0.0-beta.13",
"webpack-sources": "2.0.0-beta.8"
+ },
+ "dependencies": {
+ "acorn": {
+ "version": "7.3.1",
+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.3.1.tgz",
+ "integrity": "sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==",
+ "dev": true
+ }
}
},
"webpack-cli": {
diff --git a/package.json b/package.json
index 2fabe2f858..b20b077820 100644
--- a/package.json
+++ b/package.json
@@ -75,7 +75,7 @@
},
"devDependencies": {
"cross-env": "^7.0.2",
- "electron": "10.0.0-beta.9",
+ "electron": "10.0.0-beta.10",
"electron-builder": "22.7.0",
"electron-packager": "15.0.0",
"electron-rebuild": "1.11.0",
@@ -83,7 +83,7 @@
"jasmine": "^3.5.0",
"jsdoc": "3.6.4",
"lorem-ipsum": "2.0.3",
- "webpack": "5.0.0-beta.20",
+ "webpack": "5.0.0-beta.22",
"webpack-cli": "4.0.0-beta.8"
},
"optionalDependencies": {
diff --git a/src/public/app/dialogs/add_link.js b/src/public/app/dialogs/add_link.js
index 47270c164d..69fddb4ec4 100644
--- a/src/public/app/dialogs/add_link.js
+++ b/src/public/app/dialogs/add_link.js
@@ -42,11 +42,11 @@ export async function showDialog(widget) {
noteAutocompleteService.initNoteAutocomplete($autoComplete);
$autoComplete.on('autocomplete:selected', function(event, suggestion, dataset) {
- if (!suggestion.path) {
+ if (!suggestion.notePath) {
return false;
}
- const noteId = treeService.getNoteIdFromNotePath(suggestion.path);
+ const noteId = treeService.getNoteIdFromNotePath(suggestion.notePath);
if (noteId) {
setDefaultLinkTitle(noteId);
@@ -54,7 +54,7 @@ export async function showDialog(widget) {
});
$autoComplete.on('autocomplete:cursorchanged', function(event, suggestion, dataset) {
- const noteId = treeService.getNoteIdFromNotePath(suggestion.path);
+ const noteId = treeService.getNoteIdFromNotePath(suggestion.notePath);
if (noteId) {
setDefaultLinkTitle(noteId);
diff --git a/src/public/app/dialogs/jump_to_note.js b/src/public/app/dialogs/jump_to_note.js
index a420abd95b..05eef54c6f 100644
--- a/src/public/app/dialogs/jump_to_note.js
+++ b/src/public/app/dialogs/jump_to_note.js
@@ -13,11 +13,11 @@ export async function showDialog() {
noteAutocompleteService.initNoteAutocomplete($autoComplete, { hideGoToSelectedNoteButton: true })
.on('autocomplete:selected', function(event, suggestion, dataset) {
- if (!suggestion.path) {
+ if (!suggestion.notePath) {
return false;
}
- appContext.tabManager.getActiveTabContext().setNote(suggestion.path);
+ appContext.tabManager.getActiveTabContext().setNote(suggestion.notePath);
});
noteAutocompleteService.showRecentNotes($autoComplete);
diff --git a/src/public/app/widgets/attribute_detail.js b/src/public/app/widgets/attribute_detail.js
index 289a0b30c0..3a44cf4761 100644
--- a/src/public/app/widgets/attribute_detail.js
+++ b/src/public/app/widgets/attribute_detail.js
@@ -3,6 +3,7 @@ import treeCache from "../services/tree_cache.js";
import treeService from "../services/tree.js";
import linkService from "../services/link.js";
import BasicWidget from "./basic_widget.js";
+import noteAutocompleteService from "../services/note_autocomplete.js";
const TPL = `
<div class="attr-detail" style="display: none;">
@@ -57,28 +58,22 @@ const TPL = `
<th>Name:</th>
<td><input type="text" class="attr-edit-name form-control form-control-sm" /></td>
</tr>
- <tr>
+ <tr class="attr-value-row">
<th>Value:</th>
<td><input type="text" class="attr-edit-value form-control form-control-sm" /></td>
</tr>
+ <tr class="attr-target-note-row">
+ <th>Target note:</th>
+ <td>
+ <div class="input-group">
+ <input type="text" class="attr-edit-target-note form-control" />
+ </div>
+ </td>
+ </tr>
<tr>
<th>Inheritable:</th>
<td><input type="checkbox" class="attr-edit-inheritable form-control form-control-sm" /></td>
</tr>
- <tr>
- <td colspan="2" class="attr-edit-button-row">
- <div style="display: flex; justify-content: space-between">
- <div>
- <button type="submit" class="btn btn-sm btn-primary">Save</button>
- <button type="submit" class="btn btn-sm btn-secondary">Cancel</button>
- </div>
-
- <div>
- <button type="submit" class="btn btn-sm btn-danger">Delete</button>
- </div>
- </div>
- </td>
- </tr>
</table>
<br/>
@@ -99,17 +94,37 @@ export default class AttributeDetailWidget extends BasicWidget {
this.$relatedNotesTitle = this.$widget.find('.related-notes-tile');
this.$relatedNotesList = this.$widget.find('.related-notes-list');
this.$relatedNotesMoreNotes = this.$widget.find('.related-notes-more-notes');
+
this.$attrEditName = this.$widget.find('.attr-edit-name');
+ this.$attrEditName.on('keyup', () => this.updateParent());
+
+ this.$attrValueRow = this.$widget.find('.attr-value-row');
this.$attrEditValue = this.$widget.find('.attr-edit-value');
+ this.$attrEditValue.on('keyup', () => this.updateParent());
+
+ this.$attrTargetNoteRow = this.$widget.find('.attr-target-note-row');
+ this.$attrEditTargetNote = this.$widget.find('.attr-edit-target-note');
+
+ noteAutocompleteService.initNoteAutocomplete(this.$attrEditTargetNote)
+ .on('autocomplete:selected', (event, suggestion, dataset) => {
+ if (!suggestion.notePath) {
+ return false;
+ }
+
+ this.attribute.value = suggestion.notePath;
+
+ this.triggerCommand('updateAttributeList', { attributes: this.allAttributes });
+ });
+
this.$attrEditInheritable = this.$widget.find('.attr-edit-inheritable');
- this.$attrEditButtonRow = this.$widget.find('.attr-edit-button-row');
this.$closeAttrDetailButton = this.$widget.find('.close-attr-detail-button');
this.$attrIsOwnedBy = this.$widget.find('.attr-is-owned-by');
this.$closeAttrDetailButton.on('click', () => this.hide());
$(window).on('mouseup', e => {
- if (!$(e.target).closest(this.$widget[0]).length) {
+ if (!$(e.target).closest(this.$widget[0]).length
+ && !$(e.target).closest(".algolia-autocomplete").length) {
this.hide();
}
});
@@ -176,15 +191,24 @@ export default class AttributeDetailWidget extends BasicWidget {
this.$attrEditName
.val(attribute.name)
- .attr('readonly', () => !isOwned)
- .on('keyup', () => this.updateParent());
+ .attr('readonly', () => !isOwned);
+
+ this.$attrValueRow.toggle(attribute.type === 'label');
+ this.$attrTargetNoteRow.toggle(attribute.type === 'relation');
- this.$attrEditValue
- .val(attribute.value)
- .attr('readonly', () => !isOwned)
- .on('keyup', () => this.updateParent());
+ if (attribute.type === 'label') {
+ this.$attrEditValue
+ .val(attribute.value)
+ .attr('readonly', () => !isOwned);
+ }
+ else if (attribute.type === 'relation') {
+ const targetNote = await treeCache.getNote(attribute.value);
- this.$attrEditButtonRow.toggle(!!isOwned);
+ this.$attrEditTargetNote
+ .attr('readonly', () => !isOwned)
+ .val(targetNote ? targetNote.title : "")
+ .setSelectedNotePath(attribute.value);
+ }
this.$widget.css("left", x - this.$widget.width() / 2);
this.$widget.css("top", y + 30);
diff --git a/src/public/app/widgets/type_widgets/empty.js b/src/public/app/widgets/type_widgets/empty.js
index 4ca8f5a6b4..d0156e7a5e 100644
--- a/src/public/app/widgets/type_widgets/empty.js
+++ b/src/public/app/widgets/type_widgets/empty.js
@@ -23,11 +23,11 @@ export default class EmptyTypeWidget extends TypeWidget {
noteAutocompleteService.initNoteAutocomplete(this.$autoComplete, { hideGoToSelectedNoteButton: true })
.on('autocomplete:selected', function(event, suggestion, dataset) {
- if (!suggestion.path) {
+ if (!suggestion.notePath) {
return false;
}
- appContext.tabManager.getActiveTabContext().setNote(suggestion.path);
+ appContext.tabManager.getActiveTabContext().setNote(suggestion.notePath);
});
noteAutocompleteService.showRecentNotes(this.$autoComplete);