ObjectTree: keyed elements, full width;
This commit is contained in:
@ -51,9 +51,9 @@ const ObjectTree = ({
|
||||
|
||||
if (selectedDistrict) {
|
||||
return (
|
||||
<div>
|
||||
<TypeTree map_id={map_id} label='Существующие' value={'existing'} count={existingCount} objectList={existingObjectsList} planning={0} />
|
||||
<TypeTree map_id={map_id} label='Планируемые' value={'planning'} count={planningCount} objectList={planningObjectsList} planning={1} />
|
||||
<div style={{ width: '100%' }}>
|
||||
<TypeTree key={'existing'} map_id={map_id} label='Существующие' value={'existing'} count={existingCount} objectList={existingObjectsList} planning={0} />
|
||||
<TypeTree key={'planning'} map_id={map_id} label='Планируемые' value={'planning'} count={planningCount} objectList={planningObjectsList} planning={1} />
|
||||
</div>
|
||||
)
|
||||
} else {
|
||||
@ -84,12 +84,12 @@ const TypeTree = ({
|
||||
|
||||
return (
|
||||
<Tree size="small" aria-label="Small Size Tree">
|
||||
<TreeItem itemType="branch">
|
||||
<TreeItem key={`branch-${label}`} itemType="branch">
|
||||
<TreeItemLayout>{`${label} ${count ? `(${count})` : ''}`}</TreeItemLayout>
|
||||
|
||||
<Tree>
|
||||
{Array.isArray(objectList) && objectList.map(list => (
|
||||
<ObjectList map_id={map_id} key={list.id} label={list.name} id={list.id} planning={planning} count={list.count} />
|
||||
<ObjectList map_id={map_id} key={`${label}-${list.id}`} label={list.name} id={list.id} planning={planning} count={list.count} />
|
||||
))}
|
||||
</Tree>
|
||||
</TreeItem>
|
||||
@ -124,8 +124,8 @@ const ObjectList = ({
|
||||
)
|
||||
|
||||
const navLinks = useMemo(() => (
|
||||
Array.isArray(data) ? data.map((type) => (
|
||||
<TreeItem itemType='leaf' onClick={() => setCurrentObjectId(map_id, type.object_id)}>
|
||||
Array.isArray(data) ? data.map((type, index) => (
|
||||
<TreeItem key={`${label}-${id}-${index}`} itemType='leaf' onClick={() => setCurrentObjectId(map_id, type.object_id)}>
|
||||
<TreeItemLayout>{type.caption ? type.caption : 'Без названия'}</TreeItemLayout>
|
||||
</TreeItem>
|
||||
)) : null
|
||||
@ -140,14 +140,6 @@ const ObjectList = ({
|
||||
</Tree>
|
||||
</TreeItem>
|
||||
)
|
||||
|
||||
// return (
|
||||
// <NavLink onClick={() => { setSelectedObjectType(map_id, id) }} rightSection={<IconChevronDown size={14} />} p={0} label={`${label} ${count ? `(${count})` : ''}`}>
|
||||
// {Array.isArray(data) && data.map((type) => (
|
||||
// <NavLink key={type.object_id} label={type.caption ? type.caption : 'Без названия'} p={0} onClick={() => setCurrentObjectId(map_id, type.object_id)} />
|
||||
// ))}
|
||||
// </NavLink>
|
||||
// )
|
||||
}
|
||||
|
||||
export default ObjectTree
|
Reference in New Issue
Block a user