-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Relation Grid and dialogs
- Loading branch information
Showing
26 changed files
with
400 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
UIWasm/Components/Modules/Documents/RelationGrid/EGAddRelationDialog.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@implements IDialogContentComponent<EncyclopediaGalactica.BusinessLogic.Contracts.RelationResult> | ||
|
||
<FluentDialogHeader ShowDismiss="true">Add new Relation</FluentDialogHeader> | ||
<FluentDialogBody> | ||
<FluentNumberField TValue="long" @bind-Value="Content.Id" Disabled="true">File format id:</FluentNumberField> | ||
<FluentNumberField TValue="long" @bind-Value="Content.LeftDocument.Id">Left Document Name:</FluentNumberField> | ||
<FluentTextField @bind-Value="Content.LeftDocument.Name">Left Document Name:</FluentTextField> | ||
<FluentNumberField TValue="long" @bind-Value="Content.RelationType.Id">Relation type id:</FluentNumberField> | ||
<FluentTextField @bind-Value="Content.RelationType.Name">Relation Type Name:</FluentTextField> | ||
<FluentNumberField TValue="long" @bind-Value="Content.RightDocument.Id">Right Document Name:</FluentNumberField> | ||
<FluentTextField @bind-Value="Content.RightDocument.Name">Right Document Name:</FluentTextField> | ||
</FluentDialogBody> |
18 changes: 18 additions & 0 deletions
18
UIWasm/Components/Modules/Documents/RelationGrid/EGAddRelationDialog.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#region | ||
|
||
using EncyclopediaGalactica.BusinessLogic.Contracts; | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.FluentUI.AspNetCore.Components; | ||
|
||
#endregion | ||
|
||
namespace UIWasm.Components.Modules.Documents.RelationGrid; | ||
|
||
public partial class EGAddRelationDialog | ||
{ | ||
[CascadingParameter] | ||
public FluentDialog? FluentDialog { get; set; } | ||
|
||
[Parameter] | ||
public RelationResult Content { get; set; } | ||
} |
15 changes: 15 additions & 0 deletions
15
UIWasm/Components/Modules/Documents/RelationGrid/EGDeleteRelationDialog.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
@implements IDialogContentComponent<EncyclopediaGalactica.BusinessLogic.Contracts.RelationResult> | ||
|
||
<FluentDialogHeader ShowDismiss="true">Delete Relation</FluentDialogHeader> | ||
<FluentDialogBody> | ||
<FluentNumberField TValue="long" @bind-Value="Content.Id" Disabled="true">File format id:</FluentNumberField> | ||
<FluentNumberField TValue="long" @bind-Value="Content.LeftDocument.Id" Disabled="true">Left Document Name: | ||
</FluentNumberField> | ||
<FluentTextField @bind-Value="Content.LeftDocument.Name" Disabled="true">Left Document Name:</FluentTextField> | ||
<FluentNumberField TValue="long" @bind-Value="Content.RelationType.Id" Disabled="true">Relation type id: | ||
</FluentNumberField> | ||
<FluentTextField @bind-Value="Content.RelationType.Name" Disabled="true">Relation Type Name:</FluentTextField> | ||
<FluentNumberField TValue="long" @bind-Value="Content.RightDocument.Id" Disabled="true">Right Document Name: | ||
</FluentNumberField> | ||
<FluentTextField @bind-Value="Content.RightDocument.Name" Disabled="true">Right Document Name:</FluentTextField> | ||
</FluentDialogBody> |
18 changes: 18 additions & 0 deletions
18
UIWasm/Components/Modules/Documents/RelationGrid/EGDeleteRelationDialog.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#region | ||
|
||
using EncyclopediaGalactica.BusinessLogic.Contracts; | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.FluentUI.AspNetCore.Components; | ||
|
||
#endregion | ||
|
||
namespace UIWasm.Components.Modules.Documents.RelationGrid; | ||
|
||
public partial class EGDeleteRelationDialog | ||
{ | ||
[CascadingParameter] | ||
public FluentDialog? FluentDialog { get; set; } | ||
|
||
[Parameter] | ||
public RelationResult Content { get; set; } | ||
} |
12 changes: 12 additions & 0 deletions
12
UIWasm/Components/Modules/Documents/RelationGrid/EGEditRelationDialog.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
@implements IDialogContentComponent<EncyclopediaGalactica.BusinessLogic.Contracts.RelationResult> | ||
|
||
<FluentDialogHeader ShowDismiss="true">Edit Relation</FluentDialogHeader> | ||
<FluentDialogBody> | ||
<FluentNumberField TValue="long" @bind-Value="Content.Id" Disabled="true">File format id:</FluentNumberField> | ||
<FluentNumberField TValue="long" @bind-Value="Content.LeftDocument.Id">Left Document Name:</FluentNumberField> | ||
<FluentTextField @bind-Value="Content.LeftDocument.Name">Left Document Name:</FluentTextField> | ||
<FluentNumberField TValue="long" @bind-Value="Content.RelationType.Id">Relation type id:</FluentNumberField> | ||
<FluentTextField @bind-Value="Content.RelationType.Name">Relation Type Name:</FluentTextField> | ||
<FluentNumberField TValue="long" @bind-Value="Content.RightDocument.Id">Right Document Name:</FluentNumberField> | ||
<FluentTextField @bind-Value="Content.RightDocument.Name">Right Document Name:</FluentTextField> | ||
</FluentDialogBody> |
18 changes: 18 additions & 0 deletions
18
UIWasm/Components/Modules/Documents/RelationGrid/EGEditRelationDialog.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#region | ||
|
||
using EncyclopediaGalactica.BusinessLogic.Contracts; | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.FluentUI.AspNetCore.Components; | ||
|
||
#endregion | ||
|
||
namespace UIWasm.Components.Modules.Documents.RelationGrid; | ||
|
||
public partial class EGEditRelationDialog | ||
{ | ||
[CascadingParameter] | ||
public FluentDialog? FluentDialog { get; set; } | ||
|
||
[Parameter] | ||
public RelationResult Content { get; set; } | ||
} |
33 changes: 33 additions & 0 deletions
33
UIWasm/Components/Modules/Documents/RelationGrid/EGRelationGrid.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@using EncyclopediaGalactica.BusinessLogic.Contracts | ||
@inherits Fluxor.Blazor.Web.Components.FluxorComponent | ||
<FluentGrid Justify="JustifyContent.SpaceEvenly" Style="border: #1b6ec2; border-style: solid; border-width: 1px;"> | ||
<FluentGridItem xs="2">Relations</FluentGridItem> | ||
<FluentGridItem xs="8"></FluentGridItem> | ||
<FluentGridItem xs="2"> | ||
<FluentButton IconStart="@(new Icons.Filled.Size24.AddCircle())" | ||
OnClick="@(async () => await HandleClickOnAddAsync().ConfigureAwait(false))"> | ||
Add | ||
</FluentButton> | ||
</FluentGridItem> | ||
<FluentGridItem xs="12"> | ||
<FluentDataGrid TGridItem="RelationResult" | ||
ItemsProvider="GridItemsProvider" | ||
Virtualize="true" | ||
@ref="Grid"> | ||
<PropertyColumn Title="Id" Property="@(item => item.Id)"/> | ||
<PropertyColumn Title="Left Document Id" Property="@(item => item.LeftDocument.Id)"/> | ||
<PropertyColumn Title="Left Document Title" Property="@(item => item.LeftDocument.Name)"/> | ||
<PropertyColumn Title="Relation Type" Property="@(item => item.RelationType.Name)"/> | ||
<PropertyColumn Title="Right Document Id" Property="@(item => item.RightDocument.Id)"/> | ||
<PropertyColumn Title="Right Document Title" Property="@(item => item.RightDocument.Name)"/> | ||
<TemplateColumn Title="Actions"> | ||
<FluentButton IconEnd="@(new Icons.Regular.Size16.Edit())" | ||
OnClick="@(async e => await HandleOnClickEditAsync(e, context).ConfigureAwait(false))"> | ||
</FluentButton> | ||
<FluentButton IconEnd="@(new Icons.Regular.Size16.Delete())" | ||
OnClick="@(async e => await HandleOnClickDeleteAsync(e, context).ConfigureAwait(false))"> | ||
</FluentButton> | ||
</TemplateColumn> | ||
</FluentDataGrid> | ||
</FluentGridItem> | ||
</FluentGrid> |
107 changes: 107 additions & 0 deletions
107
UIWasm/Components/Modules/Documents/RelationGrid/EGRelationGrid.razor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#region | ||
|
||
using EncyclopediaGalactica.BusinessLogic.Contracts; | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.AspNetCore.Components.Web; | ||
using Microsoft.FluentUI.AspNetCore.Components; | ||
using UIWasm.Services; | ||
|
||
#endregion | ||
|
||
namespace UIWasm.Components.Modules.Documents.RelationGrid; | ||
|
||
public partial class EGRelationGrid | ||
{ | ||
private FluentDataGrid<RelationResult> Grid; | ||
private GridItemsProvider<RelationResult> GridItemsProvider; | ||
|
||
[Inject] | ||
private ILogger<EGRelationGrid> Logger { get; set; } | ||
|
||
[Inject] | ||
private IRelationService RelationService { get; set; } | ||
|
||
[Inject] | ||
private IDialogService DialogService { get; set; } | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
GridItemsProvider = async request => | ||
{ | ||
ICollection<RelationResult> r = await RelationService.GetAllAsync().ConfigureAwait(false); | ||
return GridItemsProviderResult.From<RelationResult>(r, r.Count); | ||
}; | ||
} | ||
|
||
private async Task HandleClickOnAddAsync() | ||
{ | ||
await DialogService.ShowDialogAsync<EGAddRelationDialog>( | ||
new RelationResult(), | ||
new DialogParameters | ||
{ | ||
Width = "600px", | ||
Height = "400px", | ||
PrimaryAction = "Save", | ||
PrimaryActionEnabled = true, | ||
OnDialogResult = DialogService.CreateDialogCallback(this, HandleAddSaveAsync), | ||
PreventScroll = true, | ||
PreventDismissOnOverlayClick = true | ||
}).ConfigureAwait(false); | ||
} | ||
|
||
private async Task HandleAddSaveAsync(DialogResult dialogResult) | ||
{ | ||
if (dialogResult is { Cancelled: false, Data: not null }) | ||
{ | ||
Logger.LogInformation("Add is saved"); | ||
} | ||
} | ||
|
||
private async Task HandleOnClickEditAsync(MouseEventArgs mouseEventArgs, RelationResult context) | ||
{ | ||
await DialogService.ShowDialogAsync<EGEditRelationDialog>( | ||
context, | ||
new DialogParameters | ||
{ | ||
Width = "600px", | ||
Height = "400px", | ||
PrimaryAction = "Delete", | ||
PrimaryActionEnabled = true, | ||
OnDialogResult = DialogService.CreateDialogCallback(this, HandleEditSaveAsync), | ||
PreventScroll = true, | ||
PreventDismissOnOverlayClick = true | ||
}).ConfigureAwait(false); | ||
} | ||
|
||
private async Task HandleEditSaveAsync(DialogResult dialogResult) | ||
{ | ||
if (dialogResult is { Cancelled: false, Data: not null }) | ||
{ | ||
Logger.LogInformation("Edit is saved"); | ||
} | ||
} | ||
|
||
private async Task HandleOnClickDeleteAsync(MouseEventArgs mouseEventArgs, RelationResult context) | ||
{ | ||
await DialogService.ShowDialogAsync<EGDeleteRelationDialog>( | ||
context, | ||
new DialogParameters | ||
{ | ||
Width = "600px", | ||
Height = "400px", | ||
PrimaryAction = "Delete", | ||
PrimaryActionEnabled = true, | ||
OnDialogResult = DialogService.CreateDialogCallback(this, HandleDeleteSaveAsync), | ||
PreventScroll = true, | ||
PreventDismissOnOverlayClick = true | ||
}).ConfigureAwait(false); | ||
} | ||
|
||
private async Task HandleDeleteSaveAsync(DialogResult dialogResult) | ||
{ | ||
if (dialogResult is { Cancelled: false, Data: not null }) | ||
{ | ||
Logger.LogInformation("Delete is saved"); | ||
} | ||
} | ||
} |
Oops, something went wrong.