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();
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
@using Tasks.Module.Models
|
||||
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
<MudTextField @bind-Value="_name" Label="Tag Name" Required="true" Class="mb-3" />
|
||||
<MudTextField @bind-Value="_color" Label="Color (optional)" Placeholder="#FF5733" 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 Tag { get; set; } = new();
|
||||
|
||||
[Parameter]
|
||||
public bool IsUpdate { get; set; }
|
||||
|
||||
private string _name = string.Empty;
|
||||
private string? _color;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
if (IsUpdate)
|
||||
{
|
||||
if (Tag is UpdateTagDto updateDto)
|
||||
{
|
||||
_name = updateDto.Name;
|
||||
_color = updateDto.Color;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Tag is CreateTagDto createDto)
|
||||
{
|
||||
_name = createDto.Name;
|
||||
_color = createDto.Color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Submit()
|
||||
{
|
||||
if (IsUpdate)
|
||||
{
|
||||
if (Tag is UpdateTagDto updateDto)
|
||||
{
|
||||
updateDto.Name = _name;
|
||||
updateDto.Color = _color;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Tag is CreateTagDto createDto)
|
||||
{
|
||||
createDto.Name = _name;
|
||||
createDto.Color = _color;
|
||||
}
|
||||
}
|
||||
MudDialog?.Close(DialogResult.Ok(true));
|
||||
}
|
||||
|
||||
private void Cancel() => MudDialog?.Cancel();
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
@using Tasks.Module.Models
|
||||
@using Tasks.Module.Services
|
||||
@inject ICategoryService CategoryService
|
||||
@inject ITagService TagService
|
||||
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
@if (IsChild)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Class="mb-3">
|
||||
Adding sub-task to: <strong>@ParentTitle</strong>
|
||||
</MudAlert>
|
||||
}
|
||||
|
||||
<MudTextField @bind-Value="Task.Title" Label="Title" Required="true" Class="mb-3" />
|
||||
<MudTextField @bind-Value="Task.Description" Label="Description" Lines="3" Class="mb-3" />
|
||||
|
||||
<MudSelect T="string" @bind-Value="_categoryId" Label="Category" Clearable="true" Class="mb-3">
|
||||
@foreach (var cat in _flatCategories)
|
||||
{
|
||||
<MudSelectItem T="string" Value="cat.Id">
|
||||
@if (cat.Depth > 0)
|
||||
{
|
||||
@for (int i = 0; i < cat.Depth; i++)
|
||||
{
|
||||
<text> </text>
|
||||
}
|
||||
<text>└ </text>
|
||||
}
|
||||
@cat.Name
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
|
||||
<MudSelect T="int" @bind-Value="_priority" Label="Priority" Class="mb-3" Style="max-width: 200px;">
|
||||
<MudSelectItem T="int" Value="0">Low</MudSelectItem>
|
||||
<MudSelectItem T="int" Value="1">Medium</MudSelectItem>
|
||||
<MudSelectItem T="int" Value="2">High</MudSelectItem>
|
||||
</MudSelect>
|
||||
|
||||
<MudSelect T="string" @bind-Value="_selectedTagId" Label="Add Tag" Clearable="true" Class="mb-3">
|
||||
@foreach (var tag in _availableTags)
|
||||
{
|
||||
<MudSelectItem T="string" Value="tag.Id">@tag.Name</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Primary" Size="Size.Small" OnClick="AddSelectedTag" Disabled="string.IsNullOrEmpty(_selectedTagId)">Add</MudButton>
|
||||
|
||||
@if (_selectedTagIds.Count > 0)
|
||||
{
|
||||
<div class="mb-3 d-flex flex-wrap gap-1">
|
||||
@foreach (var tagId in _selectedTagIds)
|
||||
{
|
||||
var tag = _allTags.FirstOrDefault(t => t.Id == tagId);
|
||||
if (tag != null)
|
||||
{
|
||||
<MudChip T="string" Color="Color.Primary" Size="Size.Small" OnClick="() => RemoveTag(tagId)">@tag.Name</MudChip>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<MudDatePicker @bind-Date="Task.DueDate" Label="Due Date" Class="mb-3" />
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel">Cancel</MudButton>
|
||||
<MudButton Color="Color.Primary" OnClick="Submit">Save</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public CreateTodoItemDto Task { get; set; } = new();
|
||||
|
||||
[Parameter]
|
||||
public bool IsUpdate { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool IsChild { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public string? ParentTitle { get; set; }
|
||||
|
||||
[CascadingParameter]
|
||||
private IMudDialogInstance? MudDialog { get; set; }
|
||||
|
||||
private List<FlatCategory> _flatCategories = new();
|
||||
private List<TagDto> _allTags = new();
|
||||
private List<TagDto> _availableTags = new();
|
||||
private int _priority = 0;
|
||||
private string? _selectedTagId;
|
||||
private List<string> _selectedTagIds = new();
|
||||
private string? _categoryId = null;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
await LoadData();
|
||||
}
|
||||
|
||||
private async Task LoadData()
|
||||
{
|
||||
var hierarchy = await CategoryService.GetHierarchyAsync();
|
||||
_flatCategories = FlattenCategories(hierarchy);
|
||||
|
||||
_allTags = await TagService.GetAllAsync();
|
||||
_availableTags = _allTags.ToList();
|
||||
|
||||
_priority = Task.Priority;
|
||||
|
||||
if (!string.IsNullOrEmpty(Task.CategoryId) && _flatCategories.Any(c => c.Id == Task.CategoryId))
|
||||
{
|
||||
_categoryId = Task.CategoryId;
|
||||
}
|
||||
else
|
||||
{
|
||||
_categoryId = null;
|
||||
}
|
||||
|
||||
_selectedTagIds = Task.TagIds?.ToList() ?? new List<string>();
|
||||
_availableTags = _allTags.Where(t => !_selectedTagIds.Contains(t.Id)).ToList();
|
||||
}
|
||||
|
||||
private List<FlatCategory> FlattenCategories(List<CategoryDto> categories, int depth = 0)
|
||||
{
|
||||
var result = new List<FlatCategory>();
|
||||
foreach (var cat in categories)
|
||||
{
|
||||
result.Add(new FlatCategory { Id = cat.Id, Name = cat.Name, Depth = depth });
|
||||
if (cat.Children.Count > 0)
|
||||
{
|
||||
result.AddRange(FlattenCategories(cat.Children, depth + 1));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void AddSelectedTag()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_selectedTagId) && !_selectedTagIds.Contains(_selectedTagId))
|
||||
{
|
||||
_selectedTagIds.Add(_selectedTagId);
|
||||
_availableTags = _allTags.Where(t => !_selectedTagIds.Contains(t.Id)).ToList();
|
||||
_selectedTagId = null;
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveTag(string tagId)
|
||||
{
|
||||
_selectedTagIds.Remove(tagId);
|
||||
_availableTags = _allTags.Where(t => !_selectedTagIds.Contains(t.Id)).ToList();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void Submit()
|
||||
{
|
||||
Task.Priority = _priority;
|
||||
Task.CategoryId = _categoryId;
|
||||
Task.TagIds = _selectedTagIds;
|
||||
MudDialog?.Close(DialogResult.Ok(true));
|
||||
}
|
||||
|
||||
private void Cancel()
|
||||
{
|
||||
MudDialog?.Cancel();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
@using MudBlazor
|
||||
@using Tasks.Module.Models
|
||||
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
<MudStack Spacing="3">
|
||||
<MudTextField T="string"
|
||||
@bind-Value:get="_name"
|
||||
@bind-Value:set="(v) => _name = v"
|
||||
Label="View Name"
|
||||
Required="true"
|
||||
Placeholder="e.g., High Priority Tasks" />
|
||||
|
||||
<MudText Typo="Typo.subtitle2" Class="mt-4">Filter Criteria (optional)</MudText>
|
||||
<MudText Typo="Typo.caption" Color="Color.Default">Leave empty to show all tasks</MudText>
|
||||
|
||||
<MudSelect T="int?" Label="Priority" @bind-Value:get="_priority" @bind-Value:set="(v) => _priority = v" Clearable="true">
|
||||
<MudSelectItem T="int?" Value="null">Any Priority</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="0">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="w-2 h-2 bg-green-500 rounded-full"></span> Low
|
||||
</div>
|
||||
</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="1">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="w-2 h-2 bg-yellow-500 rounded-full"></span> Medium
|
||||
</div>
|
||||
</MudSelectItem>
|
||||
<MudSelectItem T="int?" Value="2">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="w-2 h-2 bg-red-500 rounded-full"></span> High
|
||||
</div>
|
||||
</MudSelectItem>
|
||||
</MudSelect>
|
||||
|
||||
<MudSelect T="bool?" Label="Status" @bind-Value:get="_isCompleted" @bind-Value:set="(v) => _isCompleted = v" Clearable="true">
|
||||
<MudSelectItem T="bool?" Value="null">Any Status</MudSelectItem>
|
||||
<MudSelectItem T="bool?" Value="false">
|
||||
<div class="flex items-center gap-2">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Pending" Size="Size.Small" Color="Color.Warning" />
|
||||
Pending
|
||||
</div>
|
||||
</MudSelectItem>
|
||||
<MudSelectItem T="bool?" Value="true">
|
||||
<div class="flex items-center gap-2">
|
||||
<MudIcon Icon="@Icons.Material.Filled.CheckCircle" Size="Size.Small" Color="Color.Success" />
|
||||
Completed
|
||||
</div>
|
||||
</MudSelectItem>
|
||||
</MudSelect>
|
||||
|
||||
<MudTextField T="string"
|
||||
@bind-Value:get="_containsText"
|
||||
@bind-Value:set="(v) => _containsText = v"
|
||||
Label="Contains Text"
|
||||
Placeholder="Filter by title or description..." />
|
||||
|
||||
<MudStack Row="true" Spacing="2">
|
||||
<MudDatePicker Label="Due Date From"
|
||||
@bind-Date:get="_dueDateFrom"
|
||||
@bind-Date:set="(v) => _dueDateFrom = v"
|
||||
Clearable="true" />
|
||||
<MudDatePicker Label="Due Date To"
|
||||
@bind-Date:get="_dueDateTo"
|
||||
@bind-Date:set="(v) => _dueDateTo = v"
|
||||
Clearable="true" />
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel">Cancel</MudButton>
|
||||
<MudButton Color="Color.Primary" OnClick="Submit" Disabled="string.IsNullOrWhiteSpace(_name)">Create View</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
[CascadingParameter]
|
||||
private IMudDialogInstance? MudDialog { get; set; }
|
||||
|
||||
private string _name = string.Empty;
|
||||
private int? _priority;
|
||||
private bool? _isCompleted;
|
||||
private string? _containsText;
|
||||
private DateTime? _dueDateFrom;
|
||||
private DateTime? _dueDateTo;
|
||||
|
||||
private void Submit()
|
||||
{
|
||||
var dto = new CreateTaskViewDto
|
||||
{
|
||||
Name = _name,
|
||||
Priority = _priority,
|
||||
IsCompleted = _isCompleted,
|
||||
ContainsText = string.IsNullOrWhiteSpace(_containsText) ? null : _containsText,
|
||||
DueDateFrom = _dueDateFrom,
|
||||
DueDateTo = _dueDateTo
|
||||
};
|
||||
MudDialog?.Close(DialogResult.Ok(dto));
|
||||
}
|
||||
|
||||
private void Cancel() => MudDialog?.Cancel();
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<MudDialog>
|
||||
<DialogContent>
|
||||
<MudTextField @bind-Value="_value" Label="@Label" Required="true" Class="mb-3" />
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel">Cancel</MudButton>
|
||||
<MudButton Color="Color.Primary" OnClick="Submit">Save</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
private string _value = string.Empty;
|
||||
|
||||
[Parameter] public string Title { get; set; } = string.Empty;
|
||||
[Parameter] public string Label { get; set; } = string.Empty;
|
||||
[Parameter] public string? Value { get; set; }
|
||||
|
||||
[CascadingParameter]
|
||||
private IMudDialogInstance? MudDialog { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_value = Value ?? string.Empty;
|
||||
}
|
||||
|
||||
private void Submit()
|
||||
{
|
||||
if (MudDialog != null && !string.IsNullOrWhiteSpace(_value))
|
||||
{
|
||||
MudDialog.Close(DialogResult.Ok(_value));
|
||||
}
|
||||
}
|
||||
|
||||
private void Cancel()
|
||||
{
|
||||
MudDialog?.Cancel();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user