File tree Expand file tree Collapse file tree 3 files changed +33
-4
lines changed Expand file tree Collapse file tree 3 files changed +33
-4
lines changed Original file line number Diff line number Diff line change 9696 ondragover =" event.preventDefault();"
9797 ondragstart =" event.dataTransfer.setData('', event.target.id);"
9898 @ondrop =" HandleServerDrop" >
99- <EditList ElementType =" ModellingAppServer" Elements =" ModellingAppServerWrapper.Resolve(AppRoleHandler.ActAppRole.AppServers)" ElementsToAdd =" AppRoleHandler.AppServerToAdd" ElementsToDelete =" AppRoleHandler.AppServerToDelete" StdLayout =" false" >
99+ <EditList ElementType =" ModellingAppServer" Elements =" ModellingAppServerWrapper.Resolve(AppRoleHandler.ActAppRole.AppServers)" ElementsToAdd =" AppRoleHandler.AppServerToAdd" ElementsToDelete =" AppRoleHandler.AppServerToDelete" StdLayout =" false" ElementsRemoved = " OnAppServerRemovedFromEditList " >
100100 <Display >
101101 <div class =" row" >
102102 <div class =" col-sm-12 ms-2 bg-transparent" >@( (MarkupString )context .DisplayWithIcon ()) </div >
296296 {
297297 areas .Sort ((ModellingNetworkArea a , ModellingNetworkArea b ) => a ? .CompareTo (b ) ?? - 1 );
298298 }
299+
300+ /// <summary >
301+ /// Updates the view after removing an app server from the list of app role's app servers.
302+ /// </summary >
303+ private void OnAppServerRemovedFromEditList ()
304+ {
305+ InvokeAsync (StateHasChanged );
306+ }
299307}
Original file line number Diff line number Diff line change 1414 {
1515 <div class =" form-group row" >
1616 <div class =" col-sm-10" >
17- <DraggableList AllElements =" AppRoleHandler.AppServersInArea " @bind-SelectedElements =" selectedAppServers"
17+ <DraggableList AllElements =" selectableAppServers " @bind-SelectedElements =" selectedAppServers"
1818 HandleDragStart =" HandleDragStart" Display =" @(x => x.DisplayWithIcon())" MaxHeight =" 50" />
1919 </div >
2020 @if (selectedAppServers .Count > 0 )
5656 private List <ModellingAppServer > selectedAppServers = [];
5757 private int sidebarLeftWidth { get { return Width ; } set { Width = value ; WidthChanged .InvokeAsync (Width );}}
5858
59+ /// <summary >
60+ /// The app servers which are available for adding (i.e. which are not already in the AppServerToAdd collection).
61+ /// </summary >
62+ private List <ModellingAppServer > selectableAppServers => AppRoleHandler .AppServersInArea .Except (AppRoleHandler .AppServerToAdd ).ToList ();
63+
5964
6065 private bool HandleDragStart (DragEventArgs e , ModellingAppServer appServer )
6166 {
Original file line number Diff line number Diff line change 1010 int j = i ;
1111 <li class =" @(StdLayout ? StdClass : AltClass) d-flex justify-content-between" >
1212 <div class =" @(StdLayout ? " " : AltElemClass)" >@( Display (ElementsToAdd [i ])) </div >
13- <span @onclick =" () => {ElementsToAdd.Remove(ElementsToAdd[j]);AfterRemoveAction();} " class =" @(StdLayout ? " " : AltButtonClass) badge bg-danger" >
13+ <span @onclick =" () => OnRemoveElementButtonClick(j) " class =" @(StdLayout ? " " : AltButtonClass) badge bg-danger" >
1414 <i class =" @(Icons.Close) text-light" ></i >
1515 </span >
1616 </li >
5353 [Parameter ]
5454 public Func <bool > AfterRemoveAction { get ; set ; } = DefaultInit .DoNothingSync ;
5555
56+ /// <summary >
57+ /// Gets invoked after user removes element from the ElementsToAdd collection via button.
58+ /// </summary >
59+ [Parameter ]
60+ public EventCallback ElementsRemoved { get ; set ; }
61+
5662 private string StdClass = " bg-success-subtle list-group-item pb-2 pt-2" ;
5763 private string AltClass = " draggable-selected pb-0 pt-0" ;
5864 private string AltElemClass = " col-sm-11" ;
6975 ElementsToDelete .Add (Elements [index ]);
7076 }
7177 }
72- }
78+
79+ /// <summary >
80+ /// Handles the click on an 'x' button of a server that is in the list of configured servers.
81+ /// </summary >
82+ private void OnRemoveElementButtonClick (int index )
83+ {
84+ ElementsToAdd .Remove (ElementsToAdd [index ]);
85+ AfterRemoveAction ();
86+ ElementsRemoved .InvokeAsync ();
87+ }
88+ }
You can’t perform that action at this time.
0 commit comments