Skip to content

Commit

Permalink
Merge branch 'main' into fix_nad_update_after_geoinit_param_changed
Browse files Browse the repository at this point in the history
  • Loading branch information
souissimai authored Jan 23, 2025
2 parents 14cd89f + 59b4991 commit eeaa6a6
Show file tree
Hide file tree
Showing 55 changed files with 2,335 additions and 1,544 deletions.
42 changes: 25 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@gridsuite/commons-ui": "0.78.0",
"@gridsuite/commons-ui": "0.79.0",
"@hookform/resolvers": "^3.3.4",
"@mui/icons-material": "^5.15.14",
"@mui/lab": "5.0.0-alpha.169",
Expand All @@ -18,8 +18,8 @@
"@svgdotjs/svg.js": "^3.2.0",
"@svgdotjs/svg.panzoom.js": "^2.1.2",
"@xyflow/react": "^12.3.2",
"ag-grid-community": "^31.0.0",
"ag-grid-react": "^31.2.0",
"ag-grid-community": "^33.0.3",
"ag-grid-react": "^33.0.3",
"cheap-ruler": "^3.0.2",
"clsx": "^2.1.0",
"core-js": "^3.36.1",
Expand Down
7 changes: 7 additions & 0 deletions src/components/app-wrapper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ import {
MAP_BASEMAP_CARTO_NOLABEL,
} from '../utils/config-params';
import useNotificationsUrlGenerator from 'hooks/use-notifications-url-generator';
import { AllCommunityModule, ModuleRegistry, provideGlobalGridOptions } from 'ag-grid-community';

// Register all community features (migration to V33)
ModuleRegistry.registerModules([AllCommunityModule]);

// Mark all grids as using legacy themes (migration to V33)
provideGlobalGridOptions({ theme: 'legacy' });

