rubyforgood / homeward-tails

Homeward Tails is an application making it easy to link adopters/fosters with pets. We work with grassroots pet rescue organizations to understand how we can make the most impact.
MIT License
70 stars 117 forks source link

1106-staff-deactivation-refactor #1142

Open wandergithub opened 1 week ago

wandergithub commented 1 week ago

🔗 Issue

https://github.com/rubyforgood/homeward-tails/issues/1106

✍️ Description

Refactor staff deactivation

📷 Screenshots/Demos

image

jmilljr24 commented 1 week ago

@wandergithub Awesome job!

The only thing I noticed on my end is that the flash is no longer working. Are you seeing the same thing?

This is on the main branch: Screenshot from 2024-11-15 09-07-02

wandergithub commented 1 week ago

Now that you point that out 🤔 I will take a look.

wandergithub commented 1 week ago

Something is happening with the template, I think related to turbo stream and how the flash message is being handled but I don't fully understand how it works jet...

jmilljr24 commented 1 week ago

Something is happening with the template, I think related to turbo stream and how the flash message is being handled but I don't fully understand how it works jet...

The update action in ActivationsController is implicitly looking for update.turbo_stream.erb in views/organizations/activations. You can explicitly render a file that is in a differently path but we probably should stick with convention unless there is a specific reason you can think of not to.

kasugaijin commented 1 week ago

Yeah what @jmilljr24 said. Check out app/views/organizations/staff/staff/update_activation.turbo_stream.erb. You need this for your new controller and action, so just move that turbo stream view file to the correct view directory for that new controller and rename it to update.turbo_stream.erb. You will note that this file does two things. It replaces the toggle because it should change after changing the activation, and it renders the flash.

jmilljr24 commented 1 week ago

Yeah what @jmilljr24 said. Check out app/views/organizations/staff/staff/update_activation.turbo_stream.erb. You need this for your new controller and action, so just move that turbo stream view file to the correct view directory for that new controller and rename it to update.turbo_stream.erb. You will note that this file does two things. It replaces the toggle because it should change after changing the activation, and it renders the flash.

@kasugaijin I don't believe we need the turbo replace of the toggle any longer. I think that was used when the page was rendering two layouts that were user selected(table vs cards). If the user clicked the toggle in the table, the card wouldn't reflect the change until a page fresh.

kasugaijin commented 1 week ago

@jmilljr24 Ah yes we got rid of those cards...good point. We can remove the toggle bit in the turbostream response, then @wandergithub !

wandergithub commented 1 week ago

It works now! image

Thanks guys. Now I understand better how turbo_streams and the real-time update work.