Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reload icon on association fields #2172

Closed
4 tasks
adrianthedev opened this issue Dec 18, 2023 · 1 comment · Fixed by #2386
Closed
4 tasks

Add reload icon on association fields #2172

adrianthedev opened this issue Dec 18, 2023 · 1 comment · Fixed by #2386
Labels
Front end Good first issue Good for newcomers Help wanted We could use some help with this Hotwire

Comments

@adrianthedev
Copy link
Collaborator

adrianthedev commented Dec 18, 2023

I sometimes want the association table to be reloaded after I know that something has been added/updated.
I don't want to reload the page.

Approach

  • add "arrow-path-rounded-square" icon (from heroicons) to the index view if it's used in the association. This is how we add svgs.
  • Because all the associations use Turbo frames and that resources' index page, the link should reload the current turbo-frame.
  • Check the Avo::Views::ResourceIndexComponent
  • The link should not be visible if the component is not rendered in an association

Image

@adrianthedev adrianthedev added Help wanted We could use some help with this Good first issue Good for newcomers Hotwire Front end labels Dec 18, 2023
@Paul-Bob Paul-Bob assigned Paul-Bob and unassigned Paul-Bob Jan 15, 2024
@gabrielgiroe1 gabrielgiroe1 mentioned this issue Jan 19, 2024
4 tasks
@Paul-Bob
Copy link
Contributor

Paul-Bob commented Jan 23, 2024

Let's explore another approach

  • Generate stimulus controller
  • Connect button with stimulus controller passing the turbo_frame as target* (if not possible pass the frame id as value** and use document.getElementById('frame_value') to get it)
  • Register an on click event that triggers turbo_frame target to reload using reload()

Docs

Stimulus - https://stimulus.hotwired.dev/
*Stimulus targets - https://stimulus.hotwired.dev/reference/targets
**Stimulus values - https://stimulus.hotwired.dev/reference/values

Suggestions

After generating the stimulus controller replace the connect method with and make sure that "Here!!!" appears on browser console before proceeding:

  connect() {
    console.log("Here!!!")
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Front end Good first issue Good for newcomers Help wanted We could use some help with this Hotwire
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants