Provide indicator when editing bookmarks

This commit is contained in:
Justin Hawkins 2022-08-21 09:45:27 +09:30
parent 2d488ffdcc
commit 1904bfd265
2 changed files with 6 additions and 3 deletions

View File

@ -30,7 +30,10 @@
</tr> </tr>
</table> </table>
<p> <p>
<button type="button" hx-confirm="Delete this bookmark permanently?" hx-delete="/edit/{{.bookmark.ID}}" class="alert button">delete</button> <button type="button" hx-confirm="Delete this bookmark permanently?" hx-delete="/edit/{{.bookmark.ID}}" class="alert button">Delete</button>
<button type="button" class="button" hx-post="/edit/{{.bookmark.ID}}">save</button> <button type="button" class="button" hx-indicator="#saving" hx-post="/edit/{{.bookmark.ID}}"> {{ if .saved }} Saved {{ else }} Save {{ end }}</button>
<span id="saving" class="htmx-indicator">
<img style="height:1em;" src="/assets/image/beating.gif" /> Saving...
</span>
</p> </p>
</form> </form>

View File

@ -371,7 +371,7 @@ func Create(bmm *db.BookmarkManager, cmm *db.ConfigManager) *Server {
bmm.SaveBookmark(&bookmark) bmm.SaveBookmark(&bookmark)
bmm.UpdateIndexForBookmark(&bookmark) // because title may have changed bmm.UpdateIndexForBookmark(&bookmark) // because title may have changed
meta := gin.H{"page": "edit", "bookmark": bookmark, "tw": gin.H{"tags": bookmark.Tags, "tags_hidden": strings.Join(bookmark.Tags, "|")}} meta := gin.H{"page": "edit", "bookmark": bookmark, "saved": true, "tw": gin.H{"tags": bookmark.Tags, "tags_hidden": strings.Join(bookmark.Tags, "|")}}
c.HTML(http.StatusOK, c.HTML(http.StatusOK,
"edit_form.html", meta, "edit_form.html", meta,