Group FAQs by a topic relation, ordered; drop unused FAQ teaser
This commit is contained in:
1 parent
28944c155a
commit
2ea8856d65
14 files changed
+328
-128
No files matched your search
@@ -6,7 +6,9 @@ namespace Elternbeirat.Contracts;
|
||||
/// A single question and answer of the FAQ, as stored in PocketBase.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// On the FAQ page, entries are grouped by <see cref="Topic"/>.
|
||||
/// On the FAQ page, entries are grouped by their <see cref="Topic"/>. The topic is
|
||||
/// a PocketBase relation; <see cref="Topic"/> is the resolved topic record, present
|
||||
/// only when the query expanded the relation (see <see cref="FaqExpand"/>).
|
||||
/// </remarks>
|
||||
public record Faq
|
||||
{
|
||||
@@ -42,17 +44,39 @@ public record Faq
|
||||
public required string Answer { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the topic the question is grouped under, e.g.
|
||||
/// <c>"Mensa und Mittagessen"</c>.
|
||||
/// Gets the expanded relations returned by PocketBase, or <see langword="null"/>
|
||||
/// when the query did not expand any.
|
||||
/// </summary>
|
||||
[JsonPropertyName("expand")]
|
||||
public FaqExpand? Expand { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the resolved topic this entry is grouped under, or <see langword="null"/>
|
||||
/// when the query did not expand the topic relation.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <see langword="required"/>: the FAQ page groups entries by topic, so an entry
|
||||
/// without one has no place. The field is required in PocketBase.
|
||||
///
|
||||
/// This is the heading shown on the page verbatim, not a slug: editors add a
|
||||
/// new group by typing its heading here, no code change. Entries with the same
|
||||
/// topic text land in one group.
|
||||
/// Convenience over <see cref="Expand"/>: the FAQ page reads the grouping
|
||||
/// heading from here. It is <see langword="null"/> unless the entry was loaded
|
||||
/// with the topic relation expanded.
|
||||
/// </remarks>
|
||||
[JsonIgnore]
|
||||
public FaqTopic? Topic => Expand?.Topic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The relations of a <see cref="Faq"/> that PocketBase returns under
|
||||
/// <c>expand</c> when the query asks for them.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// One property per expandable relation, named after its PocketBase field, so the
|
||||
/// JSON <c>expand</c> object maps straight onto it. <see cref="Faq.Topic"/> reads
|
||||
/// through this.
|
||||
/// </remarks>
|
||||
public record FaqExpand
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the expanded topic of the <c>topic</c> relation, if it was expanded.
|
||||
/// </summary>
|
||||
[JsonPropertyName("topic")]
|
||||
public required string Topic { get; init; }
|
||||
public FaqTopic? Topic { get; init; }
|
||||
}
|
||||
Reference in new issue
Block a user