From 27738acefcac37409fb4a215322802e035a19cf5 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 10 Jul 2025 19:39:08 +0300 Subject: [PATCH] feat(popup_editor): support collections --- apps/client/src/layouts/desktop_layout.ts | 5 +++-- apps/client/src/widgets/note_list.ts | 20 ++++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/apps/client/src/layouts/desktop_layout.ts b/apps/client/src/layouts/desktop_layout.ts index 61b3ac8e8..5e1573ab8 100644 --- a/apps/client/src/layouts/desktop_layout.ts +++ b/apps/client/src/layouts/desktop_layout.ts @@ -230,7 +230,7 @@ export default class DesktopLayout { .child(new PromotedAttributesWidget()) .child(new SqlTableSchemasWidget()) .child(new NoteDetailWidget()) - .child(new NoteListWidget()) + .child(new NoteListWidget(false)) .child(new SearchResultWidget()) .child(new SqlResultWidget()) .child(new ScrollPaddingWidget()) @@ -268,7 +268,8 @@ export default class DesktopLayout { .child(new NoteTitleWidget())) .child(new ClassicEditorToolbar()) .child(new PromotedAttributesWidget()) - .child(new NoteDetailWidget())); + .child(new NoteDetailWidget()) + .child(new NoteListWidget(true))); applyModals(rootContainer); return rootContainer; diff --git a/apps/client/src/widgets/note_list.ts b/apps/client/src/widgets/note_list.ts index afc31a66a..972711503 100644 --- a/apps/client/src/widgets/note_list.ts +++ b/apps/client/src/widgets/note_list.ts @@ -40,16 +40,32 @@ export default class NoteListWidget extends NoteContextAwareWidget { private shownNoteId?: string | null; private viewMode?: ViewMode | null; private attributeDetailWidget: AttributeDetailWidget; + private displayOnlyCollections: boolean; - constructor() { + /** + * @param displayOnlyCollections if set to `true` then only collection-type views are displayed such as geo-map and the calendar. The original book types grid and list will be ignored. + */ + constructor(displayOnlyCollections: boolean) { super(); this.attributeDetailWidget = new AttributeDetailWidget() .contentSized() .setParent(this); + this.displayOnlyCollections = displayOnlyCollections; } isEnabled() { - return super.isEnabled() && this.noteContext?.hasNoteList(); + if (!super.isEnabled()) { + return false; + } + + if (this.displayOnlyCollections) { + const viewType = this.note?.getLabelValue("viewType"); + if (!viewType || ["grid", "list"].includes(viewType)) { + return false; + } + } + + return this.noteContext?.hasNoteList(); } doRender() {