mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
@@ -122,7 +122,7 @@ export const TableBody = memo(function TableBody({
|
||||
|
||||
if (cell.id.includes("_rowy_select")) {
|
||||
return (
|
||||
<StyledCell key={cell.id} role="gridcell">
|
||||
<StyledCell key={cell.id} role="gridcell" data-frozen="left">
|
||||
{flexRender(cell.column.columnDef.cell, cell.getContext())}
|
||||
</StyledCell>
|
||||
);
|
||||
|
||||
@@ -79,7 +79,8 @@ export const TableHeader = memo(function TableHeader({
|
||||
<StyledColumnHeader
|
||||
key={header.id}
|
||||
role="columnheader"
|
||||
style={{ padding: 0 }}
|
||||
style={{ padding: 0, zIndex: 11 }}
|
||||
data-frozen="left"
|
||||
>
|
||||
{flexRender(
|
||||
header.column.columnDef.header,
|
||||
|
||||
@@ -165,6 +165,10 @@ export function useMenuAction(
|
||||
async (e?: ClipboardEvent) => {
|
||||
try {
|
||||
if (!selectedCell || !selectedCol) return;
|
||||
|
||||
// checks which element has focus, if it is not the gridcell it won't paste the copied content inside the gridcell
|
||||
if (document.activeElement?.role !== "gridcell") return;
|
||||
|
||||
let text: string;
|
||||
// Firefox doesn't allow for reading clipboard data, hence the workaround
|
||||
if (navigator.userAgent.includes("Firefox")) {
|
||||
|
||||
@@ -26,6 +26,8 @@ import {
|
||||
userRolesAtom,
|
||||
compatibleRowyRunVersionAtom,
|
||||
rowyRunModalAtom,
|
||||
altPressAtom,
|
||||
confirmDialogAtom,
|
||||
} from "@src/atoms/projectScope";
|
||||
import {
|
||||
tableScope,
|
||||
@@ -91,6 +93,8 @@ function RowSelectedToolBar({
|
||||
}) {
|
||||
const [serverDocCount] = useAtom(serverDocCountAtom, tableScope);
|
||||
const deleteRow = useSetAtom(deleteRowAtom, tableScope);
|
||||
const [altPress] = useAtom(altPressAtom, projectScope);
|
||||
const confirm = useSetAtom(confirmDialogAtom, projectScope);
|
||||
|
||||
const handleDelete = async () => {
|
||||
await deleteRow({ path: Object.keys(selectedRows) });
|
||||
@@ -107,7 +111,20 @@ function RowSelectedToolBar({
|
||||
variant="outlined"
|
||||
startIcon={<DeleteIcon fontSize="small" />}
|
||||
color="error"
|
||||
onClick={handleDelete}
|
||||
onClick={
|
||||
altPress
|
||||
? handleDelete
|
||||
: () => {
|
||||
confirm({
|
||||
title: `Delete ${
|
||||
Object.values(selectedRows).length
|
||||
} of ${serverDocCount} selected rows?`,
|
||||
confirm: "Delete",
|
||||
confirmColor: "error",
|
||||
handleConfirm: handleDelete,
|
||||
});
|
||||
}
|
||||
}
|
||||
>
|
||||
Delete
|
||||
</Button>
|
||||
|
||||
@@ -88,8 +88,8 @@ 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;
|
||||
|
||||
onSubmit: () => void;
|
||||
/** Field locked. Do NOT check `column.locked` */
|
||||
disabled: boolean;
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
setDoc,
|
||||
doc,
|
||||
deleteDoc,
|
||||
updateDoc,
|
||||
deleteField,
|
||||
CollectionReference,
|
||||
Query,
|
||||
@@ -263,7 +264,7 @@ export function useFirestoreCollectionWithAtom<
|
||||
// set the atom’s value to a function that updates a doc in the collection
|
||||
if (updateDocAtom) {
|
||||
setUpdateDocAtom(
|
||||
() => (path: string, update: T, deleteFields?: string[]) => {
|
||||
() => async (path: string, update: T, deleteFields?: string[]) => {
|
||||
const updateToDb = { ...update };
|
||||
|
||||
if (Array.isArray(deleteFields)) {
|
||||
@@ -271,8 +272,13 @@ export function useFirestoreCollectionWithAtom<
|
||||
set(updateToDb as any, field, deleteField());
|
||||
}
|
||||
}
|
||||
|
||||
return setDoc(doc(firebaseDb, path), updateToDb, { merge: true });
|
||||
try {
|
||||
return await updateDoc(doc(firebaseDb, path), updateToDb);
|
||||
} catch (e) {
|
||||
return await setDoc(doc(firebaseDb, path), updateToDb, {
|
||||
merge: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user