Add week notes to frontend_script_api (#2253)

Note: getWeekNote can take `startOfTheWeek` as options but is not passed to the api route.
This commit is contained in:
Sathyam M Vellal 2021-10-21 03:16:51 -07:00 committed by GitHub
parent 3d98644bf6
commit 3b551e3e4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 0 deletions

View File

@ -23,6 +23,15 @@ async function getDateNote(date) {
return await froca.getNote(note.noteId); return await froca.getNote(note.noteId);
} }
/** @return {NoteShort} */
async function getWeekNote(date) {
const note = await server.get('special-notes/week/' + date, "date-note");
await ws.waitForMaxKnownEntityChangeId();
return await froca.getNote(note.noteId);
}
/** @return {NoteShort} */ /** @return {NoteShort} */
async function getMonthNote(month) { async function getMonthNote(month) {
const note = await server.get('special-notes/month/' + month, "date-note"); const note = await server.get('special-notes/month/' + month, "date-note");
@ -63,6 +72,7 @@ export default {
getInboxNote, getInboxNote,
getTodayNote, getTodayNote,
getDateNote, getDateNote,
getWeekNote,
getMonthNote, getMonthNote,
getYearNote, getYearNote,
createSqlConsole, createSqlConsole,

View File

@ -396,6 +396,15 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
*/ */
this.getDateNote = dateNotesService.getDateNote; this.getDateNote = dateNotesService.getDateNote;
/**
* Returns date-note for the first date of the week of the given date. If it doesn't exist, it is automatically created.
*
* @method
* @param {string} date - e.g. "2019-04-29"
* @return {Promise<NoteShort>}
*/
this.getWeekNote = dateNotesService.getWeekNote;
/** /**
* Returns month-note. If it doesn't exist, it is automatically created. * Returns month-note. If it doesn't exist, it is automatically created.
* *

View File

@ -14,6 +14,10 @@ function getDateNote(req) {
return dateNoteService.getDateNote(req.params.date); return dateNoteService.getDateNote(req.params.date);
} }
function getWeekNote(req) {
return dateNoteService.getWeekNote(req.params.date);
}
function getMonthNote(req) { function getMonthNote(req) {
return dateNoteService.getMonthNote(req.params.month); return dateNoteService.getMonthNote(req.params.month);
} }
@ -65,6 +69,7 @@ function getHoistedNote() {
module.exports = { module.exports = {
getInboxNote, getInboxNote,
getDateNote, getDateNote,
getWeekNote,
getMonthNote, getMonthNote,
getYearNote, getYearNote,
getDateNotesForMonth, getDateNotesForMonth,

View File

@ -262,6 +262,7 @@ function register(app) {
apiRoute(GET, '/api/special-notes/inbox/:date', specialNotesRoute.getInboxNote); apiRoute(GET, '/api/special-notes/inbox/:date', specialNotesRoute.getInboxNote);
apiRoute(GET, '/api/special-notes/date/:date', specialNotesRoute.getDateNote); apiRoute(GET, '/api/special-notes/date/:date', specialNotesRoute.getDateNote);
apiRoute(GET, '/api/special-notes/week/:date', specialNotesRoute.getWeekNote);
apiRoute(GET, '/api/special-notes/month/:month', specialNotesRoute.getMonthNote); apiRoute(GET, '/api/special-notes/month/:month', specialNotesRoute.getMonthNote);
apiRoute(GET, '/api/special-notes/year/:year', specialNotesRoute.getYearNote); apiRoute(GET, '/api/special-notes/year/:year', specialNotesRoute.getYearNote);
apiRoute(GET, '/api/special-notes/notes-for-month/:month', specialNotesRoute.getDateNotesForMonth); apiRoute(GET, '/api/special-notes/notes-for-month/:month', specialNotesRoute.getDateNotesForMonth);