index.gohtml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. {{define "index.html"}}
  2. {{ block "content" . }}
  3. {{ template "archive_ui.html" . }}
  4. <form action="/contacts" method="get" class="tool-bar">
  5. <label for="search">Search Term</label>
  6. <input id="search" type="search" name="q" value="{{ .search }}"
  7. hx-get="/contacts"
  8. hx-trigger="search, keyup delay:200ms changed"
  9. hx-target="tbody"
  10. hx-push-url="true"
  11. hx-indicator="#spinner"/>
  12. <img style="height: 20px" id="spinner" class="htmx-indicator" src="/static/img/spinning-circles.svg"/>
  13. <input type="submit" value="Search"/>
  14. </form>
  15. <form x-data="{ selected: [] }">
  16. <template
  17. x-if="selected.length > 0">
  18. <div class="box info tool-bar flxed top">
  19. <slot x-text="selected.length"></slot>
  20. contacts selected
  21. <button type="button" class="bad bg color border"
  22. @click="confirm(`Delete ${selected.length} contacts?`) &&
  23. htmx.ajax('DELETE', '/contacts/', { source: $root, target: document.body })"
  24. >Delete
  25. </button>
  26. <hr aria-orientation="vertical">
  27. <button type="button" @click="selected = []">Cancel</button>
  28. </div>
  29. </template>
  30. <table>
  31. <thead>
  32. <tr>
  33. <th></th>
  34. <th>First</th>
  35. <th>Last</th>
  36. <th>Phone</th>
  37. <th>Email</th>
  38. <th></th>
  39. </tr>
  40. </thead>
  41. <tbody>
  42. {{ template "rows.html" . }}
  43. </tbody>
  44. </table>
  45. <button hx-delete="/contacts"
  46. hx-confirm="Are you sure you want to delete these contacts?"
  47. hx-target="body">
  48. Delete Selected Contacts
  49. </button>
  50. </form>
  51. <p>
  52. <a href="/contacts/new">Add Contact</a>
  53. <span hx-get="/contacts/count" hx-trigger="revealed">
  54. <img id="spinner" style="height: 20px" class="htmx-indicator" src="/static/img/spinning-circles.svg"/>
  55. </span>
  56. </p>
  57. {{ end }}
  58. {{end}}