diff --git a/src/FluentCMS.Admin/Components/Forms/FactFields.razor b/src/FluentCMS.Admin/Components/Forms/FactFields.razor new file mode 100644 index 000000000..81ff72ec2 --- /dev/null +++ b/src/FluentCMS.Admin/Components/Forms/FactFields.razor @@ -0,0 +1,75 @@ +@using FluentCMS.Admin.Forms +@using FluentCMS.Core.Schema +@inject IStringLocalizer L + +@* The fact around an entity field's value (SCH-03): its source, owner and validity, each posted under the field's name. *@ +
+ @L["Fact details for {0}", Field] + @if (Unsourced) + { +

@L["This fact has no source, so it is flagged unsourced. Say where the value comes from."]

+ } +
+ + + + + + +
+
+ + + + + + + + + + + + +
+
+ +@code { + [Parameter, EditorRequired] public string Field { get; set; } = string.Empty; + [Parameter] public IReadOnlyDictionary Values { get; set; } = new Dictionary(); + [Parameter] public IReadOnlyDictionary Problems { get; set; } = new Dictionary(); + [Parameter] public IReadOnlyList Owners { get; set; } = []; + [Parameter] public bool Unsourced { get; set; } + + private string Name(string part) => $"Form.Facts[{FactValues.Key(Field, part)}]"; + + private string? Value(string part) => Values.GetValueOrDefault(FactValues.Key(Field, part)); + + private string? Error(string part) => Problems.GetValueOrDefault(part) switch + { + null => null, + "kind" => L["Choose a kind of source."].Value, + "source" => L["Give both the kind of source and the source, or neither."].Value, + "owner" => L["Choose an owner from the list."].Value, + _ => L["Enter a date and a time."].Value, + }; + + private string KindLabel(string kind) => kind switch + { + "url" => L["URL"], + "file" => L["File"], + "person" => L["Person"], + _ => L["System"], + }; +} diff --git a/src/FluentCMS.Admin/Components/Pages/EntriesView.razor b/src/FluentCMS.Admin/Components/Pages/EntriesView.razor index 7eb4a9864..1c28e823c 100644 --- a/src/FluentCMS.Admin/Components/Pages/EntriesView.razor +++ b/src/FluentCMS.Admin/Components/Pages/EntriesView.razor @@ -20,15 +20,8 @@ @(type.Definition.IsEntity ? L["An entity type: each field is a fact with its source, owner and validity."] : L["Entries of this content type."])

- @if (!type.Definition.IsEntity) - { - @L["New entry"] - } + @L["New entry"] - @if (type.Definition.IsEntity) - { -

@L["Entity forms, with a source, owner and validity on every fact, come with the next forms slice. Agents write entities with set_entity_fact until then."]

- } @if (_entries.Count == 0) { @@ -51,14 +44,7 @@ { - @if (type.Definition.IsEntity) - { - @entry.Id - } - else - { - @entry.Id - } + @entry.Id @StateLabel(entry.State) @entry.LatestVersion diff --git a/src/FluentCMS.Admin/Components/Pages/EntryEditor.razor b/src/FluentCMS.Admin/Components/Pages/EntryEditor.razor index bd3934527..80c089855 100644 --- a/src/FluentCMS.Admin/Components/Pages/EntryEditor.razor +++ b/src/FluentCMS.Admin/Components/Pages/EntryEditor.razor @@ -13,6 +13,7 @@ @inject IEntryDirectory Entries @inject IEntryEdits Edits @inject IMediaLibrary Media +@inject FluentCMS.Core.Identity.IUserDirectory Users @inject FieldTypeRegistry FieldTypes @inject NavigationManager Navigation @inject IStringLocalizer L @@ -31,47 +32,48 @@ @if (type.Definition.IsEntity) { -

@L["Entity forms, with a source, owner and validity on every fact, come with the next forms slice."]

+

@L["An entity type: every field is a fact with its source, owner and validity."]

} - else - { -
- - - @if (_formError is not null) - { - - } - - -

@L["Fields"]

-
- - @foreach (var field in type.Definition.Fields) + + + + @if (_formError is not null) + { + + } + + +

@L["Fields"]

+
+ + @foreach (var field in type.Definition.Fields) + { + + @if (type.Definition.IsEntity) { - + } - -
- - -

@L["Change set"]

- @L["The reviewer reads why you made the change and where it comes from."] -
- - -