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

Rework twt modification dialog #2535

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f3a894b
Revert "fix for edit data in line modification dialog form (#2483)"
ghazwarhili Jan 22, 2025
9bf2f64
Revert "fix for edit data in twt modification dialog form (#2487)"
ghazwarhili Jan 22, 2025
8c5c447
Merge branch 'main' into revert-fix-properties-line-twt-form
ghazwarhili Jan 22, 2025
7ca360c
rework code to fix properties
ghazwarhili Jan 22, 2025
ba33685
Merge remote-tracking branch 'origin/revert-fix-properties-line-twt-f…
ghazwarhili Jan 23, 2025
b0ab057
use getValues instead of useRef
ghazwarhili Jan 23, 2025
2e43422
use getValues instead of useRef (line)
ghazwarhili Jan 23, 2025
2ea9f77
fix of updated data
ghazwarhili Jan 23, 2025
1faf730
fix for ratio and tap changer values
ghazwarhili Jan 24, 2025
f74c6d2
import issues
ghazwarhili Jan 24, 2025
447f4cd
add getValues
ghazwarhili Jan 24, 2025
9fc18d7
add some check on the enable button
ghazwarhili Jan 27, 2025
2c6e905
handle values based on build node state
ghazwarhili Jan 27, 2025
4bcfdac
Merge branch 'main' into revert-fix-properties-line-twt-form
etiennehomer Jan 28, 2025
fcbe4b2
handle notbuild node case
ghazwarhili Jan 28, 2025
5333ff9
Merge remote-tracking branch 'origin/revert-fix-properties-line-twt-f…
ghazwarhili Jan 28, 2025
a6cfe12
Merge branch 'main' into revert-fix-properties-line-twt-form
Mathieu-Deharbe Jan 28, 2025
fc51f90
add some check and fix button state
ghazwarhili Jan 28, 2025
3285618
Merge remote-tracking branch 'origin/revert-fix-properties-line-twt-f…
ghazwarhili Jan 28, 2025
87e394e
draft version to rework the dialog
ghazwarhili Jan 28, 2025
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 @@ -122,7 +122,6 @@ const LineModificationDialog = ({
const [lineToModify, setLineToModify] = useState(null);
const [tabIndex, setTabIndex] = useState(LineModificationDialogTab.CONNECTIVITY_TAB);
const [isOpenLineTypesCatalogDialog, setOpenLineTypesCatalogDialog] = useState(false);

const emptyFormData = useMemo(
() => ({
[EQUIPMENT_NAME]: '',
Expand Down Expand Up @@ -277,10 +276,7 @@ const LineModificationDialog = ({

const onEquipmentIdChange = useCallback(
(equipmentId) => {
if (!equipmentId) {
setLineToModify(null);
reset(emptyFormData, { keepDefaultValues: true });
} else {
if (equipmentId) {
setDataFetchStatus(FetchStatus.RUNNING);
fetchNetworkElementInfos(
studyUuid,
Expand All @@ -298,32 +294,23 @@ const LineModificationDialog = ({
setConnectivityValue(CONNECTIVITY_1, BUS_OR_BUSBAR_SECTION, line?.busOrBusbarSectionId1);
setConnectivityValue(CONNECTIVITY_2, BUS_OR_BUSBAR_SECTION, line?.busOrBusbarSectionId2);
const updatedTemporaryLimits1 = updateTemporaryLimits(
formatTemporaryLimits(getValues(`${CURRENT_LIMITS_1}.${TEMPORARY_LIMITS}`)),
formatTemporaryLimits(getValues(`${LIMITS}.${CURRENT_LIMITS_1}.${TEMPORARY_LIMITS}`)),
formatTemporaryLimits(line?.currentLimits1?.temporaryLimits)
);
const updatedTemporaryLimits2 = updateTemporaryLimits(
formatTemporaryLimits(getValues(`${CURRENT_LIMITS_2}.${TEMPORARY_LIMITS}`)),
formatTemporaryLimits(getValues(`${LIMITS}.${CURRENT_LIMITS_2}.${TEMPORARY_LIMITS}`)),
formatTemporaryLimits(line?.currentLimits2?.temporaryLimits)
);
reset(
(formValues) => ({
...formValues,
...getLimitsFormData({
temporaryLimits1: addSelectedFieldToRows(
updatedTemporaryLimits1
? updatedTemporaryLimits1
: formatTemporaryLimits(line.currentLimits1?.temporaryLimits)
),
temporaryLimits2: addSelectedFieldToRows(
updatedTemporaryLimits2
? updatedTemporaryLimits2
: formatTemporaryLimits(line.currentLimits2?.temporaryLimits)
),
}),
[ADDITIONAL_PROPERTIES]: getConcatenatedProperties(line, getValues),
reset((formValues) => ({
...formValues,
...getLimitsFormData({
permanentLimit1: getValues(`${LIMITS}.${CURRENT_LIMITS_1}.${PERMANENT_LIMIT}`),
permanentLimit2: getValues(`${LIMITS}.${CURRENT_LIMITS_2}.${PERMANENT_LIMIT}`),
temporaryLimits1: addSelectedFieldToRows(updatedTemporaryLimits1),
temporaryLimits2: addSelectedFieldToRows(updatedTemporaryLimits2),
}),
{ keepDefaultValues: true }
);
[ADDITIONAL_PROPERTIES]: getConcatenatedProperties(line, getValues),
}));
}
setDataFetchStatus(FetchStatus.SUCCEED);
})
Expand All @@ -334,9 +321,12 @@ const LineModificationDialog = ({
reset(emptyFormData);
}
});
} else {
setLineToModify(null);
reset(emptyFormData, { keepDefaultValues: true });
}
},
[studyUuid, currentNodeUuid, editData, reset, emptyFormData, getValues, setConnectivityValue]
[studyUuid, currentNodeUuid, editData?.equipmentId, reset, emptyFormData, getValues, setConnectivityValue]
);

useEffect(() => {
Expand Down
Loading
Loading