From 4e068a86669d8d029a4ecad2fc3301bc09f3ae30 Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Thu, 18 Jul 2024 14:54:11 +0200 Subject: [PATCH] prepare calendar view --- dist/index.js | 24 +++++++++++++++++++++++- src/Views/Objects/calendarView.tsx | 28 ++++++++++++++++++++++++++++ src/Views/Objects/objectPane.tsx | 4 ++++ src/translations.ts | 3 +++ 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 src/Views/Objects/calendarView.tsx diff --git a/dist/index.js b/dist/index.js index a2c07767..5a92dcce 100644 --- a/dist/index.js +++ b/dist/index.js @@ -516,6 +516,7 @@ viewNotes: "Notes", viewKanban: "Kanban", viewStatus: "Status", + viewCalendar: "Calendar", noObjects: "No objects", objectTitle: "Object title", objectTitlePlaceholder: "My object", @@ -622,6 +623,7 @@ viewNotes: "Notas", viewKanban: "Kanban", viewStatus: "Estado", + viewCalendar: "Calendario", noObjects: "Sin objetos", objectTitle: "T\xEDtulo", objectTitlePlaceholder: "Mi objeto", @@ -726,6 +728,7 @@ viewNotes: "Notizen", viewKanban: "Kanban", viewStatus: "Status", + viewCalendar: "Kalender", noObjects: "Keine Objekte", objectTitle: "Titel", objectTitlePlaceholder: "Mein Objekt", @@ -2063,12 +2066,29 @@ ); } + // src/Views/Objects/calendarView.tsx + function CalendarView(chat, messageObjects, selectedObject, isShowingObjectModal) { + const notes = new ListState(); + messageObjects.handleAddition((messageObject) => { + const latest = chat.getMostRecentContent(messageObject); + if (!latest) return; + if (!latest.date) return; + notes.add(messageObject); + messageObjects.handleRemoval( + messageObject, + () => notes.remove(messageObject) + ); + }); + return /* @__PURE__ */ createElement("div", { class: "width-100 height-100 scroll-v padding" }, ObjectGridView(chat, notes, selectedObject, isShowingObjectModal)); + } + // src/Views/Objects/objectPane.tsx var viewTypes = { all: [translation.viewAll, "grid_view"], notes: [translation.viewNotes, icons.noteContent], kanban: [translation.viewKanban, "view_kanban"], - status: [translation.viewStatus, icons.status] + status: [translation.viewStatus, icons.status], + calendar: [translation.viewCalendar, icons.date] }; function ObjectPane(chat) { const isShowingObjectModal = new State(false); @@ -2168,6 +2188,8 @@ return KanbanView; case "status": return StatusView; + case "calendar": + return CalendarView; default: return AllObjectsView; } diff --git a/src/Views/Objects/calendarView.tsx b/src/Views/Objects/calendarView.tsx new file mode 100644 index 00000000..a2f5d43e --- /dev/null +++ b/src/Views/Objects/calendarView.tsx @@ -0,0 +1,28 @@ +import * as React from "bloatless-react"; + +import { Chat, MessageObject } from "../../Model/chatModel"; + +import { ObjectGridView } from "./objectGridView"; + +export function CalendarView( + chat: Chat, + messageObjects: React.MapState, + selectedObject: React.State, + isShowingObjectModal: React.State +) { + const notes = new React.ListState(); + messageObjects.handleAddition((messageObject) => { + const latest = chat.getMostRecentContent(messageObject); + if (!latest) return; + if (!latest.date) return; + + notes.add(messageObject); + messageObjects.handleRemoval(messageObject, () => + notes.remove(messageObject) + ); + }); + + return
+ {ObjectGridView(chat, notes, selectedObject, isShowingObjectModal)} +
; +} diff --git a/src/Views/Objects/objectPane.tsx b/src/Views/Objects/objectPane.tsx index 8cf87795..bfe087b5 100644 --- a/src/Views/Objects/objectPane.tsx +++ b/src/Views/Objects/objectPane.tsx @@ -12,12 +12,14 @@ import { icons } from "../../icons"; import { translation } from "../../translations"; import { previousObjectSearches } from "../../Model/model"; import { stringToOptionTag } from "../../utility"; +import { CalendarView } from "./calendarView"; export const viewTypes = { all: [translation.viewAll, "grid_view"], notes: [translation.viewNotes, icons.noteContent], kanban: [translation.viewKanban, "view_kanban"], status: [translation.viewStatus, icons.status], + calendar: [translation.viewCalendar, icons.date], }; export function ObjectPane(chat: Chat) { @@ -143,6 +145,8 @@ export function ObjectPane(chat: Chat) { return KanbanView; case "status": return StatusView; + case "calendar": + return CalendarView; default: return AllObjectsView; } diff --git a/src/translations.ts b/src/translations.ts index 3d0c8759..0e8d799e 100644 --- a/src/translations.ts +++ b/src/translations.ts @@ -114,6 +114,7 @@ const englishTranslations = { viewNotes: "Notes", viewKanban: "Kanban", viewStatus: "Status", + viewCalendar: "Calendar", noObjects: "No objects", @@ -254,6 +255,7 @@ const allTranslations: { [key: string]: typeof englishTranslations } = { viewNotes: "Notas", viewKanban: "Kanban", viewStatus: "Estado", + viewCalendar: "Calendario", noObjects: "Sin objetos", @@ -391,6 +393,7 @@ const allTranslations: { [key: string]: typeof englishTranslations } = { viewNotes: "Notizen", viewKanban: "Kanban", viewStatus: "Status", + viewCalendar: "Kalender", noObjects: "Keine Objekte",