mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
removed unwanted changes
This commit is contained in:
@@ -146,11 +146,7 @@ export const addRowAtom = atom(
|
||||
|
||||
// Write to database if no required fields are missing
|
||||
else {
|
||||
await updateRowDb(
|
||||
row._rowy_ref.path,
|
||||
omitRowyFields(rowValues),
|
||||
undefined
|
||||
);
|
||||
await updateRowDb(row._rowy_ref.path, omitRowyFields(rowValues));
|
||||
}
|
||||
|
||||
if (auditChange) auditChange("ADD_ROW", row._rowy_ref.path);
|
||||
@@ -341,8 +337,6 @@ export interface IUpdateFieldOptions {
|
||||
useArrayRemove?: boolean;
|
||||
/** Optionally, used to locate the row in ArraySubTable. */
|
||||
arrayTableData?: ArrayTableRowData;
|
||||
/** Optionally, explicitly specify to use firestore's update method. Required in case of JSON field update. */
|
||||
// useUpdate?: boolean;
|
||||
}
|
||||
/**
|
||||
* Set function updates or deletes a field in a row.
|
||||
|
||||
@@ -88,6 +88,7 @@ export interface ISideDrawerFieldProps<T = any> {
|
||||
/** Update the local value. Also calls onDirty */
|
||||
onChange: (value: T) => void;
|
||||
/** Call when user input is ready to be saved (e.g. onBlur) */
|
||||
|
||||
onSubmit: () => void;
|
||||
/** Field locked. Do NOT check `column.locked` */
|
||||
disabled: boolean;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import useMemoValue from "use-memo-value";
|
||||
import { useAtom, PrimitiveAtom, useSetAtom, SetStateAction } from "jotai";
|
||||
import { set, update } from "lodash-es";
|
||||
import { set } from "lodash-es";
|
||||
import {
|
||||
Firestore,
|
||||
query,
|
||||
@@ -36,7 +36,6 @@ import {
|
||||
TableFilter,
|
||||
TableSort,
|
||||
TableRow,
|
||||
UpdateRowOptions,
|
||||
} from "@src/types/table";
|
||||
import { firebaseDbAtom } from "@src/sources/ProjectSourceFirebase";
|
||||
import { COLLECTION_PAGE_SIZE } from "@src/config/db";
|
||||
@@ -257,28 +256,22 @@ export function useFirestoreCollectionWithAtom<
|
||||
// set the atom’s value to a function that updates a doc in the collection
|
||||
if (updateDocAtom) {
|
||||
setUpdateDocAtom(
|
||||
() =>
|
||||
async (
|
||||
path: string,
|
||||
update: T,
|
||||
deleteFields?: string[],
|
||||
options?: UpdateRowOptions
|
||||
) => {
|
||||
const updateToDb = { ...update };
|
||||
() => async (path: string, update: T, deleteFields?: string[]) => {
|
||||
const updateToDb = { ...update };
|
||||
|
||||
if (Array.isArray(deleteFields)) {
|
||||
for (const field of deleteFields) {
|
||||
set(updateToDb as any, field, deleteField());
|
||||
}
|
||||
}
|
||||
try {
|
||||
return await updateDoc(doc(firebaseDb, path), updateToDb);
|
||||
} catch (e) {
|
||||
return await setDoc(doc(firebaseDb, path), updateToDb, {
|
||||
merge: true,
|
||||
});
|
||||
if (Array.isArray(deleteFields)) {
|
||||
for (const field of deleteFields) {
|
||||
set(updateToDb as any, field, deleteField());
|
||||
}
|
||||
}
|
||||
try {
|
||||
return await updateDoc(doc(firebaseDb, path), updateToDb);
|
||||
} catch (e) {
|
||||
return await setDoc(doc(firebaseDb, path), updateToDb, {
|
||||
merge: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
6
src/types/table.d.ts
vendored
6
src/types/table.d.ts
vendored
@@ -32,7 +32,7 @@ export type UpdateCollectionDocFunction<T = TableRow> = (
|
||||
path: string,
|
||||
update: Partial<T>,
|
||||
deleteFields?: string[],
|
||||
options?: ArrayTableRowData & UpdateRowOptions
|
||||
options?: ArrayTableRowData
|
||||
) => Promise<void>;
|
||||
|
||||
/**
|
||||
@@ -211,10 +211,6 @@ export type TableSort = {
|
||||
direction: Parameters<typeof orderBy>[1];
|
||||
};
|
||||
|
||||
export type UpdateRowOptions = {
|
||||
useUpdate?: boolean;
|
||||
};
|
||||
|
||||
export type ArrayTableRowData = {
|
||||
index?: number;
|
||||
parentField?: string;
|
||||
|
||||
Reference in New Issue
Block a user