114 lines
5.4 KiB
Plaintext
114 lines
5.4 KiB
Plaintext
@page "/product/brands"
|
|
@using StringExtensions = Netina.Common.Extensions.StringExtensions
|
|
|
|
@inject IDialogService DialogService
|
|
@inject NavigationManager NavigationManager
|
|
@inject IRestWrapper RestWrapper
|
|
@inject ISnackbar Snackbar
|
|
@inject IUserUtility UserUtility
|
|
@inject IConfiguration Configuration
|
|
@inject IJSRuntime JsRuntime
|
|
|
|
|
|
<MudStack class="h-full w-full p-8">
|
|
<MudGrid>
|
|
<MudItem xs="12">
|
|
<MudStack Row="true" class="mb-5">
|
|
<MudText Typo="Typo.h4">برنــــدها</MudText>
|
|
@* <MudChip Color="Color.Info" Variant="Variant.Outlined">124 عدد</MudChip> *@
|
|
|
|
<MudSpacer />
|
|
<MudButton Variant="Variant.Filled"
|
|
DisableElevation="true"
|
|
StartIcon="@Icons.Material.Outlined.Add"
|
|
Color="Color.Secondary"
|
|
OnClick="ViewModel.AddBrandClicked"
|
|
class="my-auto">افزودن برند</MudButton>
|
|
</MudStack>
|
|
<MudPaper>
|
|
<MudDataGrid Striped="true" T="BrandSDto" Items="@ViewModel.PageDto" Filterable="false" Loading="@ViewModel.IsProcessing"
|
|
CurrentPage="@ViewModel.CurrentPage"
|
|
RowsPerPage="10"
|
|
SortMode="@SortMode.None" Groupable="false">
|
|
<ToolBarContent>
|
|
<MudTextField T="string" Placeholder="جست جو بر اساس نام" Adornment="Adornment.Start" Immediate="true"
|
|
AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" class="my-auto"
|
|
ValueChanged="@ViewModel.SearchChanged"
|
|
Clearable="true"
|
|
OnAdornmentClick="@ViewModel.SearchAsync"></MudTextField>
|
|
</ToolBarContent>
|
|
<Columns>
|
|
<PropertyColumn Title="نام برند" Property="arg => arg.PersianName" />
|
|
<PropertyColumn Title="نام انگلیسی برند" Property="arg => arg.EnglishName" />
|
|
<TemplateColumn Title="صفحه اختصاصی دارد" T="BrandSDto">
|
|
<CellTemplate>
|
|
@if (@context.Item.HasSpecialPage)
|
|
{
|
|
<p>بلی</p>
|
|
}
|
|
else
|
|
{
|
|
<p>خیر</p>
|
|
|
|
}
|
|
</CellTemplate>
|
|
</TemplateColumn>
|
|
<TemplateColumn CellClass="d-flex justify-end">
|
|
<CellTemplate>
|
|
<MudStack Row="true">
|
|
|
|
<MudIconButton Icon="@Icons.Material.Filled.Link"
|
|
Size="@Size.Small"
|
|
Variant="@Variant.Outlined"
|
|
Color="@Color.Surface"
|
|
OnClick="async()=>await ShowBrand(context.Item)" />
|
|
|
|
<MudIconButton Icon="@Icons.Material.Filled.Edit"
|
|
Size="@Size.Small"
|
|
Variant="@Variant.Outlined"
|
|
Color="@Color.Info"
|
|
OnClick="async () => await ViewModel.EditBrandAsync(context.Item)"></MudIconButton>
|
|
<MudIconButton Icon="@Icons.Material.Filled.Delete"
|
|
Size="@Size.Small"
|
|
Variant="@Variant.Outlined"
|
|
OnClick="async () => await ViewModel.DeleteBrandAsync(context.Item.Id)"
|
|
Color="@Color.Error"></MudIconButton>
|
|
</MudStack>
|
|
</CellTemplate>
|
|
</TemplateColumn>
|
|
</Columns>
|
|
<PagerContent>
|
|
<MudStack Row="true" class="w-full">
|
|
|
|
<MudPagination Rectangular="true" Variant="Variant.Filled" Count="@ViewModel.PageCount"
|
|
SelectedChanged="@ViewModel.ChangePageAsync" class="mx-auto my-4" />
|
|
</MudStack>
|
|
|
|
</PagerContent>
|
|
</MudDataGrid>
|
|
</MudPaper>
|
|
</MudItem>
|
|
</MudGrid>
|
|
</MudStack>
|
|
|
|
@code
|
|
{
|
|
public BrandsPageViewModel ViewModel { get; set; }
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
ViewModel = new BrandsPageViewModel(NavigationManager, Snackbar, UserUtility, RestWrapper, DialogService);
|
|
await ViewModel.InitializeAsync();
|
|
await base.OnInitializedAsync();
|
|
}
|
|
|
|
private async Task ShowBrand(BrandSDto item)
|
|
{
|
|
var webUrl = Configuration.GetValue<string>("WebSiteUrl") ?? string.Empty;
|
|
var slug = WebUtility.UrlEncode(item.Slug.Replace(' ', '-'));
|
|
var url = $"{webUrl}/brands/{item.Id}/{slug}";
|
|
await JsRuntime.InvokeVoidAsync("open", url, "_blank");
|
|
}
|
|
|
|
}
|
|
|