mirror of
https://github.com/rowyio/rowy.git
synced 2025-12-28 16:06:41 +01:00
save the sort in firebase
This commit is contained in:
@@ -192,9 +192,10 @@ export default function ColumnMenu({
|
||||
setTableSorts(
|
||||
isSorted && !isAsc ? [] : [{ key: sortKey, direction: "desc" }]
|
||||
);
|
||||
if (!isSorted || isAsc) {
|
||||
triggerSaveTableSorts([{ key: sortKey, direction: "desc" }]);
|
||||
}
|
||||
|
||||
triggerSaveTableSorts(
|
||||
isSorted && !isAsc ? [] : [{ key: sortKey, direction: "desc" }]
|
||||
);
|
||||
handleClose();
|
||||
},
|
||||
active: isSorted && !isAsc,
|
||||
@@ -209,9 +210,9 @@ export default function ColumnMenu({
|
||||
setTableSorts(
|
||||
isSorted && isAsc ? [] : [{ key: sortKey, direction: "asc" }]
|
||||
);
|
||||
if (!isSorted || !isAsc) {
|
||||
triggerSaveTableSorts([{ key: sortKey, direction: "asc" }]);
|
||||
}
|
||||
triggerSaveTableSorts(
|
||||
isSorted && isAsc ? [] : [{ key: sortKey, direction: "asc" }]
|
||||
);
|
||||
handleClose();
|
||||
},
|
||||
active: isSorted && isAsc,
|
||||
|
||||
@@ -38,14 +38,12 @@ export const ColumnHeaderSort = memo(function ColumnHeaderSort({
|
||||
const triggerSaveTableSorts = useSaveTableSorts(canEditColumns);
|
||||
|
||||
const handleSortClick = () => {
|
||||
if (nextSort === "none") setTableSorts([]);
|
||||
else setTableSorts([{ key: sortKey, direction: nextSort }]);
|
||||
triggerSaveTableSorts([
|
||||
{
|
||||
key: sortKey,
|
||||
direction: nextSort === "none" ? "asc" : nextSort,
|
||||
},
|
||||
]);
|
||||
setTableSorts(
|
||||
nextSort === "none" ? [] : [{ key: sortKey, direction: nextSort }]
|
||||
);
|
||||
triggerSaveTableSorts(
|
||||
nextSort === "none" ? [] : [{ key: sortKey, direction: nextSort }]
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -57,17 +57,16 @@ export default function Sort() {
|
||||
options={sortColumns}
|
||||
value={tableSorts[0].key}
|
||||
onChange={(value: string | null) => {
|
||||
if (value) {
|
||||
setTableSorts([
|
||||
{ key: value, direction: tableSorts[0].direction },
|
||||
]);
|
||||
|
||||
triggerSaveTableSorts([
|
||||
{ key: value, direction: tableSorts[0].direction },
|
||||
]);
|
||||
} else {
|
||||
setTableSorts([]);
|
||||
}
|
||||
setTableSorts(
|
||||
value === null
|
||||
? []
|
||||
: [{ key: value, direction: tableSorts[0].direction }]
|
||||
);
|
||||
triggerSaveTableSorts(
|
||||
value === null
|
||||
? []
|
||||
: [{ key: value, direction: tableSorts[0].direction }]
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</Grid>
|
||||
@@ -111,7 +110,10 @@ export default function Sort() {
|
||||
<Grid item xs={1} alignSelf="flex-end">
|
||||
<IconButton
|
||||
size="small"
|
||||
onClick={() => setTableSorts([])}
|
||||
onClick={() => {
|
||||
setTableSorts([]);
|
||||
triggerSaveTableSorts([]);
|
||||
}}
|
||||
sx={{
|
||||
"&:hover, &:focus": {
|
||||
color: "error.main",
|
||||
|
||||
Reference in New Issue
Block a user