Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version may change things that need attention when updating, and these notes say
### For curators

- The page of an item shows its **earlier texts**: when the title, description, date, credit, original location or reference
number was changed, by whom, and what it said before. A curator can put an earlier text back with one button; the text it
number was changed, by whom, and what it said before, shown beside what the field says now. A curator can put an earlier text back with one button; the text it
replaces is kept in turn. Texts from before this version have no history, and the history is not part of the export.
- AVIF and GIF photos can be uploaded, also through contribution links and as the logo. A GIF becomes one still picture:
the first frame. The original file is kept as it was sent.
Expand Down
2 changes: 1 addition & 1 deletion docs/curator-handbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ For the people who look after what an archive holds. You need no technical knowl
exists under a slightly different name.

**Going back to an earlier text.** Under the form, "Earlier texts" lists each change to the title, description, date, credit,
original location and reference number: when, by whom, and what it said before ("Show the text before this change"). "Restore
original location and reference number: when, by whom, and what it said before ("Compare with the text now" shows it beside what the field says today). "Restore
this text" puts it back, and the text it replaces is kept in turn, so you can change your mind. A helper can read the list
but not restore. Nothing is listed for changes made before this version.

Expand Down
2 changes: 1 addition & 1 deletion docs/handbuch-kuratoren.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Für alle, die sich um den Bestand eines Archivs kümmern. Technische Kenntnisse
es schon unter einem ähnlichen Namen existiert.

**Zu einem früheren Text zurückkehren.** Unter dem Formular listet „Frühere Texte“ jede Änderung an Titel, Beschreibung, Datierung,
Nennung, ursprünglichem Ort und Referenznummer: wann, von wem und was vorher dastand („Den Text vor dieser Änderung zeigen“). „Diesen
Nennung, ursprünglichem Ort und Referenznummer: wann, von wem und was vorher dastand („Mit dem heutigen Text vergleichen“ zeigt es neben dem heutigen Stand). „Diesen
Text wiederherstellen“ setzt ihn zurück, und der ersetzte Text bleibt seinerseits erhalten, Sie können es sich also anders überlegen.
Helfer können die Liste lesen, aber nichts wiederherstellen. Für Änderungen vor dieser Version steht nichts in der Liste.

Expand Down
2 changes: 1 addition & 1 deletion docs/roadmap.md
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ shows the years of its published items. M19 is complete.
- *Built (part 1):* `ItemRevisions` holds one row per changed field (title, description, date, credit, original location,
reference number) with the text before, the account's name at the time and when; written by `AuditLog.RecordRevision` in the
save of the change. "Restore this text" (curators) puts it back and keeps the replaced text. The item's admin page lists
them. Left out of the export, with a test. Not yet: tags, a side-by-side comparison, a history page across items.
them. Left out of the export, with a test. *Part 2:* each earlier text is shown beside what the field says now. Not yet: tags, a history page across items.
- A revision holds the changed fields only, written in the same save as the activity log. A curator can restore one. No
contributor details in revisions, and the personal-data tools reach them. The export leaves them out, with the reason.

