From 9a97fe09ee8eaf4425dfcfbb34652210e38f7ec2 Mon Sep 17 00:00:00 2001 From: zadam Date: Sun, 5 May 2019 18:24:59 +0200 Subject: [PATCH] note actions now work again --- src/public/javascripts/desktop.js | 8 ++-- src/public/javascripts/dialogs/import.js | 2 +- .../javascripts/services/entrypoints.js | 39 ++++++++++--------- .../javascripts/services/note_detail.js | 6 +-- .../services/note_detail_protected_session.js | 18 +++++++++ .../javascripts/services/protected_session.js | 2 +- src/public/stylesheets/desktop.css | 2 +- src/views/dialogs/import.ejs | 2 +- 8 files changed, 49 insertions(+), 30 deletions(-) create mode 100644 src/public/javascripts/services/note_detail_protected_session.js diff --git a/src/public/javascripts/desktop.js b/src/public/javascripts/desktop.js index c34240254..7e5f31c98 100644 --- a/src/public/javascripts/desktop.js +++ b/src/public/javascripts/desktop.js @@ -126,7 +126,9 @@ if (utils.isElectron()) { }); } -$("#export-note-button").click(function () { +const $noteTabContainer = $("#note-tab-container"); + +$noteTabContainer.on("click", ".export-note-button", function () { if ($(this).hasClass("disabled")) { return; } @@ -134,12 +136,12 @@ $("#export-note-button").click(function () { exportDialog.showDialog('single'); }); +$noteTabContainer.on("click", ".import-files-button", importDialog.showDialog); + $('[data-toggle="tooltip"]').tooltip({ html: true }); -$("#import-files-button").click(importDialog.showDialog); - macInit.init(); searchNotesService.init(); // should be in front of treeService since that one manipulates address bar hash diff --git a/src/public/javascripts/dialogs/import.js b/src/public/javascripts/dialogs/import.js index 2402ca297..0f08a0703 100644 --- a/src/public/javascripts/dialogs/import.js +++ b/src/public/javascripts/dialogs/import.js @@ -7,7 +7,7 @@ import messagingService from "../services/messaging.js"; const $dialog = $("#import-dialog"); const $form = $("#import-form"); -const $noteTitle = $dialog.find(".note-title"); +const $noteTitle = $dialog.find(".import-note-title"); const $fileUploadInput = $("#import-file-upload-input"); const $importProgressCountWrapper = $("#import-progress-count-wrapper"); const $importProgressCount = $("#import-progress-count"); diff --git a/src/public/javascripts/services/entrypoints.js b/src/public/javascripts/services/entrypoints.js index e63e98bc5..a169981a5 100644 --- a/src/public/javascripts/services/entrypoints.js +++ b/src/public/javascripts/services/entrypoints.js @@ -28,22 +28,6 @@ function registerEntrypoints() { $("#jump-to-note-dialog-button").click(jumpToNoteDialog.showDialog); utils.bindShortcut('ctrl+j', jumpToNoteDialog.showDialog); - $("#show-note-revisions-button").click(function() { - if ($(this).hasClass("disabled")) { - return; - } - - noteRevisionsDialog.showCurrentNoteRevisions(); - }); - - $("#show-source-button").click(function() { - if ($(this).hasClass("disabled")) { - return; - } - - noteSourceDialog.showDialog(); - }); - $("#recent-changes-button").click(recentChangesDialog.showDialog); $("#enter-protected-session-button").click(protectedSessionService.enterProtectedSession); @@ -52,9 +36,28 @@ function registerEntrypoints() { $("#toggle-search-button").click(searchNotesService.toggleSearch); utils.bindShortcut('ctrl+s', searchNotesService.toggleSearch); - $(".show-attributes-button").click(attributesDialog.showDialog); + const $noteTabContainer = $("#note-tab-container"); + $noteTabContainer.on("click", ".show-attributes-button", attributesDialog.showDialog); utils.bindShortcut('alt+a', attributesDialog.showDialog); + $noteTabContainer.on("click", ".show-note-info-button", noteInfoDialog.showDialog); + + $noteTabContainer.on("click", ".show-note-revisions-button", function() { + if ($(this).hasClass("disabled")) { + return; + } + + noteRevisionsDialog.showCurrentNoteRevisions(); + }); + + $noteTabContainer.on("click", ".show-source-button", function() { + if ($(this).hasClass("disabled")) { + return; + } + + noteSourceDialog.showDialog(); + }); + $("#options-button").click(optionsDialog.showDialog); $("#show-help-button").click(helpDialog.showDialog); @@ -63,8 +66,6 @@ function registerEntrypoints() { $("#open-sql-console-button").click(sqlConsoleDialog.showDialog); utils.bindShortcut('alt+o', sqlConsoleDialog.showDialog); - $("#show-note-info-button").click(noteInfoDialog.showDialog); - $("#show-about-dialog-button").click(aboutDialog.showDialog); if (utils.isElectron()) { diff --git a/src/public/javascripts/services/note_detail.js b/src/public/javascripts/services/note_detail.js index beccf47d5..cd7be2094 100644 --- a/src/public/javascripts/services/note_detail.js +++ b/src/public/javascripts/services/note_detail.js @@ -148,13 +148,11 @@ async function loadNoteDetail(noteId, newTab = false) { if (utils.isDesktop()) { // needs to happen after loading the note itself because it references active noteId - // FIXME - //attributeService.refreshAttributes(); + ctx.attributes.refreshAttributes(); } else { // mobile usually doesn't need attributes so we just invalidate - // FIXME - //attributeService.invalidateAttributes(); + ctx.attributes.invalidateAttributes(); } ctx.updateNoteView(); diff --git a/src/public/javascripts/services/note_detail_protected_session.js b/src/public/javascripts/services/note_detail_protected_session.js new file mode 100644 index 000000000..d0335e968 --- /dev/null +++ b/src/public/javascripts/services/note_detail_protected_session.js @@ -0,0 +1,18 @@ +class NoteDetailImage { + /** + * @param {NoteContext} ctx + */ + constructor(ctx) { + this.ctx = ctx; + this.$component = ctx.$noteTabContent.find(".protected-session-password-component"); + const $passwordForms = ctx.$noteTabContent.find(".protected-session-password-form"); + const $passwordInputs = ctx.$noteTabContent.find(".protected-session-password"); + const $passwordInModal = ctx.$noteTabContent.find(".protected-session-password-in-modal"); + const $protectButton = ctx.$noteTabContent.find(".protect-button"); + const $unprotectButton = ctx.$noteTabContent.find(".unprotect-button"); + } + + show() { + this.$component.show(); + } +} \ No newline at end of file diff --git a/src/public/javascripts/services/protected_session.js b/src/public/javascripts/services/protected_session.js index dab19612a..1319fbb68 100644 --- a/src/public/javascripts/services/protected_session.js +++ b/src/public/javascripts/services/protected_session.js @@ -10,7 +10,7 @@ const $component = $("#protected-session-password-component"); const $passwordForms = $(".protected-session-password-form"); const $passwordInputs = $(".protected-session-password"); const $passwordInModal = $("#protected-session-password-in-modal"); -const $tabContent = $(".note-tab-content"); // FIXME TAB +const $tabContent = $(".note-tab-content"); const $protectButton = $("#protect-button"); const $unprotectButton = $("#unprotect-button"); const $enterProtectedSessionButton = $("#enter-protected-session-button"); diff --git a/src/public/stylesheets/desktop.css b/src/public/stylesheets/desktop.css index c09f21d4c..dbaf4477d 100644 --- a/src/public/stylesheets/desktop.css +++ b/src/public/stylesheets/desktop.css @@ -147,7 +147,7 @@ li.dropdown-submenu:hover > ul.dropdown-menu { border: 1px solid var(--main-border-color); } -.note-info-table td, .note-info-table th { +#note-info-table td, #note-info-table th { padding: 15px; } diff --git a/src/views/dialogs/import.ejs b/src/views/dialogs/import.ejs index 28be7aa3e..6c908e57f 100644 --- a/src/views/dialogs/import.ejs +++ b/src/views/dialogs/import.ejs @@ -18,7 +18,7 @@ -

Content of the file will be imported as child note(s) into . +

Content of the file will be imported as child note(s) into .