Skip to content

Commit

Permalink
improves limit sets ihm (#2623)
Browse files Browse the repository at this point in the history
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
  • Loading branch information
Mathieu-Deharbe authored Feb 26, 2025
1 parent 581b952 commit 78cfaf0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
13 changes: 8 additions & 5 deletions src/components/dialogs/limits/limits-groups-contextual-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,31 @@ export function LimitsGroupsContextualMenu({
};

const handleDuplicateTab = () => {
let newName: string = '';
if (indexSelectedLimitSet1 !== null) {
const duplicatedLimits1 = getValues(
const duplicatedLimits1: OperationalLimitsGroup = getValues(
`${parentFormName}.${OPERATIONAL_LIMITS_GROUPS_1}[${indexSelectedLimitSet1}]`
);
newName = duplicatedLimits1.id + '_COPY';
const newLimitsGroup1: OperationalLimitsGroup = {
...duplicatedLimits1,
[ID]: '',
[ID]: newName,
};
appendToLimitsGroups1(newLimitsGroup1);
}

if (indexSelectedLimitSet2 !== null) {
const duplicatedLimits2 = getValues(
const duplicatedLimits2: OperationalLimitsGroup = getValues(
`${parentFormName}.${OPERATIONAL_LIMITS_GROUPS_2}[${indexSelectedLimitSet2}]`
);
newName = duplicatedLimits2.id + '_COPY';
const newLimitsGroup2: OperationalLimitsGroup = {
...duplicatedLimits2,
[ID]: '',
[ID]: newName,
};
appendToLimitsGroups2(newLimitsGroup2);
}
startEditingLimitsGroup(getValues(`${parentFormName}.${OPERATIONAL_LIMITS_GROUPS_1}`).length - 1, '');
startEditingLimitsGroup(getValues(`${parentFormName}.${OPERATIONAL_LIMITS_GROUPS_1}`).length - 1, newName);
};

return (
Expand Down
13 changes: 9 additions & 4 deletions src/components/dialogs/limits/operational-limits-groups-tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export function OperationalLimitsGroupsTabs({
const newIndex: number = limitsGroups1.length;
appendEmptyOperationalLimitsGroup(`${parentFormName}.${OPERATIONAL_LIMITS_GROUPS_1}`, '');
appendEmptyOperationalLimitsGroup(`${parentFormName}.${OPERATIONAL_LIMITS_GROUPS_2}`, '');
startEditingLimitsGroup(newIndex, `LIMIT_SET`);
startEditingLimitsGroup(newIndex, `DEFAULT`);
}
}, [
editingTabIndex,
Expand Down Expand Up @@ -356,10 +356,11 @@ export function OperationalLimitsGroupsTabs({
{(index === hoveredRowIndex || index === activatedByMenuTabIndex) && (
<IconButton
size="small"
hidden
onClick={(e: React.MouseEvent<HTMLButtonElement>) =>
handleOpenMenu(e, index)
}
// during the naming of a limit set no other limit set manipulation is allowed :
disabled={editingTabIndex !== -1}
>
<MenuIcon fontSize="small" />
</IconButton>
Expand All @@ -371,27 +372,31 @@ export function OperationalLimitsGroupsTabs({
/>
))}
<Tab
key="addLimitSet"
label={
editingTabIndex === -1 && (
<Box
sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
width: '100%',
flexGrow: 1,
}}
>
<IconButton
size="small"
onClick={addNewLimitSet}
sx={{
align: 'right',
marginLeft: 'auto',
}}
>
<AddCircleIcon />
<AddCircleIcon fontSize="small" />
</IconButton>
</Box>
)
}
sx={limitsStyles.limitsBackground}
/>
</Tabs>
<LimitsGroupsContextualMenu
Expand Down

0 comments on commit 78cfaf0

Please sign in to comment.