Validation work
This commit is contained in:
+7
-55
@@ -8,58 +8,6 @@ import (
|
||||
"strconv"
|
||||
)
|
||||
|
||||
templ NewThreadForm(board database.Board) {
|
||||
<div style="display: none;" id="newPostWarning" class="warning"></div>
|
||||
<form
|
||||
hx-encoding="multipart/form-data"
|
||||
style="display: none;"
|
||||
id="newThreadForm"
|
||||
hx-swap="none"
|
||||
hx-post={ fmt.Sprintf("/%s/threads", board.Slug) }
|
||||
_="
|
||||
on htmx:beforeSend toggle @disabled on <button/> until htmx:afterRequest
|
||||
on htmx:afterRequest
|
||||
if event.detail.xhr.status is not 429
|
||||
hide me
|
||||
then show #newThreadBtn
|
||||
then set #newPostBody.value to ''
|
||||
then set #newPostFile.value to ''
|
||||
then set #newPostSubject.value to ''
|
||||
then hide #newPostWarning
|
||||
then trigger refreshThreads on body
|
||||
else
|
||||
show #newPostWarning
|
||||
then put event.detail.xhr.responseText into #newPostWarning
|
||||
end"
|
||||
>
|
||||
<table>
|
||||
<tbody>
|
||||
<tr class="new-post-form-field">
|
||||
<th>Subject</th>
|
||||
<td><input id="newPostSubject" name="subject"/></td>
|
||||
</tr>
|
||||
<tr class="new-post-form-field">
|
||||
<th>Comment</th>
|
||||
<td><textarea id="newPostBody" name="body" required></textarea></td>
|
||||
</tr>
|
||||
<tr class="new-post-form-field">
|
||||
<th>File</th>
|
||||
<td>
|
||||
<input
|
||||
accept="image/*,video/mp4,video/webm,video/ogg"
|
||||
id="newPostFile"
|
||||
name="file"
|
||||
type="file"
|
||||
required
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<button type="submit">Submit</button>
|
||||
</form>
|
||||
}
|
||||
|
||||
templ BoardHeader(board database.Board) {
|
||||
<header class="board-header">
|
||||
<img src={ fmt.Sprintf("/static/media/banners/%s.png", board.Slug) }/>
|
||||
@@ -74,8 +22,12 @@ templ Board(board database.Board) {
|
||||
@shared.Layout() {
|
||||
@BoardHeader(board)
|
||||
<div class="new-post-container">
|
||||
<button _="on click hide me then show #newThreadForm" id="newThreadBtn">[New Thread]</button>
|
||||
@NewThreadForm(board)
|
||||
<button
|
||||
_="on load hide #newPostForm
|
||||
on click hide me then show #newPostForm"
|
||||
id="newThreadBtn"
|
||||
>[New Thread]</button>
|
||||
@shared.NewPostForm(board, fmt.Sprintf("/%s/threads", board.Slug), true)
|
||||
</div>
|
||||
<hr/>
|
||||
<div id="boardActionBar">
|
||||
@@ -89,7 +41,7 @@ templ Board(board database.Board) {
|
||||
<hr/>
|
||||
<div
|
||||
hx-get={ fmt.Sprintf("/hx/%s/catalog", board.Slug) }
|
||||
hx-trigger="load, refreshThreads from:body"
|
||||
hx-trigger="load, refreshPosts from:body"
|
||||
_="on htmx:afterRequest
|
||||
call resizeCatalogPreviewImgs()
|
||||
then call applyCatalogSearch()"
|
||||
|
||||
Reference in New Issue
Block a user