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

Modification by filter #2186

Merged
merged 45 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
efa98f0
Modification by filter
thangqp Jul 17, 2024
f073920
Merge from main
thangqp Jul 22, 2024
533c2b2
get predefined properties
thangqp Jul 23, 2024
ffce003
using rhf inputs for value editor
thangqp Jul 25, 2024
d434265
Merge branch 'main' into modification_by_filter
thangqp Jul 26, 2024
ae9dff2
rename FLOAT dataType to NUMBER dataType
thangqp Jul 26, 2024
c6d2d65
Merge branch 'main' into modification_by_filter
thangqp Jul 26, 2024
fa91854
Merge branch 'main' into modification_by_filter
thangqp Jul 31, 2024
e4f86b9
rename NUMBER dataType to DOUBLE dataType
thangqp Aug 1, 2024
687bee8
send dataType to backend
thangqp Aug 1, 2024
f70f8f0
Merge from main
thangqp Aug 21, 2024
6fdf5a8
Merge branch 'main' into modification_by_filter
thangqp Aug 29, 2024
812439f
format prettier
thangqp Aug 29, 2024
9d3324d
rename dto field
thangqp Sep 2, 2024
1a280b3
add boolean and enum fields
thangqp Sep 3, 2024
5f8e619
support property for all equipment types
thangqp Sep 4, 2024
1c7c2c3
dialogue in TSX
thangqp Sep 5, 2024
4a2394b
renaming
thangqp Sep 5, 2024
8a1f622
typing problem with rhf
thangqp Sep 5, 2024
0ef88c8
reset value when data type changed
thangqp Sep 5, 2024
e261338
set default value for boolean type
thangqp Sep 5, 2024
488270a
remove usage of searchTree of common ui
thangqp Sep 6, 2024
d8df6e7
Merge branch 'main' into modification_by_filter
thangqp Sep 6, 2024
bde8046
Merge branch 'main' into modification_by_filter
thangqp Sep 9, 2024
f2ce391
using localCompare when sort
thangqp Sep 9, 2024
bc6babe
sonar
thangqp Sep 9, 2024
128ec41
using DeepNullable for typing rhf form with null default values
thangqp Sep 9, 2024
e619ee5
group components into by-filter directory
thangqp Sep 9, 2024
71a5ee0
remove .js in import
thangqp Sep 9, 2024
f17ba7a
Merge branch 'main' into modification_by_filter
thangqp Sep 10, 2024
b06e2d7
Merge branch 'main' into modification_by_filter
Mathieu-Deharbe Sep 11, 2024
0f567c6
Merge branch 'main' into modification_by_filter
thangqp Sep 11, 2024
69a887a
Merge branch 'main' into modification_by_filter
thangqp Sep 12, 2024
adff6f0
bug lost value when reopen a modification
thangqp Sep 12, 2024
5f363a9
renaming to assignment
thangqp Sep 12, 2024
c96d4fe
Merge branch 'main' into modification_by_filter
thangqp Sep 17, 2024
96c154b
merge from main
thangqp Sep 26, 2024
38b6a8d
Merge branch 'main' into modification_by_filter
thangqp Sep 30, 2024
dfac876
rectify code
thangqp Oct 1, 2024
3128a6f
Merge branch 'main' into modification_by_filter
thangqp Oct 1, 2024
989e877
Sonar
thangqp Oct 2, 2024
ac4abd3
Sonar
thangqp Oct 2, 2024
4c9e1a2
Merge branch 'main' into modification_by_filter
Mathieu-Deharbe Oct 2, 2024
4ff1d14
Merge branch 'main' into modification_by_filter
thangqp Oct 2, 2024
9b6db2a
remark
thangqp Oct 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,27 @@ import React, { FunctionComponent, useState } from 'react';
import { useController } from 'react-hook-form';
import { Select, SelectChangeEvent } from '@mui/material';
import MenuItem from '@mui/material/MenuItem';
import { FormattedMessage } from 'react-intl';
import { CustomDialog } from '../../../utils/custom-dialog';
import { FormattedMessage, useIntl } from 'react-intl';
import { CustomDialog } from '../../utils/custom-dialog';
import FormControl from '@mui/material/FormControl';
import InputLabel from '@mui/material/InputLabel';

interface SelectWithConfirmationInputProps {
name: string;
options: string[];
onValidate: () => void;
getOptionLabel?: (option: string) => string;
label: string;
}

