Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions src/components/parameters/short-circuit/columns-definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,14 @@ export const COLUMNS_DEFINITIONS_ICC_CLUSTERS: IccClusterIColumnsDef[] = [
equipmentTypes: [EquipmentType.GENERATOR, EquipmentType.BATTERY],
elementType: ElementType.FILTER,
titleId: 'FiltersListsSelection',
initialValue: [],
initialValue: null,
},
{
label: 'ShortCircuitIccClusterType',
dataKey: SHORT_CIRCUIT_ICC_CLUSTER_TYPE,
tooltip: 'ShortCircuitIccClusterTypeTooltip',
titleId: 'ShortCircuitIccClusterTypeListsSelection',
initialValue: [],
initialValue: null,
width: '20%',
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export function ShortCircuitIccClusterTableCell({
equipmentTypes={column.equipmentTypes}
elementType={column.elementType ?? ''}
titleId={column.titleId}
hideErrorMessage
label={undefined}
itemFilter={undefined}
disable={inputsDisabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@
});
};

const requiredWhenActive = <T extends yup.AnySchema>(schema: T) =>
schema.when('active', {
is: true,
then: (s) => s.required(),

Check failure on line 65 in src/components/parameters/short-circuit/short-circuit-parameters-utils.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not add `then` to an object.

See more on https://sonarcloud.io/project/issues?id=gridsuite_commons-ui&issues=AZ0lyG8Bbam_UNBbAoWc&open=AZ0lyG8Bbam_UNBbAoWc&pullRequest=1069
otherwise: (s) => s.notRequired().nullable(),
});

export const getSpecificShortCircuitParametersFormSchema = (
specificParametersDescriptionForProvider: SpecificParameterInfos[] | undefined
) => {
Expand All @@ -74,11 +81,11 @@
.of(
yup.object<PowerElectronicsMaterial & { active: boolean }>().shape({
active: yup.boolean().required(),
alpha: yup.number().required(),
u0: yup.number().required(),
usMin: yup.number().required(),
usMax: yup.number().required(),
type: yup.string().oneOf(['WIND', 'SOLAR', 'HVDC']).required(),
alpha: requiredWhenActive(yup.number()),
u0: requiredWhenActive(yup.number()),
usMin: requiredWhenActive(yup.number()),
usMax: requiredWhenActive(yup.number()),
type: requiredWhenActive(yup.string().oneOf(['WIND', 'SOLAR', 'HVDC'])),
})
)
.required()
Expand Down Expand Up @@ -107,17 +114,25 @@
.of(
yup.object<FormPowerElectronicsCluster & { active: boolean }>().shape({
active: yup.boolean().required(),
alpha: yup.number().required(),
u0: yup.number().required(),
usMin: yup.number().required(),
usMax: yup.number().required(),
filters: yup.array().of(
yup.object<FilterPOJO>().shape({
[ID]: yup.string().required(),
[NAME]: yup.string().required(),
})
),
type: yup.string().oneOf(['GENERATOR', 'HVDC']).required(),
alpha: requiredWhenActive(yup.number()),
u0: requiredWhenActive(yup.number()),
usMin: requiredWhenActive(yup.number()),
usMax: requiredWhenActive(yup.number()),
filters: yup
.array()
.of(
yup.object<FilterPOJO>().shape({
[ID]: yup.string().required(),
[NAME]: yup.string().required(),
})
)
.nullable()
.when('active', {
is: true,
then: (s) => s.required().min(1, 'FilterInputMinError'),

Check failure on line 132 in src/components/parameters/short-circuit/short-circuit-parameters-utils.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Do not add `then` to an object.

See more on https://sonarcloud.io/project/issues?id=gridsuite_commons-ui&issues=AZ0lyG8Bbam_UNBbAoWd&open=AZ0lyG8Bbam_UNBbAoWd&pullRequest=1069
otherwise: (s) => s.notRequired().nullable(),
}),
type: requiredWhenActive(yup.string().oneOf(['GENERATOR', 'HVDC']).nullable()),
})
)
.required()
Expand Down
Loading