@gridsuite/commons-ui 0.276.0 → 0.277.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,3 +12,6 @@ export type Property = {
12
12
  export type Properties = {
13
13
  [FieldConstants.ADDITIONAL_PROPERTIES]?: Property[];
14
14
  };
15
+ export type FilledProperties = {
16
+ [FieldConstants.ADDITIONAL_PROPERTIES]: FilledProperty[];
17
+ };
@@ -1,5 +1,5 @@
1
1
  import { PredefinedProperties } from '../../../../utils';
2
- import { FilledProperty, Properties, Property } from './properties.type';
2
+ import { FilledProperties, FilledProperty, Properties, Property } from './properties.type';
3
3
  export type EquipmentWithProperties = {
4
4
  properties?: Record<string, string>;
5
5
  };
@@ -7,9 +7,9 @@ export declare const fetchPredefinedProperties: (networkElementType: string) =>
7
7
  export declare const emptyProperties: Properties;
8
8
  export declare const createPropertyModification: (name: string, value: string | null) => Property;
9
9
  export declare const initializedProperty: () => Property;
10
- export declare const getFilledPropertiesFromModification: (properties: Property[] | undefined | null) => FilledProperty[];
10
+ export declare const getFilledPropertiesFromModification: (properties: Property[] | undefined | null, includePreviousValue?: boolean) => FilledProperty[];
11
11
  export declare const getPropertiesFromModification: (properties: Property[] | undefined | null, includePreviousValue?: boolean) => Properties;
12
- export declare const copyEquipmentPropertiesForCreation: (equipmentInfos: EquipmentWithProperties) => Properties;
12
+ export declare const copyEquipmentPropertiesForCreation: (equipmentInfos: EquipmentWithProperties) => FilledProperties;
13
13
  export declare const mergeModificationAndEquipmentProperties: (modificationProperties: Property[], equipment: EquipmentWithProperties) => Property[];
14
14
  export declare function getConcatenatedProperties(equipment: EquipmentWithProperties, getValues: (name: string) => any, id?: string): any;
15
15
  export declare const toModificationProperties: (properties: Properties) => Property[] | null;
@@ -29,12 +29,12 @@ const initializedProperty = () => {
29
29
  const isFilledProperty = (property) => {
30
30
  return property.value != null;
31
31
  };
32
- const getFilledPropertiesFromModification = (properties) => {
32
+ const getFilledPropertiesFromModification = (properties, includePreviousValue = true) => {
33
33
  return properties?.filter(isFilledProperty).map((p) => {
34
34
  return {
35
35
  [FieldConstants.NAME]: p[FieldConstants.NAME],
36
36
  [FieldConstants.VALUE]: p[FieldConstants.VALUE],
37
- [FieldConstants.PREVIOUS_VALUE]: p[FieldConstants.PREVIOUS_VALUE],
37
+ [FieldConstants.PREVIOUS_VALUE]: includePreviousValue ? p[FieldConstants.PREVIOUS_VALUE] : void 0,
38
38
  [FieldConstants.ADDED]: p[FieldConstants.ADDED],
39
39
  [FieldConstants.DELETION_MARK]: p[FieldConstants.DELETION_MARK]
40
40
  };
@@ -118,28 +118,4 @@ export declare const voltageLevelCreationEmptyFormData: {
118
118
  };
119
119
  export declare const voltageLevelCreationFormToDto: (voltageLevelForm: VoltageLevelCreationFormData) => VoltageLevelCreationDto;
120
120
  export declare const translateSwitchKinds: (switchKinds: SwitchKind[] | null, intl?: IntlShape) => string;
121
- export declare const voltageLevelCreationDtoToForm: (voltageLevelDto: VoltageLevelCreationDto, intl?: IntlShape, includePreviousValue?: boolean) => {
122
- AdditionalProperties?: import('../..').Property[];
123
- equipmentID: string;
124
- equipmentName: string;
125
- substationId: string | null;
126
- nominalV: number | null;
127
- lowVoltageLimit: number | null;
128
- highVoltageLimit: number | null;
129
- lowShortCircuitCurrentLimit: any;
130
- highShortCircuitCurrentLimit: any;
131
- busbarCount: number;
132
- sectionCount: number;
133
- switchesBetweenSections: string;
134
- couplingOmnibus: import('./voltageLevelCreation.types').CouplingDevice[];
135
- switchKinds: {
136
- switchKind: SwitchKind;
137
- }[];
138
- addSubstationCreationId: boolean;
139
- substationCreationId: string | null;
140
- substationName: string | null;
141
- country: string | null;
142
- substationCreation: import('../..').Properties;
143
- hideNominalVoltage: boolean;
144
- hideBusBarSection: boolean;
145
- };
121
+ export declare const voltageLevelCreationDtoToForm: (voltageLevelDto: VoltageLevelCreationDto, intl?: IntlShape, includePreviousValue?: boolean) => VoltageLevelCreationFormData;
@@ -1,5 +1,5 @@
1
1
  import { object, array, string, ref, number, boolean } from "yup";
2
- import { creationPropertiesSchema, getPropertiesFromModification, emptyProperties, toModificationProperties } from "../../common/properties/propertyUtils.js";
2
+ import { creationPropertiesSchema, getFilledPropertiesFromModification, toModificationProperties } from "../../common/properties/propertyUtils.js";
3
3
  import { FieldConstants } from "../../../../utils/constants/fieldConstants.js";
4
4
  import { SHORT_CIRCUIT_CURRENT_LIMIT_MUST_BE_GREATER_OR_EQUAL_TO_ZERO, MUST_BE_GREATER_OR_EQUAL_TO_ZERO, CREATE_SUBSTATION_IN_VOLTAGE_LEVEL_IDENTICAL_ID } from "../../../../utils/constants/translationKeys.js";
5
5
  import { convertInputValue, convertOutputValue } from "../../../../utils/conversionUtils.js";
@@ -234,7 +234,9 @@ const voltageLevelCreationFormToDto = (voltageLevelForm) => {
234
234
  const translateSwitchKinds = (switchKinds, intl) => switchKinds?.map((kind) => intl ? intl.formatMessage({ id: kind }) : kind).join(" / ") ?? "";
235
235
  const voltageLevelCreationDtoToForm = (voltageLevelDto, intl, includePreviousValue = true) => {
236
236
  const isSubstationCreation = voltageLevelDto.substationCreation?.equipmentId != null;
237
- const substationProperties = isSubstationCreation ? getPropertiesFromModification(voltageLevelDto.substationCreation?.properties, includePreviousValue) : emptyProperties;
237
+ const substationProperties = {
238
+ [FieldConstants.ADDITIONAL_PROPERTIES]: isSubstationCreation ? getFilledPropertiesFromModification(voltageLevelDto.substationCreation?.properties, includePreviousValue) : []
239
+ };
238
240
  return {
239
241
  [FieldConstants.EQUIPMENT_ID]: voltageLevelDto.equipmentId,
240
242
  [FieldConstants.EQUIPMENT_NAME]: voltageLevelDto.equipmentName ?? "",
@@ -264,7 +266,10 @@ const voltageLevelCreationDtoToForm = (voltageLevelDto, intl, includePreviousVal
264
266
  [FieldConstants.SUBSTATION_CREATION]: substationProperties,
265
267
  [FieldConstants.HIDE_NOMINAL_VOLTAGE]: false,
266
268
  [FieldConstants.HIDE_BUS_BAR_SECTION]: false,
267
- ...getPropertiesFromModification(voltageLevelDto.properties, includePreviousValue)
269
+ [FieldConstants.ADDITIONAL_PROPERTIES]: getFilledPropertiesFromModification(
270
+ voltageLevelDto.properties,
271
+ includePreviousValue
272
+ )
268
273
  };
269
274
  };
270
275
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.276.0",
3
+ "version": "0.277.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",