setting the relation target note

This commit is contained in:
zadam 2020-07-13 00:15:00 +02:00
parent 1c97310e92
commit 62cacf85ed
6 changed files with 90 additions and 58 deletions

58
package-lock.json generated
View File

@ -573,9 +573,9 @@
"integrity": "sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ==" "integrity": "sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ=="
}, },
"@types/estree": { "@types/estree": {
"version": "0.0.42", "version": "0.0.45",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.42.tgz", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.45.tgz",
"integrity": "sha512-K1DPVvnBCPxzD+G51/cxVIoc2X8uUVl1zpJeE6iKcgHMj4+tbat5Xu4TjV7v2QSDbIeAfLi2hIk+u2+s0MlpUQ==", "integrity": "sha512-jnqIUKDUqJbDIUxm0Uj7bnlMnRm1T/eZ9N+AVMqhPgzrba2GhGG5o/jCTwmdPK709nEZsGoMzXEDUjcXHa3W0g==",
"dev": true "dev": true
}, },
"@types/events": { "@types/events": {
@ -2841,9 +2841,9 @@
} }
}, },
"electron": { "electron": {
"version": "10.0.0-beta.9", "version": "10.0.0-beta.10",
"resolved": "https://registry.npmjs.org/electron/-/electron-10.0.0-beta.9.tgz", "resolved": "https://registry.npmjs.org/electron/-/electron-10.0.0-beta.10.tgz",
"integrity": "sha512-trK7AsHIr8+f5kfCVLM/IAiHhr0CVIpf6GEokvkUMqoi/6q3q2PAgeaPnQhb102AREwKruCiE/wVEXCZiY7spQ==", "integrity": "sha512-ARJaqzKFjP3DSyv0G50Uo3JMvi+kMP6k4J2pJXPhWJt7BZkI/AV2aWlHqe4SxBYRKuiUtFW16dF/wMcIWU2sdA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@electron/get": "^1.0.1", "@electron/get": "^1.0.1",
@ -3470,9 +3470,9 @@
} }
}, },
"enhanced-resolve": { "enhanced-resolve": {
"version": "5.0.0-beta.7", "version": "5.0.0-beta.8",
"resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.0.0-beta.7.tgz", "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.0.0-beta.8.tgz",
"integrity": "sha512-4r9mhIEedx7IsNgutSPyFtD0hKukbknr8Fuee36IXg9dYcAeDLb7l6LzBAeiDBgUKeFv+OgMSkCyp/SGCZ5Xag==", "integrity": "sha512-6MteIR5h29V8UAsBVXkW7P2cAf+5p/c+Gu79xNCpBPt+hgKcJ0vujcX4vAiMGJjyq3SCHaY5N64C8HXwwRS3gQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"graceful-fs": "^4.2.0", "graceful-fs": "^4.2.0",
@ -5160,9 +5160,9 @@
} }
}, },
"loader-runner": { "loader-runner": {
"version": "3.1.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-3.1.0.tgz", "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.0.0.tgz",
"integrity": "sha512-wE/bOCdTKMR2rm7Xxh+eirDOmN7Vx7hntWgiTayuFPtF8MgsFDo49SP8kkYz8IVlEBTOtR7P+XI7bE1xjo/IkA==", "integrity": "sha512-Rqf48ufrr48gFjnaqss04QesoXB7VenbpFFIV/0yOKGnpbejrVlOPqTsoX42FG5goXM5Ixekcs4DqDzHOX2z7Q==",
"dev": true "dev": true
}, },
"locate-path": { "locate-path": {
@ -5608,9 +5608,9 @@
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
}, },
"neo-async": { "neo-async": {
"version": "2.6.1", "version": "2.6.2",
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.1.tgz", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
"integrity": "sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==", "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
"dev": true "dev": true
}, },
"nocache": { "nocache": {
@ -6901,9 +6901,9 @@
}, },
"dependencies": { "dependencies": {
"ajv": { "ajv": {
"version": "6.12.2", "version": "6.12.3",
"resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.2.tgz", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.3.tgz",
"integrity": "sha512-k+V+hzjm5q/Mr8ef/1Y9goCmlsK4I6Sm74teeyGvFk1XrOsbsKLjEdrvny42CZ+a8sXbk8KWpY/bDwS+FLL2UQ==", "integrity": "sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA==",
"dev": true, "dev": true,
"requires": { "requires": {
"fast-deep-equal": "^3.1.1", "fast-deep-equal": "^3.1.1",
@ -8027,25 +8027,25 @@
"integrity": "sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA==" "integrity": "sha512-VlZwKPCkYKxQgeSbH5EyngOmRp7Ww7I9rQLERETtf5ofd9pGeswWiOtogpEO850jziPRarreGxn5QIiTqpb2wA=="
}, },
"webpack": { "webpack": {
"version": "5.0.0-beta.20", "version": "5.0.0-beta.22",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-5.0.0-beta.20.tgz", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.0.0-beta.22.tgz",
"integrity": "sha512-bIUAephArRkyWBzhLJ7OD5ys+jTNgANuJJy4+qhAWd5De4T0l/qKrVYdXZCbAj3PXUdxyEL5KsJHPQHacyfBGQ==", "integrity": "sha512-t3HnQPy88PASM2ur0rvUXau8vAz287BlH8DpiaHoWkjlLThLx7olzExtTsVJEFen/9uTfWOV21dWS8kiYmGLkA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/estree": "0.0.42", "@types/estree": "^0.0.45",
"@webassemblyjs/ast": "1.9.0", "@webassemblyjs/ast": "1.9.0",
"@webassemblyjs/helper-module-context": "1.9.0", "@webassemblyjs/helper-module-context": "1.9.0",
"@webassemblyjs/wasm-edit": "1.9.0", "@webassemblyjs/wasm-edit": "1.9.0",
"@webassemblyjs/wasm-parser": "1.9.0", "@webassemblyjs/wasm-parser": "1.9.0",
"acorn": "^7.0.0", "acorn": "^7.3.0",
"chrome-trace-event": "^1.0.2", "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", "eslint-scope": "^5.0.0",
"events": "^3.0.0", "events": "^3.0.0",
"glob-to-regexp": "^0.4.1", "glob-to-regexp": "^0.4.1",
"graceful-fs": "^4.1.15", "graceful-fs": "^4.1.15",
"json-parse-better-errors": "^1.0.2", "json-parse-better-errors": "^1.0.2",
"loader-runner": "^3.1.0", "loader-runner": "^4.0.0",
"mime-types": "^2.1.26", "mime-types": "^2.1.26",
"neo-async": "^2.6.1", "neo-async": "^2.6.1",
"pkg-dir": "^4.2.0", "pkg-dir": "^4.2.0",
@ -8054,6 +8054,14 @@
"terser-webpack-plugin": "^3.0.2", "terser-webpack-plugin": "^3.0.2",
"watchpack": "2.0.0-beta.13", "watchpack": "2.0.0-beta.13",
"webpack-sources": "2.0.0-beta.8" "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": { "webpack-cli": {

View File

@ -75,7 +75,7 @@
}, },
"devDependencies": { "devDependencies": {
"cross-env": "^7.0.2", "cross-env": "^7.0.2",
"electron": "10.0.0-beta.9", "electron": "10.0.0-beta.10",
"electron-builder": "22.7.0", "electron-builder": "22.7.0",
"electron-packager": "15.0.0", "electron-packager": "15.0.0",
"electron-rebuild": "1.11.0", "electron-rebuild": "1.11.0",
@ -83,7 +83,7 @@
"jasmine": "^3.5.0", "jasmine": "^3.5.0",
"jsdoc": "3.6.4", "jsdoc": "3.6.4",
"lorem-ipsum": "2.0.3", "lorem-ipsum": "2.0.3",
"webpack": "5.0.0-beta.20", "webpack": "5.0.0-beta.22",
"webpack-cli": "4.0.0-beta.8" "webpack-cli": "4.0.0-beta.8"
}, },
"optionalDependencies": { "optionalDependencies": {

View File

@ -42,11 +42,11 @@ export async function showDialog(widget) {
noteAutocompleteService.initNoteAutocomplete($autoComplete); noteAutocompleteService.initNoteAutocomplete($autoComplete);
$autoComplete.on('autocomplete:selected', function(event, suggestion, dataset) { $autoComplete.on('autocomplete:selected', function(event, suggestion, dataset) {
if (!suggestion.path) { if (!suggestion.notePath) {
return false; return false;
} }
const noteId = treeService.getNoteIdFromNotePath(suggestion.path); const noteId = treeService.getNoteIdFromNotePath(suggestion.notePath);
if (noteId) { if (noteId) {
setDefaultLinkTitle(noteId); setDefaultLinkTitle(noteId);
@ -54,7 +54,7 @@ export async function showDialog(widget) {
}); });
$autoComplete.on('autocomplete:cursorchanged', function(event, suggestion, dataset) { $autoComplete.on('autocomplete:cursorchanged', function(event, suggestion, dataset) {
const noteId = treeService.getNoteIdFromNotePath(suggestion.path); const noteId = treeService.getNoteIdFromNotePath(suggestion.notePath);
if (noteId) { if (noteId) {
setDefaultLinkTitle(noteId); setDefaultLinkTitle(noteId);

View File

@ -13,11 +13,11 @@ export async function showDialog() {
noteAutocompleteService.initNoteAutocomplete($autoComplete, { hideGoToSelectedNoteButton: true }) noteAutocompleteService.initNoteAutocomplete($autoComplete, { hideGoToSelectedNoteButton: true })
.on('autocomplete:selected', function(event, suggestion, dataset) { .on('autocomplete:selected', function(event, suggestion, dataset) {
if (!suggestion.path) { if (!suggestion.notePath) {
return false; return false;
} }
appContext.tabManager.getActiveTabContext().setNote(suggestion.path); appContext.tabManager.getActiveTabContext().setNote(suggestion.notePath);
}); });
noteAutocompleteService.showRecentNotes($autoComplete); noteAutocompleteService.showRecentNotes($autoComplete);

View File

@ -3,6 +3,7 @@ import treeCache from "../services/tree_cache.js";
import treeService from "../services/tree.js"; import treeService from "../services/tree.js";
import linkService from "../services/link.js"; import linkService from "../services/link.js";
import BasicWidget from "./basic_widget.js"; import BasicWidget from "./basic_widget.js";
import noteAutocompleteService from "../services/note_autocomplete.js";
const TPL = ` const TPL = `
<div class="attr-detail" style="display: none;"> <div class="attr-detail" style="display: none;">
@ -57,28 +58,22 @@ const TPL = `
<th>Name:</th> <th>Name:</th>
<td><input type="text" class="attr-edit-name form-control form-control-sm" /></td> <td><input type="text" class="attr-edit-name form-control form-control-sm" /></td>
</tr> </tr>
<tr> <tr class="attr-value-row">
<th>Value:</th> <th>Value:</th>
<td><input type="text" class="attr-edit-value form-control form-control-sm" /></td> <td><input type="text" class="attr-edit-value form-control form-control-sm" /></td>
</tr> </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> <tr>
<th>Inheritable:</th> <th>Inheritable:</th>
<td><input type="checkbox" class="attr-edit-inheritable form-control form-control-sm" /></td> <td><input type="checkbox" class="attr-edit-inheritable form-control form-control-sm" /></td>
</tr> </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> </table>
<br/> <br/>
@ -99,17 +94,37 @@ export default class AttributeDetailWidget extends BasicWidget {
this.$relatedNotesTitle = this.$widget.find('.related-notes-tile'); this.$relatedNotesTitle = this.$widget.find('.related-notes-tile');
this.$relatedNotesList = this.$widget.find('.related-notes-list'); this.$relatedNotesList = this.$widget.find('.related-notes-list');
this.$relatedNotesMoreNotes = this.$widget.find('.related-notes-more-notes'); this.$relatedNotesMoreNotes = this.$widget.find('.related-notes-more-notes');
this.$attrEditName = this.$widget.find('.attr-edit-name'); 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 = 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.$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.$closeAttrDetailButton = this.$widget.find('.close-attr-detail-button');
this.$attrIsOwnedBy = this.$widget.find('.attr-is-owned-by'); this.$attrIsOwnedBy = this.$widget.find('.attr-is-owned-by');
this.$closeAttrDetailButton.on('click', () => this.hide()); this.$closeAttrDetailButton.on('click', () => this.hide());
$(window).on('mouseup', e => { $(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(); this.hide();
} }
}); });
@ -176,15 +191,24 @@ export default class AttributeDetailWidget extends BasicWidget {
this.$attrEditName this.$attrEditName
.val(attribute.name) .val(attribute.name)
.attr('readonly', () => !isOwned) .attr('readonly', () => !isOwned);
.on('keyup', () => this.updateParent());
this.$attrEditValue this.$attrValueRow.toggle(attribute.type === 'label');
.val(attribute.value) this.$attrTargetNoteRow.toggle(attribute.type === 'relation');
.attr('readonly', () => !isOwned)
.on('keyup', () => this.updateParent());
this.$attrEditButtonRow.toggle(!!isOwned); 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.$attrEditTargetNote
.attr('readonly', () => !isOwned)
.val(targetNote ? targetNote.title : "")
.setSelectedNotePath(attribute.value);
}
this.$widget.css("left", x - this.$widget.width() / 2); this.$widget.css("left", x - this.$widget.width() / 2);
this.$widget.css("top", y + 30); this.$widget.css("top", y + 30);

View File

@ -23,11 +23,11 @@ export default class EmptyTypeWidget extends TypeWidget {
noteAutocompleteService.initNoteAutocomplete(this.$autoComplete, { hideGoToSelectedNoteButton: true }) noteAutocompleteService.initNoteAutocomplete(this.$autoComplete, { hideGoToSelectedNoteButton: true })
.on('autocomplete:selected', function(event, suggestion, dataset) { .on('autocomplete:selected', function(event, suggestion, dataset) {
if (!suggestion.path) { if (!suggestion.notePath) {
return false; return false;
} }
appContext.tabManager.getActiveTabContext().setNote(suggestion.path); appContext.tabManager.getActiveTabContext().setNote(suggestion.notePath);
}); });
noteAutocompleteService.showRecentNotes(this.$autoComplete); noteAutocompleteService.showRecentNotes(this.$autoComplete);