Skip to content

Commit

Permalink
fix(demo): upd demo to use correct layout and components
Browse files Browse the repository at this point in the history
Refs: BLOCKLY-T-2
  • Loading branch information
SonicGD committed Jan 18, 2022
1 parent 98371fb commit 18a02a0
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 95 deletions.
18 changes: 4 additions & 14 deletions apps/Sitko.Blockly.Demo/Pages/Add.razor
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
@page "/Posts/Add"
<PageContainer Title="Add post">
<Breadcrumb>
<Breadcrumb>
<BreadcrumbItem>Home</BreadcrumbItem>
<BreadcrumbItem>Posts</BreadcrumbItem>
<BreadcrumbItem>Add</BreadcrumbItem>
</Breadcrumb>
</Breadcrumb>
<Content>
</Content>
<ChildContent>
<PostFormComponent></PostFormComponent>
</ChildContent>
</PageContainer>
@inherits BaseComponent
<MudPageLayout Title="@LocalizationProvider["Add Post"]">
<PostFormComponent></PostFormComponent>
</MudPageLayout>
23 changes: 4 additions & 19 deletions apps/Sitko.Blockly.Demo/Pages/Edit.razor
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
@page "/Posts/{PostId:guid}/Edit"
@inherits BaseComponent
@{
var title = $"Edit post {PostId}";
}
<PageContainer Title="@title">
<Breadcrumb>
<Breadcrumb>
<BreadcrumbItem>Home</BreadcrumbItem>
<BreadcrumbItem>Posts</BreadcrumbItem>
<BreadcrumbItem>Edit</BreadcrumbItem>
</Breadcrumb>
</Breadcrumb>
<Content>
</Content>
<ExtraContent>
<Button>
<a href="/Posts/@PostId">View</a>
</Button>
</ExtraContent>
<ChildContent>
<PostFormComponent PostId="PostId"></PostFormComponent>
</ChildContent>
</PageContainer>
<MudPageLayout Title="@title">
<PostFormComponent PostId="PostId"></PostFormComponent>
</MudPageLayout>

@code {

Expand Down
55 changes: 22 additions & 33 deletions apps/Sitko.Blockly.Demo/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,29 @@
@using Sitko.Blockly.Display
@using Sitko.Core.Storage
@inherits BaseComponent
<PageContainer Title="Posts">
<Breadcrumb>
<Breadcrumb>
<BreadcrumbItem>Home</BreadcrumbItem>
<BreadcrumbItem>Posts</BreadcrumbItem>
</Breadcrumb>
</Breadcrumb>
<Content>
</Content>
<ExtraContent>
<Button>
<a href="/Posts/Add">Add</a>
</Button>
</ExtraContent>
<MudPageLayout Title="@LocalizationProvider["Posts"]">
<Extra>
<MudButton Color="Color.Primary" Variant="Variant.Filled" Link="/Posts/Add">Add</MudButton>
</Extra>
<ChildContent>
@foreach (Post post in Posts)
{
<Card Title="@post.Title">
<Extra>
<a href="/Posts/@post.Id/Edit">
<Button>Edit</Button>
</a>
</Extra>
<ChildContent>
<MudBlocksList
EntityBlocks="post.Blocks" Options="@(new MudBlazorBlocklyListOptions(BlocksListMode.Preview, GetService<IStorage<BlocklyStorageOptions>>(), $"Posts/{post.Id}"))">
</MudBlocksList>
</ChildContent>
</Card>
}

@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<BlocklyStorageOptions>>(), $"Posts/{post.Id}"))">
</MudBlocksList>
</MudCardContent>
</MudCard>
}
</ChildContent>
</PageContainer>

</MudPageLayout>

@code{

Expand All @@ -48,6 +37,6 @@
Posts = posts.items;
}

