Show revision information

This commit is contained in:
SiriusXT 2024-09-14 14:32:43 +08:00
parent 84bf0cbae5
commit 3e085e5cae
2 changed files with 29 additions and 3 deletions

View File

@ -8,7 +8,8 @@ import openService from "../../services/open.js";
import protectedSessionHolder from "../../services/protected_session_holder.js"; import protectedSessionHolder from "../../services/protected_session_holder.js";
import BasicWidget from "../basic_widget.js"; import BasicWidget from "../basic_widget.js";
import dialogService from "../../services/dialog.js"; import dialogService from "../../services/dialog.js";
import OnClickButtonWidget from "../buttons/onclick_button.js";
import options from "../../services/options.js";
const TPL = ` const TPL = `
<div class="revisions-dialog modal fade mx-auto" tabindex="-1" role="dialog"> <div class="revisions-dialog modal fade mx-auto" tabindex="-1" role="dialog">
<style> <style>
@ -66,6 +67,11 @@ const TPL = `
<div class="revision-content"></div> <div class="revision-content"></div>
</div> </div>
</div> </div>
<div class="modal-footer py-0">
<span class="revisions-snapshot-interval flex-grow-1 my-0 py-0"></span>
<span class="maximum-revisions-for-current-note flex-grow-1 my-0 py-0"></span>
<button class="revision-settings-button icon-action bx bx-cog my-0 py-0" title="${t("revisions.settings")}"></button>
</div>
</div> </div>
</div> </div>
</div>`; </div>`;
@ -89,7 +95,9 @@ export default class RevisionsDialog extends BasicWidget {
this.$title = this.$widget.find(".revision-title"); this.$title = this.$widget.find(".revision-title");
this.$titleButtons = this.$widget.find(".revision-title-buttons"); this.$titleButtons = this.$widget.find(".revision-title-buttons");
this.$eraseAllRevisionsButton = this.$widget.find(".revisions-erase-all-revisions-button"); this.$eraseAllRevisionsButton = this.$widget.find(".revisions-erase-all-revisions-button");
this.$snapshotInterval = this.$widget.find(".revisions-snapshot-interval");
this.$maximumRevisions = this.$widget.find(".maximum-revisions-for-current-note");
this.$revisionSettingsButton = this.$widget.find(".revision-settings-button")
this.$listDropdown.dropdown(); this.$listDropdown.dropdown();
this.$listDropdown.parent().on('hide.bs.dropdown', e => { this.$listDropdown.parent().on('hide.bs.dropdown', e => {
@ -128,6 +136,10 @@ export default class RevisionsDialog extends BasicWidget {
this.setContentPane(); this.setContentPane();
}); });
this.$revisionSettingsButton.on('click', async () => {
appContext.tabManager.openContextWithNote('_optionsOther', {activate: true});
});
} }
async showRevisionsEvent({ noteId = appContext.tabManager.getActiveContextNoteId() }) { async showRevisionsEvent({ noteId = appContext.tabManager.getActiveContextNoteId() }) {
@ -165,6 +177,17 @@ export default class RevisionsDialog extends BasicWidget {
} }
this.$eraseAllRevisionsButton.toggle(this.revisionItems.length > 0); this.$eraseAllRevisionsButton.toggle(this.revisionItems.length > 0);
// Show the footer of the revisions dialog
this.$snapshotInterval.text(t("revisions.snapshot_interval", { seconds: options.getInt('revisionSnapshotTimeInterval') }))
let revisionsNumberLimit = parseInt(this.note.getLabelValue("versioningLimit") ?? "");
if (!Number.isInteger(revisionsNumberLimit)) {
revisionsNumberLimit = parseInt(options.getInt('revisionSnapshotNumberLimit'));
}
if (revisionsNumberLimit === -1) {
revisionsNumberLimit = "∞"
}
this.$maximumRevisions.text(t("revisions.maximum_revisions", { number: revisionsNumberLimit }))
} }
async setContentPane() { async setContentPane() {

View File

@ -247,6 +247,9 @@
"revisions_deleted": "Note revisions has been deleted.", "revisions_deleted": "Note revisions has been deleted.",
"revision_restored": "Note revision has been restored.", "revision_restored": "Note revision has been restored.",
"revision_deleted": "Note revision has been deleted.", "revision_deleted": "Note revision has been deleted.",
"snapshot_interval":"Note Revisions Snapshot Interval: {{seconds}}s.",
"maximum_revisions":"Maximum revisions for current note: {{number}}.",
"settings":"Settings for Note revisions.",
"download_button": "Download", "download_button": "Download",
"mime": "MIME: ", "mime": "MIME: ",
"file_size": "File size:", "file_size": "File size:",
@ -1085,7 +1088,7 @@
}, },
"revisions_snapshot_limit": { "revisions_snapshot_limit": {
"note_revisions_snapshot_limit_title": "Note Revision Snapshots Limit", "note_revisions_snapshot_limit_title": "Note Revision Snapshots Limit",
"note_revisions_snapshot_limit_description": "The note revision snapshot number limit refers to the maximum number of revisions that can be saved for each note. Where -1 means no limit, 0 means delete all revisions.", "note_revisions_snapshot_limit_description": "The note revision snapshot number limit refers to the maximum number of revisions that can be saved for each note. Where -1 means no limit, 0 means delete all revisions. You can set the maximum revisions for a single note through the #versioningLimit label.",
"snapshot_number_limit_label": "Note revision snapshot number limit:", "snapshot_number_limit_label": "Note revision snapshot number limit:",
"erase_excess_revision_snapshots": "Erase excess revision snapshots now", "erase_excess_revision_snapshots": "Erase excess revision snapshots now",
"erase_excess_revision_snapshots_prompt": "Excess revision snapshots have been erased." "erase_excess_revision_snapshots_prompt": "Excess revision snapshots have been erased."