1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| {% import ( "{{{ .Package }}}/app/controller/cutil" "{{{ .Package }}}/app/util" "{{{ .Package }}}/views/components" ) %}
{% func Diffs(value util.Diffs) %}{% stripspace %} {%- if len(value) == 0 -%} <em>no changes</em> {%- else -%} <div class="overflow full-width"> <table class="expanded"> <thead> <tr> <th>Path</th> <th>Old</th> <th></th> <th>New</th> </tr> </thead> <tbody> {%- for _, d := range value -%} <tr> <td style="width: 30%;"><code>{%s d.Path %}</code></td> <td style="width: 30%;"><code><em>{%s d.Old %}</em></code></td> <td style="width: 10%;">→</td> <td style="width: 30%;"><code class="success">{%s d.New %}</code></td> </tr> {%- endfor -%} </tbody> </table> </div> {%- endif -%} {% endstripspace %}{% endfunc %}
{% func DiffsTable(title string, value util.Diffs, indent int) %}{% stripspace %} <tr> {%= components.Indent(true, indent + 1) %} <th class="shrink">{%s title %}</th> {%= components.Indent(true, indent + 1) %} <td>{%= Diffs(value) %}</td> {%= components.Indent(true, indent) %} </tr> {% endstripspace %}{% endfunc %}
{% func DiffsSet(key string, value util.DiffsSet, limit int, ps *cutil.PageState) %}{% stripspace %} {%- if len(value) == 0 -%} <em>no changes</em> {%- else -%} <ul class="accordion"> {%- for idx, k := range value.Keys() -%} {%- code dk, u := util.StringSplitLast(k, '^', true) v := value[k] if limit == 0 { limit = 100 } -%} {%- if limit > 0 && idx < limit -%} <li> <input id="accordion-{%s k %}-{%d idx %}" type="checkbox" hidden="hidden" /> <label for="accordion-{%s k %}-{%d idx %}"> <div class="right"> {%- if len(v) == 1 -%} <em>({%s v[0].String() %})</em>{% space %} {%- endif -%} {%s util.StringPlural(len(v), "diff") %} </div> {%= components.ExpandCollapse(3, ps) %} {% if u != "" %}<a href="{%s u %}">{%s dk %}</a>{% else %}{%s dk %}{% endif %} </label> <div class="bd"><div><div> {%= Diffs(v) %} </div></div></div> </li> {%- endif -%} {%- if idx == limit && limit > 0 -%} <li> <input id="accordion-{%s k %}-extras" type="checkbox" hidden="hidden" /> <label for="accordion-{%s k %}-extras">...and{% space %}{%d len(value) - limit %}{% space %}extra</label> </li> {%- endif -%} {%- endfor -%} </ul> {%- endif -%} {% endstripspace %}{% endfunc %}
|