@@ -1567,7 +1567,31 @@ export const reducer = createReducer(initialState, (builder) => {
1567
1567
1568
1568
builder . addCase ( DELETE_EQUIPMENTS , ( state , action : DeleteEquipmentsAction ) => {
1569
1569
action . equipments . forEach ( ( { equipmentType : equipmentToDeleteType , equipmentId : equipmentToDeleteId } ) => {
1570
+ if (
1571
+ // If we delete a line or a two windings transformer we also have to delete it from branch type
1572
+ ( equipmentToDeleteType === SpreadsheetEquipmentType . LINE ||
1573
+ equipmentToDeleteType === SpreadsheetEquipmentType . TWO_WINDINGS_TRANSFORMER ) &&
1574
+ state . spreadsheetNetwork [ SpreadsheetEquipmentType . BRANCH ] ?. equipmentsByNodeId [ action . nodeId ]
1575
+ ) {
1576
+ delete state . spreadsheetNetwork [ SpreadsheetEquipmentType . BRANCH ] . equipmentsByNodeId [ action . nodeId ] [
1577
+ equipmentToDeleteId
1578
+ ] ;
1579
+ }
1570
1580
if ( state . spreadsheetNetwork [ equipmentToDeleteType ] ?. equipmentsByNodeId [ action . nodeId ] ) {
1581
+ // in case of voltage level deletion, we need to update the linked substation which contains a list of its voltage levels
1582
+ if ( equipmentToDeleteType === SpreadsheetEquipmentType . VOLTAGE_LEVEL ) {
1583
+ const currentSubstations = state . spreadsheetNetwork [ SpreadsheetEquipmentType . SUBSTATION ]
1584
+ . equipmentsByNodeId [ action . nodeId ] as Record < string , Substation > | null ;
1585
+ if ( currentSubstations != null ) {
1586
+ state . spreadsheetNetwork [ SpreadsheetEquipmentType . SUBSTATION ] . equipmentsByNodeId [
1587
+ action . nodeId
1588
+ ] = updateSubstationAfterVLDeletion ( currentSubstations , equipmentToDeleteId ) ;
1589
+ }
1590
+ }
1591
+ delete state . spreadsheetNetwork [ equipmentToDeleteType ] . equipmentsByNodeId [ action . nodeId ] [
1592
+ equipmentToDeleteId
1593
+ ] ;
1594
+ }
1571
1595
// in case of voltage level deletion, we need to update the linked substation which contains a list of its voltage levels
1572
1596
if ( equipmentToDeleteType === SpreadsheetEquipmentType . VOLTAGE_LEVEL ) {
1573
1597
const currentSubstations = state . spreadsheetNetwork [ SpreadsheetEquipmentType . SUBSTATION ]
0 commit comments