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
2 changes: 1 addition & 1 deletion ResourceInformationV2/Components/Pages/OrgChart/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<button class="ilw-button" @onclick="GoUpLevel">Up to @ParentText</button>
</div>
}
<h2>Children of Current Level</h2>
<h3>Children of "@VisibleOrgchartItem.Title"</h3>
@foreach (var child in VisibleOrgchartItems)
{
<p>@child.Title, @child.Subtitle</p>
Expand Down
12 changes: 10 additions & 2 deletions ResourceInformationV2/Components/Pages/OrgChart/Edit.razor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using ResourceInformationV2.Components.Layout;
using ResourceInformationV2.Data.DataHelpers;
using ResourceInformationV2.Data.DataModels;
Expand All @@ -23,6 +24,9 @@ public partial class Edit {
[CascadingParameter]
public SidebarLayout Layout { get; set; } = default!;

[Inject]
protected IJSRuntime JsRuntime { get; set; } = default!;

[Inject]
protected NavigationManager NavigationManager { get; set; } = default!;

Expand Down Expand Up @@ -56,11 +60,14 @@ protected void AddChild() {
RefreshVisibleItems();
}

protected void DeleteChild(Orgchart child) {
protected async Task DeleteChild(Orgchart child) {
if (VisibleOrgchartItem.Children is null) {
return;
}
_ = VisibleOrgchartItem.Children.Remove(child);
var alert = child.Children is not null && child.Children.Count > 0 ? "This will delete this item and all children" : "This will delete this item";
if (!(await JsRuntime.InvokeAsync<bool>("confirm", $"{alert}. Are you sure?"))) {
_ = VisibleOrgchartItem.Children.Remove(child);
}
RefreshVisibleItems();
}

Expand All @@ -79,6 +86,7 @@ protected void GoUpLevel() {
protected async Task Save() {
SetParents(CurrentOrgchart, null);
var saved = await OrgChartHelper.SaveOrgChartJson(_sourceCode, CurrentOrgchart.ToString());
Layout.IsDirty = false;
await Layout.AddMessage(saved ? "Org chart saved." : "Unable to save org chart.");
}

Expand Down
Loading