const SelectWithConfirmationInput: FunctionComponent<SelectWithConfirmationInputProps> = ({
name,
options,
onValidate,
getOptionLabel,
label,
}) => {
const intl = useIntl();
const [openConfirmationDialog, setOpenConfirmationDialog] = useState(false);
const [newValue, setNewValue] = useState('');
const {
Expand All @@ -44,7 +47,7 @@ const SelectWithConfirmationInput: FunctionComponent<SelectWithConfirmationInput
};

const handleValidate = () => {
onValidate && onValidate();
onValidate?.();
onChange(newValue);
};

Expand All @@ -61,16 +64,16 @@ const SelectWithConfirmationInput: FunctionComponent<SelectWithConfirmationInput
onChange={handleChange}
label={<FormattedMessage id={label} />}
>
{options.map((option, index) => (
<MenuItem key={index} value={option}>
<FormattedMessage id={option} />
{options.map((option) => (
<MenuItem key={option} value={option}>
{getOptionLabel ? getOptionLabel(option) : intl.formatMessage({ id: option })}
</MenuItem>
))}
</Select>
</FormControl>
{openConfirmationDialog && (
<CustomDialog
content={<FormattedMessage id={'byFormulaChangeTypeConfirmation'} />}
content={<FormattedMessage id={'changeTypeConfirmation'} />}
onValidate={handleValidate}
validateButtonLabel="button.changeType"
onClose={() => setOpenConfirmationDialog(false)}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
/**
* Copyright (c) 2024, 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 { DataType, FieldOptionType, FieldType } from './assignment.type';
import { LOAD_TYPES } from '../../../../../network/constants';
import { EquipmentType } from '@gridsuite/commons-ui';

export const FIELD_OPTIONS: {
[key: string]: FieldOptionType;
} = {
PROPERTY: {
id: FieldType.PROPERTY,
label: 'Property',
dataType: DataType.PROPERTY,
},
RATED_NOMINAL_POWER: {
id: FieldType.RATED_NOMINAL_POWER,
label: 'RatedNominalPowerText',
dataType: DataType.DOUBLE,
},
MINIMUM_ACTIVE_POWER: {
id: FieldType.MINIMUM_ACTIVE_POWER,
label: 'MinimumActivePowerText',
dataType: DataType.DOUBLE,
},
MAXIMUM_ACTIVE_POWER: {
id: FieldType.MAXIMUM_ACTIVE_POWER,
label: 'MaximumActivePowerText',
dataType: DataType.DOUBLE,
},
ACTIVE_POWER_SET_POINT: {
id: FieldType.ACTIVE_POWER_SET_POINT,
label: 'ActivePowerText',
dataType: DataType.DOUBLE,
},
REACTIVE_POWER_SET_POINT: {
id: FieldType.REACTIVE_POWER_SET_POINT,
label: 'ReactivePowerText',
dataType: DataType.DOUBLE,
},
VOLTAGE_SET_POINT: {
id: FieldType.VOLTAGE_SET_POINT,
label: 'GeneratorTargetV',
dataType: DataType.DOUBLE,
},
PLANNED_ACTIVE_POWER_SET_POINT: {
id: FieldType.PLANNED_ACTIVE_POWER_SET_POINT,
label: 'PlannedActivePowerSetPointForm',
dataType: DataType.DOUBLE,
},
MARGINAL_COST: {
id: FieldType.MARGINAL_COST,
label: 'marginalCost',
dataType: DataType.DOUBLE,
},
PLANNED_OUTAGE_RATE: {
id: FieldType.PLANNED_OUTAGE_RATE,
label: 'plannedOutageRate',
dataType: DataType.DOUBLE,
},
FORCED_OUTAGE_RATE: {
id: FieldType.FORCED_OUTAGE_RATE,
label: 'forcedOutageRate',
dataType: DataType.DOUBLE,
},
DROOP: {
id: FieldType.DROOP,
label: 'ActivePowerRegulationDroop',
dataType: DataType.DOUBLE,
},
TRANSIENT_REACTANCE: {
id: FieldType.TRANSIENT_REACTANCE,
label: 'TransientReactanceForm',
dataType: DataType.DOUBLE,
},
STEP_UP_TRANSFORMER_REACTANCE: {
id: FieldType.STEP_UP_TRANSFORMER_REACTANCE,
label: 'TransformerReactanceForm',
dataType: DataType.DOUBLE,
},
Q_PERCENT: {
id: FieldType.Q_PERCENT,
label: 'ReactivePercentageVoltageRegulation',
dataType: DataType.DOUBLE,
},
VOLTAGE_REGULATOR_ON: {
id: FieldType.VOLTAGE_REGULATOR_ON,
label: 'voltageRegulationOn',
dataType: DataType.BOOLEAN,
},
MAXIMUM_SECTION_COUNT: {
id: FieldType.MAXIMUM_SECTION_COUNT,
label: 'maximumSectionCount',
dataType: DataType.INTEGER,
},
SECTION_COUNT: {
id: FieldType.SECTION_COUNT,
label: 'sectionCount',
dataType: DataType.INTEGER,
},
MAXIMUM_SUSCEPTANCE: {
id: FieldType.MAXIMUM_SUSCEPTANCE,
label: 'maxSusceptance',
dataType: DataType.DOUBLE,
},
MAXIMUM_Q_AT_NOMINAL_VOLTAGE: {
id: FieldType.MAXIMUM_Q_AT_NOMINAL_VOLTAGE,
label: 'maxQAtNominalV',
dataType: DataType.DOUBLE,
},
NOMINAL_VOLTAGE: {
id: FieldType.NOMINAL_VOLTAGE,
label: 'NominalVoltage',
dataType: DataType.DOUBLE,
},
LOW_VOLTAGE_LIMIT: {
id: FieldType.LOW_VOLTAGE_LIMIT,
label: 'LowVoltageLimit',
dataType: DataType.DOUBLE,
},
HIGH_VOLTAGE_LIMIT: {
id: FieldType.HIGH_VOLTAGE_LIMIT,
label: 'HighVoltageLimit',
dataType: DataType.DOUBLE,
},
LOW_SHORT_CIRCUIT_CURRENT_LIMIT: {
id: FieldType.LOW_SHORT_CIRCUIT_CURRENT_LIMIT,
label: 'LowShortCircuitCurrentLimit',
dataType: DataType.DOUBLE,
},
HIGH_SHORT_CIRCUIT_CURRENT_LIMIT: {
id: FieldType.HIGH_SHORT_CIRCUIT_CURRENT_LIMIT,
label: 'HighShortCircuitCurrentLimit',
dataType: DataType.DOUBLE,
},
ACTIVE_POWER: {
id: FieldType.ACTIVE_POWER,
label: 'ActivePowerText',
dataType: DataType.DOUBLE,
},
REACTIVE_POWER: {
id: FieldType.REACTIVE_POWER,
label: 'ReactivePowerText',
dataType: DataType.DOUBLE,
},
R: {
id: FieldType.R,
label: 'SeriesResistanceText',
dataType: DataType.DOUBLE,
},
X: {
id: FieldType.X,
label: 'SeriesReactanceText',
dataType: DataType.DOUBLE,
},
G: { id: FieldType.G, label: 'G', dataType: DataType.DOUBLE },
B: { id: FieldType.B, label: 'B', dataType: DataType.DOUBLE },
RATED_U1: {
id: FieldType.RATED_U1,
label: 'RatedU1',
dataType: DataType.DOUBLE,
},
RATED_U2: {
id: FieldType.RATED_U2,
label: 'RatedU2',
dataType: DataType.DOUBLE,
},
RATED_S: {
id: FieldType.RATED_S,
label: 'RatedNominalPowerText',
dataType: DataType.DOUBLE,
},
TARGET_V: {
id: FieldType.TARGET_V,
label: 'RatioTargetV',
dataType: DataType.DOUBLE,
},
RATIO_LOW_TAP_POSITION: {
id: FieldType.RATIO_LOW_TAP_POSITION,
label: 'RatioLowTapPosition',
dataType: DataType.INTEGER,
},
RATIO_TAP_POSITION: {
id: FieldType.RATIO_TAP_POSITION,
label: 'RatioTapPosition',
dataType: DataType.INTEGER,
},
RATIO_TARGET_DEADBAND: {
id: FieldType.RATIO_TARGET_DEADBAND,
label: 'RatioDeadBand',
dataType: DataType.DOUBLE,
},
REGULATION_VALUE: {
id: FieldType.REGULATION_VALUE,
label: 'PhaseRegulatingValue',
dataType: DataType.DOUBLE,
},
PHASE_LOW_TAP_POSITION: {
id: FieldType.PHASE_LOW_TAP_POSITION,
label: 'PhaseLowTapPosition',
dataType: DataType.INTEGER,
},
PHASE_TAP_POSITION: {
id: FieldType.PHASE_TAP_POSITION,
label: 'PhaseTapPosition',
dataType: DataType.INTEGER,
},
PHASE_TARGET_DEADBAND: {
id: FieldType.PHASE_TARGET_DEADBAND,
label: 'PhaseDeadBand',
dataType: DataType.DOUBLE,
},
LOAD_TYPE: {
id: FieldType.LOAD_TYPE,
label: 'loadType',
dataType: DataType.ENUM,
values: LOAD_TYPES,
},
};

export const EQUIPMENTS_FIELDS = {
[EquipmentType.SUBSTATION]: [FIELD_OPTIONS.PROPERTY],
[EquipmentType.VOLTAGE_LEVEL]: [
FIELD_OPTIONS.PROPERTY,
FIELD_OPTIONS.NOMINAL_VOLTAGE,
FIELD_OPTIONS.LOW_VOLTAGE_LIMIT,
FIELD_OPTIONS.HIGH_VOLTAGE_LIMIT,
FIELD_OPTIONS.LOW_SHORT_CIRCUIT_CURRENT_LIMIT,
FIELD_OPTIONS.HIGH_SHORT_CIRCUIT_CURRENT_LIMIT,
],
[EquipmentType.LINE]: [FIELD_OPTIONS.PROPERTY],
[EquipmentType.TWO_WINDINGS_TRANSFORMER]: [
FIELD_OPTIONS.PROPERTY,
FIELD_OPTIONS.R,
FIELD_OPTIONS.X,
FIELD_OPTIONS.G,
FIELD_OPTIONS.B,
FIELD_OPTIONS.RATED_U1,
FIELD_OPTIONS.RATED_U2,
FIELD_OPTIONS.RATED_S,
FIELD_OPTIONS.TARGET_V,
FIELD_OPTIONS.RATIO_LOW_TAP_POSITION,
FIELD_OPTIONS.RATIO_TAP_POSITION,
FIELD_OPTIONS.RATIO_TARGET_DEADBAND,
FIELD_OPTIONS.REGULATION_VALUE,
FIELD_OPTIONS.PHASE_LOW_TAP_POSITION,
FIELD_OPTIONS.PHASE_TAP_POSITION,
FIELD_OPTIONS.PHASE_TARGET_DEADBAND,
],
[EquipmentType.THREE_WINDINGS_TRANSFORMER]: [FIELD_OPTIONS.PROPERTY],
[EquipmentType.GENERATOR]: [
FIELD_OPTIONS.PROPERTY,
FIELD_OPTIONS.VOLTAGE_REGULATOR_ON,
FIELD_OPTIONS.RATED_NOMINAL_POWER,
FIELD_OPTIONS.MINIMUM_ACTIVE_POWER,
FIELD_OPTIONS.MAXIMUM_ACTIVE_POWER,
FIELD_OPTIONS.ACTIVE_POWER_SET_POINT,
FIELD_OPTIONS.REACTIVE_POWER_SET_POINT,
FIELD_OPTIONS.VOLTAGE_SET_POINT,
FIELD_OPTIONS.PLANNED_ACTIVE_POWER_SET_POINT,
FIELD_OPTIONS.MARGINAL_COST,
FIELD_OPTIONS.PLANNED_OUTAGE_RATE,
FIELD_OPTIONS.FORCED_OUTAGE_RATE,
FIELD_OPTIONS.DROOP,
FIELD_OPTIONS.TRANSIENT_REACTANCE,
FIELD_OPTIONS.STEP_UP_TRANSFORMER_REACTANCE,
FIELD_OPTIONS.Q_PERCENT,
],
[EquipmentType.BATTERY]: [
FIELD_OPTIONS.PROPERTY,
FIELD_OPTIONS.MINIMUM_ACTIVE_POWER,
FIELD_OPTIONS.MAXIMUM_ACTIVE_POWER,
FIELD_OPTIONS.ACTIVE_POWER_SET_POINT,
FIELD_OPTIONS.REACTIVE_POWER_SET_POINT,
FIELD_OPTIONS.DROOP,
],
[EquipmentType.LOAD]: [
FIELD_OPTIONS.PROPERTY,
FIELD_OPTIONS.LOAD_TYPE,
FIELD_OPTIONS.ACTIVE_POWER,
FIELD_OPTIONS.REACTIVE_POWER,
],
[EquipmentType.SHUNT_COMPENSATOR]: [
FIELD_OPTIONS.PROPERTY,
FIELD_OPTIONS.MAXIMUM_SECTION_COUNT,
FIELD_OPTIONS.SECTION_COUNT,
FIELD_OPTIONS.MAXIMUM_SUSCEPTANCE,
FIELD_OPTIONS.MAXIMUM_Q_AT_NOMINAL_VOLTAGE,
],
[EquipmentType.STATIC_VAR_COMPENSATOR]: [FIELD_OPTIONS.PROPERTY],
[EquipmentType.HVDC_LINE]: [FIELD_OPTIONS.PROPERTY],
};
Loading
Loading