From 509813d07e733005eaf92e18e635a39bdad04e88 Mon Sep 17 00:00:00 2001 From: "Seb H." <138793908+SebHenn@users.noreply.github.com> Date: Thu, 19 Nov 2026 17:22:30 +0100 Subject: [PATCH] M26, second part: an earlier text beside the text now Co-Authored-By: Claude Sonnet 5.5 Signed-off-by: Seb H. <138793908+SebHenn@users.noreply.github.com> --- CHANGELOG.md | 2 +- docs/curator-handbook.md | 2 +- docs/handbuch-kuratoren.md | 2 +- docs/roadmap.md | 2 +- src/Commonage.Web/Pages/Admin/Items/Edit.cshtml | 14 ++++++++++++-- src/Commonage.Web/Pages/Admin/Items/Edit.cshtml.cs | 5 ++++- src/Commonage.Web/Resources/SharedResource.de.resx | 4 +++- src/Commonage.Web/Resources/SharedResource.resx | 4 +++- tests/Commonage.Tests/RevisionTests.cs | 6 +++++- 9 files changed, 31 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9b97a9..bd4aef3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/docs/curator-handbook.md b/docs/curator-handbook.md index 353ea60..ea47f03 100644 --- a/docs/curator-handbook.md +++ b/docs/curator-handbook.md @@ -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. diff --git a/docs/handbuch-kuratoren.md b/docs/handbuch-kuratoren.md index 5788c2a..9e49699 100644 --- a/docs/handbuch-kuratoren.md +++ b/docs/handbuch-kuratoren.md @@ -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. diff --git a/docs/roadmap.md b/docs/roadmap.md index b64248f..b4ff018 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -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. diff --git a/src/Commonage.Web/Pages/Admin/Items/Edit.cshtml b/src/Commonage.Web/Pages/Admin/Items/Edit.cshtml index b67f6a3..e573efe 100644 --- a/src/Commonage.Web/Pages/Admin/Items/Edit.cshtml +++ b/src/Commonage.Web/Pages/Admin/Items/Edit.cshtml @@ -336,8 +336,18 @@ }) · @(revision.UserName ?? T["Unknown"].Value)
- @T["Show the text before this change"] -

@(string.IsNullOrEmpty(revision.OldValue) ? T["Empty"].Value : revision.OldValue)

+ @T["Compare with the text now"] +
+
+

@T["Before this change"]

+

@(string.IsNullOrEmpty(revision.OldValue) ? T["Empty"].Value : revision.OldValue)

+
+
+

@T["Now"]

+ @{ var now = Model.CurrentTexts.GetValueOrDefault(revision.Field); } +

@(string.IsNullOrEmpty(now) ? T["Empty"].Value : now)

+
+
@if (mayManage) { diff --git a/src/Commonage.Web/Pages/Admin/Items/Edit.cshtml.cs b/src/Commonage.Web/Pages/Admin/Items/Edit.cshtml.cs index 693fb02..6e3bd32 100644 --- a/src/Commonage.Web/Pages/Admin/Items/Edit.cshtml.cs +++ b/src/Commonage.Web/Pages/Admin/Items/Edit.cshtml.cs @@ -63,6 +63,9 @@ public class EditModel( public IReadOnlyList History { get; private set; } = []; public IReadOnlyList Revisions { get; private set; } = []; + /// What the revised fields say now, to show beside an earlier text. + public IReadOnlyDictionary CurrentTexts { get; private set; } = new Dictionary(); + /// When the disk is nearly full, curators are told so instead of being offered the upload form. public bool CanUpload => health.CanAcceptUploads(); @@ -596,7 +599,6 @@ public async Task OnPostDeleteAsync(int id, CancellationToken can return RedirectToPage("/Admin/Index"); } - /// Hides a contribution for good because the contributor withdrew their consent. /// Puts a field back to what it said before a change. The text it has now is kept as a revision in turn. public async Task OnPostRestoreTextAsync(int id, long revisionId, CancellationToken cancellationToken) { @@ -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().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) diff --git a/src/Commonage.Web/Resources/SharedResource.de.resx b/src/Commonage.Web/Resources/SharedResource.de.resx index aa49f8a..26ab572 100644 --- a/src/Commonage.Web/Resources/SharedResource.de.resx +++ b/src/Commonage.Web/Resources/SharedResource.de.resx @@ -999,7 +999,9 @@ Ausgelassen, weil eine Aufnahme noch keine Abschrift hat: {0}. Einen früheren Text des Eintrags wiederhergestellt Frühere Texte - Den Text vor dieser Änderung zeigen + Mit dem heutigen Text vergleichen + Vor dieser Änderung + Jetzt Leer Diesen Text wiederherstellen Der frühere Text ist wieder da. diff --git a/src/Commonage.Web/Resources/SharedResource.resx b/src/Commonage.Web/Resources/SharedResource.resx index 4e9e941..c53cb7b 100644 --- a/src/Commonage.Web/Resources/SharedResource.resx +++ b/src/Commonage.Web/Resources/SharedResource.resx @@ -90,6 +90,7 @@ Back to the item Backup Backups and keys + Before this change Best match Bin Browse by tag @@ -137,6 +138,7 @@ Columns that are not imported: {0} 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. Commonage archive export + Compare with the text now Consent Contact Contact the archive @@ -462,6 +464,7 @@ Nothing has been recorded yet. Nothing is waiting for help right now. Thank you for looking. Nothing matches your search. Try fewer words or remove a filter. + Now Of which originals: {0} in {1, plural, one {# file} other {# files}}. The rest are the picture sizes made from them.Has a count. Write a form for each one your language needs, in ICU MessageFormat. Oldest first 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. @@ -657,7 +660,6 @@ Show all tags Show everything Show my name with what I send in - Show the text before this change Showing the newest {0}. Shown to admins on this page and in the list of accounts. Never to visitors. Six digits. Without your phone, type one of your recovery codes instead. Each one works once. diff --git a/tests/Commonage.Tests/RevisionTests.cs b/tests/Commonage.Tests/RevisionTests.cs index 2ac8ef1..d9267d2 100644 --- a/tests/Commonage.Tests/RevisionTests.cs +++ b/tests/Commonage.Tests/RevisionTests.cs @@ -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}");