Skip to content

Commit

Permalink
feat: Relation Grid and dialogs #2
Browse files Browse the repository at this point in the history
feat: Relation Grid and dialogs
  • Loading branch information
Andras-Csanyi authored Apr 30, 2024
2 parents 07bd7b6 + e43c557 commit e2fdb5a
Show file tree
Hide file tree
Showing 26 changed files with 400 additions and 28 deletions.
55 changes: 55 additions & 0 deletions FrontEnd.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,4 +1,59 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/CodeCleanup/Profiles/=Acsanyi/@EntryIndexedValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&lt;Profile name="Acsanyi"&gt;&lt;GherkinReformatCode&gt;True&lt;/GherkinReformatCode&gt;&lt;XAMLCollapseEmptyTags&gt;False&lt;/XAMLCollapseEmptyTags&gt;&lt;HtmlReformatCode&gt;True&lt;/HtmlReformatCode&gt;&lt;CSReformatCode&gt;True&lt;/CSReformatCode&gt;&lt;CSharpFormatDocComments&gt;True&lt;/CSharpFormatDocComments&gt;&lt;CSOptimizeUsings&gt;&lt;OptimizeUsings&gt;True&lt;/OptimizeUsings&gt;&lt;EmbraceInRegion&gt;True&lt;/EmbraceInRegion&gt;&lt;/CSOptimizeUsings&gt;&lt;CSShortenReferences&gt;True&lt;/CSShortenReferences&gt;&lt;AspOptimizeRegisterDirectives&gt;True&lt;/AspOptimizeRegisterDirectives&gt;&lt;CSReorderTypeMembers&gt;True&lt;/CSReorderTypeMembers&gt;&lt;IDEA_SETTINGS&gt;&amp;lt;profile version="1.0"&amp;gt;
&amp;lt;option name="myName" value="Acsanyi" /&amp;gt;
&amp;lt;inspection_tool class="WrongPropertyKeyValueDelimiter" enabled="false" level="WEAK WARNING" enabled_by_default="false" /&amp;gt;
&amp;lt;/profile&amp;gt;&lt;/IDEA_SETTINGS&gt;&lt;RIDER_SETTINGS&gt;&amp;lt;profile&amp;gt;
&amp;lt;Language id="CSS"&amp;gt;
&amp;lt;Rearrange&amp;gt;true&amp;lt;/Rearrange&amp;gt;
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;
&amp;lt;/Language&amp;gt;
&amp;lt;Language id="EditorConfig"&amp;gt;
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;
&amp;lt;/Language&amp;gt;
&amp;lt;Language id="GraphQL"&amp;gt;
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;
&amp;lt;/Language&amp;gt;
&amp;lt;Language id="HTML"&amp;gt;
&amp;lt;Rearrange&amp;gt;true&amp;lt;/Rearrange&amp;gt;
&amp;lt;OptimizeImports&amp;gt;true&amp;lt;/OptimizeImports&amp;gt;
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;
&amp;lt;/Language&amp;gt;
&amp;lt;Language id="Handlebars"&amp;gt;
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;
&amp;lt;/Language&amp;gt;
&amp;lt;Language id="Ini"&amp;gt;
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;
&amp;lt;/Language&amp;gt;
&amp;lt;Language id="JSON"&amp;gt;
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;
&amp;lt;/Language&amp;gt;
&amp;lt;Language id="Markdown"&amp;gt;
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;
&amp;lt;/Language&amp;gt;
&amp;lt;Language id="Mermaid"&amp;gt;
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;
&amp;lt;/Language&amp;gt;
&amp;lt;Language id="Properties"&amp;gt;
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;
&amp;lt;/Language&amp;gt;
&amp;lt;Language id="RELAX-NG"&amp;gt;
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;
&amp;lt;/Language&amp;gt;
&amp;lt;Language id="SQL"&amp;gt;
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;
&amp;lt;/Language&amp;gt;
&amp;lt;Language id="XML"&amp;gt;
&amp;lt;Rearrange&amp;gt;true&amp;lt;/Rearrange&amp;gt;
&amp;lt;OptimizeImports&amp;gt;true&amp;lt;/OptimizeImports&amp;gt;
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;
&amp;lt;/Language&amp;gt;
&amp;lt;Language id="liquid"&amp;gt;
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;
&amp;lt;/Language&amp;gt;
&amp;lt;Language id="yaml"&amp;gt;
&amp;lt;Reformat&amp;gt;true&amp;lt;/Reformat&amp;gt;
&amp;lt;/Language&amp;gt;
&amp;lt;/profile&amp;gt;&lt;/RIDER_SETTINGS&gt;&lt;/Profile&gt;</s:String>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/MAX_ATTRIBUTE_LENGTH_FOR_SAME_LINE/@EntryValue">1</s:Int64>
<s:String x:Key="/Default/Environment/Hierarchy/NuGetOptions/ConfigRestoreAuto/@EntryValue">Enable</s:String>
<s:String x:Key="/Default/Environment/Hierarchy/NuGetOptions/ConfigRestoreEnabled/@EntryValue">Enable</s:String>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using Microsoft.AspNetCore.Components;
using Microsoft.FluentUI.AspNetCore.Components;

