mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
fix sort when click on icon and 3-way sort cycle
This commit is contained in:
@@ -24,7 +24,7 @@ import { useSnackbar } from 'notistack';
|
|||||||
|
|
||||||
import { Table } from '@table-library/react-table-library/table';
|
import { Table } from '@table-library/react-table-library/table';
|
||||||
import { useTheme } from '@table-library/react-table-library/theme';
|
import { useTheme } from '@table-library/react-table-library/theme';
|
||||||
import { useSort } from '@table-library/react-table-library/sort';
|
import { useSort, SortToggleType } from '@table-library/react-table-library/sort';
|
||||||
import { Header, HeaderRow, HeaderCell, Body, Row, Cell } from '@table-library/react-table-library/table';
|
import { Header, HeaderRow, HeaderCell, Body, Row, Cell } from '@table-library/react-table-library/table';
|
||||||
import { useRowSelect } from '@table-library/react-table-library/select';
|
import { useRowSelect } from '@table-library/react-table-library/select';
|
||||||
|
|
||||||
@@ -270,6 +270,7 @@ const DashboardData: FC = () => {
|
|||||||
iconUp: <KeyboardArrowUpOutlinedIcon />,
|
iconUp: <KeyboardArrowUpOutlinedIcon />,
|
||||||
iconDown: <KeyboardArrowDownOutlinedIcon />
|
iconDown: <KeyboardArrowDownOutlinedIcon />
|
||||||
},
|
},
|
||||||
|
sortToggleType: SortToggleType.AlternateWithReset,
|
||||||
sortFns: {
|
sortFns: {
|
||||||
NAME: (array) => array.sort((a, b) => a.id.slice(2).localeCompare(b.id.slice(2)))
|
NAME: (array) => array.sort((a, b) => a.id.slice(2).localeCompare(b.id.slice(2)))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
|
|
||||||
import { Table } from '@table-library/react-table-library/table';
|
import { Table } from '@table-library/react-table-library/table';
|
||||||
import { useTheme } from '@table-library/react-table-library/theme';
|
import { useTheme } from '@table-library/react-table-library/theme';
|
||||||
import { useSort } from '@table-library/react-table-library/sort';
|
import { useSort, SortToggleType } from '@table-library/react-table-library/sort';
|
||||||
import { Header, HeaderRow, HeaderCell, Body, Row, Cell } from '@table-library/react-table-library/table';
|
import { Header, HeaderRow, HeaderCell, Body, Row, Cell } from '@table-library/react-table-library/table';
|
||||||
|
|
||||||
import { useSnackbar } from 'notistack';
|
import { useSnackbar } from 'notistack';
|
||||||
@@ -145,17 +145,13 @@ const SettingsCustomization: FC = () => {
|
|||||||
iconUp: <KeyboardArrowUpOutlinedIcon />,
|
iconUp: <KeyboardArrowUpOutlinedIcon />,
|
||||||
iconDown: <KeyboardArrowDownOutlinedIcon />
|
iconDown: <KeyboardArrowDownOutlinedIcon />
|
||||||
},
|
},
|
||||||
|
sortToggleType: SortToggleType.AlternateWithReset,
|
||||||
sortFns: {
|
sortFns: {
|
||||||
NAME: (array) => array.sort((a, b) => a.id.localeCompare(b.id))
|
NAME: (array) => array.sort((a, b) => a.id.localeCompare(b.id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const sort_name = () => {
|
|
||||||
console.log(entity_sort);
|
|
||||||
entity_sort.fns.onToggleSort({ sortKey: 'NAME' });
|
|
||||||
};
|
|
||||||
|
|
||||||
const fetchDevices = useCallback(async () => {
|
const fetchDevices = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
setDevices((await EMSESP.readDevices()).data);
|
setDevices((await EMSESP.readDevices()).data);
|
||||||
@@ -434,7 +430,7 @@ const SettingsCustomization: FC = () => {
|
|||||||
fullWidth
|
fullWidth
|
||||||
style={{ fontSize: '14px', justifyContent: 'flex-start' }}
|
style={{ fontSize: '14px', justifyContent: 'flex-start' }}
|
||||||
endIcon={getSortIcon(entity_sort.state, 'NAME')}
|
endIcon={getSortIcon(entity_sort.state, 'NAME')}
|
||||||
onClick={() => sort_name()}
|
onClick={() => entity_sort.fns.onToggleSort({ sortKey: 'NAME' })}
|
||||||
>
|
>
|
||||||
NAME
|
NAME
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Reference in New Issue
Block a user