Added Future Page

This commit is contained in:
Mia Rose Winter 2024-01-19 23:36:35 +01:00
parent daedaeda4b
commit 428b462371
Signed by: miawinter
GPG key ID: 4B6F6A83178F595E
4 changed files with 44 additions and 0 deletions

View file

@ -21,6 +21,11 @@
<li><NavLink href="review">@Localizer["Review_Label"]</NavLink></li>
</Authorized>
</AuthorizeView>
<AuthorizeView Policy="ArticleDeletePermissions">
<Authorized>
<li><NavLink href="future">@Localizer["Future_Label"]</NavLink></li>
</Authorized>
</AuthorizeView>
<AuthorizeView Policy="RoleAssignPermissions">
<Authorized>
<li><NavLink href="manage/users">@Localizer["ManageUsers_Label"]</NavLink></li>

View file

@ -0,0 +1,33 @@
@page "/future"
@using Wave.Data
@using Microsoft.EntityFrameworkCore
@using Wave.Data.Migrations.postgres
@attribute [Authorize(Policy = "ArticleDeletePermissions")]
@inject IDbContextFactory<ApplicationDbContext> ContextFactory
@inject IStringLocalizer<Future> Localizer
<div class="flex gap-x-8 gap-y-4">
@foreach (var article in Articles) {
<ArticleTile Article="article" />
}
@if(Articles.Count < 1) {
<p>@Localizer["NoArticles"]</p>
}
</div>
@code {
private List<Article> Articles { get; } = [];
protected override async Task OnInitializedAsync() {
await using var context = await ContextFactory.CreateDbContextAsync();
var now = DateTimeOffset.UtcNow;
Articles.AddRange(await
context.Set<Article>()
.Include(a => a.Author)
.Where(a => a.Status == ArticleStatus.Published && a.PublishDate > now)
.OrderByDescending(a => a.PublishDate)
.ToListAsync());
}
}

View file

@ -122,4 +122,7 @@
<data name="SignUp_Label" xml:space="preserve">
<value>Registrieren</value>
</data>
<data name="Future_Label" xml:space="preserve">
<value>In Veröffentlichung</value>
</data>
</root>

View file

@ -122,4 +122,7 @@
<data name="SignUp_Label" xml:space="preserve">
<value>Sign Up</value>
</data>
<data name="Future_Label" xml:space="preserve">
<value>Publishing</value>
</data>
</root>