| 1 | {{define "title"}}{{with .Open}}{{.Title}} · {{end}}{{.Result.Plural}} · Fichas{{end}} |
| 2 | {{define "content"}} |
| 3 | <h1 class="rst-sr-only">{{.Result.Plural}}</h1> |
| 4 | {{template "fichas-notice" (dict "N" .Notice "Here" .Here)}} |
| 5 | {{if .Open}}{{template "fichas-split" .}}{{else}} |
| 6 | |
| 7 | {{if .Result.All}} |
| 8 | <div fichas-toolbar id="list-toolbar" data-live-region> |
| 9 | {{template "seg-tabs" (dict "Label" (printf "View %s as" .Result.Plural) "Items" (list |
| 10 | (dict "Label" "Table" "Href" .TableHref "Current" (eq .View "table")) |
| 11 | (dict "Label" "Cards" "Href" .CardsHref "Current" (eq .View "cards"))))}} |
| 12 | {{if eq .View "cards"}}<a rst-btn href="{{.Base}}/layout">{{icon "layout-grid"}} Arrange cards</a> |
| 13 | {{else}}<div fichas-toolbar-end> |
| 14 | {{/* The reader's own view of the table (listprefs.go): density, and |
| 15 | which columns. Forms in a disclosure, so it works with scripts off. */}} |
| 16 | <details rst-dropdown name="rst-menus" fichas-view-menu> |
| 17 | <summary rst-btn>{{icon "sliders-horizontal"}} View</summary> |
| 18 | <div rst-dropdown-menu fichas-view-panel> |
| 19 | <form method="post" action="{{.Base}}/view" data-busy="false"> |
| 20 | <input type="hidden" name="return_to" value="{{.Here}}"> |
| 21 | <p fichas-view-heading id="view-density">Density</p> |
| 22 | <div fichas-view-seg role="group" aria-labelledby="view-density"> |
| 23 | <button type="submit" name="density" value="comfortable" aria-pressed="{{eq .Density "comfortable"}}">Comfortable</button> |
| 24 | <button type="submit" name="density" value="compact" aria-pressed="{{eq .Density "compact"}}">Compact</button> |
| 25 | </div> |
| 26 | </form> |
| 27 | <hr> |
| 28 | <form method="post" action="{{.Base}}/view"> |
| 29 | <input type="hidden" name="return_to" value="{{.Here}}"> |
| 30 | <input type="hidden" name="columns" value="1"> |
| 31 | <fieldset fichas-view-columns> |
| 32 | <legend fichas-view-heading>Columns</legend> |
| 33 | {{range .Choices}}<label fichas-view-check><input type="checkbox" name="show" value="{{.Key}}"{{if or .Shown .Locked}} checked{{end}}{{if .Locked}} disabled{{end}}> {{.Label}}</label> |
| 34 | {{end}} |
| 35 | </fieldset> |
| 36 | <button fichas-view-apply type="submit">Show these columns</button> |
| 37 | </form> |
| 38 | </div> |
| 39 | </details> |
| 40 | <a rst-btn href="{{.Base}}/fields">{{icon "pencil"}} Fields</a> |
| 41 | </div>{{end}} |
| 42 | </div> |
| 43 | |
| 44 | <div rst-lbar data-live-search id="find"> |
| 45 | {{template "list-bar-search" (dict "Action" .Base "Query" .Q "Placeholder" (printf "Search %s" (lower .Result.Plural)) "Hidden" .Hidden "ClearHref" .ClearHref)}} |
| 46 | <div id="list-filters" data-live-region>{{range .Filters}}{{template "dropdown" .}}{{end}}</div> |
| 47 | </div> |
| 48 | |
| 49 | <div id="results" rst-stack data-live-results data-live-region> |
| 50 | {{if .Cards}} |
| 51 | {{if eq .View "table"}}{{template "fichas-table" .}} |
| 52 | {{else}} |
| 53 | <ul fichas-card-grid> |
| 54 | {{range $c := .Cards}}{{$face := $c.Face $.Face}} |
| 55 | <li><article rst-card> |
| 56 | <h2 fichas-card-title><a href="{{$.List.OpenHref $c.Card.ID}}">{{$c.Title}}</a>{{with $face.Pill}}{{template "status-pill" (dict "Label" . "Tone" (stageTone .))}}{{end}}</h2> |
| 57 | {{range $face.Lines}} |
| 58 | {{if eq .Kind "call"}}<p fichas-card-quote>{{.Value}}</p> |
| 59 | {{else if eq .Kind "date"}}<p fichas-meta>{{.Label}} <time datetime="{{.Date}}" title="{{longDate $.L .Date}}"{{with dateLang $.L .Date}} lang="{{.}}"{{end}}>{{dateAgo $.L .Date}}</time></p> |
| 60 | {{else if eq .Kind "longtext"}}<p fichas-meta fichas-clamp>{{.Value}}</p> |
| 61 | {{else if eq .Kind "url"}}<p fichas-meta>{{displayURL .Value}}</p> |
| 62 | {{else if eq .Kind "number"}}<p fichas-meta>{{.Label}} <span fichas-number>{{showNumber $.L .Value}}</span></p> |
| 63 | {{else}}<p fichas-meta>{{.Value}}</p>{{end}} |
| 64 | {{end}} |
| 65 | </article></li> |
| 66 | {{end}} |
| 67 | </ul> |
| 68 | {{end}} |
| 69 | {{/* aria-live on the count, not the region: every swap would otherwise |
| 70 | re-announce a whole table to a screen reader. */}} |
| 71 | <p rst-count-line aria-live="polite">{{.Count}}</p> |
| 72 | {{with .Pages}}{{template "pagination" (dict "Items" . "Label" "Pages of results")}}{{end}} |
| 73 | {{else}} |
| 74 | {{template "empty-state" (dict |
| 75 | "Title" "Nothing matches" |
| 76 | "Body" .Count |
| 77 | "ActionHref" .ResetHref |
| 78 | "ActionLabel" "Clear the search and filters")}} |
| 79 | {{end}} |
| 80 | </div> |
| 81 | {{else}} |
| 82 | {{template "empty-state" (dict |
| 83 | "Title" (printf "No %s yet" (lower .Result.Plural)) |
| 84 | "Body" (printf "Each %s is a card: what you know about one of them, and everything you log against it." (lower .Result.Label)) |
| 85 | "ActionHref" (printf "/cards/new?type=%s" .TypeKey) |
| 86 | "ActionLabel" (printf "Add a %s" (lower .Result.Label)))}} |
| 87 | <p><a rst-btn href="{{.Base}}/fields">{{icon "pencil"}} Set up its fields first</a></p> |
| 88 | {{end}} |
| 89 | {{end}} |
| 90 | {{end}} |
| 91 | |
| 92 | {{/* fichas-table: the list as a table (§5.1, §5.7). The name opens the |
| 93 | card beside the list; every other cell is, without script, a link to |
| 94 | the edit form with that field focused, and with script, the editor |
| 95 | for its field (grid.js). Each cell carries what its editor needs: |
| 96 | the field, its kind, the stored value (was) and the editor's seed. */}} |
| 97 | {{define "fichas-table"}} |
| 98 | <div fichas-grid-wrap> |
| 99 | <table fichas-grid data-density="{{.Density}}" data-list="{{.ListQuery}}" data-here="{{.Here}}" aria-label="{{.Result.Plural}}" aria-describedby="fichas-grid-help"> |
| 100 | <thead><tr> |
| 101 | {{range .Columns}}<th scope="col"{{with .Sort}} aria-sort="{{.}}"{{end}}><a href="{{.Href}}">{{.Label}}{{if eq .Sort "ascending"}} <span aria-hidden="true">↑</span>{{else if eq .Sort "descending"}} <span aria-hidden="true">↓</span>{{end}}</a></th>{{end}} |
| 102 | </tr></thead> |
| 103 | <tbody> |
| 104 | {{range $c := .Cards}} |
| 105 | <tr data-card="{{$c.Card.ID}}"> |
| 106 | {{range $f := $c.Fields}}{{if and (not (isLong $f.Def)) (index $.Shown $f.Def.Key)}} |
| 107 | {{if $c.IsTitle $f.Def.Key}}<th scope="row" fichas-title-cell><a fichas-title-link href="{{$.List.OpenHref $c.Card.ID}}">{{$c.Title}}</a></th> |
| 108 | {{else}}<td data-field="{{$f.Def.Key}}" data-kind="{{$f.Def.Kind}}" data-label="{{$f.Label}}" data-was="{{$f.Value}}" data-seed="{{seed $.L $f.Def $f.Value}}"{{if eq $f.Def.Kind "enum"}} data-options="{{range $i, $o := $f.Options}}{{if $i}}{{"\n"}}{{end}}{{$o}}{{end}}"{{end}}><a fichas-cell-link href="/cards/{{$c.Card.ID}}/edit?field={{$f.Def.Key}}&return_to={{$.Here}}#{{$f.Def.Key}}">{{template "fichas-cell-value" (dict "F" $f "L" $.L)}}<span class="rst-sr-only">, change {{$f.Label}}</span></a></td>{{end}} |
| 109 | {{end}}{{end}} |
| 110 | {{if index $.Shown "_last_call"}}<td data-readonly>{{with $c.Latest}}<time datetime="{{.Entry.CreatedAt.Format "2006-01-02"}}" title="{{stamp $.L .Entry.CreatedAt}}"{{with agoLang $.L .Entry.CreatedAt}} lang="{{.}}"{{end}}>{{ago $.L .Entry.CreatedAt}}</time>{{else}}<span fichas-empty-cell>never</span>{{end}}</td>{{end}} |
| 111 | </tr> |
| 112 | {{end}} |
| 113 | </tbody> |
| 114 | </table> |
| 115 | </div> |
| 116 | <p fichas-grid-help id="fichas-grid-help" fichas-meta>Select a cell to change it. Select the name to open the card beside the list.</p> |
| 117 | {{end}} |
| 118 | |
| 119 | {{/* fichas-split: the card beside a narrowed list (§5.4). */}} |
| 120 | {{define "fichas-split"}}{{$open := .Open}} |
| 121 | <div fichas-split-view> |
| 122 | <nav fichas-narrow aria-label="{{.Result.Plural}}"> |
| 123 | <div fichas-narrow-head> |
| 124 | <a fichas-narrow-back href="{{.Pane.CloseHref}}" aria-label="Back to the list">{{icon "arrow-left"}}</a> |
| 125 | <span fichas-narrow-name>{{.Result.Plural}}</span> |
| 126 | <span fichas-narrow-count>{{number $.L .Result.Total}}</span> |
| 127 | </div> |
| 128 | <ol fichas-narrow-list> |
| 129 | {{range $c := .Cards}}{{$face := $c.Face $.Face}} |
| 130 | <li><a href="{{$.List.OpenHref $c.Card.ID}}"{{if eq $c.Card.ID $open.Card.ID}} aria-current="true"{{end}}> |
| 131 | <strong>{{$c.Title}}</strong> |
| 132 | <span fichas-narrow-face>{{with $face.Pill}}{{template "status-pill" (dict "Label" . "Tone" (stageTone .))}}{{end}}{{range $i, $l := $face.Lines}}{{if and (eq $i 0) (ne $l.Kind "call")}}<span fichas-meta>{{if eq $l.Kind "date"}}<time datetime="{{$l.Date}}"{{with dateLang $.L $l.Date}} lang="{{.}}"{{end}}>{{dateAgo $.L $l.Date}}</time>{{else if eq $l.Kind "number"}}{{showNumber $.L $l.Value}}{{else}}{{$l.Value}}{{end}}</span>{{end}}{{end}}</span> |
| 133 | </a></li> |
| 134 | {{end}} |
| 135 | </ol> |
| 136 | {{with .Pages}}{{template "pagination" (dict "Items" . "Label" "Pages of results")}}{{end}} |
| 137 | </nav> |
| 138 | <section fichas-pane aria-label="{{$open.Title}}"> |
| 139 | {{template "fichas-card" (dict "P" .Pane "L" .L "Here" .Here "EntryFields" .EntryFields "Errors" .Errors "Pane" true)}} |
| 140 | </section> |
| 141 | </div> |
| 142 | {{end}} |
| 143 | |