SeemGen/Components/Partials/EditContentGroup.razor

121 lines
4.1 KiB
Plaintext

@using BLAIzor.Models
@if (!editCurrentGroup)
{
@* <div class="reference-button">
<div class="text-content">
<h4>Reference</h4>
<p>Create songs inspired by a<br>reference track</p>
</div>
<div class="icon-buttons">
<div class="icon-circle">+</div>
<div class="icon-circle">★</div>
</div>
</div> *@
<div class="bg-panel rounded p-3 mb-3">
<div class="row">
<div class="col-8">
<div @key="Group.Id">
<strong>
@Group.Name
</strong>
<small class="text-muted">
Group type: @Group.Type
</small>
<small class="text-muted">
Group slug: @Group.Slug
</small>
</div>
</div>
<div class="col-4">
<div class="d-flex flex-row-reverse">
@* <RadzenButton Text="Edit" Click="() => ToggleGroupEdit()"></RadzenButton>
<RadzenButton ButtonStyle=@ButtonStyle.Warning Text="Edit" Click="() => OnForceReChunkClicked(Group)"></RadzenButton> *@
<button class="btn" type="button" @onclick="() => ToggleGroupEdit()">Edit</button>
@* <button class="btn btn-warning" type="button" @onclick="() => OnForceReChunkClicked(Group)">ReChunk</button> *@
<button class="btn btn-danger" type="button" @onclick="() => DeleteGroup(Group)">Delete</button>
</div>
</div>
</div>
<ContentItemList ContentGroupId="@Group.Id" OnManageContentItemClicked="ContentItemManagedCallback"></ContentItemList>
</div>
}
else
{
<EditForm Model="@Group" OnValidSubmit="() => SaveGroup(Group)">
<div class="rounded bg-panel p-3 mb-3">
<label>
Name
<InputText class="form-control my-1" @bind-Value="Group.Name" />
</label>
<label>
Type
<InputText class="form-control my-1" @bind-Value="Group.Type" />
</label>
<div class="d-flex flex-row-reverse">
<button class="btn btn-success" type="submit">Save</button>
<button class="btn btn-secondary" type="button" @onclick="() => ToggleGroupEdit()">Cancel</button>
</div>
</div>
</EditForm>
}
@code {
[Parameter] public ContentGroup Group { get; set; }
// [Parameter] public Action<ContentGroup> OnContentGroupUpdated { get; set; }
[Parameter] public Func<ContentGroup, Task> OnContentGroupSaveClicked { get; set; }
[Parameter] public Func<ContentGroup, Task> OnContentGroupDeleteClicked { get; set; }
[Parameter] public Func<ContentGroup, Task> OnForceReChunkClicked { get; set; }
// [Parameter] public Func<Task> OnContentGroupDeselectClicked { get; set; }
[Parameter] public Func<string, int, Task> OnManageContentItemClicked { get; set; }
private bool editCurrentGroup = false;
private async Task ForceReChunk(int contenGroupId)
{
}
private void ToggleGroupEdit()
{
Console.WriteLine($"dklsajdlaéjdksléajdéal djkéa sdjklaésj dkléajdklaéjdkléa");
editCurrentGroup = !editCurrentGroup;
StateHasChanged();
}
private async Task SaveGroup(ContentGroup group)
{
if (OnContentGroupSaveClicked != null)
await OnContentGroupSaveClicked.Invoke(group);
}
private async Task DeleteGroup(ContentGroup group)
{
if (OnContentGroupDeleteClicked != null)
await OnContentGroupDeleteClicked.Invoke(group);
}
private async Task ContentItemManagedCallback(string method, int itemId)
{
if (OnManageContentItemClicked != null)
await OnManageContentItemClicked.Invoke(method, itemId);
}
private async Task ForceContentReChunkCallback(ContentGroup group)
{
if (OnForceReChunkClicked != null)
await OnForceReChunkClicked.Invoke(group);
}
}