@gridsuite/commons-ui 0.247.0 → 0.248.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.
@@ -77,7 +77,7 @@ function ExpertFilterForm({ isEditing }) {
77
77
  const openConfirmationPopup = useCallback(() => {
78
78
  return formatQuery(getValues(EXPERT_FILTER_QUERY), "json_without_ids") !== formatQuery(defaultQuery, "json_without_ids");
79
79
  }, [getValues]);
80
- const handleResetOnConfirmation = useCallback(() => {
80
+ const resetOnTypeChange = useCallback(() => {
81
81
  setValue(EXPERT_FILTER_QUERY, defaultQuery);
82
82
  }, [setValue]);
83
83
  const watchEquipmentType = useWatch({
@@ -102,7 +102,7 @@ function ExpertFilterForm({ isEditing }) {
102
102
  options: Object.values(EXPERT_FILTER_EQUIPMENTS),
103
103
  label: "equipmentType",
104
104
  shouldOpenPopup: openConfirmationPopup,
105
- resetOnConfirmation: handleResetOnConfirmation,
105
+ onValueChange: resetOnTypeChange,
106
106
  message: "changeTypeMessage",
107
107
  validateButtonLabel: "button.changeType",
108
108
  sx: filterStyles.textField,
@@ -151,10 +151,6 @@ function ExplicitNamingFilterForm({
151
151
  const [selectedFile, setSelectedFile] = useState();
152
152
  const [fileErrorMessage, setFileErrorMessage] = useState();
153
153
  const tableRef = useRef(null);
154
- useEffect(() => {
155
- setSelectedFile(void 0);
156
- setFileErrorMessage(void 0);
157
- }, [watchEquipmentType]);
158
154
  const getTemplateData = useCallback(() => [csvFileHeaders], [csvFileHeaders]);
159
155
  const getTableData = useCallback(() => {
160
156
  const rows = getValues(FILTER_EQUIPMENTS_ATTRIBUTES) ?? [];
@@ -170,7 +166,9 @@ function ExplicitNamingFilterForm({
170
166
  (row) => row[DISTRIBUTION_KEY] || row[FieldConstants.EQUIPMENT_ID]
171
167
  );
172
168
  };
173
- const handleResetOnConfirmation = () => {
169
+ const resetOnTypeChange = () => {
170
+ setSelectedFile(void 0);
171
+ setFileErrorMessage(void 0);
174
172
  setValue(FILTER_EQUIPMENTS_ATTRIBUTES, makeDefaultTableRows());
175
173
  };
176
174
  const onStudySelected = (studyUuid) => {
@@ -204,7 +202,7 @@ function ExplicitNamingFilterForm({
204
202
  disabled: !!sourceFilterForExplicitNamingConversion || isEditing && !isDeveloperMode,
205
203
  label: "equipmentType",
206
204
  shouldOpenPopup: openConfirmationPopup,
207
- resetOnConfirmation: handleResetOnConfirmation,
205
+ onValueChange: resetOnTypeChange,
208
206
  message: "changeTypeMessage",
209
207
  validateButtonLabel: "button.changeType",
210
208
  sx: { width: 400, maxWidth: "100%" },
@@ -1,3 +1,3 @@
1
1
  export declare function InputWithPopupConfirmation({ Input, name, shouldOpenPopup, // condition to open popup confirmation
2
- resetOnConfirmation, // function to reset values in your form on confirmation,
2
+ onValueChange, // function applying the changes on EVERY value change, be it confirmed through the popup or not
3
3
  message, validateButtonLabel, ...props }: any): import("react").JSX.Element;
@@ -7,8 +7,8 @@ function InputWithPopupConfirmation({
7
7
  name,
8
8
  shouldOpenPopup,
9
9
  // condition to open popup confirmation
10
- resetOnConfirmation,
11
- // function to reset values in your form on confirmation,
10
+ onValueChange,
11
+ // function applying the changes on EVERY value change, be it confirmed through the popup or not
12
12
  message,
13
13
  validateButtonLabel,
14
14
  ...props
@@ -25,11 +25,12 @@ function InputWithPopupConfirmation({
25
25
  setOpenPopup(true);
26
26
  setNewValue(value);
27
27
  } else {
28
+ onValueChange?.();
28
29
  onChange(value);
29
30
  }
30
31
  };
31
32
  const handlePopupConfirmation = () => {
32
- resetOnConfirmation?.();
33
+ onValueChange?.();
33
34
  onChange(newValue);
34
35
  setOpenPopup(false);
35
36
  };
@@ -112,16 +112,17 @@ function LimitsPane({
112
112
  }
113
113
  return null;
114
114
  };
115
- const handlePopupConfirmation = () => {
116
- const resetOLGs = mapServerLimitsGroupsToFormInfos(
115
+ const resetOLGs = () => {
116
+ const networkOLGs = mapServerLimitsGroupsToFormInfos(
117
117
  equipmentToModify?.currentLimits ?? []
118
118
  );
119
119
  const currentValues = getValues();
120
120
  reset(
121
121
  {
122
122
  ...currentValues,
123
- [FieldConstants.LIMITS]: {
124
- [FieldConstants.OPERATIONAL_LIMITS_GROUPS]: resetOLGs,
123
+ [id]: {
124
+ ...currentValues[id],
125
+ [FieldConstants.OPERATIONAL_LIMITS_GROUPS]: networkOLGs,
125
126
  [FieldConstants.ENABLE_OLG_MODIFICATION]: false
126
127
  }
127
128
  },
@@ -161,7 +162,7 @@ function LimitsPane({
161
162
  name: `${id}.${FieldConstants.ENABLE_OLG_MODIFICATION}`,
162
163
  label: olgEditable ? "Edit" : "View",
163
164
  shouldOpenPopup: () => olgEditable,
164
- resetOnConfirmation: handlePopupConfirmation,
165
+ onValueChange: resetOLGs,
165
166
  message: "disableOLGedition",
166
167
  validateButtonLabel: "validate"
167
168
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.247.0",
3
+ "version": "0.248.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",