Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions src/NodeDev.Blazor/Components/ClassExplorer.razor
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@
[Parameter]
public EventCallback<NodeDev.Core.Class.NodeClassMethod?> SelectedMethodChanged { get; set; }

[Parameter]
public EventCallback<NodeDev.Core.Class.NodeClassMethod> MethodDeleted { get; set; }

private TreeItem? SelectedTreeItem;

private List<TreeItemData<TreeItem>> Items { get; } = [];
Expand Down Expand Up @@ -267,10 +270,24 @@

if (confirm == true)
{
// Note: There's no public API to remove methods, so we just remove from UI
Items.First(x => x.Value!.Type == TreeItemType.MethodsFolder).Children!.RemoveAll(x => x.Value?.Method == item.Method);
Snackbar.Add($"Method '{item.Method.Name}' removed from view (Note: No API to actually delete)", Severity.Warning);
StateHasChanged();
try
{
Class.RemoveMethod(item.Method);
Items.First(x => x.Value!.Type == TreeItemType.MethodsFolder).Children!.RemoveAll(x => x.Value?.Method == item.Method);
if (SelectedTreeItem == item)
{
SelectedTreeItem = null;
SelectedMethod = null;
await SelectedMethodChanged.InvokeAsync(null);
}
await MethodDeleted.InvokeAsync(item.Method);
Snackbar.Add($"Method '{item.Method.Name}' deleted", Severity.Success);
StateHasChanged();
}
catch (Exception ex)
{
Snackbar.Add(ex.Message, Severity.Error);
}
}
}

Expand All @@ -287,7 +304,7 @@

private async Task ShowPropertyTypeEdit(TreeItem item)
{
var result = await DialogService.Show<TypeSelectorDialog>("", new()

Check warning on line 307 in src/NodeDev.Blazor/Components/ClassExplorer.razor

View workflow job for this annotation

GitHub Actions / Build the entire solution / build

'IDialogService.Show<TComponent>(string?, DialogParameters, DialogOptions?)' is obsolete: 'Use ShowAsync instead. This will be removed in future major version.'
{
[nameof(TypeSelectorDialog.TypeFactory)] = Class.TypeFactory
}, new DialogOptions()
Expand All @@ -309,7 +326,7 @@

private async Task ShowMethodEdit(TreeItem item)
{
var result = await DialogService.Show<EditMethodMenu>("", new()

Check warning on line 329 in src/NodeDev.Blazor/Components/ClassExplorer.razor

View workflow job for this annotation

GitHub Actions / Build the entire solution / build

'IDialogService.Show<TComponent>(string?, DialogParameters, DialogOptions?)' is obsolete: 'Use ShowAsync instead. This will be removed in future major version.'
{
[nameof(EditMethodMenu.Method)] = item.Method
}, new DialogOptions()
Expand Down Expand Up @@ -377,7 +394,8 @@
{
// remove the textbox
if (IsNew)
Items.First().Children!.RemoveAll(x => x.Value == CurrentlyEditingItem);
Items.First(x => x.Value?.Type == (CurrentlyEditingItem.Type == TreeItemType.Method ? TreeItemType.MethodsFolder : TreeItemType.PropertiesFolder))
.Children!.RemoveAll(x => x.Value == CurrentlyEditingItem);

CurrentlyEditingItem = null;
Text = null;
Expand All @@ -398,4 +416,4 @@

}

}
}
12 changes: 6 additions & 6 deletions src/NodeDev.Blazor/Components/GraphCanvas.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

<div style="height: 100%; width: 100%">

@if (IsShowingNodeSelection)
@if (PopupState.IsShowingNodeSelection)
{
<div @onclick="CancelPopup" style="background-color: var(--mud-palette-overlay-dark); width: 100%; height: 100%; position: absolute; z-index: 1">
<NodeDev.Blazor.Components.NodeSelection PositionX="PopupX" PositionY="PopupY" GraphCanvas="this" OnNodeTypeSelected="OnNewNodeTypeSelected" Connection="PopupNodeConnection" CallableScopeId="@PopupCallableScopeId" />
<NodeDev.Blazor.Components.NodeSelection PositionX="PopupState.X" PositionY="PopupState.Y" GraphCanvas="this" OnNodeTypeSelected="OnNewNodeTypeSelected" Connection="PopupState.NodeConnection" CallableScopeId="@PopupState.CallableScopeId" />
</div>
}
@if (IsShowingGenericTypeSelection)
@if (PopupState.IsShowingGenericTypeSelection)
{
<div @onclick="CancelPopup" style="background-color: var(--mud-palette-overlay-dark); width: 100%; height: 100%; position: absolute; z-index: 1">
<NodeDev.Blazor.Components.TypeSelector PositionX="PopupX" PositionY="PopupY" TypeFactory="Graph.SelfClass.TypeFactory" OnTypeSelected="OnGenericTypeSelected" />
<NodeDev.Blazor.Components.TypeSelector PositionX="PopupState.X" PositionY="PopupState.Y" TypeFactory="Graph.SelfClass.TypeFactory" OnTypeSelected="OnGenericTypeSelected" />
</div>
}
@if (IsShowingOverloadSelection && PopupNode != null)
@if (PopupState.IsShowingOverloadSelection && PopupState.Node != null)
{
<div @onclick="CancelPopup" style="background-color: var(--mud-palette-overlay-dark); width: 100%; height: 100%; position: absolute; z-index: 1">
<NodeDev.Blazor.Components.AlternateOverloadsSelection OnNodeMethodSelected="OnNewOverloadSelected" Node="PopupNode" />
<NodeDev.Blazor.Components.AlternateOverloadsSelection OnNodeMethodSelected="OnNewOverloadSelected" Node="PopupState.Node" />
</div>
}

Expand Down
Loading
Loading