-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: .NET 8 only
- Loading branch information
Showing
68 changed files
with
685 additions
and
358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using Sitko.Core.Repository; | ||
|
||
namespace Sitko.Blockly.Data.Entities; | ||
|
||
public abstract record BaseEntityRecord : EntityRecord<Guid> | ||
{ | ||
public override Guid Id { get; set; } = Guid.NewGuid(); | ||
public DateTimeOffset DateAdded { get; set; } = DateTimeOffset.UtcNow; | ||
public DateTimeOffset DateUpdated { get; set; } = DateTimeOffset.UtcNow; | ||
public object GetId() => Id; | ||
} | ||
|
||
public record Post : BaseEntityRecord | ||
{ | ||
public string Title { get; set; } = ""; | ||
public List<ContentBlock> Blocks { get; set; } = new(); | ||
public List<ContentBlock> SecondaryBlocks { get; set; } = new(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Sitko.Core.Repository" Version="11.0.0-beta.4"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Sitko.Blockly\Sitko.Blockly.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace Sitko.Blockly.Data; | ||
|
||
public record TestMetadata(Guid Id, string Type); |
11 changes: 11 additions & 0 deletions
11
apps/Sitko.Blockly.Demo.Client/Data/Repositories/PostRemoteRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using Sitko.Blockly.Data.Entities; | ||
using Sitko.Core.Repository.Remote; | ||
|
||
namespace Sitko.Blockly.Demo.Client.Data.Repositories; | ||
|
||
public class PostRemoteRepository : BaseRemoteRepository<Post, Guid> | ||
{ | ||
public PostRemoteRepository(RemoteRepositoryContext<Post, Guid> repositoryContext) : base(repositoryContext) | ||
{ | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
apps/Sitko.Blockly.Demo.Client/Layout/MainAppDrawerBar.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
@inject IJSRuntime JSRuntime | ||
<MudAppBar> | ||
<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="@((e) => ToggleDrawer())"/> | ||
My Application | ||
</MudAppBar> | ||
<MudDrawer Class="mud-drawer-fixed" Open=_isDrawerOpen> | ||
<NavMenu /> | ||
</MudDrawer> | ||
|
||
@code { | ||
private bool _isDrawerOpen = true; | ||
private bool _shouldHandleDrawerToggled = false; | ||
private IJSObjectReference? _jsModule; | ||
|
||
void ToggleDrawer() | ||
{ | ||
_isDrawerOpen = !_isDrawerOpen; | ||
_shouldHandleDrawerToggled = true; | ||
} | ||
|
||
protected override async Task OnAfterRenderAsync(bool firstRender) | ||
{ | ||
if (firstRender) | ||
{ | ||
_jsModule = await JSRuntime.InvokeAsync<IJSObjectReference>("import", "./Layout/MainAppDrawerBar.razor.js"); | ||
} | ||
if (_shouldHandleDrawerToggled) | ||
{ | ||
await _jsModule!.InvokeVoidAsync("HandleDrawerToggled", _isDrawerOpen); | ||
_shouldHandleDrawerToggled = false; | ||
} | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
apps/Sitko.Blockly.Demo.Client/Layout/MainAppDrawerBar.razor.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//MainAppDrawerBar.razor.js | ||
export function HandleDrawerToggled(isOpen) { | ||
const layoutElement = document.querySelector(".mud-layout"); | ||
if (isOpen) { | ||
layoutElement.classList.replace("mud-drawer-close-responsive-md-left", "mud-drawer-open-responsive-md-left"); | ||
console.log("Open"); | ||
} else { | ||
layoutElement.classList.replace("mud-drawer-open-responsive-md-left", "mud-drawer-close-responsive-md-left"); | ||
console.log("Close"); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
@using Sitko.Core.App | ||
<PageTitle>@PageTitle</PageTitle> | ||
<MudMainContent> | ||
<MudHidden Breakpoint="Breakpoint.SmAndDown"> | ||
@if (Extra is not null || Breadcrumbs.Count > 0) | ||
{ | ||
<MudToolBar DisableGutters="true" Class="px-4"> | ||
<MudBreadcrumbs Items="Breadcrumbs"></MudBreadcrumbs> | ||
@if (Extra is not null) | ||
{ | ||
<MudSpacer/> | ||
@Extra | ||
} | ||
</MudToolBar> | ||
} | ||
</MudHidden> | ||
@if (!string.IsNullOrEmpty(Title) || !string.IsNullOrEmpty(Description)) | ||
{ | ||
<MudContainer MaxWidth="MaxWidth.False" Class="mb-10"> | ||
@if (!string.IsNullOrEmpty(Title)) | ||
{ | ||
<MudText Typo="Typo.h3" Class="mb-2">@Title</MudText> | ||
} | ||
@if (!string.IsNullOrEmpty(Description)) | ||
{ | ||
<MudText Typo="Typo.subtitle1">@Description</MudText> | ||
} | ||
</MudContainer> | ||
} | ||
<MudContainer MaxWidth="MaxWidth.False" Class="pb-10"> | ||
@ChildContent | ||
</MudContainer> | ||
</MudMainContent> | ||
|
||
@code{ | ||
|
||
[Parameter] public RenderFragment? Extra { get; set; } | ||
|
||
[Parameter] public List<BreadcrumbItem> Breadcrumbs { get; set; } = new(); | ||
|
||
[Parameter] public string Title { get; set; } = ""; | ||
|
||
private string PageTitle | ||
{ | ||
get | ||
{ | ||
var prefix = $" {PageTitleSeparator} {ApplicationContext.Name}"; | ||
return $"{Title}{prefix}"; | ||
} | ||
} | ||
|
||
[Parameter] public string Description { get; set; } = ""; | ||
[Parameter] public string PageTitleSeparator { get; set; } = "/"; | ||
[Inject] protected IApplicationContext ApplicationContext { get; set; } = null!; | ||
|
||
[EditorRequired] [Parameter] public RenderFragment ChildContent { get; set; } = null!; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@page "/Posts/Add" | ||
@inherits BaseComponent | ||
@rendermode InteractiveAuto | ||
<PageLayout Title="@LocalizationProvider["Add Post"]"> | ||
<PostFormComponent></PostFormComponent> | ||
</PageLayout> |
5 changes: 3 additions & 2 deletions
5
apps/Sitko.Blockly.Demo/Pages/Edit.razor → ...itko.Blockly.Demo.Client/Pages/Edit.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
@page "/" | ||
@using Sitko.Blockly.Display | ||
@using Sitko.Core.Storage | ||
@using Sitko.Blockly.Data.Entities | ||
@using Sitko.Core.Repository | ||
@inherits BaseComponent | ||
<PageLayout Title="@LocalizationProvider["Posts"]"> | ||
<Extra> | ||
<MudButton Color="Color.Primary" Variant="Variant.Filled" Link="/Posts/Add">Add</MudButton> | ||
</Extra> | ||
<ChildContent> | ||
@foreach (var post in Posts) | ||
{ | ||
<MudCard> | ||
<MudCardHeader> | ||
<MudText Typo="Typo.h6">@post.Title</MudText> | ||
</MudCardHeader> | ||
<MudCardActions> | ||
<MudButton Link="@($"/Posts/{post.Id}/Edit")" Variant="Variant.Text" Color="Color.Primary">Edit</MudButton> | ||
</MudCardActions> | ||
<MudCardContent> | ||
<MudBlocksList | ||
EntityBlocks="post.Blocks" Options="@(new MudBlazorBlocklyListOptions(BlocksListMode.Preview, GetService<IStorage>(), $"Posts/{post.Id}"))"> | ||
</MudBlocksList> | ||
</MudCardContent> | ||
</MudCard> | ||
} | ||
</ChildContent> | ||
</PageLayout> | ||
|
||
@code{ | ||
|
||
protected override async Task InitializeAsync() | ||
{ | ||
await base.InitializeAsync(); | ||
var posts = await GetRequiredService<IRepository<Post, Guid>>().GetAllAsync(); | ||
Posts = posts.items; | ||
} | ||
|
||
private Post[] Posts { get; set; } = Array.Empty<Post>(); | ||
|
||
} |
23 changes: 7 additions & 16 deletions
23
apps/Sitko.Blockly.Demo/Pages/PostForm.cs → ...tko.Blockly.Demo.Client/Pages/PostForm.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.