@using BLAIzor.Models
@using BLAIzor.Services
@inject ContentEditorService contentEditorService
@inject CacheService cache
@if (isLoading)
{
Loading content item...
}
else if (contentItem == null)
{
Content item not found.
}
else
{
}
@code {
[Parameter] public int ContentItemId { get; set; }
[Parameter] public Func OnContentUpdated { get; set; }
[Parameter] public Func OnSaved { get; set; }
[Parameter] public Func OnCancelled { get; set; }
private ContentItem? contentItem;
private bool isLoading = true;
protected override async Task OnInitializedAsync()
{
isLoading = true;
contentItem = await contentEditorService.GetContentItemByIdAsync(ContentItemId);
isLoading = false;
}
private async Task HandleSave()
{
contentItem!.LastUpdated = DateTime.UtcNow;
await contentEditorService.SaveAndSyncContentItemAsync(contentItem, contentItem.ContentGroup.SiteInfo.VectorCollectionName, false);
if (OnSaved != null)
await OnSaved.Invoke(contentItem);
}
private async Task CancelEdit()
{
if (OnCancelled != null)
await OnCancelled.Invoke();
}
private async Task OnUpdated()
{
if (OnContentUpdated != null)
await OnContentUpdated.Invoke(contentItem);
}
}