mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-29 00:16:39 +01:00
Merge pull request #1237 from iamanishroy/new-field-subtable-array
Array Subtable bug fixes
This commit is contained in:
@@ -141,6 +141,34 @@ export default function MenuContents({ onClose }: IMenuContentsProps) {
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const handleClearValue = () => {
|
||||
const clearValue = () => {
|
||||
updateField({
|
||||
path: selectedCell.path,
|
||||
fieldName: selectedColumn.fieldName,
|
||||
arrayTableData: {
|
||||
index: selectedCell.arrayIndex,
|
||||
},
|
||||
value: null,
|
||||
deleteField: true,
|
||||
});
|
||||
onClose();
|
||||
};
|
||||
|
||||
if (altPress || row._rowy_ref.arrayTableData !== undefined) {
|
||||
clearValue();
|
||||
} else {
|
||||
confirm({
|
||||
title: "Clear cell value?",
|
||||
body: "The cell’s value cannot be recovered after",
|
||||
confirm: "Delete",
|
||||
confirmColor: "error",
|
||||
handleConfirm: clearValue,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const rowActions: IContextMenuItem[] = [
|
||||
{
|
||||
label: "Copy ID",
|
||||
@@ -214,13 +242,7 @@ export default function MenuContents({ onClose }: IMenuContentsProps) {
|
||||
// Cell actions
|
||||
// TODO: Add copy and paste here
|
||||
const cellValue = row?.[selectedCell.columnKey];
|
||||
const handleClearValue = () =>
|
||||
updateField({
|
||||
path: selectedCell.path,
|
||||
fieldName: selectedColumn.fieldName,
|
||||
value: null,
|
||||
deleteField: true,
|
||||
});
|
||||
|
||||
const columnFilters = getFieldProp(
|
||||
"filter",
|
||||
selectedColumn?.type === FieldType.derivative
|
||||
@@ -247,18 +269,7 @@ export default function MenuContents({ onClose }: IMenuContentsProps) {
|
||||
!row ||
|
||||
cellValue === undefined ||
|
||||
getFieldProp("group", selectedColumn?.type) === "Auditing",
|
||||
onClick: altPress
|
||||
? handleClearValue
|
||||
: () => {
|
||||
confirm({
|
||||
title: "Clear cell value?",
|
||||
body: "The cell’s value cannot be recovered after",
|
||||
confirm: "Delete",
|
||||
confirmColor: "error",
|
||||
handleConfirm: handleClearValue,
|
||||
});
|
||||
onClose();
|
||||
},
|
||||
onClick: handleClearValue,
|
||||
},
|
||||
{
|
||||
label: "Filter value",
|
||||
|
||||
@@ -201,7 +201,7 @@ export function useFirestoreDocAsCollectionWithAtom<T = TableRow>(
|
||||
useEffect(() => {
|
||||
if (deleteDocAtom) {
|
||||
setDeleteRowAtom(() => (_: string, options?: ArrayTableRowData) => {
|
||||
if (!options || !options.index) return;
|
||||
if (!options || options.index === undefined) return;
|
||||
const updateFunction = deleteRow(options.index);
|
||||
return setRows(updateFunction);
|
||||
});
|
||||
@@ -348,7 +348,6 @@ function useAlterArrayTable<T>({
|
||||
|
||||
return (rows) => {
|
||||
if (addTo === "bottom") {
|
||||
console.log("bottom", newRow(rows.length, false));
|
||||
rows.push(newRow(rows.length, false));
|
||||
} else {
|
||||
rows = [newRow(0, false), ...rows];
|
||||
|
||||
Reference in New Issue
Block a user