Merge branch 'brendanlaschke-context-menu-vertical'
This commit is contained in:
@ -2,10 +2,10 @@ import { useCallback } from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
import { useSetRecoilState } from 'recoil';
|
||||
|
||||
import { actionBarOpenState } from '@/ui/action-bar/states/ActionBarIsOpenState';
|
||||
import { Checkbox } from '@/ui/input/checkbox/components/Checkbox';
|
||||
|
||||
import { useCurrentRowSelected } from '../hooks/useCurrentRowSelected';
|
||||
import { contextMenuPositionState } from '../states/contextMenuPositionState';
|
||||
|
||||
const StyledContainer = styled.div`
|
||||
align-items: center;
|
||||
@ -18,14 +18,13 @@ const StyledContainer = styled.div`
|
||||
`;
|
||||
|
||||
export function CheckboxCell() {
|
||||
const setContextMenuPosition = useSetRecoilState(contextMenuPositionState);
|
||||
|
||||
const setActionBarOpenState = useSetRecoilState(actionBarOpenState);
|
||||
const { currentRowSelected, setCurrentRowSelected } = useCurrentRowSelected();
|
||||
|
||||
const handleClick = useCallback(() => {
|
||||
setCurrentRowSelected(!currentRowSelected);
|
||||
setContextMenuPosition({ x: null, y: null });
|
||||
}, [currentRowSelected, setContextMenuPosition, setCurrentRowSelected]);
|
||||
setActionBarOpenState(true);
|
||||
}, [currentRowSelected, setActionBarOpenState, setCurrentRowSelected]);
|
||||
|
||||
return (
|
||||
<StyledContainer onClick={handleClick}>
|
||||
|
||||
@ -1,28 +1,29 @@
|
||||
import { useContext } from 'react';
|
||||
import { useSetRecoilState } from 'recoil';
|
||||
|
||||
import { contextMenuOpenState } from '@/ui/context-menu/states/ContextMenuIsOpenState';
|
||||
import { contextMenuPositionState } from '@/ui/context-menu/states/ContextMenuPositionState';
|
||||
import { RecoilScope } from '@/ui/utilities/recoil-scope/components/RecoilScope';
|
||||
|
||||
import { ColumnIndexContext } from '../contexts/ColumnIndexContext';
|
||||
import { ViewFieldContext } from '../contexts/ViewFieldContext';
|
||||
import { GenericEditableCell } from '../editable-cell/components/GenericEditableCell';
|
||||
import { useCurrentRowSelected } from '../hooks/useCurrentRowSelected';
|
||||
import { contextMenuPositionState } from '../states/contextMenuPositionState';
|
||||
|
||||
export function EntityTableCell({ cellIndex }: { cellIndex: number }) {
|
||||
const setContextMenuPosition = useSetRecoilState(contextMenuPositionState);
|
||||
const setContextMenuOpenState = useSetRecoilState(contextMenuOpenState);
|
||||
|
||||
const { setCurrentRowSelected } = useCurrentRowSelected();
|
||||
|
||||
function handleContextMenu(event: React.MouseEvent) {
|
||||
event.preventDefault();
|
||||
|
||||
setCurrentRowSelected(true);
|
||||
|
||||
setContextMenuPosition({
|
||||
x: event.clientX,
|
||||
y: event.clientY,
|
||||
});
|
||||
setContextMenuOpenState(true);
|
||||
}
|
||||
|
||||
const viewField = useContext(ViewFieldContext);
|
||||
|
||||
@ -8,12 +8,16 @@ export function GenericEntityTableData({
|
||||
orderBy = defaultOrderBy,
|
||||
whereFilters,
|
||||
filterDefinitionArray,
|
||||
setActionBar,
|
||||
setContextMenu,
|
||||
}: {
|
||||
useGetRequest: any;
|
||||
getRequestResultKey: string;
|
||||
orderBy?: any;
|
||||
whereFilters?: any;
|
||||
filterDefinitionArray: FilterDefinition[];
|
||||
setActionBar?: () => void;
|
||||
setContextMenu?: () => void;
|
||||
}) {
|
||||
const setEntityTableData = useSetEntityTableData();
|
||||
useGetRequest({
|
||||
@ -24,5 +28,11 @@ export function GenericEntityTableData({
|
||||
},
|
||||
});
|
||||
|
||||
if (setActionBar) {
|
||||
setActionBar();
|
||||
}
|
||||
if (setContextMenu) {
|
||||
setContextMenu();
|
||||
}
|
||||
return <></>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user