Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
capdiem committed Mar 8, 2024
1 parent d2edf23 commit 17a1e1f
Show file tree
Hide file tree
Showing 22 changed files with 664 additions and 387 deletions.
23 changes: 20 additions & 3 deletions Masa.Blazor.Pro.Components/Data/ProDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public async Task UpdateTaskAsync(TodoTask task)
await InitAsync();
await Database.UpdateAsync(task);
}

public async Task DeleteTaskAsync(TodoTask task)
{
await InitAsync();
await Database.DeleteAsync(task);
}

public async Task<List<TodoTask>> GetTasksAsync(
int page,
Expand All @@ -76,9 +82,8 @@ public async Task<List<TodoTask>> GetTasksAsync(
{
hasWhere = true;

var tick = dateTime.Ticks;
var nextDay = tick + TimeSpan.TicksPerDay;
sqlBuilder.Append(" WHERE [DueAt] >= ").Append(tick).Append(" AND [DueAt] < ").Append(nextDay);
var tick = dateTime.AddDays(1).Ticks;
sqlBuilder.Append(" WHERE [DueAt] < ").Append(tick);
}

if (tag != 0)
Expand Down Expand Up @@ -116,6 +121,18 @@ public async Task<List<TodoTag>> GetTagsAsync()

return await Database.Table<TodoTag>().ToListAsync();
}

public async Task UpdateTagAsync(TodoTag tag)
{
await InitAsync();
await Database.UpdateAsync(tag);
}

public async Task DeleteTagAsync(TodoTag tag)
{
await InitAsync();
await Database.DeleteAsync(tag);
}

#endregion
}
7 changes: 6 additions & 1 deletion Masa.Blazor.Pro.Components/Models/TodoTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ public int[] TagIds
}
}

public string? Tags { get; private set; }
public string? Tags { get; set; }

public object ShallowCopy()
{
return this.MemberwiseClone();
}
}

public enum TodoTaskPriority
Expand Down
42 changes: 33 additions & 9 deletions Masa.Blazor.Pro.Components/RenderFragments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,46 @@ public static RenderFragment GenTagItem(TodoTag tag) => builder =>
{
builder.OpenComponent(0, typeof(MListItemIcon));
builder.AddAttribute(1, "Class", "mr-4");
builder.AddAttribute(2, "ChildContent", (RenderFragment)(sub =>
builder.AddAttribute(2, "ChildContent", (RenderFragment)(sb =>
{
sub.OpenComponent(0, typeof(MIcon));
sub.AddAttribute(1, "Icon", (Icon)"mdi-circle");
sub.AddAttribute(2, "Color", tag.Color);
sub.CloseComponent();
sb.OpenComponent(0, typeof(MIcon));
sb.AddAttribute(1, "Icon", (Icon)"mdi-circle");
sb.AddAttribute(2, "Color", tag.Color);
sb.CloseComponent();
}));
builder.CloseComponent();

builder.OpenComponent<MListItemContent>(3);
builder.AddAttribute(4, "ChildContent", (RenderFragment)(sub =>
builder.AddAttribute(4, "ChildContent", (RenderFragment)(sb =>
{
sub.OpenComponent<MListItemTitle>(0);
sub.AddAttribute(1, "ChildContent", (RenderFragment)(c => c.AddContent(0, tag.Name)));
sub.CloseComponent();
sb.OpenComponent<MListItemTitle>(0);
sb.AddAttribute(1, "ChildContent", (RenderFragment)(c => c.AddContent(0, tag.Name)));
sb.CloseComponent();
}));
builder.CloseComponent();
};

public static RenderFragment GenTagChips(
IEnumerable<TodoTag> allTags,
int[] shownTagIds,
bool small = false,
bool xSmall = false) => builder =>
{
foreach (var tag in allTags)
{
if (!shownTagIds.Contains(tag.Id)) continue;

builder.OpenRegion(tag.GetHashCode());
builder.OpenComponent(0, typeof(MChip));
builder.AddAttribute(1, "Color", tag.Color);
builder.AddAttribute(2, "Dark", true);
builder.AddAttribute(3, "Small", small);
builder.AddAttribute(4, "XSmall", xSmall);
builder.AddAttribute(5, "Label", true);
builder.AddAttribute(6, "Class", "mr-1");
builder.AddAttribute(7, "ChildContent", (RenderFragment)(sb => { sb.AddContent(0, tag.Name); }));
builder.CloseComponent();
builder.CloseRegion();
}
};
}
4 changes: 2 additions & 2 deletions Masa.Blazor.Pro.Components/Todo/TodoNav.razor
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<MList Routable>
@foreach (var item in _categories)
{
<MListItem ActiveClass="primary" Href="@item.Href" Exact>
<MListItem ActiveClass="primary--text" Href="@item.Href" Exact>
<ItemContent>
<MListItemIcon Class="mr-4">
<MIcon>@item.IconOrColor</MIcon>
Expand All @@ -30,7 +30,7 @@

@foreach (var item in Tags)
{
<MListItem ActiveClass="primary" Href="@($"/todo/tag/{item.Id}")" Exact>
<MListItem Dense ActiveClass="primary--text" Href="@($"/todo/tag/{item.Id}")" Exact>
@RenderFragments.GenTagItem(item)
</MListItem>
}
Expand Down
5 changes: 5 additions & 0 deletions Masa.Blazor.ProApp.Rcl/Pages/Settings.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@page "/settings"

<PageTitle>Settings</PageTitle>

<h1>Settings</h1>
Loading

0 comments on commit 17a1e1f

Please sign in to comment.