| 1 | {{define "content"}} |
| 2 | <header rst-page-header> |
| 3 | <div rst-page-header-titles> |
| 4 | <h1>Version history</h1> |
| 5 | <p rst-page-header-sub>Every edit somebody typed, newest first.</p> |
| 6 | </div> |
| 7 | <a rst-btn="ghost" href="/sheets/{{.Data.Sheet.ID}}">Back to sheet</a> |
| 8 | </header> |
| 9 | |
| 10 | {{/* A fixed sentence chosen by code, in its tone (shared chrome spec §4); |
| 11 | role="alert" only for a submit that did not work. */}} |
| 12 | {{with .Data.Notice}}{{template "callout" (dict "Body" . "Tone" $.Data.NoticeTone "Alert" (eq $.Data.NoticeTone "negative"))}}{{end}} |
| 13 | |
| 14 | {{if .Data.MayWrite}} |
| 15 | <form method="post" action="/sheets/{{.Data.Sheet.ID}}/undo"> |
| 16 | <button rst-btn="primary" type="submit">Undo</button> |
| 17 | </form> |
| 18 | {{/* rst-field-help, not rst-help — see share.html and the guard. */}} |
| 19 | <p rst-field-help>Undo only ever touches your own edits, one cell at a time. If |
| 20 | somebody has written over that cell since, your undo takes it back — and |
| 21 | you can undo that too.</p> |
| 22 | {{end}} |
| 23 | |
| 24 | {{/* Edits, not changed cells. The log holds inputs and never derived |
| 25 | values (spec §4.3, ruling 16), so an edit that recalculated four |
| 26 | hundred cells appears here once — which is both what the storage |
| 27 | can support and what a person wants to read. */}} |
| 28 | {{if .Data.Entries}} |
| 29 | <div style="overflow-x:auto"> |
| 30 | <table data-cell-table> |
| 31 | <thead> |
| 32 | <tr> |
| 33 | <th scope="col">Cell</th> |
| 34 | <th scope="col">Was</th> |
| 35 | <th scope="col">Became</th> |
| 36 | <th scope="col">Who</th> |
| 37 | <th scope="col">When</th> |
| 38 | {{if .Data.MayWrite}}<th scope="col"><span class="rst-sr-only">Put back</span></th>{{end}} |
| 39 | </tr> |
| 40 | </thead> |
| 41 | <tbody> |
| 42 | {{$sheet := .Data.Sheet}} |
| 43 | {{$mayWrite := .Data.MayWrite}} |
| 44 | {{range .Data.Entries}} |
| 45 | <tr> |
| 46 | <th scope="row">{{.Ref}}</th> |
| 47 | <td>{{if .Old}}<code>{{.Old}}</code>{{else}}<span rst-row-sub>empty</span>{{end}}</td> |
| 48 | <td>{{if .Cleared}}<span rst-row-sub>cleared</span>{{else}}<code>{{.New}}</code>{{end}}</td> |
| 49 | <td>{{.Who}}{{if .Mine}} <span rst-badge="neutral">you</span>{{end}}</td> |
| 50 | <td>{{.When.Format "2 Jan 2006, 15:04"}}</td> |
| 51 | {{if $mayWrite}} |
| 52 | <td> |
| 53 | {{/* Restoring is a fresh write, not a rewind: it appears here as |
| 54 | an edit by whoever did it and is itself undoable. A rewind |
| 55 | would make this log disagree with the sheet. */}} |
| 56 | <form method="post" action="/sheets/{{$sheet.ID}}/restore"> |
| 57 | <input type="hidden" name="event" value="{{.ID}}"> |
| 58 | <button rst-btn="ghost" type="submit">Put back</button> |
| 59 | </form> |
| 60 | </td> |
| 61 | {{end}} |
| 62 | </tr> |
| 63 | {{end}} |
| 64 | </tbody> |
| 65 | </table> |
| 66 | </div> |
| 67 | {{else}} |
| 68 | <div rst-empty> |
| 69 | <p rst-empty-title>Nothing yet</p> |
| 70 | <p rst-empty-body>Edits show up here as soon as somebody types into a cell.</p> |
| 71 | </div> |
| 72 | {{end}} |
| 73 | {{end}} |
| 74 | |