mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-11-11 12:41:43 +08:00
feat(views/calendar): filter notes by ancestor
This commit is contained in:
parent
a4a2e55415
commit
63584c153c
@ -238,7 +238,7 @@ export default class CalendarView extends ViewMode {
|
|||||||
let allDateNoteIds: string[] = [];
|
let allDateNoteIds: string[] = [];
|
||||||
for (const month of dateRange) {
|
for (const month of dateRange) {
|
||||||
// TODO: Deduplicate get type.
|
// TODO: Deduplicate get type.
|
||||||
const dateNotesForMonth = await server.get<Record<string, string>>(`special-notes/notes-for-month/${month}`);
|
const dateNotesForMonth = await server.get<Record<string, string>>(`special-notes/notes-for-month/${month}?calendarRoot=${this.parentNote.noteId}`);
|
||||||
const dateNoteIds = Object.values(dateNotesForMonth);
|
const dateNoteIds = Object.values(dateNotesForMonth);
|
||||||
allDateNoteIds = [ ...allDateNoteIds, ...dateNoteIds ];
|
allDateNoteIds = [ ...allDateNoteIds, ...dateNoteIds ];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -29,8 +29,8 @@ function getYearNote(req: Request) {
|
|||||||
|
|
||||||
function getDayNotesForMonth(req: Request) {
|
function getDayNotesForMonth(req: Request) {
|
||||||
const month = req.params.month;
|
const month = req.params.month;
|
||||||
|
const calendarRoot = req.query.calendarRoot;
|
||||||
return sql.getMap(`
|
const query = `\
|
||||||
SELECT
|
SELECT
|
||||||
attr.value AS date,
|
attr.value AS date,
|
||||||
notes.noteId
|
notes.noteId
|
||||||
@ -40,7 +40,22 @@ function getDayNotesForMonth(req: Request) {
|
|||||||
AND attr.isDeleted = 0
|
AND attr.isDeleted = 0
|
||||||
AND attr.type = 'label'
|
AND attr.type = 'label'
|
||||||
AND attr.name = 'dateNote'
|
AND attr.name = 'dateNote'
|
||||||
AND attr.value LIKE '${month}%'`);
|
AND attr.value LIKE '${month}%'`;
|
||||||
|
|
||||||
|
if (calendarRoot) {
|
||||||
|
const rows = sql.getRows<{ date: string, noteId: string }>(query);
|
||||||
|
const result: Record<string, string> = {};
|
||||||
|
for (const {date, noteId} of rows) {
|
||||||
|
const note = becca.getNote(noteId);
|
||||||
|
if (note?.hasAncestor(String(calendarRoot))) {
|
||||||
|
result[date] = noteId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} else {
|
||||||
|
return sql.getMap(query);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveSqlConsole(req: Request) {
|
function saveSqlConsole(req: Request) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user