feat: add edit/delete buttons to list views and inline privacy toggle
Fave cards in the list and profile views now show edit, delete, and
privacy toggle buttons directly — no need to open the detail page first.
- New POST /faves/{id}/privacy route with HTMX privacy toggle partial
- New UpdatePrivacy store method for single-column update
- fave_list.html: edit link, HTMX delete, privacy toggle on every card
- profile.html: edit/delete for owner's own cards
- privacy_toggle.html: new HTMX partial that swaps inline on toggle
- CSS: compact .fave-card-actions styles
The existing handleFaveDelete already returns empty 200 for HTMX
requests, so hx-target="closest article" hx-swap="outerHTML" removes
the card from DOM seamlessly.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1260cfd18f
commit
b186fb4bc5
9 changed files with 360 additions and 3 deletions
|
|
@ -21,9 +21,6 @@
|
|||
<a href="{{basePath}}/faves/{{.ID}}">
|
||||
<strong>{{.Description}}</strong>
|
||||
</a>
|
||||
{{if eq .Privacy "private"}}
|
||||
<small class="badge-private" aria-label="Privat">Privat</small>
|
||||
{{end}}
|
||||
</header>
|
||||
{{if .Tags}}
|
||||
<footer>
|
||||
|
|
@ -32,6 +29,27 @@
|
|||
{{end}}
|
||||
</footer>
|
||||
{{end}}
|
||||
<footer class="fave-card-actions">
|
||||
<span class="privacy-toggle" id="privacy-{{.ID}}">
|
||||
<button
|
||||
hx-post="{{basePath}}/faves/{{.ID}}/privacy"
|
||||
hx-target="#privacy-{{.ID}}"
|
||||
hx-swap="outerHTML"
|
||||
class="fave-action-btn {{if eq .Privacy "private"}}secondary{{end}}"
|
||||
title="{{if eq .Privacy "public"}}Gjør privat{{else}}Gjør offentlig{{end}}"
|
||||
>{{if eq .Privacy "public"}}Offentlig{{else}}Privat{{end}}</button>
|
||||
</span>
|
||||
<a href="{{basePath}}/faves/{{.ID}}/edit" class="fave-action-link"
|
||||
aria-label="Rediger {{.Description}}">Rediger</a>
|
||||
<button
|
||||
hx-delete="{{basePath}}/faves/{{.ID}}"
|
||||
hx-confirm="Er du sikker på at du vil slette denne favoritten?"
|
||||
hx-target="closest article"
|
||||
hx-swap="outerHTML"
|
||||
class="fave-action-btn secondary"
|
||||
aria-label="Slett {{.Description}}"
|
||||
>Slett</button>
|
||||
</footer>
|
||||
</article>
|
||||
{{end}}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -75,6 +75,20 @@
|
|||
{{end}}
|
||||
</footer>
|
||||
{{end}}
|
||||
{{if $d.IsOwner}}
|
||||
<footer class="fave-card-actions">
|
||||
<a href="{{basePath}}/faves/{{.ID}}/edit" class="fave-action-link"
|
||||
aria-label="Rediger {{.Description}}">Rediger</a>
|
||||
<button
|
||||
hx-delete="{{basePath}}/faves/{{.ID}}"
|
||||
hx-confirm="Er du sikker på at du vil slette denne favoritten?"
|
||||
hx-target="closest article"
|
||||
hx-swap="outerHTML"
|
||||
class="fave-action-btn secondary"
|
||||
aria-label="Slett {{.Description}}"
|
||||
>Slett</button>
|
||||
</footer>
|
||||
{{end}}
|
||||
</article>
|
||||
{{end}}
|
||||
</div>
|
||||
|
|
|
|||
10
web/templates/partials/privacy_toggle.html
Normal file
10
web/templates/partials/privacy_toggle.html
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<span class="privacy-toggle" id="privacy-{{.ID}}">
|
||||
<button
|
||||
hx-post="{{basePath}}/faves/{{.ID}}/privacy"
|
||||
hx-target="#privacy-{{.ID}}"
|
||||
hx-swap="outerHTML"
|
||||
class="fave-action-btn {{if eq .Privacy "private"}}secondary{{end}}"
|
||||
aria-label="{{if eq .Privacy "public"}}Gjør privat{{else}}Gjør offentlig{{end}}"
|
||||
title="{{if eq .Privacy "public"}}Gjør privat{{else}}Gjør offentlig{{end}}"
|
||||
>{{if eq .Privacy "public"}}Offentlig{{else}}Privat{{end}}</button>
|
||||
</span>
|
||||
Loading…
Add table
Add a link
Reference in a new issue