Expand Down
14 changes: 12 additions & 2 deletions src/Commonage.Web/Pages/Admin/Items/Edit.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,18 @@
})
· @(revision.UserName ?? T["Unknown"].Value)
<details>
<summary>@T["Show the text before this change"]</summary>
<p class="text-preserve-lines text-break mb-2">@(string.IsNullOrEmpty(revision.OldValue) ? T["Empty"].Value : revision.OldValue)</p>
<summary>@T["Compare with the text now"]</summary>
<div class="row g-2 mb-2">
<div class="col-md-6">
<h3 class="h6 mb-1">@T["Before this change"]</h3>
<p class="text-preserve-lines text-break border rounded p-2 mb-0">@(string.IsNullOrEmpty(revision.OldValue) ? T["Empty"].Value : revision.OldValue)</p>
</div>
<div class="col-md-6">
<h3 class="h6 mb-1">@T["Now"]</h3>
@{ var now = Model.CurrentTexts.GetValueOrDefault(revision.Field); }
<p class="text-preserve-lines text-break border rounded p-2 mb-0">@(string.IsNullOrEmpty(now) ? T["Empty"].Value : now)</p>
</div>
</div>
</details>
@if (mayManage)
{
Expand Down
5 changes: 4 additions & 1 deletion src/Commonage.Web/Pages/Admin/Items/Edit.cshtml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public class EditModel(
public IReadOnlyList<AuditEntry> History { get; private set; } = [];
public IReadOnlyList<ItemRevision> Revisions { get; private set; } = [];

/// <summary>What the revised fields say now, to show beside an earlier text.</summary>
public IReadOnlyDictionary<RevisionField, string?> CurrentTexts { get; private set; } = new Dictionary<RevisionField, string?>();

/// <summary>When the disk is nearly full, curators are told so instead of being offered the upload form.</summary>
public bool CanUpload => health.CanAcceptUploads();

Expand Down Expand Up @@ -596,7 +599,6 @@ public async Task<IActionResult> OnPostDeleteAsync(int id, CancellationToken can
return RedirectToPage("/Admin/Index");
}

/// <summary>Hides a contribution for good because the contributor withdrew their consent.</summary>
/// <summary>Puts a field back to what it said before a change. The text it has now is kept as a revision in turn.</summary>
public async Task<IActionResult> OnPostRestoreTextAsync(int id, long revisionId, CancellationToken cancellationToken)
{
Expand Down Expand Up @@ -738,6 +740,7 @@ private async Task ShowStateAsync(ArchiveItem? item)
OpenNotes = await db.VisitorNotes.CountAsync(n => n.ArchiveItemId == item.Id && n.HandledAt == null);
MediaFiles = await db.MediaFiles.Where(f => f.ArchiveItemId == item.Id).OrderBy(f => f.Position).ThenBy(f => f.Id).ToListAsync();
IdenticalFiles = await FindIdenticalFilesAsync(MediaFiles);
CurrentTexts = Enum.GetValues<RevisionField>().ToDictionary(f => f, f => RevisionFields.Get(item, f));
Revisions = await db.ItemRevisions
.Where(r => r.ArchiveItemId == item.Id)
.OrderByDescending(r => r.At).ThenByDescending(r => r.Id)
Expand Down
4 changes: 3 additions & 1 deletion src/Commonage.Web/Resources/SharedResource.de.resx
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,9 @@
<data name="Left out, because a recording has no transcript yet: {0}." xml:space="preserve"><value>Ausgelassen, weil eine Aufnahme noch keine Abschrift hat: {0}.</value></data>
<data name="Restored an earlier text of the item" xml:space="preserve"><value>Einen früheren Text des Eintrags wiederhergestellt</value></data>
<data name="Earlier texts" xml:space="preserve"><value>Frühere Texte</value></data>
<data name="Show the text before this change" xml:space="preserve"><value>Den Text vor dieser Änderung zeigen</value></data>
<data name="Compare with the text now" xml:space="preserve"><value>Mit dem heutigen Text vergleichen</value></data>
<data name="Before this change" xml:space="preserve"><value>Vor dieser Änderung</value></data>
<data name="Now" xml:space="preserve"><value>Jetzt</value></data>
<data name="Empty" xml:space="preserve"><value>Leer</value></data>
<data name="Restore this text" xml:space="preserve"><value>Diesen Text wiederherstellen</value></data>
<data name="The earlier text is back." xml:space="preserve"><value>Der frühere Text ist wieder da.</value></data>
Expand Down
4 changes: 3 additions & 1 deletion src/Commonage.Web/Resources/SharedResource.resx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
<data name="Back to the item" xml:space="preserve"><value>Back to the item</value></data>
<data name="Backup" xml:space="preserve"><value>Backup</value></data>
<data name="Backups and keys" xml:space="preserve"><value>Backups and keys</value></data>
<data name="Before this change" xml:space="preserve"><value>Before this change</value></data>
<data name="Best match" xml:space="preserve"><value>Best match</value></data>
<data name="Bin" xml:space="preserve"><value>Bin</value></data>
<data name="Browse by tag" xml:space="preserve"><value>Browse by tag</value></data>
Expand Down Expand Up @@ -137,6 +138,7 @@
<data name="Columns that are not imported: {0}" xml:space="preserve"><value>Columns that are not imported: {0}</value></data>
<data name="Columns that are not in this list, such as id or status, are not imported. A cell that starts with an apostrophe before =, +, - or @ is read without it, as exports write them." xml:space="preserve"><value>Columns that are not in this list, such as id or status, are not imported. A cell that starts with an apostrophe before =, +, - or @ is read without it, as exports write them.</value></data>
<data name="Commonage archive export" xml:space="preserve"><value>Commonage archive export</value></data>
<data name="Compare with the text now" xml:space="preserve"><value>Compare with the text now</value></data>
<data name="Consent" xml:space="preserve"><value>Consent</value></data>
<data name="Contact" xml:space="preserve"><value>Contact</value></data>
<data name="Contact the archive" xml:space="preserve"><value>Contact the archive</value></data>
Expand Down Expand Up @@ -462,6 +464,7 @@
<data name="Nothing has been recorded yet." xml:space="preserve"><value>Nothing has been recorded yet.</value></data>
<data name="Nothing is waiting for help right now. Thank you for looking." xml:space="preserve"><value>Nothing is waiting for help right now. Thank you for looking.</value></data>
<data name="Nothing matches your search. Try fewer words or remove a filter." xml:space="preserve"><value>Nothing matches your search. Try fewer words or remove a filter.</value></data>
<data name="Now" xml:space="preserve"><value>Now</value></data>
<data name="Of which originals: {0} in {1, plural, one {# file} other {# files}}. The rest are the picture sizes made from them." xml:space="preserve"><value>Of which originals: {0} in {1, plural, one {# file} other {# files}}. The rest are the picture sizes made from them.</value><comment>Has a count. Write a form for each one your language needs, in ICU MessageFormat.</comment></data>
<data name="Oldest first" xml:space="preserve"><value>Oldest first</value></data>
<data name="On each contribution you can remove their name and email address, mark it as withdrawn, or move the item to the bin and delete it there for good. Backups keep older copies until they are replaced." xml:space="preserve"><value>On each contribution you can remove their name and email address, mark it as withdrawn, or move the item to the bin and delete it there for good. Backups keep older copies until they are replaced.</value></data>
Expand Down Expand Up @@ -657,7 +660,6 @@
<data name="Show all tags" xml:space="preserve"><value>Show all tags</value></data>
<data name="Show everything" xml:space="preserve"><value>Show everything</value></data>
<data name="Show my name with what I send in" xml:space="preserve"><value>Show my name with what I send in</value></data>
<data name="Show the text before this change" xml:space="preserve"><value>Show the text before this change</value></data>
<data name="Showing the newest {0}." xml:space="preserve"><value>Showing the newest {0}.</value></data>
<data name="Shown to admins on this page and in the list of accounts. Never to visitors." xml:space="preserve"><value>Shown to admins on this page and in the list of accounts. Never to visitors.</value></data>
<data name="Six digits. Without your phone, type one of your recovery codes instead. Each one works once." xml:space="preserve"><value>Six digits. Without your phone, type one of your recovery codes instead. Each one works once.</value></data>
Expand Down
6 changes: 5 additions & 1 deletion tests/Commonage.Tests/RevisionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ public async Task Changing_a_text_keeps_the_earlier_one_and_who_changed_it_and_a
Assert.Equal(RevisionField.Description, revision.Field);
Assert.Equal("The first text", revision.OldValue);
Assert.Equal(CommonageAppFactory.AdminEmail, revision.UserName);
Assert.Contains("The first text", await curator.GetStringAsync($"/Admin/Items/Edit/{item.Id}"));
var page = await curator.GetStringAsync($"/Admin/Items/Edit/{item.Id}");
// The earlier text is shown beside what the field says now, so a curator sees what a restore would change.
var section = page[page.IndexOf("id=\"revisions-heading\"", StringComparison.Ordinal)..];
Assert.Contains("The first text", section);
Assert.Contains("The second text", section);

await Browser.PostFormAsync(curator, $"/Admin/Items/Edit/{item.Id}?handler=RestoreText&revisionId={revision.Id}", new(), $"/Admin/Items/Edit/{item.Id}");

Expand Down