let lightTheme = createTheme({
components: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ export interface CustomAggridAutocompleteFilterParams extends CustomAggridFilter
}

export const CustomAggridAutocompleteFilter: FunctionComponent<CustomAggridAutocompleteFilterParams> = ({
field,
colId,
filterParams,
filterEnums,
getEnumLabel,
}) => {
const intl = useIntl();
const { selectedFilterData, handleChangeFilterValue } = useCustomAggridFilter(field, filterParams);
const { selectedFilterData, handleChangeFilterValue } = useCustomAggridFilter(colId, filterParams);

const handleFilterAutoCompleteChange = (_: SyntheticEvent, data: string[]) => {
handleChangeFilterValue({ value: data, type: FILTER_TEXT_COMPARATORS.EQUALS });
};

const filterOption = useMemo(() => filterEnums?.[field] ?? [], [field, filterEnums]);
const filterOption = useMemo(() => filterEnums?.[colId] ?? [], [colId, filterEnums]);

return (
<Autocomplete
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ const styles = {
},
};

export const CustomAggridBooleanFilter: FunctionComponent<CustomAggridFilterParams> = ({ field, filterParams }) => {
export const CustomAggridBooleanFilter: FunctionComponent<CustomAggridFilterParams> = ({ colId, filterParams }) => {
const intl = useIntl();

const { selectedFilterData, handleChangeFilterValue } = useCustomAggridFilter(field, filterParams);
const { selectedFilterData, handleChangeFilterValue } = useCustomAggridFilter(colId, filterParams);

const handleValueChange = (event: SelectChangeEvent) => {
const newValue = event.target.value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Grid } from '@mui/material';
import { useCustomAggridComparatorFilter } from '../hooks/use-custom-aggrid-comparator-filter';
import { CustomAggridFilterParams } from '../custom-aggrid-header.type';

export const CustomAggridComparatorFilter = ({ field, filterParams }: CustomAggridFilterParams) => {
export const CustomAggridComparatorFilter = ({ colId, filterParams }: CustomAggridFilterParams) => {
const {
selectedFilterData,
selectedFilterComparator,
Expand All @@ -19,7 +19,7 @@ export const CustomAggridComparatorFilter = ({ field, filterParams }: CustomAggr
handleFilterComparatorChange,
handleFilterTextChange,
handleClearFilter,
} = useCustomAggridComparatorFilter(field, filterParams);
} = useCustomAggridComparatorFilter(colId, filterParams);

const {
filterComparators = [], // used for text filter as a UI type (examples: contains, startsWith..)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ const styles = {
},
};

const CustomAggridDurationFilter: FunctionComponent<CustomAggridFilterParams> = ({ field, filterParams }) => {
const CustomAggridDurationFilter: FunctionComponent<CustomAggridFilterParams> = ({ colId, filterParams }) => {
const intl = useIntl();

const { selectedFilterData, selectedFilterComparator, handleChangeFilterValue, handleChangeComparator } =
useCustomAggridFilter(field, filterParams);
useCustomAggridFilter(colId, filterParams);

const {
filterComparators = [], // used for text filter as a UI type (examples: contains, startsWith..)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const CustomAggridFilter = <F extends CustomAggridFilterParams>({
const [filterAnchorElement, setFilterAnchorElement] = useState<HTMLElement | null>(null);

const { selectedFilterData } = useCustomAggridFilter(
filterComponentParams.field,
filterComponentParams.colId,
filterComponentParams.filterParams
);

Expand Down Expand Up @@ -67,7 +67,7 @@ export const CustomAggridFilter = <F extends CustomAggridFilterParams>({
<CustomFilterIcon selectedFilterData={selectedFilterData} handleShowFilter={handleShowFilter} />
)}
<Popover
id={`${filterComponentParams.field}-filter-popover`}
id={`${filterComponentParams.colId}-filter-popover`}
open={!!filterAnchorElement}
anchorEl={filterAnchorElement}
onClose={onClose}
Expand Down
30 changes: 19 additions & 11 deletions src/components/custom-aggrid/custom-aggrid-header-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,21 @@ import { CustomAggridFilterParams, CustomColDef, FilterSelectorType } from './cu
import CustomHeaderComponent from './custom-aggrid-header';

export const makeAgGridCustomHeaderColumn = <F extends CustomAggridFilterParams = CustomAggridFilterParams>({
sortProps, // sortProps: contains useAgGridSort params
filterTab,
forceDisplayFilterIcon,
filterComponent,
filterComponentParams,
tabIndex,
isCustomColumn,
Menu,
context,
...props // agGrid column props
}: CustomColDef<any, any, F>) => {
const { headerName, field = '', fractionDigits, numeric } = props;
const {
sortProps, // sortProps: contains useAgGridSort params
forceDisplayFilterIcon,
filterComponent,
filterComponentParams,
tabIndex,
isCustomColumn,
Menu,
fractionDigits,
numeric,
} = context || {};
const { colId, headerName, field = '' } = props;
const { onSortChanged = () => {}, sortConfig } = sortProps || {};
const isSortable = !!sortProps;
const isCurrentColumnSorted = !!sortConfig?.find((value) => value.colId === field);
Expand All @@ -35,9 +39,9 @@ export const makeAgGridCustomHeaderColumn = <F extends CustomAggridFilterParams
return {
headerTooltip: headerName,
minWidth,
fractionDigits: numeric && !fractionDigits ? 2 : fractionDigits,
headerComponent: CustomHeaderComponent,
headerComponentParams: {
colId,
field,
displayName: headerName,
sortParams: {
Expand All @@ -54,8 +58,12 @@ export const makeAgGridCustomHeaderColumn = <F extends CustomAggridFilterParams
filterComponent: filterComponent,
filterComponentParams,
},
filterParams: props?.agGridFilterParams || undefined,
filterParams: context?.agGridFilterParams || undefined,
...props,
context: {
...context,
fractionDigits: numeric && !fractionDigits ? 2 : fractionDigits,
},
};
};

Expand Down
8 changes: 5 additions & 3 deletions src/components/custom-aggrid/custom-aggrid-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const styles = {
};

interface CustomHeaderComponentProps<F extends CustomAggridFilterParams> {
colId: string;
field: string;
displayName: string;
sortParams: CustomHeaderSortParams;
Expand All @@ -31,6 +32,7 @@ interface CustomHeaderComponentProps<F extends CustomAggridFilterParams> {
}

const CustomHeaderComponent = <F extends CustomAggridFilterParams>({
colId,
field,
displayName,
sortParams,
Expand All @@ -41,7 +43,7 @@ const CustomHeaderComponent = <F extends CustomAggridFilterParams>({
}: CustomHeaderComponentProps<F>) => {
const [isHoveringColumnHeader, setIsHoveringColumnHeader] = useState(false);

const { handleSortChange } = useCustomAggridSort(field, sortParams);
const { handleSortChange } = useCustomAggridSort(colId, sortParams);
const { isSortable = false } = sortParams;
const handleClickHeader = () => {
if (isSortable) {
Expand Down Expand Up @@ -82,7 +84,7 @@ const CustomHeaderComponent = <F extends CustomAggridFilterParams>({
<Grid container sx={styles.displayName} alignItems={'center'} wrap="nowrap">
<Grid item>{displayName}</Grid>
<Grid item>
<CustomAggridSort field={field} sortParams={sortParams} />
<CustomAggridSort colId={colId} sortParams={sortParams} />
</Grid>
</Grid>
</Grid>
Expand All @@ -91,7 +93,7 @@ const CustomHeaderComponent = <F extends CustomAggridFilterParams>({
{filterComponent && (
<CustomAggridFilter
filterComponent={filterComponent}
filterComponentParams={{ ...filterComponentParams, field }}
filterComponentParams={{ ...filterComponentParams, colId }}
isHoveringColumnHeader={isHoveringColumnHeader}
forceDisplayFilterIcon={forceDisplayFilterIcon}
handleCloseFilter={handleCloseFilter}
Expand Down
28 changes: 16 additions & 12 deletions src/components/custom-aggrid/custom-aggrid-header.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ export type FilterParams = {
filterDataType?: string;
filterComparators?: string[];
debounceMs?: number;
updateFilter?: (field: string, value: FilterDataType) => void;
updateFilter?: (colId: string, value: FilterDataType) => void;
filterSelector?: FilterSelectorType[] | null;
};

export interface CustomAggridFilterParams {
field: string;
colId: string;
filterParams: FilterParams;
}

Expand Down Expand Up @@ -77,8 +77,7 @@ export type FilterStorePropsType = {
filterStoreAction: (filterTab: string, filter: FilterSelectorType[]) => AnyAction;
};

export interface CustomColDef<TData = any, TValue = any, F extends CustomAggridFilterParams = CustomAggridFilterParams>
extends ColDef<TData, TValue> {
export interface ColumnContext<F extends CustomAggridFilterParams = CustomAggridFilterParams> {
agGridFilterParams?: {
filterOptions: IFilterOptionDef[];
};
Expand All @@ -87,21 +86,26 @@ export interface CustomColDef<TData = any, TValue = any, F extends CustomAggridF
changeCmd?: string;
columnWidth?: number;
crossValidation?: CrossValidationOptions;
forceDisplayFilterIcon?: boolean;
filterComponent?: ComponentType<F>;
//We omit colId here to avoid duplicating its declaration, we reinject it later inside CustomHeaderComponent
filterComponentParams?: Omit<F, 'colId'>;
filterTab?: string[];
fractionDigits?: number;
getEnumLabel?: (value: string) => string | undefined;
id: string;
isCountry?: boolean;
isCustomColumn?: boolean;
isDefaultSort?: boolean;
isEnum?: boolean;
Menu?: React.FC<CustomColumnConfigProps>;
numeric?: boolean;
sortProps?: SortPropsType;
withFluxConvention?: boolean;
forceDisplayFilterIcon?: boolean;
tabIndex?: number;
isCustomColumn?: boolean;
Menu?: React.FC<CustomColumnConfigProps>;
filterComponent?: ComponentType<F>;
//We omit field here to avoid duplicating its declaration, we reinject it later inside CustomHeaderComponent
filterComponentParams?: Omit<F, 'field'>;
withFluxConvention?: boolean;
}

export interface CustomColDef<TData = any, TValue = any, F extends CustomAggridFilterParams = CustomAggridFilterParams>
extends ColDef<TData, TValue> {
colId: string;
context?: ColumnContext<F>;
}
6 changes: 3 additions & 3 deletions src/components/custom-aggrid/custom-aggrid-sort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ const styles = {
};

interface CustomAggridSortProps {
field: string;
colId: string;
sortParams: CustomHeaderSortParams;
}

export const CustomAggridSort = ({ field, sortParams }: CustomAggridSortProps) => {
const { columnSort, handleSortChange } = useCustomAggridSort(field, sortParams);
export const CustomAggridSort = ({ colId, sortParams }: CustomAggridSortProps) => {
const { columnSort, handleSortChange } = useCustomAggridSort(colId, sortParams);
const { isSortable } = sortParams;
const handleClick = () => {
handleSortChange();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import { countDecimalPlacesFromString } from '../../../utils/rounding';
import { useCustomAggridFilter } from './use-custom-aggrid-filter';
import { FilterParams } from '../custom-aggrid-header.type';

export const useCustomAggridComparatorFilter = (field: string, filterParams: FilterParams) => {
export const useCustomAggridComparatorFilter = (colId: string, filterParams: FilterParams) => {
const { filterDataType = FILTER_DATA_TYPES.TEXT } = filterParams;

const isNumberInput = filterDataType === FILTER_DATA_TYPES.NUMBER;

const { selectedFilterData, selectedFilterComparator, handleChangeFilterValue, handleChangeComparator } =
useCustomAggridFilter(field, filterParams);
useCustomAggridFilter(colId, filterParams);

const { snackWarning } = useSnackMessage();

Expand Down
Loading

0 comments on commit eeaa6a6

Please sign in to comment.