initial commit
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
@using Indotalent.ConfigBackEnd.Extensions
|
||||
@using Indotalent.Features.Utilities.Todo
|
||||
@using Indotalent.Features.Utilities.Todo.Cqrs
|
||||
@using MudBlazor
|
||||
@using Indotalent.Features.Root.Shared
|
||||
@inject TodoService TodoService
|
||||
@inject IDialogService DialogService
|
||||
@inject ISnackbar Snackbar
|
||||
|
||||
<MudPaper Elevation="0" Outlined="true" Style="border-radius: 12px; border: 1px solid #E5E7EB;">
|
||||
<div style="padding: 20px 24px; border-bottom: 1px solid #E5E7EB; display: flex; justify-content: space-between; align-items: center; background-color: #ffffff;">
|
||||
<MudText Typo="Typo.button" Color="Color.Primary" Style="font-weight: 800;">Todo Items</MudText>
|
||||
@if (!ReadOnly)
|
||||
{
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" StartIcon="@Icons.Material.Filled.Add" OnClick="OnAddClick" Size="Size.Small" Style="text-transform: none; font-weight: 500; border-radius: 6px; height: 34px; background: #3B82F6; color: white;">
|
||||
Add Item
|
||||
</MudButton>
|
||||
}
|
||||
</div>
|
||||
|
||||
<MudTable Items="Items" Hover="true" Elevation="0" Dense="true" Striped="true" Class="mud-table-styled" T="TodoItemResponse">
|
||||
<HeaderContent>
|
||||
<MudTh Style="font-weight: 600; color: #6B7280; text-transform: uppercase; font-size: 0.6875rem; letter-spacing: 0.05em; background-color: #F9FAFB; border-bottom: 1px solid #E5E7EB;">Name</MudTh>
|
||||
<MudTh Style="font-weight: 600; color: #6B7280; text-transform: uppercase; font-size: 0.6875rem; letter-spacing: 0.05em; background-color: #F9FAFB; border-bottom: 1px solid #E5E7EB;">Start Time</MudTh>
|
||||
<MudTh Style="font-weight: 600; color: #6B7280; text-transform: uppercase; font-size: 0.6875rem; letter-spacing: 0.05em; background-color: #F9FAFB; border-bottom: 1px solid #E5E7EB;">Status</MudTh>
|
||||
<MudTh Style="font-weight: 600; color: #6B7280; text-transform: uppercase; font-size: 0.6875rem; letter-spacing: 0.05em; background-color: #F9FAFB; border-bottom: 1px solid #E5E7EB;">Description</MudTh>
|
||||
@if (!ReadOnly)
|
||||
{
|
||||
<MudTh Style="width: 100px; text-align: right; font-weight: 600; color: #6B7280; text-transform: uppercase; font-size: 0.6875rem; letter-spacing: 0.05em; background-color: #F9FAFB; border-bottom: 1px solid #E5E7EB;">Actions</MudTh>
|
||||
}
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Name" Style="padding-top: 0.75rem; padding-bottom: 0.75rem; color: #6B7280; font-size: 0.875rem;">@context.Name</MudTd>
|
||||
<MudTd DataLabel="Start Time" Style="padding-top: 0.75rem; padding-bottom: 0.75rem; color: #6B7280; font-size: 0.875rem;">@DateTimeExtensions.ToString(context.StartTime)</MudTd>
|
||||
<MudTd DataLabel="Status" Style="padding-top: 0.75rem; padding-bottom: 0.75rem; color: #6B7280; font-size: 0.875rem;">
|
||||
@if (context.IsCompleted)
|
||||
{
|
||||
<MudChip T="string" Color="Color.Success" Size="Size.Small" Variant="Variant.Text">COMPLETED</MudChip>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudChip T="string" Color="Color.Warning" Size="Size.Small" Variant="Variant.Text">PENDING</MudChip>
|
||||
}
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Description" Style="padding-top: 0.75rem; padding-bottom: 0.75rem; color: #6B7280; font-size: 0.875rem;">@context.Description</MudTd>
|
||||
@if (!ReadOnly)
|
||||
{
|
||||
<MudTd Style="text-align: right;">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Edit" Size="Size.Small" Color="Color.Primary" OnClick="@(() => OnEditClick(context))" />
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small" Color="Color.Error" OnClick="@(() => OnDeleteClick(context))" />
|
||||
</MudTd>
|
||||
}
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
</MudPaper>
|
||||
|
||||
|
||||
<style>
|
||||
.mud-table-styled .mud-table-row:hover { background-color: #F9FAFB !important; }
|
||||
</style>
|
||||
|
||||
@code {
|
||||
[Parameter] public string TodoId { get; set; } = string.Empty;
|
||||
[Parameter] public List<TodoItemResponse> Items { get; set; } = new();
|
||||
[Parameter] public bool ReadOnly { get; set; } = false;
|
||||
[Parameter] public EventCallback OnChanged { get; set; }
|
||||
|
||||
private async Task OnAddClick()
|
||||
{
|
||||
var parameters = new DialogParameters { ["TodoId"] = TodoId };
|
||||
var options = new DialogOptions { MaxWidth = MaxWidth.Small, FullWidth = true, CloseButton = true };
|
||||
var dialog = await DialogService.ShowAsync<_TodoItemCreateForm>("Add Todo Item", parameters, options);
|
||||
var result = await dialog.Result;
|
||||
if (result != null && !result.Canceled) await OnChanged.InvokeAsync();
|
||||
}
|
||||
|
||||
private async Task OnEditClick(TodoItemResponse item)
|
||||
{
|
||||
var parameters = new DialogParameters { ["Data"] = item };
|
||||
var options = new DialogOptions { MaxWidth = MaxWidth.Small, FullWidth = true, CloseButton = true };
|
||||
var dialog = await DialogService.ShowAsync<_TodoItemUpdateForm>("Edit Todo Item", parameters, options);
|
||||
var result = await dialog.Result;
|
||||
if (result != null && !result.Canceled) await OnChanged.InvokeAsync();
|
||||
}
|
||||
|
||||
private async Task OnDeleteClick(TodoItemResponse item)
|
||||
{
|
||||
var parameters = new DialogParameters { ["ContentText"] = $"Are you sure you want to remove {item.Name}?" };
|
||||
var dialog = await DialogService.ShowAsync<_DeleteConfirmation>("Delete Confirmation", parameters, new DialogOptions { MaxWidth = MaxWidth.ExtraSmall, FullWidth = true });
|
||||
var result = await dialog.Result;
|
||||
if (result != null && !result.Canceled)
|
||||
{
|
||||
var success = await TodoService.DeleteTodoItemAsync(item.Id!);
|
||||
if (success)
|
||||
{
|
||||
Snackbar.Add("Item removed successfully", Severity.Success);
|
||||
await OnChanged.InvokeAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user