From 2a30dfc1a3f66032918ef7d2e5cb68ba621259c5 Mon Sep 17 00:00:00 2001 From: marlon-erler Date: Fri, 12 Jul 2024 20:40:03 +0200 Subject: [PATCH] add total object count --- dist/index.js | 13 ++++++++++--- src/Views/Objects/allObjectsView.tsx | 12 +++++++++++- src/Views/Objects/noteObjectsView.tsx | 2 +- src/Views/Objects/objectGridView.tsx | 2 +- src/translations.ts | 6 ++++++ 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/dist/index.js b/dist/index.js index 4a3d8bd8..e2970ff4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -490,6 +490,7 @@ copyMessage: "Copy message", deleteMessage: "Delete message", // objects + objectsInTotal: "Objects in total: ", showObjects: "show objects", createObject: "create object", untitledObject: "Untitled Object", @@ -581,6 +582,7 @@ copyMessage: "Copiar mensaje", deleteMessage: "Eliminar este mensaje", // objects + objectsInTotal: "Objetos en total: ", showObjects: "mostrar objetos", createObject: "a\xF1adir nuevo objeto", untitledObject: "Sin T\xEDtulo", @@ -670,6 +672,7 @@ copyMessage: "Nachricht kopieren", deleteMessage: "Nachricht l\xF6schen", // objects + objectsInTotal: "Objekte insgesamt: ", showObjects: "Objekte anzeigen", createObject: "Neues Objekt erstellen", untitledObject: "Unbenannt", @@ -1482,7 +1485,7 @@ return /* @__PURE__ */ createElement( "div", { - class: "width-100 max-height-100 grid gap padding scroll-v", + class: "grid gap padding", style: "grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));", "children:prepend": [messageObjects, objectConverter] } @@ -1491,7 +1494,11 @@ // src/Views/Objects/allObjectsView.tsx function AllObjectsView(chat, selectedObject, isShowingObjectModal) { - return /* @__PURE__ */ createElement("div", { class: "width-100 height-100" }, ObjectGridView(chat, chat.objects, selectedObject, isShowingObjectModal)); + const objectCount = createProxyState( + [chat.objects], + () => chat.objects.value.size + ); + return /* @__PURE__ */ createElement("div", { class: "width-100 height-100 scroll-v padding-top" }, /* @__PURE__ */ createElement("b", { class: "secondary padding" }, translation.objectsInTotal, " ", /* @__PURE__ */ createElement("span", { "subscribe:innerText": objectCount })), ObjectGridView(chat, chat.objects, selectedObject, isShowingObjectModal)); } // src/Views/renameView.tsx @@ -1629,7 +1636,7 @@ () => notes.remove(messageObject) ); }); - return /* @__PURE__ */ createElement("div", { class: "width-100 height-100" }, ObjectGridView(chat, notes, selectedObject, isShowingObjectModal)); + return /* @__PURE__ */ createElement("div", { class: "width-100 height-100 scroll-v" }, ObjectGridView(chat, notes, selectedObject, isShowingObjectModal)); } // src/Views/Objects/objectDetailModal.tsx diff --git a/src/Views/Objects/allObjectsView.tsx b/src/Views/Objects/allObjectsView.tsx index 3c3d7c0c..e196249b 100644 --- a/src/Views/Objects/allObjectsView.tsx +++ b/src/Views/Objects/allObjectsView.tsx @@ -3,14 +3,24 @@ import * as React from "bloatless-react"; import { Chat, MessageObject } from "../../Model/chatModel"; import { ObjectGridView } from "./objectGridView"; +import { translation } from "../../translations"; export function AllObjectsView( chat: Chat, selectedObject: React.State, isShowingObjectModal: React.State ) { + const objectCount = React.createProxyState( + [chat.objects], + () => chat.objects.value.size + ); + return ( -
+
+ + {translation.objectsInTotal}{" "} + + {ObjectGridView(chat, chat.objects, selectedObject, isShowingObjectModal)}
); diff --git a/src/Views/Objects/noteObjectsView.tsx b/src/Views/Objects/noteObjectsView.tsx index 501fe673..bab2c6c0 100644 --- a/src/Views/Objects/noteObjectsView.tsx +++ b/src/Views/Objects/noteObjectsView.tsx @@ -21,7 +21,7 @@ export function NoteObjectsView( ); }); - return
+ return
{ObjectGridView(chat, notes, selectedObject, isShowingObjectModal)}
; } diff --git a/src/Views/Objects/objectGridView.tsx b/src/Views/Objects/objectGridView.tsx index 0c82fb8d..4b8e5783 100644 --- a/src/Views/Objects/objectGridView.tsx +++ b/src/Views/Objects/objectGridView.tsx @@ -26,7 +26,7 @@ export function ObjectGridView( return (
diff --git a/src/translations.ts b/src/translations.ts index 620c9012..1a959d04 100644 --- a/src/translations.ts +++ b/src/translations.ts @@ -84,6 +84,8 @@ const englishTranslations = { deleteMessage: "Delete message", // objects + objectsInTotal: "Objects in total: ", + showObjects: "show objects", createObject: "create object", untitledObject: "Untitled Object", @@ -202,6 +204,8 @@ const allTranslations: { [key: string]: typeof englishTranslations } = { deleteMessage: "Eliminar este mensaje", // objects + objectsInTotal: "Objetos en total: ", + showObjects: "mostrar objetos", createObject: "añadir nuevo objeto", untitledObject: "Sin Título", @@ -317,6 +321,8 @@ const allTranslations: { [key: string]: typeof englishTranslations } = { deleteMessage: "Nachricht löschen", // objects + objectsInTotal: "Objekte insgesamt: ", + showObjects: "Objekte anzeigen", createObject: "Neues Objekt erstellen", untitledObject: "Unbenannt",