diff --git a/package-lock.json b/package-lock.json index 076adf23e..a29bc6cb2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2841,9 +2841,9 @@ } }, "electron": { - "version": "10.0.0-beta.8", - "resolved": "https://registry.npmjs.org/electron/-/electron-10.0.0-beta.8.tgz", - "integrity": "sha512-LTGVPTwBZkKNMNO8RP6ibBdAOyfnc8MFOS8ULYIavsPWMVDR4FwJJoq08++MnbYxV79/6P5SvPy1BCnSpetmTQ==", + "version": "10.0.0-beta.4", + "resolved": "https://registry.npmjs.org/electron/-/electron-10.0.0-beta.4.tgz", + "integrity": "sha512-/Jp9i0yiuM/WUdiKFjf7+5gZQJITGhijl++Zp31m94MY+QNMLEnFhaKLSqzrmPA2FPrXn2KlUPNpQs+4Wjcvpg==", "dev": true, "requires": { "@electron/get": "^1.0.1", diff --git a/package.json b/package.json index 4ba1a0426..f33fd258e 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ }, "devDependencies": { "cross-env": "^7.0.2", - "electron": "10.0.0-beta.8", + "electron": "10.0.0-beta.4", "electron-builder": "22.7.0", "electron-packager": "15.0.0", "electron-rebuild": "1.11.0", diff --git a/src/public/app/layouts/desktop_main_window_layout.js b/src/public/app/layouts/desktop_main_window_layout.js index 3d6ce0d5d..4e9fbf954 100644 --- a/src/public/app/layouts/desktop_main_window_layout.js +++ b/src/public/app/layouts/desktop_main_window_layout.js @@ -19,7 +19,6 @@ import PromotedAttributesWidget from "../widgets/promoted_attributes.js"; import NoteDetailWidget from "../widgets/note_detail.js"; import NoteInfoWidget from "../widgets/collapsible_widgets/note_info.js"; import CalendarWidget from "../widgets/collapsible_widgets/calendar.js"; -import AttributesWidget from "../widgets/collapsible_widgets/attributes.js"; import LinkMapWidget from "../widgets/collapsible_widgets/link_map.js"; import NoteRevisionsWidget from "../widgets/collapsible_widgets/note_revisions.js"; import SimilarNotesWidget from "../widgets/collapsible_widgets/similar_notes.js"; @@ -147,7 +146,6 @@ export default class DesktopMainWindowLayout { .child(new NoteInfoWidget()) .child(new TabCachingWidget(() => new CalendarWidget())) .child(new TabCachingWidget(() => new EditedNotesWidget())) - .child(new TabCachingWidget(() => new AttributesWidget())) .child(new TabCachingWidget(() => new LinkMapWidget())) .child(new TabCachingWidget(() => new NoteRevisionsWidget())) .child(new TabCachingWidget(() => new SimilarNotesWidget())) diff --git a/src/public/app/widgets/attribute_detail.js b/src/public/app/widgets/attribute_detail.js index 8e3bc2d4e..2cc115700 100644 --- a/src/public/app/widgets/attribute_detail.js +++ b/src/public/app/widgets/attribute_detail.js @@ -105,8 +105,6 @@ export default class AttributeDetailWidget extends BasicWidget { this.$closeAttrDetailButton.on('click', () => this.hide()); $(window).on('mouseup', e => { - console.log("click", e.target); - if (!$(e.target).closest(this.$widget[0]).length) { this.hide(); } diff --git a/src/public/app/widgets/collapsible_widgets/attributes.js b/src/public/app/widgets/collapsible_widgets/attributes.js deleted file mode 100644 index 25a136dec..000000000 --- a/src/public/app/widgets/collapsible_widgets/attributes.js +++ /dev/null @@ -1,94 +0,0 @@ -import utils from "../../services/utils.js"; -import linkService from "../../services/link.js"; -import ws from "../../services/ws.js"; -import CollapsibleWidget from "../collapsible_widget.js"; - -export default class AttributesWidget extends CollapsibleWidget { - get widgetTitle() { return "Attributes"; } - - get help() { - return { - title: "Attributes are key-value records owned by assigned to this note.", - url: "https://github.com/zadam/trilium/wiki/Attributes" - }; - } - - get headerActions() { - const $showFullButton = $("").append("show dialog").addClass('widget-header-action'); - $showFullButton.on('click', async () => { - const attributesDialog = await import("../../dialogs/attributes.js"); - attributesDialog.showDialog(); - }); - - return [$showFullButton]; - } - - async refreshWithNote(note) { - const ownedAttributes = note.getOwnedAttributes(); - const $attributesContainer = $("
"); - - await this.renderAttributes(ownedAttributes, $attributesContainer); - - const $inheritedAttrs = $("").append($("").text("Inherited: ")); - const $showInheritedAttributes = $("") - .attr("href", "javascript:") - .text("+show inherited") - .on('click', async () => { - const attributes = note.getAttributes(); - const inheritedAttributes = attributes.filter(attr => attr.noteId !== this.noteId); - - if (inheritedAttributes.length === 0) { - $inheritedAttrs.text("No inherited attributes yet..."); - } - else { - await this.renderAttributes(inheritedAttributes, $inheritedAttrs); - } - - $inheritedAttrs.show(); - $showInheritedAttributes.hide(); - $hideInheritedAttributes.show(); - }); - - const $hideInheritedAttributes = $("") - .attr("href", "javascript:") - .text("-hide inherited") - .on('click', () => { - $showInheritedAttributes.show(); - $hideInheritedAttributes.hide(); - $inheritedAttrs.empty().hide(); - }); - - $attributesContainer.append($showInheritedAttributes, $inheritedAttrs, $hideInheritedAttributes); - - $inheritedAttrs.hide(); - $hideInheritedAttributes.hide(); - - this.$body.empty().append($attributesContainer); - } - - async renderAttributes(attributes, $container) { - for (const attribute of attributes) { - if (attribute.type === 'label') { - $container.append(utils.formatLabel(attribute) + " "); - } else if (attribute.type === 'relation') { - if (attribute.value) { - $container.append('@' + attribute.name + "="); - $container.append(await linkService.createNoteLink(attribute.value)); - $container.append(" "); - } else { - ws.logError(`Relation ${attribute.attributeId} has empty target`); - } - } else if (attribute.type === 'label-definition' || attribute.type === 'relation-definition') { - $container.append(attribute.name + " definition "); - } else { - ws.logError("Unknown attr type: " + attribute.type); - } - } - } - - entitiesReloadedEvent({loadResults}) { - if (loadResults.getAttributes().find(attr => attr.noteId === this.noteId)) { - this.refresh(); - } - } -} \ No newline at end of file diff --git a/src/public/app/widgets/note_attributes.js b/src/public/app/widgets/note_attributes.js index 81bff329b..484e73636 100644 --- a/src/public/app/widgets/note_attributes.js +++ b/src/public/app/widgets/note_attributes.js @@ -7,6 +7,7 @@ import ws from "../services/ws.js"; import SpacedUpdate from "../services/spaced_update.js"; import attributesParser from "../services/attribute_parser.js"; import AttributeDetailWidget from "./attribute_detail.js"; +import contextMenuService from "../services/context_menu.js"; const mentionSetup = { feeds: [ @@ -144,6 +145,19 @@ const TPL = ` .attr-expander.error hr { border-color: red; } + + .add-new-attribute-button { + position: absolute; + bottom: 5px; + right: 5px; + cursor: pointer; + border: 1px solid transparent; + } + + .add-new-attribute-button:hover { + border: 1px solid var(--main-border-color); + border-radius: 2px; + }
@@ -155,7 +169,11 @@ const TPL = `
-
+
+
+ +
+

@@ -234,6 +252,24 @@ export default class NoteAttributesWidget extends TabAwareWidget { this.attributeDetailWidget.hide(); }); + this.$addNewAttributeButton = this.$widget.find('.add-new-attribute-button'); + this.$addNewAttributeButton.on('click', e => { + contextMenuService.show({ + x: e.pageX, + y: e.pageY, + items: [ + {title: "Add new label", command: "addNewLabel", uiIcon: "hash"}, + {title: "Add new relation", command: "addNewRelation", uiIcon: "transfer"}, + {title: "----"}, + {title: "Add new label definition", command: "addNewRelation", uiIcon: "empty"}, + {title: "Add new relation definition", command: "addNewRelation", uiIcon: "empty"}, + ], + selectMenuItemHandler: ({command}) => { + console.log(command); + } + }); + }); + this.$widget.append(this.attributeDetailWidget.render()); } @@ -389,7 +425,7 @@ export default class NoteAttributesWidget extends TabAwareWidget { }); const inheritedAttributes = note.getAttributes().filter(attr => attr.noteId !== this.noteId); -console.log("inheritedAttributes", inheritedAttributes); + if (inheritedAttributes.length === 0) { this.$inheritedExpander.hide(); this.$inheritedEmptyExpander.show(); @@ -402,6 +438,8 @@ console.log("inheritedAttributes", inheritedAttributes); this.$inheritedExpanderText.text(inheritedAttributes.length + ' inherited ' + this.attrPlural(inheritedAttributes.length)); await this.renderAttributes(inheritedAttributes, this.$inheritedAttributes); + + this.parseAttributes(); } attrPlural(number) { diff --git a/src/services/backup.js b/src/services/backup.js index 76cdb1256..e5fbf0df2 100644 --- a/src/services/backup.js +++ b/src/services/backup.js @@ -5,18 +5,19 @@ const optionService = require('./options'); const fs = require('fs-extra'); const dataDir = require('./data_dir'); const log = require('./log'); -const sqlInit = require('./sql_init'); const syncMutexService = require('./sync_mutex'); const attributeService = require('./attributes'); const cls = require('./cls'); const Database = require('better-sqlite3'); function regularBackup() { - periodBackup('lastDailyBackupDate', 'daily', 24 * 3600); + cls.init(() => { + periodBackup('lastDailyBackupDate', 'daily', 24 * 3600); - periodBackup('lastWeeklyBackupDate', 'weekly', 7 * 24 * 3600); + periodBackup('lastWeeklyBackupDate', 'weekly', 7 * 24 * 3600); - periodBackup('lastMonthlyBackupDate', 'monthly', 30 * 24 * 3600); + periodBackup('lastMonthlyBackupDate', 'monthly', 30 * 24 * 3600); + }); } function periodBackup(optionName, fileName, periodInSeconds) {