From 39f8926dae927da85c52249a30a018f1ea9e27ad Mon Sep 17 00:00:00 2001
From: Anish Roy <6275anishroy@gmail.com>
Date: Fri, 21 Apr 2023 14:01:35 +0530
Subject: [PATCH 1/2] description
---
src/components/fields/ArraySubTable/index.tsx | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/components/fields/ArraySubTable/index.tsx b/src/components/fields/ArraySubTable/index.tsx
index 9e062b65..ce218b58 100644
--- a/src/components/fields/ArraySubTable/index.tsx
+++ b/src/components/fields/ArraySubTable/index.tsx
@@ -22,8 +22,7 @@ export const config: IFieldConfig = {
initialValue: null,
icon: ,
settings: Settings,
- description:
- "Connects to a sub-table in the current row. Also displays number of rows inside the sub-table. Max sub-table depth: 100.",
+ description: "Connects to a array-table in the current row.",
TableCell: withRenderTableCell(DisplayCell, null, "focus", {
usesRowData: true,
disablePadding: true,
From d852459c9e84f12a861565112e711821dd68880b Mon Sep 17 00:00:00 2001
From: Anish Roy <6275anishroy@gmail.com>
Date: Fri, 21 Apr 2023 14:33:54 +0530
Subject: [PATCH 2/2] bug fix: meta getting to firstore
---
.../useFirestoreDocAsCollectionWithAtom.ts | 44 +++++++++++--------
1 file changed, 26 insertions(+), 18 deletions(-)
diff --git a/src/hooks/useFirestoreDocAsCollectionWithAtom.ts b/src/hooks/useFirestoreDocAsCollectionWithAtom.ts
index b9f2650c..5f41f266 100644
--- a/src/hooks/useFirestoreDocAsCollectionWithAtom.ts
+++ b/src/hooks/useFirestoreDocAsCollectionWithAtom.ts
@@ -24,6 +24,7 @@ import {
UpdateCollectionDocFunction,
} from "@src/types/table";
import { firebaseDbAtom } from "@src/sources/ProjectSourceFirebase";
+import { omitRowyFields } from "@src/utils/table";
type UpdateFunction = (rows: T[]) => T[];
@@ -293,22 +294,28 @@ function useAlterArrayTable({
const add = useCallback(
(addTo: "top" | "bottom", base?: T): UpdateFunction => {
- const newRow = (i: number, noMeta?: boolean) => {
- const meta = noMeta
- ? {}
- : {
- _rowy_ref: {
- id: doc(firebaseDb, path).id,
- path: doc(firebaseDb, path).path,
- arrayTableData: {
- index: i,
- parentField: fieldName,
- },
- },
- };
+ if (base) {
+ base = omitRowyFields(base);
+ }
+ const newRow = (i: number, meta: boolean) => {
+ const _meta = {
+ _rowy_ref: {
+ id: doc(firebaseDb, path).id,
+ path: doc(firebaseDb, path).path,
+ arrayTableData: {
+ index: i,
+ parentField: fieldName,
+ },
+ },
+ };
+ if (meta === true) {
+ return {
+ ...(base ?? {}),
+ ..._meta,
+ } as T;
+ }
return {
...(base ?? {}),
- ...meta,
} as T;
};
@@ -316,7 +323,7 @@ function useAlterArrayTable({
prevData = unsortRows(prevData);
if (addTo === "bottom") {
- prevData.push(newRow(prevData.length));
+ prevData.push(newRow(prevData.length, true));
} else {
const modifiedPrevData = prevData.map((row: any, i: number) => {
return {
@@ -330,16 +337,17 @@ function useAlterArrayTable({
},
};
});
- prevData = [newRow(0), ...modifiedPrevData];
+ prevData = [newRow(0, true), ...modifiedPrevData];
}
return sortRows(prevData, sorts);
});
return (rows) => {
if (addTo === "bottom") {
- rows.push(newRow(rows.length, true));
+ console.log("bottom", newRow(rows.length, false));
+ rows.push(newRow(rows.length, false));
} else {
- rows = [newRow(0, true), ...rows];
+ rows = [newRow(0, false), ...rows];
}
return rows;
};