private Post[] Posts { get; set; } = new Post[0];
private Post[] Posts { get; set; } = Array.Empty<Post>();

}
2 changes: 1 addition & 1 deletion apps/Sitko.Blockly.Demo/Pages/PostFormComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@inherits BaseComponent
<PostForm EntityId="PostId" OnAfterCreate="post => GoToPost(post)">
<MudItem>
<MudTextField Label="Title" @bind-Value="context.Entity.Title"/>
<MudTextField Label="Title" @bind-Value="context.Entity.Title" For="() => context.Entity.Title"/>
</MudItem>
<MudBlocklyForm Label="Blocks" @bind-Value="context.Entity.Blocks" Options="blocksOptions"></MudBlocklyForm>
<MudBlocklyForm Label="Secondary blocks" @bind-Value="context.Entity.SecondaryBlocks" Options="secondaryBlocksOptions"></MudBlocklyForm>
Expand Down
30 changes: 8 additions & 22 deletions apps/Sitko.Blockly.Demo/Pages/Show.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,11 @@
@using Sitko.Core.Storage
@using Sitko.Blockly.Display
@inherits BaseComponent
@if (Post is not null)
{
var title = Post.Title;
<PageContainer Title="@title">
<Breadcrumb>
<Breadcrumb>
<BreadcrumbItem>Home</BreadcrumbItem>
<BreadcrumbItem>Posts</BreadcrumbItem>
</Breadcrumb>
</Breadcrumb>
<ExtraContent>
<Button>
<a href="/Posts/@Post.Id/Edit/">Edit</a>
</Button>
</ExtraContent>
<Content>
</Content>
<ChildContent>
<MudBlocksList EntityBlocks="Post.Blocks" Options="@(new MudBlazorBlocklyListOptions(BlocksListMode.Full, GetService<IStorage<BlocklyStorageOptions>>()))"></MudBlocksList>
</ChildContent>
</PageContainer>
}
<MudPageLayout Title="@Post.Title">
<Extra>
<MudButton Color="Color.Primary" Variant="Variant.Filled" Link="@($"/Posts/{Post.Id}/Edit/")">Edit</MudButton>
</Extra>
<ChildContent>
<MudBlocksList EntityBlocks="Post.Blocks" Options="@(new MudBlazorBlocklyListOptions(BlocksListMode.Full, GetService<IStorage<BlocklyStorageOptions>>()))"></MudBlocksList>
</ChildContent>
</MudPageLayout>
7 changes: 1 addition & 6 deletions apps/Sitko.Blockly.Demo/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
@inherits LayoutComponentBase

<BasicMudLayout>
<Menu>
<MudNavMenu>
<MudNavLink Href="/" Match="NavLinkMatch.All" Icon="@Icons.Material.Outlined.Dashboard">Posts</MudNavLink>
</MudNavMenu>
<NavMenu/>
</Menu>
<ChildContent>
@Body
</ChildContent>
Sitko.ru <MudIcon Icon="@Icons.Filled.Copyright"/> @DateTimeOffset.UtcNow.Year
</BasicMudLayout>

6 changes: 6 additions & 0 deletions apps/Sitko.Blockly.Demo/Shared/NavMenu.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<MudDivider Class="mb-4" />
<MudNavMenu>
<MudNavLink Href="/" Match="NavLinkMatch.All" Icon="@Icons.Material.Outlined.Dashboard">Posts</MudNavLink>
</MudNavMenu>
<MudSpacer></MudSpacer>
<MudText Class="px-5 py-4" Color="Color.Default" Typo="Typo.subtitle2">&copy; @DateTimeOffset.Now.Year Sitko.ru</MudText>
1 change: 1 addition & 0 deletions apps/Sitko.Blockly.Demo/_Imports.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
@using Sitko.Blockly.MudBlazorComponents.Forms
@using Sitko.Blockly.MudBlazorComponents.Display
@using Sitko.Core.Blazor.Components
@using Sitko.Core.Blazor.MudBlazorComponents
@using MudBlazor

0 comments on commit 18a02a0

Please sign in to comment.