mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 01:48:32 +02:00
refactoring of date notes route
This commit is contained in:
parent
af703445e1
commit
b381331029
@ -8,3 +8,4 @@
|
||||
* readOnly=auto - like without readOnly (used to override inherited readOnly)
|
||||
* readOnly=never - like autoReadOnlyDisabled
|
||||
- remove focusOnAttributesKeyboardShortcut
|
||||
- rename white theme to "light" theme (it's not completely white and matches well to dark theme)
|
||||
|
@ -66,12 +66,13 @@ function getYearNote(dateStr, rootNote) {
|
||||
|
||||
const yearStr = dateStr.substr(0, 4);
|
||||
|
||||
let yearNote = attributeService.getNoteWithLabel(YEAR_LABEL, yearStr);
|
||||
let yearNote = attributeService.getNoteWithLabel(YEAR_LABEL, yearStr)
|
||||
|| getNoteStartingWith(rootNote.noteId, yearStr);
|
||||
|
||||
if (!yearNote) {
|
||||
yearNote = getNoteStartingWith(rootNote.noteId, yearStr);
|
||||
if (yearNote) {
|
||||
return yearNote;
|
||||
}
|
||||
|
||||
if (!yearNote) {
|
||||
sql.transactional(() => {
|
||||
yearNote = createNote(rootNote, yearStr);
|
||||
|
||||
@ -84,8 +85,6 @@ function getYearNote(dateStr, rootNote) {
|
||||
attributeService.createRelation(yearNote.noteId, 'template', yearTemplateAttr.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return yearNote;
|
||||
}
|
||||
@ -110,12 +109,18 @@ function getMonthNote(dateStr, rootNote) {
|
||||
|
||||
let monthNote = attributeService.getNoteWithLabel(MONTH_LABEL, monthStr);
|
||||
|
||||
if (!monthNote) {
|
||||
if (monthNote) {
|
||||
return monthNote;
|
||||
}
|
||||
|
||||
const yearNote = getYearNote(dateStr, rootNote);
|
||||
|
||||
monthNote = getNoteStartingWith(yearNote.noteId, monthNumber);
|
||||
|
||||
if (!monthNote) {
|
||||
if (monthNote) {
|
||||
return monthNote;
|
||||
}
|
||||
|
||||
const dateObj = dateUtils.parseLocalDate(dateStr);
|
||||
|
||||
const noteTitle = getMonthNoteTitle(rootNote, monthNumber, dateObj);
|
||||
@ -132,8 +137,6 @@ function getMonthNote(dateStr, rootNote) {
|
||||
attributeService.createRelation(monthNote.noteId, 'template', monthTemplateAttr.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return monthNote;
|
||||
}
|
||||
@ -152,17 +155,22 @@ function getDateNoteTitle(rootNote, dayNumber, dateObj) {
|
||||
|
||||
/** @return {Note} */
|
||||
function getDateNote(dateStr) {
|
||||
const rootNote = getRootCalendarNote();
|
||||
|
||||
let dateNote = attributeService.getNoteWithLabel(DATE_LABEL, dateStr);
|
||||
|
||||
if (!dateNote) {
|
||||
if (dateNote) {
|
||||
return dateNote;
|
||||
}
|
||||
|
||||
const rootNote = getRootCalendarNote();
|
||||
const monthNote = getMonthNote(dateStr, rootNote);
|
||||
const dayNumber = dateStr.substr(8, 2);
|
||||
|
||||
dateNote = getNoteStartingWith(monthNote.noteId, dayNumber);
|
||||
|
||||
if (!dateNote) {
|
||||
if (dateNote) {
|
||||
return dateNote;
|
||||
}
|
||||
|
||||
const dateObj = dateUtils.parseLocalDate(dateStr);
|
||||
|
||||
const noteTitle = getDateNoteTitle(rootNote, dayNumber, dateObj);
|
||||
@ -178,8 +186,6 @@ function getDateNote(dateStr) {
|
||||
attributeService.createRelation(dateNote.noteId, 'template', dateTemplateAttr.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return dateNote;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user