| 1 | {{define "title"}}Edit {{.Card.Title}} · Fichas{{end}} |
| 2 | {{define "content"}} |
| 3 | {{$c := .Card}}{{$L := .L}} |
| 4 | <header fichas-page-head> |
| 5 | <h1>Edit {{$c.Title}} <span fichas-meta>{{$c.TypeLabel}}</span></h1> |
| 6 | </header> |
| 7 | |
| 8 | {{if .Conflicts}}<div rst-callout="warning" role="alert"><div rst-callout-body><p>Someone changed {{if eq (len .Conflicts) 1}}a field{{else}}some fields{{end}} while you were editing, so nothing was saved. Choose which value to keep for each, then save again.</p></div></div>{{end}} |
| 9 | |
| 10 | {{/* The scriptless edit form (§5.2, §5.7): was rides beside every field, |
| 11 | and only the fields whose value differs from it are changed. After a |
| 12 | conflict, each conflicting field offers theirs and mine. */}} |
| 13 | <form method="post" action="/cards/{{$c.Card.ID}}" fichas-form rst-stack novalidate> |
| 14 | <input type="hidden" name="return_to" value="{{.ReturnTo}}"> |
| 15 | {{/* Every was first, beside return_to: a hidden input between two |
| 16 | fields hides the first from the stack's rule, and the second would |
| 17 | sit at the stack's 8px gap, not a field's 12px. */}} |
| 18 | {{range $f := $c.Fields}}<input type="hidden" name="was.{{$f.Def.Key}}" value="{{index $.Was $f.Def.Key}}"> |
| 19 | {{end}} |
| 20 | {{range $f := $c.Fields}} |
| 21 | {{with index $.Conflicts $f.Def.Key}} |
| 22 | <fieldset fichas-conflict id="{{$f.Def.Key}}"> |
| 23 | <legend>{{$f.Label}}</legend> |
| 24 | {{if eq $f.Def.Kind "number"}}<input type="hidden" name="{{$f.Def.Key}}.locale" value="{{$L.Format}}">{{end}} |
| 25 | <label fichas-conflict-choice><input type="radio" name="{{$f.Def.Key}}" value="{{.Theirs}}" checked> Keep theirs: <strong>{{.TheirsText}}</strong>{{with .By}} <span fichas-meta>(from {{.}})</span>{{end}}</label> |
| 26 | <label fichas-conflict-choice><input type="radio" name="{{$f.Def.Key}}" value="{{.Mine}}"> Use mine: <strong>{{.MineText}}</strong></label> |
| 27 | </fieldset> |
| 28 | {{else}} |
| 29 | {{template "fichas-input" (dict "F" (editField $f $.Typed $L) "Error" (errFor $.Errors $f.Def.Key) "Autofocus" (eq $.Focus $f.Def.Key) "L" $L)}} |
| 30 | {{end}} |
| 31 | {{end}} |
| 32 | {{template "form-foot" (dict "Submit" "Save changes" "CancelHref" .ReturnTo "CancelLabel" "Cancel")}} |
| 33 | </form> |
| 34 | |
| 35 | <div fichas-danger-zone rst-stack rst-section> |
| 36 | <a rst-btn="danger" href="/cards/{{$c.Card.ID}}/delete">Delete this {{lower $c.TypeLabel}}…</a> |
| 37 | <p fichas-meta>Opens a confirmation page. The change log keeps who deleted it.</p> |
| 38 | </div> |
| 39 | {{end}} |
| 40 | |