Skip to content

Commit 0fa1708

Browse files
.
1 parent dd68dfd commit 0fa1708

File tree

3 files changed

+30
-29
lines changed

3 files changed

+30
-29
lines changed

roles/lib/files/FWO.Services/ModellingConnectionHandler.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,37 +1019,35 @@ public bool CalcVisibility()
10191019
return true;
10201020
}
10211021

1022-
public bool NetworkAreaUseAllowed(ModellingDnDContainer modellingContainer)
1023-
{
1024-
return NetworkAreaUseAllowed(modellingContainer.AreaElements);
1025-
}
1026-
1027-
public bool NetworkAreaUseAllowed(List<ModellingNetworkArea> networkAreas)
1022+
public bool NetworkAreaUseAllowed(List<ModellingNetworkArea> networkAreas, out string reason)
10281023
{
10291024
if (ActConn.IsInterface)
10301025
{
1031-
DisplayMessageInUi(default, "Add Network Area", "Interfaces must not contain network areas", true);
1026+
reason = "Interfaces must not contain network areas";
10321027
return false;
10331028
}
1029+
10341030
bool hasCommonNetworkAreas = HasCommonNetworkAreas(networkAreas);
10351031

1036-
//Uncommon network areas should only be selectable under “Common Services”
10371032
if (!hasCommonNetworkAreas && ActConn.IsCommonService)
10381033
{
1034+
//Uncommon network areas should only be selectable under “Common Services”
1035+
reason = "";
10391036
return true;
10401037
}
1041-
//Common network areas may be selected in “Common Services” + “Connections”
1042-
if (hasCommonNetworkAreas && ( ActConn.IsCommonService || ( !ActConn.IsInterface && !ActConn.IsCommonService ) ))
1038+
else if (hasCommonNetworkAreas && ( ActConn.IsCommonService || ( !ActConn.IsInterface && !ActConn.IsCommonService ) ))
10431039
{
1040+
//Common network areas may be selected in “Common Services” + “Connections”
1041+
reason = "";
10441042
return true;
10451043
}
10461044

1047-
DisplayMessageInUi(default, "Add Network Area", "The reason why it's not allowed", true);
1045+
reason = "The reason why it's not allowed";
10481046
return false;
10491047
}
10501048

