mirror of
https://github.com/IRBorisov/ConceptPortal.git
synced 2025-06-26 21:10:38 +03:00
M: Remove expression column from sideview
This commit is contained in:
parent
89889c9f40
commit
ce73be22bf
|
@ -1,12 +1,11 @@
|
||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useCallback, useLayoutEffect, useMemo, useState } from 'react';
|
import { useCallback, useLayoutEffect, useMemo } from 'react';
|
||||||
|
|
||||||
import BadgeConstituenta from '@/components/info/BadgeConstituenta';
|
import BadgeConstituenta from '@/components/info/BadgeConstituenta';
|
||||||
import DataTable, { createColumnHelper, IConditionalStyle, VisibilityState } from '@/components/ui/DataTable';
|
import DataTable, { createColumnHelper, IConditionalStyle } from '@/components/ui/DataTable';
|
||||||
import NoData from '@/components/ui/NoData';
|
import NoData from '@/components/ui/NoData';
|
||||||
import { useConceptOptions } from '@/context/ConceptOptionsContext';
|
import { useConceptOptions } from '@/context/ConceptOptionsContext';
|
||||||
import useWindowSize from '@/hooks/useWindowSize';
|
|
||||||
import { ConstituentaID, IConstituenta } from '@/models/rsform';
|
import { ConstituentaID, IConstituenta } from '@/models/rsform';
|
||||||
import { isMockCst } from '@/models/rsformAPI';
|
import { isMockCst } from '@/models/rsformAPI';
|
||||||
import { PARAMETER, prefixes } from '@/utils/constants';
|
import { PARAMETER, prefixes } from '@/utils/constants';
|
||||||
|
@ -16,7 +15,6 @@ interface TableSideConstituentsProps {
|
||||||
items: IConstituenta[];
|
items: IConstituenta[];
|
||||||
activeCst?: IConstituenta;
|
activeCst?: IConstituenta;
|
||||||
onOpenEdit: (cstID: ConstituentaID) => void;
|
onOpenEdit: (cstID: ConstituentaID) => void;
|
||||||
denseThreshold?: number;
|
|
||||||
autoScroll?: boolean;
|
autoScroll?: boolean;
|
||||||
maxHeight: string;
|
maxHeight: string;
|
||||||
}
|
}
|
||||||
|
@ -28,13 +26,9 @@ function TableSideConstituents({
|
||||||
activeCst,
|
activeCst,
|
||||||
autoScroll = true,
|
autoScroll = true,
|
||||||
onOpenEdit,
|
onOpenEdit,
|
||||||
maxHeight,
|
maxHeight
|
||||||
denseThreshold = 9999
|
|
||||||
}: TableSideConstituentsProps) {
|
}: TableSideConstituentsProps) {
|
||||||
const { colors } = useConceptOptions();
|
const { colors } = useConceptOptions();
|
||||||
const windowSize = useWindowSize();
|
|
||||||
|
|
||||||
const [columnVisibility, setColumnVisibility] = useState<VisibilityState>({ expression: true });
|
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (!activeCst) {
|
if (!activeCst) {
|
||||||
|
@ -54,17 +48,6 @@ function TableSideConstituents({
|
||||||
}
|
}
|
||||||
}, [activeCst, autoScroll]);
|
}, [activeCst, autoScroll]);
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
|
||||||
setColumnVisibility(prev => {
|
|
||||||
const newValue = (windowSize.width ?? 0) >= denseThreshold;
|
|
||||||
if (newValue === prev.expression) {
|
|
||||||
return prev;
|
|
||||||
} else {
|
|
||||||
return { expression: newValue };
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, [windowSize, denseThreshold]);
|
|
||||||
|
|
||||||
const handleRowClicked = useCallback(
|
const handleRowClicked = useCallback(
|
||||||
(cst: IConstituenta) => {
|
(cst: IConstituenta) => {
|
||||||
if (!isMockCst(cst)) {
|
if (!isMockCst(cst)) {
|
||||||
|
@ -103,25 +86,6 @@ function TableSideConstituents({
|
||||||
{props.getValue()}
|
{props.getValue()}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}),
|
|
||||||
columnHelper.accessor('definition_formal', {
|
|
||||||
id: 'expression',
|
|
||||||
header: 'Выражение',
|
|
||||||
size: 2000,
|
|
||||||
minSize: 0,
|
|
||||||
maxSize: 2000,
|
|
||||||
enableHiding: true,
|
|
||||||
cell: props => (
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
textWrap: 'pretty',
|
|
||||||
fontSize: 12,
|
|
||||||
color: isMockCst(props.row.original) ? colors.fgWarning : undefined
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{props.getValue()}
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
[colors]
|
[colors]
|
||||||
|
@ -162,8 +126,6 @@ function TableSideConstituents({
|
||||||
conditionalRowStyles={conditionalRowStyles}
|
conditionalRowStyles={conditionalRowStyles}
|
||||||
headPosition='0'
|
headPosition='0'
|
||||||
enableHiding
|
enableHiding
|
||||||
columnVisibility={columnVisibility}
|
|
||||||
onColumnVisibilityChange={setColumnVisibility}
|
|
||||||
noDataComponent={
|
noDataComponent={
|
||||||
<NoData className='min-h-[5rem]'>
|
<NoData className='min-h-[5rem]'>
|
||||||
<p>Список конституент пуст</p>
|
<p>Список конституент пуст</p>
|
||||||
|
|
|
@ -14,9 +14,6 @@ import { animateSideView } from '@/styling/animations';
|
||||||
import ConstituentsSearch from './ConstituentsSearch';
|
import ConstituentsSearch from './ConstituentsSearch';
|
||||||
import TableSideConstituents from './TableSideConstituents';
|
import TableSideConstituents from './TableSideConstituents';
|
||||||
|
|
||||||
// Window width cutoff for expression show
|
|
||||||
const COLUMN_EXPRESSION_HIDE_THRESHOLD = 1500;
|
|
||||||
|
|
||||||
// Window width cutoff for dense search bar
|
// Window width cutoff for dense search bar
|
||||||
const COLUMN_DENSE_SEARCH_THRESHOLD = 1100;
|
const COLUMN_DENSE_SEARCH_THRESHOLD = 1100;
|
||||||
|
|
||||||
|
@ -47,7 +44,6 @@ function ViewConstituents({ expression, schema, activeCst, isBottom, onOpenEdit
|
||||||
activeCst={activeCst}
|
activeCst={activeCst}
|
||||||
onOpenEdit={onOpenEdit}
|
onOpenEdit={onOpenEdit}
|
||||||
autoScroll={!isBottom}
|
autoScroll={!isBottom}
|
||||||
denseThreshold={COLUMN_EXPRESSION_HIDE_THRESHOLD}
|
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
[isBottom, filteredData, activeCst, onOpenEdit, calculateHeight, accessLevel]
|
[isBottom, filteredData, activeCst, onOpenEdit, calculateHeight, accessLevel]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user