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

Fix behaviour for index_display_preview to match documentation #163

Merged
merged 2 commits into from
May 17, 2024

Conversation

pedantic-git
Copy link
Contributor

This PR fixes the issue in #160, by doing the following:

  • Allowing _items and _item to accept a display_preview parameter that defaults to show_display_preview?
  • Changing the behaviour of _index to pass this value based on index_display_preview?
  • Also simplifying _index to remove the if that selects _items vs _item to match the behaviour in _show where it calls _items regardless.
  • Bumping the version of sqlite3 in the two Gemfile.locks because the version they were locked to doesn't build on recent OSes (e.g. Fedora 40)

I have tested this manually and it now behaves like the documentation, but there are no extant tests for views so I didn't add or modify the tests. The current tests still pass. LMK if you need me to add tests for this!

@Dreamersoul
Copy link
Owner

Thanks for the PR. I haven't worked with this codebase in a while since I'm no longer dependent on administrate. So, I apologize for being slightly pedantic with my questions (haha).

Jokes aside, does that mean that the 'item' partial isn't going to be used anymore? I'm not familiar with how to test views in Rails. If you can lend a hand, I'd be thankful.

One last question: did you test with has_one and has_many attachments?

@pedantic-git
Copy link
Contributor Author

The item partial is still used but it is only called from within items so you could consolidate them into one partial. I prefer two because there might be use-cases where people want the singular one.

I'll test with has_many now to be sure. The test app doesn't have them.

I could add view tests but because the test app doesn't have any seed data or anything it would be quite a big task to get it set up (much bigger than the bugfix itself, at least). If it's important let me know and I can do it.

@pedantic-git
Copy link
Contributor Author

@Dreamersoul I've confirmed it works with has_many_attached at least as much as it did before and I've updated the test app to include such a type. It's worth noting that the Rails 7.1 incompatibility with this type - that you describe in the README - means you can't actually attach multiple files using the form, but if you do it elsewhere (e.g. in the console) then they do display correctly.

@Dreamersoul Dreamersoul merged commit 4d42fdc into Dreamersoul:master May 17, 2024
1 check passed
@Dreamersoul
Copy link
Owner

LGTM. If you feel like working on the tests that would be great but not that important from my end. There are talks of this gem being merged into the administrate repo, so it could be better to wait for that to happen.

@Dreamersoul
Copy link
Owner

pushed as 1.0.3

@pedantic-git
Copy link
Contributor Author

Thank you! It works perfectly in my app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants