calendar now indicates whether date note already exists or not + tooltip

This commit is contained in:
zadam
2019-09-08 16:30:33 +02:00
parent c82de8b6b2
commit 16be0c1014
4 changed files with 41 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ import libraryLoader from "../services/library_loader.js";
import utils from "../services/utils.js";
import dateNoteService from "../services/date_notes.js";
import treeService from "../services/tree.js";
import server from "../services/server.js";
const TPL = `
<div class="calendar-widget">
@@ -87,8 +88,8 @@ class CalendarWidget extends StandardWidget {
});
}
createDay(num, day) {
const $newDay = $('<div>')
createDay(dateNotesForMonth, num, day) {
const $newDay = $('<a>')
.addClass("calendar-date")
.attr('data-calendar-date', utils.formatDateISO(this.date));
const $date = $('<span>').html(num);
@@ -102,6 +103,13 @@ class CalendarWidget extends StandardWidget {
}
}
const dateNoteId = dateNotesForMonth[utils.formatDateISO(this.date)];
if (dateNoteId) {
$newDay.addClass('calendar-date-exists');
$newDay.attr("data-note-path", dateNoteId);
}
if (this.isEqual(this.date, this.activeDate)) {
$newDay.addClass('calendar-date-active');
}
@@ -120,10 +128,14 @@ class CalendarWidget extends StandardWidget {
&& a.getDate() === b.getDate();
}
createMonth() {
async createMonth() {
const month = utils.formatDateISO(this.date).substr(0, 7);
const dateNotesForMonth = await server.get('date-notes/notes-for-month/' + month);
const currentMonth = this.date.getMonth();
while (this.date.getMonth() === currentMonth) {
this.createDay(
dateNotesForMonth,
this.date.getDate(),
this.date.getDay(),
this.date.getFullYear()