Skip to content

Commit

Permalink
Merge branch 'main' into fix_Selection_Forms
Browse files Browse the repository at this point in the history
  • Loading branch information
basseche authored Feb 26, 2025
2 parents 20d186f + 78cfaf0 commit e96f334
Show file tree
Hide file tree
Showing 24 changed files with 1,307 additions and 39 deletions.
13 changes: 8 additions & 5 deletions src/components/dialogs/limits/limits-groups-contextual-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,31 @@ export function LimitsGroupsContextualMenu({
};

const handleDuplicateTab = () => {
let newName: string = '';
if (indexSelectedLimitSet1 !== null) {
const duplicatedLimits1 = getValues(
const duplicatedLimits1: OperationalLimitsGroup = getValues(
`${parentFormName}.${OPERATIONAL_LIMITS_GROUPS_1}[${indexSelectedLimitSet1}]`
);
newName = duplicatedLimits1.id + '_COPY';
const newLimitsGroup1: OperationalLimitsGroup = {
...duplicatedLimits1,
[ID]: '',
[ID]: newName,
};
appendToLimitsGroups1(newLimitsGroup1);
}

if (indexSelectedLimitSet2 !== null) {
const duplicatedLimits2 = getValues(
const duplicatedLimits2: OperationalLimitsGroup = getValues(
`${parentFormName}.${OPERATIONAL_LIMITS_GROUPS_2}[${indexSelectedLimitSet2}]`
);
newName = duplicatedLimits2.id + '_COPY';
const newLimitsGroup2: OperationalLimitsGroup = {
...duplicatedLimits2,
[ID]: '',
[ID]: newName,
};
appendToLimitsGroups2(newLimitsGroup2);
}
startEditingLimitsGroup(getValues(`${parentFormName}.${OPERATIONAL_LIMITS_GROUPS_1}`).length - 1, '');
startEditingLimitsGroup(getValues(`${parentFormName}.${OPERATIONAL_LIMITS_GROUPS_1}`).length - 1, newName);
};

return (
Expand Down
13 changes: 9 additions & 4 deletions src/components/dialogs/limits/operational-limits-groups-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export function OperationalLimitsGroupsTabs({
const newIndex: number = limitsGroups1.length;
appendEmptyOperationalLimitsGroup(`${parentFormName}.${OPERATIONAL_LIMITS_GROUPS_1}`, '');
appendEmptyOperationalLimitsGroup(`${parentFormName}.${OPERATIONAL_LIMITS_GROUPS_2}`, '');
startEditingLimitsGroup(newIndex, `LIMIT_SET`);
startEditingLimitsGroup(newIndex, `DEFAULT`);
}
}, [
editingTabIndex,
Expand Down Expand Up @@ -356,10 +356,11 @@ export function OperationalLimitsGroupsTabs({
{(index === hoveredRowIndex || index === activatedByMenuTabIndex) && (
<IconButton
size="small"
hidden
onClick={(e: React.MouseEvent<HTMLButtonElement>) =>
handleOpenMenu(e, index)
}
// during the naming of a limit set no other limit set manipulation is allowed :
disabled={editingTabIndex !== -1}
>
<MenuIcon fontSize="small" />
</IconButton>
Expand All @@ -371,27 +372,31 @@ export function OperationalLimitsGroupsTabs({
/>
))}
<Tab
key="addLimitSet"
label={
editingTabIndex === -1 && (
<Box
sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
width: '100%',
flexGrow: 1,
}}
>
<IconButton
size="small"
onClick={addNewLimitSet}
sx={{
align: 'right',
marginLeft: 'auto',
}}
>
<AddCircleIcon />
<AddCircleIcon fontSize="small" />
</IconButton>
</Box>
)
}
sx={limitsStyles.limitsBackground}
/>
</Tabs>
<LimitsGroupsContextualMenu
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import {
ILimitReductionsByVoltageLevel,
ITemporaryLimitReduction,
LIMIT_DURATION_FORM,
LIMIT_REDUCTIONS_FORM,
} from './columns-definitions';
import { useIntl } from 'react-intl';
import LimitReductionsTable from './limit-reductions-table';
import CustomVoltageLevelTable from '../voltage-level-table/custom-voltage-level-table';

const getLabelColumn = (limit: ITemporaryLimitReduction) => {
const lowBound = `${Math.trunc(limit.limitDuration.lowBound / 60)} min`;
Expand Down Expand Up @@ -67,7 +68,13 @@ const LimitReductionsTableForm: FunctionComponent<{
return columnsDefinition;
}, [intl, limits, getToolTipColumn]);

return <LimitReductionsTable columnsDefinition={columnsDefinition} tableHeight={450} />;
return (
<CustomVoltageLevelTable
formName={LIMIT_REDUCTIONS_FORM}
columnsDefinition={columnsDefinition}
tableHeight={450}
/>
);
};

export default LimitReductionsTableForm;
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright (c) 2025, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { FunctionComponent } from 'react';
import { IColumnsDef } from '../limitreductions/columns-definitions';
import { TableCell } from '@mui/material';
import { FloatInput, RawReadOnlyInput } from '@gridsuite/commons-ui';
import { VOLTAGE_LEVEL } from '../../../../utils/field-constants';

export const CustomVoltageLevelTableCell: FunctionComponent<{
formName: string;
rowIndex: number;
column: IColumnsDef;
}> = ({ formName, rowIndex, column }) => {
return (
<TableCell sx={{ fontWeight: 'bold' }}>
{column.dataKey === VOLTAGE_LEVEL ? (
<RawReadOnlyInput name={`${formName}[${rowIndex}].${column.dataKey}`} />
) : (
<FloatInput name={`${formName}[${rowIndex}].${column.dataKey}`} />
)}
</TableCell>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyright (c) 2025, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { TableRow } from '@mui/material';
import { FunctionComponent } from 'react';

import { CustomVoltageLevelTableCell } from './custom-voltage-level-table-cell';
import { IColumnsDef } from '../limitreductions/columns-definitions';

interface TableRowComponentProps {
formName: string;
columnsDefinition: IColumnsDef[];
index: number;
}

export const CustomVoltageLevelTableRow: FunctionComponent<TableRowComponentProps> = ({
formName,
columnsDefinition,
index,
}) => {
return (
<TableRow>
{columnsDefinition.map((column: IColumnsDef) => (
<CustomVoltageLevelTableCell
key={`${column.dataKey}`}
formName={formName}
rowIndex={index}
column={column}
/>
))}
</TableRow>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,32 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from '@mui/material';
import { FunctionComponent } from 'react';
import { IColumnsDef, LIMIT_REDUCTIONS_FORM } from './columns-definitions';
import { FunctionComponent, useMemo } from 'react';
import { IColumnsDef, LIMIT_REDUCTIONS_FORM } from '../limitreductions/columns-definitions';
import { useFieldArray } from 'react-hook-form';
import LimitReductionTableRow from './limit-reduction-table-row';
import LimitReductionTableRow from '../limitreductions/limit-reduction-table-row';
import { CustomVoltageLevelTableRow } from './custom-voltage-level-table-row';

interface LimitReductionsTableProps {
columnsDefinition: IColumnsDef[];
tableHeight: number;
formName: string;
}

const LimitReductionsTable: FunctionComponent<LimitReductionsTableProps> = ({ columnsDefinition, tableHeight }) => {
const CustomVoltageLevelTable: FunctionComponent<LimitReductionsTableProps> = ({
formName,
columnsDefinition,
tableHeight,
}) => {
const { fields: rows } = useFieldArray({
name: LIMIT_REDUCTIONS_FORM,
name: formName,
});

const TableRowComponent = useMemo(
() => (formName === LIMIT_REDUCTIONS_FORM ? LimitReductionTableRow : CustomVoltageLevelTableRow),
[formName]
);

return (
<TableContainer
sx={{
Expand All @@ -46,12 +57,17 @@ const LimitReductionsTable: FunctionComponent<LimitReductionsTableProps> = ({ co
</TableHead>
<TableBody>
{rows.map((row, index) => (
<LimitReductionTableRow key={`${row.id}`} columnsDefinition={columnsDefinition} index={index} />
<TableRowComponent
key={`${row.id}`}
columnsDefinition={columnsDefinition}
index={index}
formName={formName}
/>
))}
</TableBody>
</Table>
</TableContainer>
);
};

export default LimitReductionsTable;
export default CustomVoltageLevelTable;
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Copyright (c) 2025, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { Grid } from '@mui/material';
import { ESTIM_ALGO_TYPE, ESTIM_LOG_LEVEL, PRINCIPAL_OBSERVABLE_ZONE } from 'components/utils/field-constants';
import { estimAlgoTypeValues, estimLogLevelValues, TabValue } from './state-estimation-parameters-utils';
import { FieldLabel, MuiSelectInput, SwitchInput } from '@gridsuite/commons-ui';
import { styles } from '../parameters-style';

export const StateEstimationGeneralParameters = () => {
return (
<Grid container>
<Grid container item alignItems="center" spacing={2} direction={'row'}>
<Grid item xs={10} sx={styles.parameterName}>
<FieldLabel label={'StateEstimationParametersPrincipalObservableZoneLabel'} />
</Grid>
<Grid item xs={2}>
<SwitchInput name={`${TabValue.GENERAL}.${PRINCIPAL_OBSERVABLE_ZONE}`} />
</Grid>
</Grid>

<Grid container item spacing={1} paddingTop={3}>
<Grid item xs={8} sx={styles.parameterName}>
<FieldLabel label={'StateEstimationParametersLogLevelLabel'} />
</Grid>
<Grid item xs={4}>
<MuiSelectInput
name={`${TabValue.GENERAL}.${ESTIM_LOG_LEVEL}`}
options={estimLogLevelValues}
fullWidth
/>
</Grid>
</Grid>
<Grid container item spacing={1} paddingTop={3}>
<Grid item xs={8} sx={styles.parameterName}>
<FieldLabel label={'StateEstimationParametersAlgoTypeLabel'} />
</Grid>
<Grid item xs={4}>
<MuiSelectInput
name={`${TabValue.GENERAL}.${ESTIM_ALGO_TYPE}`}
options={estimAlgoTypeValues}
fullWidth
/>
</Grid>
</Grid>
</Grid>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* Copyright (c) 2025, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { FunctionComponent, useMemo } from 'react';
import { DEFAULT_BOUNDS, DEFAULT_FIXED_BOUNDS, VOLTAGE_LEVEL } from '../../../utils/field-constants';
import { loadboundsParametersFields, TabValue } from './state-estimation-parameters-utils';
import { IColumnsDef } from '../common/limitreductions/columns-definitions';
import { useIntl } from 'react-intl';
import { Box, Grid } from '@mui/material';
import LineSeparator from '../../commons/line-separator';
import GridSection from '../../commons/grid-section';
import CustomVoltageLevelTable from '../common/voltage-level-table/custom-voltage-level-table';

export const StateEstimationLoadboundsParameters: FunctionComponent = () => {
const intl = useIntl();

const columnsDefinition = useMemo<IColumnsDef[]>(() => {
const definition = [
{
dataKey: VOLTAGE_LEVEL,
label: intl.formatMessage({ id: 'voltageRange' }),
tooltip: intl.formatMessage({ id: 'voltageRange' }),
},
];
definition.push(
...loadboundsParametersFields.map((parameter) => {
return {
dataKey: parameter,
label: intl.formatMessage({ id: parameter }),
tooltip: intl.formatMessage({ id: parameter }),
};
})
);
return definition;
}, [intl]);

return (
<Grid container>
<GridSection title="StateEstimationParametersDefaultBoundsSection" heading={4} />

<CustomVoltageLevelTable
formName={`${TabValue.LOADBOUNDS}.${DEFAULT_BOUNDS}`}
columnsDefinition={columnsDefinition}
tableHeight={450}
/>

<Box my={2}>
<LineSeparator />
</Box>
<GridSection title="StateEstimationParametersDefaultFixedBoundsSection" heading={4} />

<CustomVoltageLevelTable
formName={`${TabValue.LOADBOUNDS}.${DEFAULT_FIXED_BOUNDS}`}
columnsDefinition={columnsDefinition}
tableHeight={450}
/>
</Grid>
);
};
Loading

0 comments on commit e96f334

Please sign in to comment.