Merge branch 'master' into next60

This commit is contained in:
zadam
2023-04-17 22:27:21 +02:00
46 changed files with 629 additions and 345 deletions

View File

@@ -9,11 +9,11 @@ function cloneNoteToBranch(req) {
return cloningService.cloneNoteToBranch(noteId, parentBranchId, prefix);
}
function cloneNoteToNote(req) {
function cloneNoteToParentNote(req) {
const {noteId, parentNoteId} = req.params;
const {prefix} = req.body;
return cloningService.cloneNoteToNote(noteId, parentNoteId, prefix);
return cloningService.cloneNoteToParentNote(noteId, parentNoteId, prefix);
}
function cloneNoteAfter(req) {
@@ -30,7 +30,7 @@ function toggleNoteInParent(req) {
module.exports = {
cloneNoteToBranch,
cloneNoteToNote,
cloneNoteToParentNote,
cloneNoteAfter,
toggleNoteInParent
};

View File

@@ -129,7 +129,7 @@ function getEditedNotesOnDate(req) {
notes = notes.map(note => note.getPojo());
for (const note of notes) {
const notePath = note.isDeleted ? null : beccaService.getNotePath(note.noteId);
const notePath = note.isDeleted ? null : getNotePathData(note);
note.notePath = notePath ? notePath.notePath : null;
}
@@ -137,6 +137,32 @@ function getEditedNotesOnDate(req) {
return notes;
}
function getNotePathData(note) {
const retPath = note.getBestNotePath();
if (retPath) {
const noteTitle = beccaService.getNoteTitleForPath(retPath);
let branchId;
if (note.isRoot()) {
branchId = 'none_root';
}
else {
const parentNote = note.parents[0];
branchId = becca.getBranchFromChildAndParent(note.noteId, parentNote.noteId).branchId;
}
return {
noteId: note.noteId,
branchId: branchId,
title: noteTitle,
notePath: retPath,
path: retPath.join('/')
};
}
}
module.exports = {
getNoteRevisions,
getNoteRevision,

View File

@@ -3,14 +3,14 @@
const sql = require('../../services/sql');
const protectedSessionService = require('../../services/protected_session');
const noteService = require('../../services/notes');
const beccaService = require('../../becca/becca_service');
const becca = require("../../becca/becca");
function getRecentChanges(req) {
const {ancestorNoteId} = req.params;
let recentChanges = [];
const noteRevisions = sql.getRows(`
const noteRevisionRows = sql.getRows(`
SELECT
notes.noteId,
notes.isDeleted AS current_isDeleted,
@@ -24,16 +24,18 @@ function getRecentChanges(req) {
note_revisions
JOIN notes USING(noteId)`);
for (const noteRevision of noteRevisions) {
if (beccaService.isInAncestor(noteRevision.noteId, ancestorNoteId)) {
recentChanges.push(noteRevision);
for (const noteRevisionRow of noteRevisionRows) {
const note = becca.getNote(noteRevisionRow.noteId);
if (note?.hasAncestor(ancestorNoteId)) {
recentChanges.push(noteRevisionRow);
}
}
// now we need to also collect date points not represented in note revisions:
// 1. creation for all notes (dateCreated)
// 2. deletion for deleted notes (dateModified)
const notes = sql.getRows(`
const noteRows = sql.getRows(`
SELECT
notes.noteId,
notes.isDeleted AS current_isDeleted,
@@ -57,9 +59,11 @@ function getRecentChanges(req) {
FROM notes
WHERE notes.isDeleted = 1`);
for (const note of notes) {
if (beccaService.isInAncestor(note.noteId, ancestorNoteId)) {
recentChanges.push(note);
for (const noteRow of noteRows) {
const note = becca.getNote(noteRow.noteId);
if (note?.hasAncestor(ancestorNoteId)) {
recentChanges.push(noteRow);
}
}