namespace UIWasm.Components.Modules.Documents.Application;
namespace UIWasm.Components.Modules.Documents.ApplicationGrid;

public partial class EGAddApplicationDialog
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using EncyclopediaGalactica.BusinessLogic.Contracts;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.FluentUI.AspNetCore.Components;
using UIWasm.Services;

namespace UIWasm.Components.Modules.Documents.Application;
namespace UIWasm.Components.Modules.Documents.ApplicationGrid;

public partial class EGApplicationGrid
{
Expand Down Expand Up @@ -34,7 +33,7 @@ protected override Task OnInitializedAsync()

private async Task HandleAddClick()
{
DialogService.ShowDialogAsync<EGAddApplicationDialog>(
DialogService.ShowDialogAsync<ApplicationGrid.EGAddApplicationDialog>(
new ApplicationResult(),
new DialogParameters
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using EncyclopediaGalactica.BusinessLogic.Contracts;
using Microsoft.AspNetCore.Components;
using Microsoft.FluentUI.AspNetCore.Components;
using UIWasm.Components.Modules.Documents.Application;
using UIWasm.Components.Modules.Documents.ApplicationGrid;

namespace UIWasm.Components.Modules.Documents.DocumentTypeGrid;

Expand All @@ -15,4 +15,4 @@ public partial class EGAddDocumentTypeDialog

[Parameter]
public DocumentTypeResult Content { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using EncyclopediaGalactica.BusinessLogic.Contracts;
using Microsoft.AspNetCore.Components;
using Microsoft.FluentUI.AspNetCore.Components;
using UIWasm.Components.Modules.Documents.Application;
using UIWasm.Components.Modules.Documents.ApplicationGrid;

namespace UIWasm.Components.Modules.Documents.DocumentTypeGrid;

Expand All @@ -15,4 +15,4 @@ public partial class EGDeleteDocumentTypeDialog

[Parameter]
public DocumentTypeResult Content { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using EncyclopediaGalactica.BusinessLogic.Contracts;
using Microsoft.AspNetCore.Components;
using Microsoft.FluentUI.AspNetCore.Components;
using UIWasm.Components.Modules.Documents.Application;
using UIWasm.Components.Modules.Documents.ApplicationGrid;

namespace UIWasm.Components.Modules.Documents.DocumentTypeGrid;

Expand All @@ -15,4 +15,4 @@ public partial class EGEditDocumentTypeDialog

[Parameter]
public DocumentTypeResult Content { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ else
<EGRelationTypeGrid/>
break;

case "relations":
<EGRelationGrid/>
break;

case "applications":
<EGApplicationGrid/>
break;
}
}
}
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>
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; }
}
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>
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; }
}
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>
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; }
}
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>
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");
}
}
}
Loading

0 comments on commit e2fdb5a

Please sign in to comment.