mirror of
https://github.com/zadam/trilium.git
synced 2025-11-06 05:15:59 +01:00
refactored all mentions of "history" to "revision"
This commit is contained in:
@@ -1,72 +0,0 @@
|
||||
import noteDetailService from '../services/note_detail.js';
|
||||
import utils from '../services/utils.js';
|
||||
import server from '../services/server.js';
|
||||
|
||||
const $dialog = $("#note-history-dialog");
|
||||
const $list = $("#note-history-list");
|
||||
const $content = $("#note-history-content");
|
||||
const $title = $("#note-history-title");
|
||||
|
||||
let historyItems = [];
|
||||
|
||||
async function showCurrentNoteHistory() {
|
||||
await showNoteHistoryDialog(noteDetailService.getCurrentNoteId());
|
||||
}
|
||||
|
||||
async function showNoteHistoryDialog(noteId, noteRevisionId) {
|
||||
glob.activeDialog = $dialog;
|
||||
|
||||
$dialog.dialog({
|
||||
modal: true,
|
||||
width: 800,
|
||||
height: 700
|
||||
});
|
||||
|
||||
$list.empty();
|
||||
$content.empty();
|
||||
|
||||
historyItems = await server.get('notes-history/' + noteId);
|
||||
|
||||
for (const item of historyItems) {
|
||||
const dateModified = utils.parseDate(item.dateModifiedFrom);
|
||||
|
||||
$list.append($('<option>', {
|
||||
value: item.noteRevisionId,
|
||||
text: utils.formatDateTime(dateModified)
|
||||
}));
|
||||
}
|
||||
|
||||
if (historyItems.length > 0) {
|
||||
if (!noteRevisionId) {
|
||||
noteRevisionId = $list.find("option:first").val();
|
||||
}
|
||||
|
||||
$list.val(noteRevisionId).trigger('change');
|
||||
}
|
||||
else {
|
||||
$title.text("No history for this note yet...");
|
||||
}
|
||||
}
|
||||
|
||||
$list.on('change', () => {
|
||||
const optVal = $list.find(":selected").val();
|
||||
|
||||
const historyItem = historyItems.find(r => r.noteRevisionId === optVal);
|
||||
|
||||
$title.html(historyItem.title);
|
||||
$content.html(historyItem.content);
|
||||
});
|
||||
|
||||
$(document).on('click', "a[action='note-history']", event => {
|
||||
const linkEl = $(event.target);
|
||||
const noteId = linkEl.attr('note-path');
|
||||
const noteRevisionId = linkEl.attr('note-history-id');
|
||||
|
||||
showNoteHistoryDialog(noteId, noteRevisionId);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
export default {
|
||||
showCurrentNoteHistory
|
||||
};
|
||||
72
src/public/javascripts/dialogs/note_revisions.js
Normal file
72
src/public/javascripts/dialogs/note_revisions.js
Normal file
@@ -0,0 +1,72 @@
|
||||
import noteDetailService from '../services/note_detail.js';
|
||||
import utils from '../services/utils.js';
|
||||
import server from '../services/server.js';
|
||||
|
||||
const $dialog = $("#note-revisions-dialog");
|
||||
const $list = $("#note-revision-list");
|
||||
const $content = $("#note-revision-content");
|
||||
const $title = $("#note-revision-title");
|
||||
|
||||
let revisionItems = [];
|
||||
|
||||
async function showCurrentNoteRevisions() {
|
||||
await showNoteRevisionsDialog(noteDetailService.getCurrentNoteId());
|
||||
}
|
||||
|
||||
async function showNoteRevisionsDialog(noteId, noteRevisionId) {
|
||||
glob.activeDialog = $dialog;
|
||||
|
||||
$dialog.dialog({
|
||||
modal: true,
|
||||
width: 800,
|
||||
height: 700
|
||||
});
|
||||
|
||||
$list.empty();
|
||||
$content.empty();
|
||||
|
||||
revisionItems = await server.get('notes-revisions/' + noteId);
|
||||
|
||||
for (const item of revisionItems) {
|
||||
const dateModified = utils.parseDate(item.dateModifiedFrom);
|
||||
|
||||
$list.append($('<option>', {
|
||||
value: item.noteRevisionId,
|
||||
text: utils.formatDateTime(dateModified)
|
||||
}));
|
||||
}
|
||||
|
||||
if (revisionItems.length > 0) {
|
||||
if (!noteRevisionId) {
|
||||
noteRevisionId = $list.find("option:first").val();
|
||||
}
|
||||
|
||||
$list.val(noteRevisionId).trigger('change');
|
||||
}
|
||||
else {
|
||||
$title.text("No revisions for this note yet...");
|
||||
}
|
||||
}
|
||||
|
||||
$list.on('change', () => {
|
||||
const optVal = $list.find(":selected").val();
|
||||
|
||||
const revisionItem = revisionItems.find(r => r.noteRevisionId === optVal);
|
||||
|
||||
$title.html(revisionItem.title);
|
||||
$content.html(revisionItem.content);
|
||||
});
|
||||
|
||||
$(document).on('click', "a[action='note-revision']", event => {
|
||||
const linkEl = $(event.target);
|
||||
const noteId = linkEl.attr('note-path');
|
||||
const noteRevisionId = linkEl.attr('note-revision-id');
|
||||
|
||||
showNoteRevisionsDialog(noteId, noteRevisionId);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
export default {
|
||||
showCurrentNoteRevisions
|
||||
};
|
||||
@@ -30,9 +30,9 @@ async function showDialog() {
|
||||
const revLink = $("<a>", {
|
||||
href: 'javascript:',
|
||||
text: 'rev'
|
||||
}).attr('action', 'note-history')
|
||||
}).attr('action', 'note-revision')
|
||||
.attr('note-path', change.noteId)
|
||||
.attr('note-history-id', change.noteRevisionId);
|
||||
.attr('note-revision-id', change.noteRevisionId);
|
||||
|
||||
let noteLink;
|
||||
|
||||
|
||||
@@ -117,9 +117,9 @@ addModule((function() {
|
||||
})());
|
||||
|
||||
addModule((function () {
|
||||
const $form = $("#history-snapshot-time-interval-form");
|
||||
const $timeInterval = $("#history-snapshot-time-interval-in-seconds");
|
||||
const settingName = 'history_snapshot_time_interval';
|
||||
const $form = $("#note-revision-snapshot-time-interval-form");
|
||||
const $timeInterval = $("#note-revision-snapshot-time-interval-in-seconds");
|
||||
const settingName = 'note_revision_snapshot_time_interval';
|
||||
|
||||
function settingsLoaded(settings) {
|
||||
$timeInterval.val(settings[settingName]);
|
||||
|
||||
Reference in New Issue
Block a user