10511049
private bool HasCommonNetworkAreas(List<ModellingNetworkArea> networkAreas)
1052-
{
1050+
{
10531051
foreach (ModellingNetworkArea area in networkAreas)
10541052
{
10551053
if (CommonAreaConfigItems.Any(_ => _.AreaId == area.Id))

roles/ui/files/FWO.UI/Pages/NetworkModelling/EditConn.razor

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
@if((ConnHandler.ActConn.InterfaceIsRequested && ConnHandler.ActConn.SrcFromInterface) || (ConnHandler.ActConn.IsRequested && ConnHandler.ActConn.SourceFilled()))
120120
{
121121
@((MarkupString)ModellingHandlerBase.DisplayReqInt(userConfig, ConnHandler.ActConn.TicketId, ConnHandler.ActConn.InterfaceIsRequested,
122-
ConnHandler.ActConn.GetBoolProperty(ConState.InterfaceRejected.ToString()) || ConnHandler.ActConn.GetBoolProperty(ConState.Rejected.ToString())))
122+
ConnHandler.ActConn.GetBoolProperty(ConState.InterfaceRejected.ToString()) || ConnHandler.ActConn.GetBoolProperty(ConState.Rejected.ToString())))
123123
}
124124
else
125125
{
@@ -217,7 +217,7 @@
217217
@if(ConnHandler.ActConn.InterfaceIsRequested || ConnHandler.ActConn.IsRequested)
218218
{
219219
@((MarkupString)ModellingHandlerBase.DisplayReqInt(userConfig, ConnHandler.ActConn.TicketId, ConnHandler.ActConn.InterfaceIsRequested,
220-
ConnHandler.ActConn.GetBoolProperty(ConState.InterfaceRejected.ToString()) || ConnHandler.ActConn.GetBoolProperty(ConState.Rejected.ToString())))
220+
ConnHandler.ActConn.GetBoolProperty(ConState.InterfaceRejected.ToString()) || ConnHandler.ActConn.GetBoolProperty(ConState.Rejected.ToString())))
221221
}
222222
else
223223
{
@@ -277,7 +277,7 @@
277277
@if((ConnHandler.ActConn.InterfaceIsRequested && ConnHandler.ActConn.DstFromInterface) || (ConnHandler.ActConn.IsRequested && ConnHandler.ActConn.DestinationFilled()))
278278
{
279279
@((MarkupString)ModellingHandlerBase.DisplayReqInt(userConfig, ConnHandler.ActConn.TicketId, ConnHandler.ActConn.InterfaceIsRequested,
280-
ConnHandler.ActConn.GetBoolProperty(ConState.InterfaceRejected.ToString()) || ConnHandler.ActConn.GetBoolProperty(ConState.Rejected.ToString())))
280+
ConnHandler.ActConn.GetBoolProperty(ConState.InterfaceRejected.ToString()) || ConnHandler.ActConn.GetBoolProperty(ConState.Rejected.ToString())))
281281
}
282282
else
283283
{
@@ -487,12 +487,6 @@
487487

488488
private async Task HandleSrcDrop()
489489
{
490-
if (ConnHandler is null || !ConnHandler.NetworkAreaUseAllowed(Container))
491-
{
492-
Container.Clear();
493-
return;
494-
}
495-
496490
if(Container.ConnElement != null)
497491
{
498492
if(ConnHandler!.ActConn.IsInterface)
@@ -512,7 +506,14 @@
512506
}
513507
if(Container.AreaElements.Count > 0)
514508
{
515-
ConnHandler?.AreasToSource(Container.AreaElements);
509+
if (ConnHandler is not null && !ConnHandler.NetworkAreaUseAllowed(Container.AreaElements, out string reason))
510+
{
511+
DisplayMessageInUi(default, "Add Network Area", reason, true);
512+
Container.Clear();
513+
return;
514+
}
515+
516+
ConnHandler?.AreasToSource(Container.AreaElements);
516517
}
517518
if(Container.NwGroupElements.Count > 0)
518519
{
@@ -528,12 +529,6 @@
528529

529530
private async Task HandleDstDrop()
530531
{
531-
if (ConnHandler is null || !ConnHandler.NetworkAreaUseAllowed(Container))
532-
{
533-
Container.Clear();
534-
return;
535-
}
536-
537532
if(Container.ConnElement != null)
538533
{
539534
if(ConnHandler!.ActConn.IsInterface)
@@ -553,6 +548,13 @@
553548
}
554549
if(Container.AreaElements.Count > 0)
555550
{
551+
if (ConnHandler is not null && !ConnHandler.NetworkAreaUseAllowed(Container.AreaElements, out string reason))
552+
{
553+
DisplayMessageInUi(default, "Add Network Area", reason, true);
554+
Container.Clear();
555+
return;
556+
}
557+
556558
ConnHandler?.AreasToDestination(Container.AreaElements);
557559
}
558560
if(Container.NwGroupElements.Count > 0)

roles/ui/files/FWO.UI/Pages/NetworkModelling/EditConnLeftSide.razor

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,9 @@
345345
}
346346
}
347347

348-
if (areas.Count > 0 && !ConnHandler.NetworkAreaUseAllowed(areas))
348+
if (areas.Count > 0 && ConnHandler is not null && !ConnHandler.NetworkAreaUseAllowed(areas, out string reason))
349349
{
350+
DisplayMessageInUi(default, "Add Network Area", reason, true);
350351
return;
351352
}
352353

0 commit comments

Comments
 (0)