Initial commit: Tasks.Module
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
@using Tasks.Module.Models
|
||||
@using Tasks.Module.Services
|
||||
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
<MudTextField @bind-Value="_name" Label="Category Name" Required="true" Class="mb-3" />
|
||||
<MudTextField @bind-Value="_description" Label="Description" Lines="2" Class="mb-3" />
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel">Cancel</MudButton>
|
||||
<MudButton Color="Color.Primary" OnClick="Submit" Disabled="string.IsNullOrWhiteSpace(_name)">
|
||||
@(IsUpdate ? "Update" : "Create")
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
[CascadingParameter]
|
||||
private IMudDialogInstance? MudDialog { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public object Category { get; set; } = new();
|
||||
|
||||
[Parameter]
|
||||
public bool IsUpdate { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool IsChild { get; set; }
|
||||
|
||||
private string _name = string.Empty;
|
||||
private string? _description;
|
||||
private string? _id;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
if (IsUpdate)
|
||||
{
|
||||
if (Category is UpdateCategoryDto updateDto)
|
||||
{
|
||||
_id = updateDto.Id;
|
||||
_name = updateDto.Name;
|
||||
_description = updateDto.Description;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Category is CreateCategoryDto createDto)
|
||||
{
|
||||
_name = createDto.Name;
|
||||
_description = createDto.Description;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Submit()
|
||||
{
|
||||
if (IsUpdate)
|
||||
{
|
||||
if (Category is UpdateCategoryDto updateDto)
|
||||
{
|
||||
updateDto.Name = _name;
|
||||
updateDto.Description = _description;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Category is CreateCategoryDto createDto)
|
||||
{
|
||||
createDto.Name = _name;
|
||||
createDto.Description = _description;
|
||||
}
|
||||
}
|
||||
MudDialog?.Close(DialogResult.Ok(true));
|
||||
}
|
||||
|
||||
private void Cancel() => MudDialog?.Cancel();
|
||||
}
|
||||
Reference in New Issue
Block a user