From 169b2269b1665d9299d475169172b0200406c08f Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 16 Feb 2025 19:17:15 +0200 Subject: [PATCH] feat(view/calendar): improve display when creating empty note --- src/public/app/components/note_context.ts | 2 +- src/public/app/widgets/note_list.ts | 3 +-- src/public/app/widgets/type_widgets/book.ts | 12 +++++++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/public/app/components/note_context.ts b/src/public/app/components/note_context.ts index 7656894c9..6179ac57f 100644 --- a/src/public/app/components/note_context.ts +++ b/src/public/app/components/note_context.ts @@ -290,7 +290,7 @@ class NoteContext extends Component implements EventListener<"entitiesReloaded"> return ( this.note && ["default", "contextual-help"].includes(this.viewScope?.viewMode ?? "") && - this.note.hasChildren() && + (this.note.hasChildren() || this.note.getLabelValue("viewType") === "calendar") && ["book", "text", "code"].includes(this.note.type) && this.note.mime !== "text/x-sqlite;schema=trilium" && !this.note.isLabelTruthy("hideChildrenOverview") diff --git a/src/public/app/widgets/note_list.ts b/src/public/app/widgets/note_list.ts index b1cfd06d9..2775aea78 100644 --- a/src/public/app/widgets/note_list.ts +++ b/src/public/app/widgets/note_list.ts @@ -107,8 +107,7 @@ export default class NoteListWidget extends NoteContextAwareWidget { entitiesReloadedEvent(e: EventData<"entitiesReloaded">) { if (e.loadResults.getAttributeRows().find((attr) => attr.noteId === this.noteId && attr.name && ["viewType", "expanded", "pageSize"].includes(attr.name))) { - this.shownNoteId = null; // force render - + this.refresh(); this.checkRenderStatus(); } diff --git a/src/public/app/widgets/type_widgets/book.ts b/src/public/app/widgets/type_widgets/book.ts index bb872d50e..38be2a56c 100644 --- a/src/public/app/widgets/type_widgets/book.ts +++ b/src/public/app/widgets/type_widgets/book.ts @@ -1,6 +1,7 @@ import TypeWidget from "./type_widget.js"; import { t } from "../../services/i18n.js"; import type FNote from "../../entities/fnote.js"; +import type { EventData } from "../../components/app_context.js"; const TPL = `
@@ -35,6 +36,15 @@ export default class BookTypeWidget extends TypeWidget { } async doRefresh(note: FNote) { - this.$helpNoChildren.toggle(!this.note?.hasChildren()); + this.$helpNoChildren.toggle( + !this.note?.hasChildren() + && this.note?.getAttributeValue("label", "viewType") !== "calendar"); } + + entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) { + if (loadResults.getAttributeRows().find((attr) => attr.noteId === this.noteId && attr.name === "viewType")) { + this.refresh(); + } + } + }