diff --git a/src/public/javascripts/dialogs/branch_prefix.js b/src/public/javascripts/dialogs/branch_prefix.js index 8a63dea00..47238149f 100644 --- a/src/public/javascripts/dialogs/branch_prefix.js +++ b/src/public/javascripts/dialogs/branch_prefix.js @@ -24,7 +24,7 @@ async function showDialog() { const noteTitle = await treeUtils.getNoteTitle(currentNode.data.noteId); - $noteTitle.html(noteTitle); + $noteTitle.text(" - " + noteTitle); } async function savePrefix() { diff --git a/src/public/javascripts/services/protected_session.js b/src/public/javascripts/services/protected_session.js index 7f3506f5e..ba71556c5 100644 --- a/src/public/javascripts/services/protected_session.js +++ b/src/public/javascripts/services/protected_session.js @@ -6,8 +6,10 @@ import protectedSessionHolder from './protected_session_holder.js'; import infoService from "./info.js"; const $dialog = $("#protected-session-password-dialog"); -const $passwordForm = $("#protected-session-password-form"); -const $password = $("#protected-session-password"); +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 $noteDetailWrapper = $("#note-detail-wrapper"); const $protectButton = $("#protect-button"); const $unprotectButton = $("#unprotect-button"); @@ -36,12 +38,16 @@ function ensureProtectedSession(requireProtectedSession, modal) { // using deferred instead of promise because it allows resolving from outside protectedSessionDeferred = dfd; - if (treeService.getCurrentNode().data.isProtected) { - $noteDetailWrapper.hide(); - } + if (modal) { + if (treeService.getCurrentNode().data.isProtected) { + $noteDetailWrapper.hide(); + } - $dialog.toggleClass("modalless", !modal); - $dialog.modal(); + $dialog.modal(); + } + else { + $component.show(); + } } else { dfd.resolve(false); @@ -50,9 +56,8 @@ function ensureProtectedSession(requireProtectedSession, modal) { return dfd.promise(); } -async function setupProtectedSession() { - const password = $password.val(); - $password.val(""); +async function setupProtectedSession(password) { + $passwordInputs.val(""); const response = await enterProtectedSessionOnServer(password); @@ -72,7 +77,7 @@ async function setupProtectedSession() { await noteDetailService.reload(); if (protectedSessionDeferred !== null) { - ensureDialogIsClosed($dialog, $password); + ensureDialogIsClosed(); $noteDetailWrapper.show(); @@ -93,7 +98,7 @@ function ensureDialogIsClosed() { } catch (e) {} - $password.val(''); + $passwordInputs.val(''); } async function enterProtectedSessionOnServer(password) { @@ -116,7 +121,7 @@ async function protectNoteAndSendToServer() { treeService.setProtected(note.noteId, note.isProtected); - noteDetailService.setNoteBackgroundIfProtected(note);console.log(note); + noteDetailService.setNoteBackgroundIfProtected(note); } async function unprotectNoteAndSendToServer() { @@ -157,27 +162,18 @@ async function protectSubtree(noteId, protect) { noteDetailService.reload(); } -$passwordForm.submit(() => { - setupProtectedSession(); +$passwordForms.submit(function() { // needs to stay as function + const password = $(this).find(".protected-session-password").val(); + + setupProtectedSession(password); return false; }); -// this doesn't work, event is not triggered :/ -$dialog.on("show.bs.modal", e => function() { - if ($(this).hasClass("modalless")) { - // return "stolen" focus to tree - treeService.getCurrentNode().setFocus(); - } - else { - $password.focus(); - } -}); - $protectButton.click(protectNoteAndSendToServer); $unprotectButton.click(unprotectNoteAndSendToServer); -$dialog.on("shown.bs.modal", e => $password.focus()); +$dialog.on("shown.bs.modal", e => $passwordInModal.focus()); export default { ensureProtectedSession, diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css index 14a804dc8..ede0b9221 100644 --- a/src/public/stylesheets/style.css +++ b/src/public/stylesheets/style.css @@ -619,13 +619,6 @@ table.promoted-attributes-in-tooltip td, table.promoted-attributes-in-tooltip th cursor: pointer; } -/*.modalless {*/ - /*top: 15%;*/ - /*left: 40%;*/ - /*bottom: auto;*/ - /*right: auto;*/ -/*}*/ - .multiplicity { font-size: 1.3em; } @@ -703,4 +696,10 @@ div[data-notify="container"] { text-decoration: underline !important; color: blue !important; cursor: pointer !important; +} + +#protected-session-password-component { + max-width: 450px; + margin: auto; + padding-top: 50px; } \ No newline at end of file diff --git a/src/views/details/detail.ejs b/src/views/details/detail.ejs index bc82fccb1..f39b04598 100644 --- a/src/views/details/detail.ejs +++ b/src/views/details/detail.ejs @@ -21,6 +21,8 @@ <% include relation_map.ejs %> + <% include protected_session_password.ejs %> +
diff --git a/src/views/details/protected_session_password.ejs b/src/views/details/protected_session_password.ejs new file mode 100644 index 000000000..5cb534a81 --- /dev/null +++ b/src/views/details/protected_session_password.ejs @@ -0,0 +1,10 @@ +