-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathindex.html
75 lines (68 loc) · 2.47 KB
/
index.html
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
{% extends 'layout.html' %}
{% block content %}
{% include 'archive_ui.html' %}
<form action="/contacts" method="get" class="tool-bar">
<label for="search">Search Term</label>
<input id="search" type="search" name="q" value="{{ request.args.get('q') or '' }}"
hx-get="/contacts"
hx-trigger="search, keyup delay:200ms changed"
hx-target="tbody"
hx-push-url="true"
hx-indicator="#spinner"
placeholder="Search Contacts"
_="on keydown[altKey and code is 'KeyS'] from the window me.focus()" />
<img style="height: 20px" id="spinner" class="htmx-indicator" src="/static/img/spinning-circles.svg" />
<input type="submit" value="Search" />
</form>
<form x-data="{ selected: [] }">
<template
x-if="selected.length > 0">
<div class="box info tool-bar flxed top">
<slot x-text="selected.length"></slot>
contacts selected
<button type="button" class="bad bg color border"
@click="confirm(`Delete ${selected.length} contacts?`) &&
htmx.ajax('DELETE', '/contacts', { source: $root, target: document.body })"
>Delete</button>
<hr aria-orientation="vertical">
<button type="button" @click="selected = []">Cancel</button>
</div>
</template>
<table>
<thead>
<tr>
<th></th>
<th>First</th>
<th>Last</th>
<th>Phone</th>
<th>Email</th>
<th></th>
</tr>
</thead>
<tbody>
{% include 'rows.html' %}
{% if contacts|length == 10 %}
<tr>
<td colspan="5" style="text-align: center;">
<button hx-target="closest tr" hx-swap="outerHTML" hx-select="tbody tr"
hx-get="/contacts?page={{ page+1 }}">
Load More
</button>
</td>
</tr>
{% endif %}
</tbody>
</table>
<button hx-delete="/contacts"
hx-confirm="Are you sure you want to delete these contacts?"
hx-target="body">
Delete Selected Contacts
</button>
</form>
<p>
<a href="/contacts/new">Add Contact</a>
<span hx-get="/contacts/count" hx-trigger="revealed">
<img id="spinner" style="height: 20px" class="htmx-indicator" src="/static/img/spinning-circles.svg" />
</span>
</p>
{% endblock %}