diff --git a/apps/client/src/services/note_list_renderer.ts b/apps/client/src/services/note_list_renderer.ts index ede0c3132..a55e93c8a 100644 --- a/apps/client/src/services/note_list_renderer.ts +++ b/apps/client/src/services/note_list_renderer.ts @@ -1,10 +1,11 @@ import type FNote from "../entities/fnote.js"; import CalendarView from "../widgets/view_widgets/calendar_view.js"; import ListOrGridView from "../widgets/view_widgets/list_or_grid_view.js"; +import TableView from "../widgets/view_widgets/table_view.js"; import type { ViewModeArgs } from "../widgets/view_widgets/view_mode.js"; import type ViewMode from "../widgets/view_widgets/view_mode.js"; -export type ViewTypeOptions = "list" | "grid" | "calendar"; +export type ViewTypeOptions = "list" | "grid" | "calendar" | "table"; export default class NoteListRenderer { @@ -20,19 +21,26 @@ export default class NoteListRenderer { showNotePath }; - if (this.viewType === "list" || this.viewType === "grid") { - this.viewMode = new ListOrGridView(this.viewType, args); - } else if (this.viewType === "calendar") { - this.viewMode = new CalendarView(args); - } else { - this.viewMode = null; + switch (this.viewType) { + case "list": + case "grid": + this.viewMode = new ListOrGridView(this.viewType, args); + break; + case "calendar": + this.viewMode = new CalendarView(args); + break; + case "table": + this.viewMode = new TableView(args); + break; + default: + this.viewMode = null; } } #getViewType(parentNote: FNote): ViewTypeOptions { const viewType = parentNote.getLabelValue("viewType"); - if (!["list", "grid", "calendar"].includes(viewType || "")) { + if (!["list", "grid", "calendar", "table"].includes(viewType || "")) { // when not explicitly set, decide based on the note type return parentNote.type === "search" ? "list" : "grid"; } else { diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index e3ae657b7..fadf09a4a 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -760,7 +760,8 @@ "expand": "Expand", "book_properties": "Book Properties", "invalid_view_type": "Invalid view type '{{type}}'", - "calendar": "Calendar" + "calendar": "Calendar", + "table": "Table" }, "edited_notes": { "no_edited_notes_found": "No edited notes on this day yet...", diff --git a/apps/client/src/widgets/ribbon_widgets/book_properties.ts b/apps/client/src/widgets/ribbon_widgets/book_properties.ts index f1a06f640..5be7a86c5 100644 --- a/apps/client/src/widgets/ribbon_widgets/book_properties.ts +++ b/apps/client/src/widgets/ribbon_widgets/book_properties.ts @@ -24,6 +24,7 @@ const TPL = /*html*/` + @@ -126,7 +127,7 @@ export default class BookPropertiesWidget extends NoteContextAwareWidget { return; } - if (!["list", "grid", "calendar"].includes(type)) { + if (!["list", "grid", "calendar", "table"].includes(type)) { throw new Error(t("book_properties.invalid_view_type", { type })); } diff --git a/apps/client/src/widgets/view_widgets/table_view.ts b/apps/client/src/widgets/view_widgets/table_view.ts new file mode 100644 index 000000000..6029df9e6 --- /dev/null +++ b/apps/client/src/widgets/view_widgets/table_view.ts @@ -0,0 +1,24 @@ +import ViewMode, { ViewModeArgs } from "./view_mode"; + +const TPL = /*html*/` +
Table view goes here.
+