-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinline-entry-editing.twig
More file actions
57 lines (57 loc) · 2.86 KB
/
Copy pathinline-entry-editing.twig
File metadata and controls
57 lines (57 loc) · 2.86 KB
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
<!DOCTYPE html>
<html lang="en-GB" data-theme="dark">
<head>
<title>Datastar Demo</title>
<meta charset="utf-8"/>
<link href="https://cdn.jsdelivr.net/npm/daisyui@4.12.13/dist/full.min.css" rel="stylesheet" type="text/css"/>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
{# https://tailwindcss.com/docs/container #}
<div class="container mx-auto max-w-3xl py-8">
<div id="alert"></div>
{# https://daisyui.com/components/table/ #}
<div class="overflow-x-auto mt-4">
<table data-signals="{alert: false, entryId: 0}" class="table table-pin-rows">
<thead>
<tr>
<th class="w-10">ID</th>
<th class="w-1/2">Title</th>
<th>Author</th>
<th class="w-48"></th>
</tr>
</thead>
<tbody>
{% for entry in craft.entries.section('listings').all() %}
<tr>
<td>{{ entry.id }}</td>
<td>
<div data-show="$entryId != {{ entry.id }}">
<div id="title-{{ entry.id }}">
{{ entry.title }}
</div>
</div>
<div data-show="$entryId == {{ entry.id }}" style="display: none">
<input data-bind:title data-on:keydown="evt.key == 'Enter' && confirm('Are you sure?') && {{ datastar.post('_partials/save-entry.twig') }}" type="text" class="input input-bordered w-full">
</div>
</td>
<td>{{ entry.author.username }}</td>
<td>
<button id="edit-{{ entry.id }}" data-on:click="$alert = false; $entryId = {{ entry.id }}; $title = '{{ entry.title }}'" data-show="$entryId != {{ entry.id }}" class="btn">
Edit
</button>
<button data-on:click="$alert = false; $entryId = 0" data-show="$entryId == {{ entry.id }}" class="btn" style="display: none">
Cancel
</button>
<button data-on:click="confirm('Are you sure?') && {{ datastar.post('_partials/save-entry.twig') }}" data-show="$entryId == {{ entry.id }}" class="btn btn-primary" style="display: none">
Save
</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</body>
</html>