-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add catalogue editor draft with name editing
- Loading branch information
Showing
6 changed files
with
96 additions
and
15 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/Phalanx.GodMode.NativeApp/Infrastructure/WorkspaceManager.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,10 @@ | ||
using WarHub.ArmouryModel.Concrete; | ||
using WarHub.ArmouryModel.Workspaces.BattleScribe; | ||
|
||
namespace Phalanx.GodMode.NativeApp.Infrastructure; | ||
internal class WorkspaceManager | ||
{ | ||
public XmlWorkspace? CurrentXmlWorkspace { get; set; } | ||
|
||
public WhamCompilation? CurrentCompilation { 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
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,57 @@ | ||
@page "/editor" | ||
|
||
@using Phalanx.GodMode.NativeApp.Infrastructure; | ||
@using WarHub.ArmouryModel; | ||
@using WarHub.ArmouryModel.Source; | ||
|
||
@inject WorkspaceManager Manager | ||
|
||
@if (CatalogueId is null) | ||
{ | ||
<h3>no catalogue selected</h3> | ||
} | ||
else | ||
{ | ||
var node = (CatalogueBaseNode) catalogue!.GetDeclaration()!; | ||
<h3>Catalogue Edit</h3> | ||
|
||
<h4>name: @catalogue!.Name</h4> | ||
<h5>id: @catalogue!.Id</h5> | ||
|
||
<div> | ||
<label> | ||
Name: | ||
<FluentTextField @bind-Value:get=catalogue.Name @bind-Value:set="x => Update(node, node.WithName(x))"></FluentTextField> | ||
</label> | ||
</div> | ||
} | ||
|
||
@code { | ||
|
||
[Parameter, SupplyParameterFromQuery(Name = "id")] | ||
public string? CatalogueId { get; set; } | ||
|
||
ICatalogueSymbol? catalogue; | ||
|
||
protected override void OnParametersSet() | ||
{ | ||
base.OnParametersSet(); | ||
if (CatalogueId is { } id && Manager.CurrentCompilation is { } compilation) | ||
{ | ||
catalogue = compilation.GlobalNamespace.Catalogues.Single(x => x.Id == id); | ||
} | ||
} | ||
|
||
void Update(CatalogueBaseNode oldNode, CatalogueBaseNode newNode) | ||
{ | ||
var compilation = Manager.CurrentCompilation!; | ||
var oldTree = compilation.SourceTrees.Single(x => x.GetRoot() == oldNode); | ||
var newCompilation = compilation.ReplaceSourceTree(oldTree, oldTree.WithRoot(newNode)); | ||
Manager.CurrentCompilation = newCompilation; | ||
} | ||
|
||
class CatalogueVm | ||
{ | ||
|
||
} | ||
} |
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