From 07498c6bef37550530c3031078587bfc23a5589e Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 5 Dec 2025 09:02:51 +0200 Subject: [PATCH] chore(react/launch_bar): add link to existing days --- apps/client/src/widgets/buttons/calendar.ts | 28 ------------------- .../src/widgets/launch_bar/Calendar.tsx | 12 +++++++- 2 files changed, 11 insertions(+), 29 deletions(-) diff --git a/apps/client/src/widgets/buttons/calendar.ts b/apps/client/src/widgets/buttons/calendar.ts index df71819c1..636ee50e4 100644 --- a/apps/client/src/widgets/buttons/calendar.ts +++ b/apps/client/src/widgets/buttons/calendar.ts @@ -46,22 +46,6 @@ export default class CalendarWidget extends RightDropdownButtonWidget { this.manageFirstDayOfWeek(); this.initWeekCalculation(); - // Month navigation - this.$monthSelect = this.$dropdownContent.find('[data-calendar-input="month"]'); - this.$monthSelect.on("show.bs.dropdown", (e) => { - // Don't trigger dropdownShown() at widget level when the month selection dropdown is shown, since it would cause a redundant refresh. - e.stopPropagation(); - }); - this.monthDropdown = Dropdown.getOrCreateInstance(this.$monthSelect[0]); - this.$dropdownContent.find('[data-calendar-input="month-list"] button').on("click", (e) => { - const target = e.target as HTMLElement; - const value = target.dataset.value; - if (value) { - this.date = this.date.month(parseInt(value)); - this.createMonth(); - } - }); - // Date click this.$dropdownContent.on("click", ".calendar-date", async (ev) => { const date = $(ev.target).closest(".calendar-date").attr("data-calendar-date"); @@ -139,18 +123,6 @@ export default class CalendarWidget extends RightDropdownButtonWidget { this.init( ?? null); } - createDay() { - const $date = $("").html(String(num)); - const dateNoteId = dateNotesForMonth[this.date.local().format('YYYY-MM-DD')]; - - if (dateNoteId) { - $newDay.addClass("calendar-date-exists").attr("data-href", `#root/${dateNoteId}`); - } - - $newDay.append($date); - return $newDay; - } - createWeekNumber(weekNumber: number) { const weekNoteId = this.date.local().format('YYYY-') + 'W' + String(weekNumber).padStart(2, '0'); let $newWeekNumber; diff --git a/apps/client/src/widgets/launch_bar/Calendar.tsx b/apps/client/src/widgets/launch_bar/Calendar.tsx index 14d5fe516..a4b4886d3 100644 --- a/apps/client/src/widgets/launch_bar/Calendar.tsx +++ b/apps/client/src/widgets/launch_bar/Calendar.tsx @@ -85,13 +85,20 @@ function CurrentMonthDays({ date, firstDayOfWeekISO, ...args }: { date: Dayjs, f let dateCursor = date; const currentMonth = date.month(); const items: VNode[] = []; + const curMonthString = date.format('YYYY-MM'); + const [ dateNotesForCurMonth, setDateNotesForCurMonth ] = useState(); + + useEffect(() => { + server.get(`special-notes/notes-for-month/${curMonthString}`).then(setDateNotesForCurMonth); + }, [ date ]); + while (dateCursor.month() === currentMonth) { const weekNumber = getWeekNumber(dateCursor, firstDayOfWeekISO); if (dateCursor.isoWeekday() === firstDayOfWeekISO) { items.push() } - items.push() + items.push() dateCursor = dateCursor.add(1, "day"); } @@ -112,13 +119,16 @@ function NextMonthDays({ date, dates, ...args }: { date: Dayjs, dates: Dayjs[] } } function CalendarDay({ date, dateNotesForMonth, className, activeDate, todaysDate }: { date: Dayjs, dateNotesForMonth?: DateNotesForMonth, className?: string } & CalendarArgs) { + const dateNoteId = dateNotesForMonth?.[date.local().format('YYYY-MM-DD')]; return ( {date.date()}