-
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: Document structure editor basics #3
feat: Document structure editor basics
- Loading branch information
Showing
20 changed files
with
502 additions
and
10 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
UIWasm/Components/Modules/Documents/DocumentStructureEditor/EGDocumentStructureEditor.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,28 @@ | ||
@using EncyclopediaGalactica.BusinessLogic.Contracts | ||
<FluentGrid> | ||
<FluentGridItem xs="12" sm="12" md="12" lg="12" xl="12" xxl="12"> | ||
<FluentCombobox TOption="DocumentResult" | ||
OptionValue="@(r => r.Id.ToString())" | ||
OptionText="@(r => r.Name)" | ||
Items="_documentResults" | ||
Label="Documents" | ||
SelectedOptionChanged="SelectDocumentAsync!"> | ||
</FluentCombobox> | ||
</FluentGridItem> | ||
<FluentGridItem xs="12" sm="12" md="12" lg="12" xl="12" xxl="12"> | ||
@if (_selectedDocument == null) | ||
{ | ||
<h4>No document is selected</h4> | ||
} | ||
else | ||
{ | ||
<h4>Document (@(_selectedDocument.Id)): @(_selectedDocument.Name)</h4> | ||
<hr/> | ||
<p>Root Document Structure id: </p> | ||
<FluentTreeView> | ||
<EGDocumentStructureTree | ||
StructureNode="_selectedDocument.DocumentStructure.StructureNode"/> | ||
</FluentTreeView> | ||
} | ||
</FluentGridItem> | ||
</FluentGrid> |
165 changes: 165 additions & 0 deletions
165
...m/Components/Modules/Documents/DocumentStructureEditor/EGDocumentStructureEditor.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,165 @@ | ||
#region | ||
|
||
using EncyclopediaGalactica.BusinessLogic.Contracts; | ||
using Microsoft.AspNetCore.Components; | ||
using UIWasm.Services; | ||
|
||
#endregion | ||
|
||
namespace UIWasm.Components.Modules.Documents.DocumentStructureEditor; | ||
|
||
public partial class EGDocumentStructureEditor | ||
{ | ||
private ICollection<DocumentResult> _documentResults = new List<DocumentResult>(); | ||
private DocumentResult? _selectedDocument; | ||
private StructureNode? _structureNode; | ||
|
||
[Inject] | ||
private IDocumentService DocumentService { get; set; } | ||
|
||
[Inject] | ||
private IDocumentStructureService DocumentStructureService { get; set; } | ||
|
||
[Inject] | ||
private ILogger<EGDocumentStructureEditor> Logger { get; set; } | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
_documentResults = await DocumentService.GetAllAsync().ConfigureAwait(false); | ||
Logger.LogInformation("documents size: {Size}", _documentResults.Count); | ||
} | ||
|
||
private async Task SelectDocumentAsync(DocumentResult selectedDocument) | ||
{ | ||
_selectedDocument = await DocumentService.GetById(selectedDocument.Id).ConfigureAwait(false); | ||
// List<StructureNode> flatNodes = MapStructureNodeResultToStructureNode(_selectedDocument.StructureNodes); | ||
_structureNode = new StructureNode | ||
{ | ||
Id = 1, | ||
DocumentId = 1, | ||
StructureNodes = new List<StructureNode> | ||
{ | ||
new StructureNode | ||
{ | ||
Id = 2, | ||
DocumentId = 1, | ||
StructureNodes = new List<StructureNode> | ||
{ | ||
new StructureNode | ||
{ | ||
Id = 21, | ||
DocumentId = 1, | ||
StructureNodes = new List<StructureNode> | ||
{ | ||
new StructureNode | ||
{ | ||
Id = 211, | ||
DocumentId = 1, | ||
StructureNodes = new List<StructureNode> | ||
{ | ||
} | ||
}, | ||
new StructureNode | ||
{ | ||
Id = 212, | ||
DocumentId = 1, | ||
StructureNodes = new List<StructureNode> | ||
{ | ||
} | ||
}, | ||
new StructureNode | ||
{ | ||
Id = 213, | ||
DocumentId = 1, | ||
StructureNodes = new List<StructureNode> | ||
{ | ||
} | ||
}, | ||
} | ||
}, | ||
new StructureNode | ||
{ | ||
Id = 3, | ||
DocumentId = 1, | ||
StructureNodes = new List<StructureNode> | ||
{ | ||
new StructureNode | ||
{ | ||
Id = 31, | ||
DocumentId = 1, | ||
StructureNodes = new List<StructureNode> | ||
{ | ||
new StructureNode | ||
{ | ||
Id = 311, | ||
DocumentId = 1, | ||
StructureNodes = new List<StructureNode> | ||
{ | ||
} | ||
}, | ||
new StructureNode | ||
{ | ||
Id = 312, | ||
DocumentId = 1, | ||
StructureNodes = new List<StructureNode> | ||
{ | ||
} | ||
}, | ||
new StructureNode | ||
{ | ||
Id = 313, | ||
DocumentId = 1, | ||
StructureNodes = new List<StructureNode> | ||
{ | ||
} | ||
}, | ||
} | ||
}, | ||
new StructureNode | ||
{ | ||
Id = 4, | ||
DocumentId = 1, | ||
StructureNodes = new List<StructureNode> | ||
{ | ||
new StructureNode | ||
{ | ||
Id = 41, | ||
DocumentId = 1, | ||
StructureNodes = new List<StructureNode> | ||
{ | ||
new StructureNode | ||
{ | ||
Id = 411, | ||
DocumentId = 1, | ||
StructureNodes = new List<StructureNode> | ||
{ | ||
} | ||
}, | ||
new StructureNode | ||
{ | ||
Id = 412, | ||
DocumentId = 1, | ||
StructureNodes = new List<StructureNode> | ||
{ | ||
} | ||
}, | ||
new StructureNode | ||
{ | ||
Id = 413, | ||
DocumentId = 1, | ||
StructureNodes = new List<StructureNode> | ||
{ | ||
} | ||
}, | ||
} | ||
}, | ||
} | ||
}, | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
UIWasm/Components/Modules/Documents/DocumentStructureEditor/EGDocumentStructureTree.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,24 @@ | ||
@using EncyclopediaGalactica.BusinessLogic.Contracts | ||
@if (StructureNode is not null) | ||
{ | ||
<FluentTreeItem Text="@StructureNode.Id.ToString()"> | ||
|
||
<FluentIcon Value="@(new Icons.Regular.Size16.ListBarTree())" Color="Color.Neutral" Slot="start"/> | ||
<FluentButton Appearance="Appearance.Neutral" | ||
OnClick="@(async e => await HandleAddStructureNodeAsync(e, StructureNode.Id).ConfigureAwait(false))"> | ||
+1 | ||
</FluentButton> | ||
<FluentButton Appearance="Appearance.Accent" | ||
OnClick="@(async e => await HandleDeleteStructureNodeAsync(e, StructureNode.Id).ConfigureAwait(false))"> | ||
Delete | ||
</FluentButton> | ||
|
||
@if (StructureNode.HasChildren && StructureNodes.Any()) | ||
{ | ||
foreach (DocumentStructureNodeResult child in StructureNodes) | ||
{ | ||
<EGDocumentStructureTree StructureNode="child"/> | ||
} | ||
} | ||
</FluentTreeItem> | ||
} |
46 changes: 46 additions & 0 deletions
46
UIWasm/Components/Modules/Documents/DocumentStructureEditor/EGDocumentStructureTree.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,46 @@ | ||
#region | ||
|
||
using EncyclopediaGalactica.BusinessLogic.Contracts; | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.AspNetCore.Components.Web; | ||
using UIWasm.Services; | ||
|
||
#endregion | ||
|
||
namespace UIWasm.Components.Modules.Documents.DocumentStructureEditor; | ||
|
||
public partial class EGDocumentStructureTree | ||
{ | ||
private ICollection<DocumentStructureNodeResult> StructureNodes = new List<DocumentStructureNodeResult>(); | ||
|
||
[Inject] | ||
private ILogger<EGDocumentStructureEditor> Logger { get; set; } | ||
|
||
[Parameter] | ||
public DocumentStructureNodeResult? StructureNode { get; set; } | ||
|
||
[Inject] | ||
private IDocumentStructureNodeService DocumentStructureNodeService { get; set; } | ||
|
||
protected override void OnInitialized() | ||
{ | ||
Logger.LogInformation("structure node id: {Id}", StructureNode.Id); | ||
Logger.LogInformation("has children: {Id}", StructureNode.HasChildren); | ||
if (StructureNode is not null && StructureNode.HasChildren) | ||
{ | ||
StructureNodes = DocumentStructureNodeService.GetChildrenOfANode(StructureNode.Id); | ||
} | ||
|
||
Logger.LogInformation("structurenodes amount: {amount}", StructureNodes.Count); | ||
} | ||
|
||
private async Task HandleAddStructureNodeAsync(MouseEventArgs mouseEventArgs, long structureNodeId) | ||
{ | ||
Logger.LogInformation("HandleAddStructureNodeAsync"); | ||
} | ||
|
||
private async Task HandleDeleteStructureNodeAsync(MouseEventArgs mouseEventArgs, long structureNodeId) | ||
{ | ||
Logger.LogInformation("HandleDeleteStructureNodeAsync"); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
UIWasm/Components/Modules/Documents/DocumentStructureEditor/StructureNode.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,9 @@ | ||
namespace UIWasm.Components.Modules.Documents.DocumentStructureEditor; | ||
|
||
public class StructureNode | ||
{ | ||
public long Id { get; set; } | ||
public long DocumentId { get; set; } | ||
public long ParentId { get; set; } | ||
public List<StructureNode> StructureNodes { get; set; } | ||
} |
4 changes: 4 additions & 0 deletions
4
...Components/Modules/Documents/DocumentStructuresGrid/EGAddDocumentStructureDialog.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
4 changes: 4 additions & 0 deletions
4
...ponents/Modules/Documents/DocumentStructuresGrid/EGDeleteDocumentStructureDialog.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
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
4 changes: 4 additions & 0 deletions
4
...omponents/Modules/Documents/DocumentStructuresGrid/EGEditDocumentStructureDialog.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
10 changes: 7 additions & 3 deletions
10
...ts/Modules/Documents/DocumentStructuresGrid/EGShowDocumentStructurePreviewDialog.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 |
---|---|---|
@@ -1,14 +1,18 @@ | ||
#region | ||
|
||
using EncyclopediaGalactica.BusinessLogic.Contracts; | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.FluentUI.AspNetCore.Components; | ||
|
||
#endregion | ||
|
||
namespace UIWasm.Components.Modules.Documents.DocumentStructuresGrid; | ||
|
||
public partial class EGShowDocumentStructurePreviewDialog | ||
{ | ||
[Parameter] | ||
public DocumentStructureResult Content { get; set; } | ||
|
||
[CascadingParameter] | ||
public FluentDialog? DialogService { get; set; } | ||
|
||
[Parameter] | ||
public DocumentStructureResult Content { get; set; } | ||
} |
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
Oops, something went wrong.