{{extends "../layouts/application.jet"}}

{{block button(label, href="javascript:void(0)")}}
  <a href="{{ href }}">{{ label }}</a>
{{end}}

{{block ul()}}
  <ul>
    {{yield content}}
  </ul>
{{end}}

{{block documentBody()}}
  <h1>List of TODOs</h1>

  {{if isset(showingAllDone) && showingAllDone}}
    <p>Showing only TODOs that are done</p>
  {{else}}
    <p><a href="/all-done">Show only TODOs that are done</a></p>
  {{end}}

  {{yield ul() content}}
    {{range id, value := .}}
      <li {{if value.Done}}style="color:red;text-decoration: line-through;"{{end}}>
        <a href="/todo?id={{ id }}">{{ value.Text }}</a>
        {{yield button(label="UP", href="/update/?id="+base64(id))}} - {{yield button(href="/delete/?id="+id, label="DL")}}
      </li>
    {{end}}
  {{end}}
{{end}}
