Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE-198 - Reorganization of the plot of land interface, in particular for waste garbage cans #207

Merged
merged 15 commits into from
Jan 23, 2025
Merged
36 changes: 34 additions & 2 deletions js/extension/components/table/PlotsSelectionTable.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {useState} from 'react';
import React, {useEffect, useState} from 'react';
import { sortBy } from 'lodash';
import ReactDataGrid from './MultilineHeaderTable';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -55,12 +55,44 @@ function PlotsSelectionTable({
}
return processedRows;
})(sorting);

// Calcul height of parcels tab
const [dynamicHeight, setDynamicHeight] = useState(0);
const parentChildren = document.querySelector(".right-side").children.length

useEffect(() => {
const calculateHeight = () => {
const parent = document.querySelector(".right-side");
const parentHeight = document.querySelector(".right-side").clientHeight;
// Header size
const h3Height = document.querySelector("h3.pull-left").clientHeight;
const ulSize = document.querySelector(".plots-selection .nav").clientHeight;

// add margin if needed to parent to see all the panel on top of footer
const tabElement = document.querySelector(".plots-selection .tab-content");
parent.children.length > 2 ? tabElement.style.marginBottom = "50px" : tabElement.style.marginBottom = "";

const remainingHeight = parent.children.length > 2 ? Math.max(data.length * 35 + h3Height + ulSize + 30, 200) : Math.max(parentHeight - 220, 200); // 200px min
Copy link
Member

@pierrejego pierrejego Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See if 35 can be changed by a dynamic line height
Add comments to explain 30 and 200 px values ( 200 replace old 230 existing fixed values ) 30 margin to see object number

setDynamicHeight(remainingHeight);
};

calculateHeight();

window.addEventListener("click", calculateHeight);
window.addEventListener("resize", calculateHeight);
return () => {
window.removeEventListener("click", calculateHeight);
window.removeEventListener("resize", calculateHeight);
}
}, [data, parentChildren]);


return (<ReactDataGrid
sortable
onRowDoubleClick={onRowDoubleClick}
rowGetter={i => rows[i]}
rowsCount={rows.length}
minHeight={230}
minHeight={dynamicHeight}
columns={columns}
onGridSort={(sortColumn, sortDirection) => {
// sortDirection: "ASC", "DESC", "NONE"
Expand Down