jwjacobson / jazztunes

a jazz repertoire management app
https://jazztunes.org
GNU General Public License v3.0
3 stars 1 forks source link

New play functionality - needs second play view? #222

Closed jwjacobson closed 7 months ago

jwjacobson commented 7 months ago

@ryaustin

I updated the list template and the _play.html partial To update the last_played field of the table when the play button is pressed. This is great but it breaks the pressing of the play button in the play template, where the button now gets replaced by the date.

Possible solutions: (1) Make a second view that also updates last_played of a tune but returns a different partial. Cons: It seems bad to duplicate functionality like this.

(2) Add branching in the current play view to return different partials depending on which page the user is coming from. Cons: could be messy

(3) ???

ryaustin commented 7 months ago

Reviewing this and the code it seems either of the methods suggested work well. This sort of functionality though is best handled in a out-of-band swap or event trigger. see: https://htmx.org/examples/update-other-content/

Another consideration to keep this even more simple would be to simply refresh the page? This way, in the tune search, you already have a div for 'last_played' above the 'Play and No Thanks' buttons. If you press 'Play' on this page, then it is refreshed and the last updated is also updated. I do believe the experience with an event or oob-swap is worth it so that you continue returning the partial.