AdminPanel/Netina.AdminPanel.PWA/Dialogs/PageActionDialogBox.razor

130 lines
7.0 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

@inject ISnackbar Snackbar
@inject IRestWrapper RestWrapper
@inject IUserUtility UserUtility
@inject IDialogService DialogService
<MudDialog DisableSidePadding="true" class="mx-auto">
<DialogContent>
<MudContainer class="max-h-[30rem]" Style="overflow-y: scroll">
<MudStack>
<MudDivider class="-mt-3" />
<MudStack Spacing="0">
<MudText Typo="Typo.h6"><b>اطلاعات کلی</b></MudText>
<MudText Typo="Typo.caption">اطلاعات کلی روش ارسال را به دقت وارد کنید</MudText>
</MudStack>
<MudGrid>
<MudItem sm="12" md="6">
<MudTextField T="string" Label="نام" @bind-Value="@ViewModel.PageDto.Title" Variant="Variant.Outlined"></MudTextField>
</MudItem>
<MudItem sm="12" md="6">
<MudTextField T="string" Label="آدرس صفحه" @bind-Value="@ViewModel.PageDto.Slug" Variant="Variant.Outlined"></MudTextField>
</MudItem>
<MudItem sm="12" md="6">
<MudSelect T="bool" @bind-Value="@ViewModel.PageDto.Indexing" Label="ایا صفحه ایندکس شور ؟" ToStringFunc="b=>b.ToPersianString()" Variant="Variant.Outlined" AnchorOrigin="Origin.BottomCenter">
<MudSelectItem T="bool" Value="false" />
<MudSelectItem T="bool" Value="true" />
</MudSelect>
</MudItem>
</MudGrid>
<MudStack Row="true">
<MudStack Spacing="0" class="mt-3">
<MudText Typo="Typo.h6"><b>سکشن ها</b></MudText>
<MudText Typo="Typo.caption">اطلاعات سکشن ها را می توانید تغییر دهید</MudText>
</MudStack>
<MudSpacer />
<MudButton Variant="Variant.Filled"
DisableElevation="true"
StartIcon="@Icons.Material.Outlined.Add"
Color="Color.Secondary"
OnClick="@ViewModel.AddSection"
class="my-auto">افزودن سکشن</MudButton>
</MudStack>
<MudGrid>
<MudItem sm="12">
<MudDataGrid Items="@ViewModel.PageDto.Sections"
T="BasePageSection"
Elevation="0"
Outlined="true"
Bordered="true"
Striped="true"
Filterable="false"
SortMode="@SortMode.None"
Groupable="false">
<Columns>
<PropertyColumn T="BasePageSection" TProperty="string" Property="x => x.Title" Title="عنوان" />
<PropertyColumn T="BasePageSection" TProperty="string" Property="x => x.CTAText" Title="عنوان دکمه" />
<PropertyColumn T="BasePageSection" TProperty="string" Property="x => x.CTARoute" Title="ادرس دکمه" />
<PropertyColumn T="BasePageSection" TProperty="BasePageSectionType" Property="x => x.Type" Title="نوع سکشن" />
<PropertyColumn T="BasePageSection" TProperty="string" Property="x => x.Query" Title="کوئری" />
<TemplateColumn T="BasePageSection" CellClass="d-flex justify-end">
<CellTemplate>
<MudStack Row>
<MudButton DisableElevation="true"
Size="@Size.Small"
Variant="@Variant.Filled"
OnClick="()=>ViewModel.PageDto.Sections.Remove(context.Item)"
Color="@Color.Error"
StartIcon="@Icons.Material.Outlined.Delete">حذف</MudButton>
<MudButton DisableElevation="true"
Size="@Size.Small"
Variant="@Variant.Filled"
OnClick="async()=>await ViewModel.EditSection(context.Item)"
Color="@Color.Info"
StartIcon="@Icons.Material.Outlined.Edit">ویرایش</MudButton>
</MudStack>
</CellTemplate>
</TemplateColumn>
</Columns>
</MudDataGrid>
</MudItem>
</MudGrid>
</MudStack>
</MudContainer>
</DialogContent>
<DialogActions>
<MudStack Row="true" class="w-full mx-4 mb-2">
@if (ViewModel.IsEditing)
{
<BaseButtonUi class="w-64 rounded-md" IsProcessing="@ViewModel.IsProcessing"
Icon="@Icons.Material.Outlined.Check"
Variant="Variant.Filled" Color="Color.Success"
Content="ثبت ویرایش" OnClickCallback="@ViewModel.SubmitEditAsync" />
}
else
{
<BaseButtonUi class="w-64 rounded-md" IsProcessing="@ViewModel.IsProcessing"
Icon="@Icons.Material.Outlined.Check"
Variant="Variant.Filled" Color="Color.Success"
Content="تایید" OnClickCallback="@ViewModel.SubmitCreateAsync" />
}
<MudSpacer />
<MudButton Variant="Variant.Outlined" Size="Size.Large" Color="Color.Error" OnClick="@ViewModel.Cancel">بستن</MudButton>
</MudStack>
</DialogActions>
</MudDialog>
@code {
[CascadingParameter]
MudDialogInstance MudDialog { get; set; }
[Parameter]
public BasePageSDto? Page { get; set; }
public PageActionDialogBoxViewModel ViewModel { get; set; }
protected override async Task OnInitializedAsync()
{
if (Page == null)
ViewModel = new PageActionDialogBoxViewModel(Snackbar, RestWrapper, UserUtility, DialogService, MudDialog);
else
ViewModel = new PageActionDialogBoxViewModel(Snackbar, RestWrapper, UserUtility, DialogService, MudDialog, Page);
await ViewModel.InitializeAsync();
await base.OnInitializedAsync();
}
}