Skip to content

Commit

Permalink
fix: sort knowledge entries by order & show indicator in overview (#212)
Browse files Browse the repository at this point in the history
* fix: Fixed knowledge entry order and added order number indicator in overview

* feat: Added web preview link for knowledge base entries and groups (#208)

* feat: Added web preview link for knowledge base entries and groups

* chore(just): add recreate recipe

* refactor(backoffice): use single setting for backend URL

---------

Co-authored-by: Fenrikur <3359222+Fenrikur@users.noreply.github.com>

* fix: Fixed knowledge entry order and added order number indicator in overview

* feat(backoffice): show order as badge on card

---------

Co-authored-by: Fenrikur <3359222+Fenrikur@users.noreply.github.com>
  • Loading branch information
Metawolve and Fenrikur authored Sep 4, 2024
1 parent 849daeb commit d734e2d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 32 deletions.
1 change: 1 addition & 0 deletions src/Eurofurence.App.Backoffice/Layout/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
{
Primary = "#69a3a2",
Secondary = "#a2c5c4",
Tertiary = "#dedede",
AppbarBackground = "#005953",
}
};
Expand Down
73 changes: 41 additions & 32 deletions src/Eurofurence.App.Backoffice/Pages/KnowledgeBase.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page "/knowledgebase"
@page "/knowledgebase"
@attribute [Authorize(Policy = "RequireKnowledgeBaseEditor")]
@using Eurofurence.App.Backoffice.Services
@using Eurofurence.App.Domain.Model.Knowledge
Expand Down Expand Up @@ -45,20 +45,24 @@
{
<MudListItem @onclick="() => _selectedGroup = knowledgeGroup">
<MudCard Style="background-color: transparent">
<MudCardHeader>
<CardHeaderAvatar>
<MudIcon Icon="@("fas fa-" + knowledgeGroup.FontAwesomeIconName)"></MudIcon>
</CardHeaderAvatar>
<CardHeaderContent>
<MudText Typo="Typo.h6">@knowledgeGroup.Name</MudText>
</CardHeaderContent>
<CardHeaderActions>
<MudIconButton Icon="@Icons.Material.Filled.Edit"
@onclick="() => UpdateKnowledgeGroup(knowledgeGroup)"></MudIconButton>
<MudIconButton Icon="@Icons.Material.Filled.Delete"
@onclick="() => DeleteKnowledgeGroup(knowledgeGroup.Id)"></MudIconButton>
</CardHeaderActions>
</MudCardHeader>
<MudBadge Content="@("#" + knowledgeGroup.Order)" Origin="Origin.TopLeft" Overlap="true">
<MudCardHeader>
<CardHeaderAvatar>
<MudIcon Icon="@("fas fa-" + knowledgeGroup.FontAwesomeIconName)"></MudIcon>
</CardHeaderAvatar>
<CardHeaderContent>
<MudText Typo="Typo.h6">@knowledgeGroup.Name</MudText>
</CardHeaderContent>
<CardHeaderActions>
<MudIconButton Icon="@Icons.Material.Filled.Edit"
@onclick="() => UpdateKnowledgeGroup(knowledgeGroup)">
</MudIconButton>
<MudIconButton Icon="@Icons.Material.Filled.Delete"
@onclick="() => DeleteKnowledgeGroup(knowledgeGroup.Id)">
</MudIconButton>
</CardHeaderActions>
</MudCardHeader>
</MudBadge>
<MudCardContent>
<MudText>@knowledgeGroup.Description</MudText>
</MudCardContent>
Expand Down Expand Up @@ -94,22 +98,24 @@
@foreach (var knowledgeEntry in GetKnowledgeEntities())
{
<MudCard Class="mt-4">
<MudCardHeader>
<CardHeaderContent>
<MudText Typo="Typo.caption" HtmlTag="h5">@knowledgeEntry.KnowledgeGroup.Name</MudText>
<MudText Typo="Typo.h6">@knowledgeEntry.Title</MudText>
</CardHeaderContent>
<CardHeaderActions>
<MudIconButton Icon="@Icons.Material.Filled.OpenInNew"
Href="@GetWebPreviewUrl(["KnowledgeEntries", knowledgeEntry.Id.ToString()])"
Target="_blank">
</MudIconButton>
<MudIconButton Icon="@Icons.Material.Filled.Edit"
@onclick="() => UpdateKnowledgeEntry(knowledgeEntry)" />
<MudIconButton Icon="@Icons.Material.Filled.Delete"
@onclick="() => DeleteKnowledgeEntry(knowledgeEntry.Id)" />
</CardHeaderActions>
</MudCardHeader>
<MudBadge Content="@("#" + knowledgeEntry.Order)" Origin="Origin.TopLeft" Overlap="true">
<MudCardHeader>
<CardHeaderContent>
<MudText Typo="Typo.caption" HtmlTag="h5">@knowledgeEntry.KnowledgeGroup.Name</MudText>
<MudText Typo="Typo.h6">@knowledgeEntry.Title</MudText>
</CardHeaderContent>
<CardHeaderActions>
<MudIconButton Icon="@Icons.Material.Filled.OpenInNew"
Href="@GetWebPreviewUrl(["KnowledgeEntries", knowledgeEntry.Id.ToString()])"
Target="_blank">
</MudIconButton>
<MudIconButton Icon="@Icons.Material.Filled.Edit"
@onclick="() => UpdateKnowledgeEntry(knowledgeEntry)"/>
<MudIconButton Icon="@Icons.Material.Filled.Delete"
@onclick="() => DeleteKnowledgeEntry(knowledgeEntry.Id)"/>
</CardHeaderActions>
</MudCardHeader>
</MudBadge>
<MudCardContent>
<MarkdownRenderer Text="@knowledgeEntry.Text"></MarkdownRenderer>

Expand Down Expand Up @@ -156,7 +162,8 @@
Loading = true;
_knowledgeEntries = [];

var responses = (await KnowledgeService.GetKnowledgeEntriesAsync()).OrderBy(ke => ke.Order);
var responses = (await KnowledgeService.GetKnowledgeEntriesAsync()).OrderBy(ke => _knowledgeGroups.FirstOrDefault(kg => kg.Key == ke.KnowledgeGroupId).Value.Order).ThenBy(ke => ke.Order);

foreach (var response in responses)
{
var record = new KnowledgeEntryRecord()
Expand Down Expand Up @@ -295,6 +302,7 @@
{
Loading = true;
await LoadKnowledgeGroups();
await LoadKnowledgeEntries();
}
}

Expand All @@ -310,6 +318,7 @@
{
Loading = true;
await LoadKnowledgeGroups();
await LoadKnowledgeEntries();
}
}

Expand Down

0 comments on commit d734e2d

Please sign in to comment.