mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
non-modal protected session password form is now done separately as a kind of detail component. Also reworked branch prefix dialog input
This commit is contained in:
parent
1dad919de9
commit
d4db265fd9
@ -24,7 +24,7 @@ async function showDialog() {
|
|||||||
|
|
||||||
const noteTitle = await treeUtils.getNoteTitle(currentNode.data.noteId);
|
const noteTitle = await treeUtils.getNoteTitle(currentNode.data.noteId);
|
||||||
|
|
||||||
$noteTitle.html(noteTitle);
|
$noteTitle.text(" - " + noteTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function savePrefix() {
|
async function savePrefix() {
|
||||||
|
@ -6,8 +6,10 @@ import protectedSessionHolder from './protected_session_holder.js';
|
|||||||
import infoService from "./info.js";
|
import infoService from "./info.js";
|
||||||
|
|
||||||
const $dialog = $("#protected-session-password-dialog");
|
const $dialog = $("#protected-session-password-dialog");
|
||||||
const $passwordForm = $("#protected-session-password-form");
|
const $component = $("#protected-session-password-component");
|
||||||
const $password = $("#protected-session-password");
|
const $passwordForms = $(".protected-session-password-form");
|
||||||
|
const $passwordInputs = $(".protected-session-password");
|
||||||
|
const $passwordInModal = $("#protected-session-password-in-modal");
|
||||||
const $noteDetailWrapper = $("#note-detail-wrapper");
|
const $noteDetailWrapper = $("#note-detail-wrapper");
|
||||||
const $protectButton = $("#protect-button");
|
const $protectButton = $("#protect-button");
|
||||||
const $unprotectButton = $("#unprotect-button");
|
const $unprotectButton = $("#unprotect-button");
|
||||||
@ -36,12 +38,16 @@ function ensureProtectedSession(requireProtectedSession, modal) {
|
|||||||
// using deferred instead of promise because it allows resolving from outside
|
// using deferred instead of promise because it allows resolving from outside
|
||||||
protectedSessionDeferred = dfd;
|
protectedSessionDeferred = dfd;
|
||||||
|
|
||||||
if (treeService.getCurrentNode().data.isProtected) {
|
if (modal) {
|
||||||
$noteDetailWrapper.hide();
|
if (treeService.getCurrentNode().data.isProtected) {
|
||||||
}
|
$noteDetailWrapper.hide();
|
||||||
|
}
|
||||||
|
|
||||||
$dialog.toggleClass("modalless", !modal);
|
$dialog.modal();
|
||||||
$dialog.modal();
|
}
|
||||||
|
else {
|
||||||
|
$component.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
dfd.resolve(false);
|
dfd.resolve(false);
|
||||||
@ -50,9 +56,8 @@ function ensureProtectedSession(requireProtectedSession, modal) {
|
|||||||
return dfd.promise();
|
return dfd.promise();
|
||||||
}
|
}
|
||||||
|
|
||||||
async function setupProtectedSession() {
|
async function setupProtectedSession(password) {
|
||||||
const password = $password.val();
|
$passwordInputs.val("");
|
||||||
$password.val("");
|
|
||||||
|
|
||||||
const response = await enterProtectedSessionOnServer(password);
|
const response = await enterProtectedSessionOnServer(password);
|
||||||
|
|
||||||
@ -72,7 +77,7 @@ async function setupProtectedSession() {
|
|||||||
await noteDetailService.reload();
|
await noteDetailService.reload();
|
||||||
|
|
||||||
if (protectedSessionDeferred !== null) {
|
if (protectedSessionDeferred !== null) {
|
||||||
ensureDialogIsClosed($dialog, $password);
|
ensureDialogIsClosed();
|
||||||
|
|
||||||
$noteDetailWrapper.show();
|
$noteDetailWrapper.show();
|
||||||
|
|
||||||
@ -93,7 +98,7 @@ function ensureDialogIsClosed() {
|
|||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
|
|
||||||
$password.val('');
|
$passwordInputs.val('');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function enterProtectedSessionOnServer(password) {
|
async function enterProtectedSessionOnServer(password) {
|
||||||
@ -116,7 +121,7 @@ async function protectNoteAndSendToServer() {
|
|||||||
|
|
||||||
treeService.setProtected(note.noteId, note.isProtected);
|
treeService.setProtected(note.noteId, note.isProtected);
|
||||||
|
|
||||||
noteDetailService.setNoteBackgroundIfProtected(note);console.log(note);
|
noteDetailService.setNoteBackgroundIfProtected(note);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function unprotectNoteAndSendToServer() {
|
async function unprotectNoteAndSendToServer() {
|
||||||
@ -157,27 +162,18 @@ async function protectSubtree(noteId, protect) {
|
|||||||
noteDetailService.reload();
|
noteDetailService.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
$passwordForm.submit(() => {
|
$passwordForms.submit(function() { // needs to stay as function
|
||||||
setupProtectedSession();
|
const password = $(this).find(".protected-session-password").val();
|
||||||
|
|
||||||
|
setupProtectedSession(password);
|
||||||
|
|
||||||
return false;
|
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);
|
$protectButton.click(protectNoteAndSendToServer);
|
||||||
$unprotectButton.click(unprotectNoteAndSendToServer);
|
$unprotectButton.click(unprotectNoteAndSendToServer);
|
||||||
|
|
||||||
$dialog.on("shown.bs.modal", e => $password.focus());
|
$dialog.on("shown.bs.modal", e => $passwordInModal.focus());
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
ensureProtectedSession,
|
ensureProtectedSession,
|
||||||
|
@ -619,13 +619,6 @@ table.promoted-attributes-in-tooltip td, table.promoted-attributes-in-tooltip th
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*.modalless {*/
|
|
||||||
/*top: 15%;*/
|
|
||||||
/*left: 40%;*/
|
|
||||||
/*bottom: auto;*/
|
|
||||||
/*right: auto;*/
|
|
||||||
/*}*/
|
|
||||||
|
|
||||||
.multiplicity {
|
.multiplicity {
|
||||||
font-size: 1.3em;
|
font-size: 1.3em;
|
||||||
}
|
}
|
||||||
@ -704,3 +697,9 @@ div[data-notify="container"] {
|
|||||||
color: blue !important;
|
color: blue !important;
|
||||||
cursor: pointer !important;
|
cursor: pointer !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#protected-session-password-component {
|
||||||
|
max-width: 450px;
|
||||||
|
margin: auto;
|
||||||
|
padding-top: 50px;
|
||||||
|
}
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
<% include relation_map.ejs %>
|
<% include relation_map.ejs %>
|
||||||
|
|
||||||
|
<% include protected_session_password.ejs %>
|
||||||
|
|
||||||
<div id="children-overview"></div>
|
<div id="children-overview"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
10
src/views/details/protected_session_password.ejs
Normal file
10
src/views/details/protected_session_password.ejs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<div id="protected-session-password-component" class="note-detail-component">
|
||||||
|
<form class="protected-session-password-form">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="protected-session-password-in-detail">Showing protected note requires entering your password:</label>
|
||||||
|
<input id="protected-session-password-in-detail" class="form-control protected-session-password" type="password">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button class="btn btn-primary">Start protected session <kbd>enter</kbd></button>
|
||||||
|
</form>
|
||||||
|
</div>
|
@ -13,7 +13,14 @@
|
|||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="branch-prefix-input">Prefix: </label>
|
<label for="branch-prefix-input">Prefix: </label>
|
||||||
<input id="branch-prefix-input" style="width: 20em;"> - <span id="branch-prefix-note-title"></span>
|
|
||||||
|
<div class="input-group">
|
||||||
|
<input id="branch-prefix-input" class="form-control">
|
||||||
|
|
||||||
|
<div class="input-group-append">
|
||||||
|
<div id="branch-prefix-note-title" class="input-group-text"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<div id="protected-session-password-dialog" class="modal mx-auto" data-backdrop="false" tabindex="-1" role="dialog">
|
<div id="protected-session-password-dialog" class="modal mx-auto" data-backdrop="false" tabindex="-1" role="dialog">
|
||||||
<div class="modal-dialog modal-sm" role="document">
|
<div class="modal-dialog modal-md" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title mr-auto">Protected session</h5>
|
<h5 class="modal-title mr-auto">Protected session</h5>
|
||||||
@ -10,11 +10,11 @@
|
|||||||
<span aria-hidden="true">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<form id="protected-session-password-form">
|
<form class="protected-session-password-form">
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="protected-session-password">Enter password to start protected session:</label>
|
<label for="protected-session-password-in-modal">To proceed with requested action you need to start protected session by entering password:</label>
|
||||||
<input id="protected-session-password" class="form-control" type="password">
|
<input id="protected-session-password-in-modal" class="form-control protected-session-password" type="password">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user