109 lines
3.8 KiB
Plaintext
109 lines
3.8 KiB
Plaintext
@page "/"
|
|
@using Drab.LocalDb
|
|
@using Drab.LocalDb.Entities
|
|
@using Drab.Logic.Services
|
|
@using Drab.Ui.components
|
|
@using Radzen
|
|
@inject LocalDbContext LocalDbContext
|
|
@inject DialogService DialogService
|
|
@inject OrderEventBus EventBus
|
|
|
|
@implements IDisposable
|
|
|
|
<RadzenDataGrid Data="@_orders"
|
|
TItem="OrderDb"
|
|
@ref="_dataGridRef"
|
|
AllowFiltering="true"
|
|
AllowColumnResize="false"
|
|
AllowAlternatingRows="false"
|
|
AllowColumnReorder="false"
|
|
Density="Density.Default"
|
|
FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive"
|
|
AllowSorting="true"
|
|
PageSize="20"
|
|
AllowPaging="true"
|
|
GridLines="DataGridGridLines.Both"
|
|
PagerHorizontalAlign="HorizontalAlign.Center"
|
|
ShowPagingSummary="true"
|
|
LogicalFilterOperator="LogicalFilterOperator.Or"
|
|
SelectionMode="DataGridSelectionMode.Single"
|
|
RowClick="@(RowClick)">
|
|
<Columns>
|
|
<RadzenDataGridColumn Property="@nameof(OrderDb.Shop)"
|
|
Filterable="true"
|
|
Title="Sklep"
|
|
Width="200px"
|
|
FilterMode="FilterMode.CheckBoxList"/>
|
|
<RadzenDataGridColumn Property="@nameof(OrderDb.Created)"
|
|
Title="Data"
|
|
Filterable="false"
|
|
SortOrder="SortOrder.Descending"
|
|
TextAlign="TextAlign.Center"
|
|
Width="160px"/>
|
|
<RadzenDataGridColumn Property="@nameof(OrderDb.IsPrinted)"
|
|
Title="Wydrukowane"
|
|
FilterMode="FilterMode.CheckBoxList"
|
|
TextAlign="TextAlign.Center"
|
|
Width="100px">
|
|
<Template Context="order">
|
|
@if (order.IsPrinted)
|
|
{
|
|
<RadzenIcon IconStyle="IconStyle.Success" Icon="check_circle"/>
|
|
}
|
|
else
|
|
{
|
|
<RadzenIcon IconStyle="IconStyle.Danger" Icon="highlight_off"/>
|
|
}
|
|
</Template>
|
|
</RadzenDataGridColumn>
|
|
<RadzenDataGridColumn Property="@nameof(OrderDb.OrderNumber)"
|
|
FilterMode="FilterMode.CheckBoxList"
|
|
Title="Numer"
|
|
Width="150px"/>
|
|
</Columns>
|
|
</RadzenDataGrid>
|
|
|
|
@code {
|
|
IQueryable<OrderDb> _orders;
|
|
private RadzenDataGrid<OrderDb>? _dataGridRef;
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
EventBus.OrdersChanged += OnOrdersChanged;
|
|
_orders = LocalDbContext.Orders;
|
|
}
|
|
|
|
private async Task RowClick(DataGridRowMouseEventArgs<OrderDb> obj)
|
|
{
|
|
await DialogService.OpenAsync<PdfViewer>($"Zamówienie {obj.Data.OrderNumber} - Sklep {obj.Data.Shop}",
|
|
new Dictionary<string, object>() {{nameof(PdfViewer.Filename), obj.Data.Filename}},
|
|
new DialogOptions()
|
|
{
|
|
CloseDialogOnEsc = true,
|
|
CloseDialogOnOverlayClick = true,
|
|
Resizable = false,
|
|
Draggable = false,
|
|
Width = "80%",
|
|
Height = "90vh"
|
|
});
|
|
}
|
|
|
|
private void OnOrdersChanged()
|
|
{
|
|
InvokeAsync(() =>
|
|
{
|
|
_orders = LocalDbContext.Orders;
|
|
_dataGridRef?.Reload();
|
|
StateHasChanged();
|
|
return Task.CompletedTask;
|
|
});
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
EventBus.OrdersChanged -= OnOrdersChanged;
|
|
LocalDbContext?.Dispose();
|
|
DialogService?.Dispose();
|
|
}
|
|
|
|
} |