Skip to content

Commit b1d62c1

Browse files
.
1 parent 560306b commit b1d62c1

File tree

5 files changed

+38
-4
lines changed

5 files changed

+38
-4
lines changed

roles/database/files/sql/idempotent/fworch-texts.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,6 +1158,8 @@ INSERT INTO txt VALUES ('edit_interface', 'German', 'Schnittstelle bearbeit
11581158
INSERT INTO txt VALUES ('edit_interface', 'English', 'Edit Interface');
11591159
INSERT INTO txt VALUES ('interface_contain_nwarea','German', 'Schnittstellen dürfen keine Netzbereiche enthalten');
11601160
INSERT INTO txt VALUES ('interface_contain_nwarea','English','Interfaces must not contain network areas');
1161+
INSERT INTO txt VALUES ('direction_contain_nwarea', 'German','Schnittstelle löschen');
1162+
INSERT INTO txt VALUES ('direction_contain_nwarea', 'English','Delete Interface');
11611163
INSERT INTO txt VALUES ('delete_interface', 'German', 'Schnittstelle löschen');
11621164
INSERT INTO txt VALUES ('delete_interface', 'English', 'Delete Interface');
11631165
INSERT INTO txt VALUES ('insert_forbidden', 'German', 'Einfügen verboten');
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace FWO.Data
2+
{
3+
public enum Direction
4+
{
5+
Source,
6+
Destination
7+
}
8+
}

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,10 +1019,26 @@ public bool CalcVisibility()
10191019
return true;
10201020
}
10211021

1022-
public bool NetworkAreaUseAllowed(List<ModellingNetworkArea> networkAreas, out (string Title, string Text) reason)
1022+
private bool IsAreaForbiddenInDirection(Direction direction)
1023+
{
1024+
return direction switch
1025+
{
1026+
Direction.Source => ActConn.DestinationAreas.Count > 0,
1027+
Direction.Destination => ActConn.SourceAreas.Count > 0,
1028+
_ => false,
1029+
};
1030+
}
1031+
1032+
/// <summary>
1033+
/// Checks if the given network areas are allowed in the current connection/interface/service.
1034+
/// </summary>
1035+
/// <param name="networkAreas">The list of network areas to check.</param>
1036+
/// <param name="reason">Out parameter to give context as a reason why it's not allowed, otherwise is's empty.</param>
1037+
public bool NetworkAreaUseAllowed(List<ModellingNetworkArea> networkAreas, Direction direction, out (string Title, string Text) reason)
10231038
{
10241039
reason.Text = "";
10251040

1041+
10261042
if (ActConn.IsCommonService)
10271043
{
10281044
reason.Title = userConfig.GetText("edit_service");
@@ -1036,6 +1052,12 @@ public bool NetworkAreaUseAllowed(List<ModellingNetworkArea> networkAreas, out (
10361052
reason.Title = userConfig.GetText("edit_connection");
10371053
}
10381054

1055+
if (IsAreaForbiddenInDirection(direction))
1056+
{
1057+
reason.Text = userConfig.GetText("direction_contain_nwarea");
1058+
return false;
1059+
}
1060+
10391061
if (ActConn.IsInterface)
10401062
{
10411063
reason.Text = userConfig.GetText("interface_contain_nwarea");

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@
506506
}
507507
if(Container.AreaElements.Count > 0)
508508
{
509-
if (ConnHandler is not null && !ConnHandler.NetworkAreaUseAllowed(Container.AreaElements, out (string Title, string Text) reason))
509+
if (ConnHandler is not null && !ConnHandler.NetworkAreaUseAllowed(Container.AreaElements, Direction.Source, out (string Title, string Text) reason))
510510
{
511511
DisplayMessageInUi(default, reason.Title, reason.Text, true);
512512
Container.Clear();
@@ -548,7 +548,7 @@
548548
}
549549
if(Container.AreaElements.Count > 0)
550550
{
551-
if (ConnHandler is not null && !ConnHandler.NetworkAreaUseAllowed(Container.AreaElements, out (string Title, string Text) reason))
551+
if (ConnHandler is not null && !ConnHandler.NetworkAreaUseAllowed(Container.AreaElements, Direction.Destination, out (string Title, string Text) reason))
552552
{
553553
DisplayMessageInUi(default, reason.Title, reason.Text, true);
554554
Container.Clear();

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

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

348-
if (areas.Count > 0 && ConnHandler is not null && !ConnHandler.NetworkAreaUseAllowed(areas, out (string Title, string Text) reason))
348+
Direction direction = toSource ? Direction.Source : Direction.Destination;
349+
350+
if (areas.Count > 0 && ConnHandler is not null && !ConnHandler.NetworkAreaUseAllowed(areas, direction, out (string Title, string Text) reason))
349351
{
350352
DisplayMessageInUi(default, reason.Title, reason.Text, true);
351353
return;

0 commit comments

Comments
 (0)