Add Delete row

This commit is contained in:
2025-01-29 11:40:18 +01:00
parent 380795d054
commit 53e7d79f7c
6 changed files with 69 additions and 20 deletions

View File

@@ -8,6 +8,15 @@
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.14.8/dist/cdn.min.js"></script>
<style>
[x-cloak] { display: none !important; }
.htmx-indicator{
display:none;
}
.htmx-request .htmx-indicator{
display:inline;
}
.htmx-request.htmx-indicator{
display:inline;
}
</style>
{% block head %}{% endblock %}
</head>

View File

@@ -3,11 +3,17 @@
<td>{{feed.feed_url}}</td>
<td>{{feed.last_pub_date.clone().unwrap_or("None".to_string())}}</td>
<td>
<button hx-get="/feed/{{feed.id}}/"
<button hx-get="/feed/{{feed.id}}"
hx-target="#feed_{{feed.id}}"
hx-swap="outerHTML"
hx-trigger="click">
hx-swap="outerHTML">
Refresh
</button>
<button class="danger"
hx-confirm="Are you sure?"
hx-delete="/feed/{{feed.id}}"
hx-target="#feed_{{feed.id}}"
hx-swap="outerHTML">
Delete
</button>
</td>
</tr>

View File

@@ -1,3 +0,0 @@
{% for feed in feeds %}
{% include "feed.html" %}
{% endfor %}

View File

@@ -37,14 +37,14 @@
<div style="height: 48px; margin-bottom: 8px"></div>
<div x-data="{'isModalOpen': false}">
<div style="display:flex; justify-content:flex-end">
<button x-on:click="isModalOpen = true">Create</button>
<button @click="isModalOpen = true">Create</button>
</div>
<div class="overlay" style="z-index: 30" x-show="isModalOpen" x-cloak></div>
<dialog open style="z-index: 31" x-show="isModalOpen" x-cloak x-transition>
<header>
<h2>Create new RSS Feed subscription</h2>
</header>
<form id="create_form" hx-post="/feed/" hx-swap="none">
<form id="create_form" hx-post="/feed/" hx-swap="none" x-ref="create_form" hx-indicator="#indicator">
<label>
Name
<input type="text" name="name">
@@ -55,8 +55,11 @@
</label>
</form>
<footer>
<button form="create_form" type="reset" x-on:click="isModalOpen = false">Close</button>
<button form="create_form" type="submit">Submit</button>
<button form="create_form" type="reset" @click="isModalOpen = false">Close</button>
<button form="create_form" type="submit">
Submit
<img id="indicator" class="htmx-indicator" src="/assets/oval.svg" style="height: 1rem; margin-left: 2px" alt="...">
</button>
</footer>
</dialog>
<table style="text-align:center">
@@ -68,7 +71,7 @@
<th>Actions</th>
</tr>
</thead>
<tbody hx-get="/feed/" hx-trigger="newFeed from:body" x-on:htmx:after-settle="isModalOpen = false">
<tbody hx-get="/feed/" hx-trigger="newFeed from:body" @htmx:after-settle="isModalOpen = false;$refs['create_form'].reset()">
{{ feeds|safe }}
</tbody>
</table>