moved protected note switch to "note actions", added shadow to protected note title

This commit is contained in:
zadam
2020-04-29 00:01:07 +02:00
parent 989a003d2f
commit 4c308ad68f
6 changed files with 89 additions and 47 deletions

View File

@@ -1,42 +0,0 @@
import protectedSessionService from "../services/protected_session.js";
import TabAwareWidget from "./tab_aware_widget.js";
const TPL = `
<div class="btn-group btn-group-xs">
<button type="button"
class="btn btn-sm icon-button bx bx-check-shield protect-button"
title="Set this note as protected which means it will possible to view and edit this note only after entering password">
</button>
<button type="button"
class="btn btn-sm icon-button bx bx-shield-x unprotect-button"
title="Set this note as unprotected which will make it viewable and editable without entering password">
</button>
</div>`;``;
export default class ProtectedNoteSwitchWidget extends TabAwareWidget {
doRender() {
this.$widget = $(TPL);
this.$protectButton = this.$widget.find(".protect-button");
this.$protectButton.on('click', () => protectedSessionService.protectNote(this.noteId, true, false));
this.$unprotectButton = this.$widget.find(".unprotect-button");
this.$unprotectButton.on('click', () => protectedSessionService.protectNote(this.noteId, false, false));
return this.$widget;
}
refreshWithNote(note) {
this.$protectButton.toggleClass("active", note.isProtected);
this.$protectButton.prop("disabled", note.isProtected);
this.$unprotectButton.toggleClass("active", !note.isProtected);
this.$unprotectButton.prop("disabled", !note.isProtected);
}
async entitiesReloadedEvent({loadResults}) {
if (loadResults.isNoteReloaded(this.noteId)) {
this.refresh();
}
}
}