Introduce partial search similar to Rails#2467
Conversation
577a77d to
1fe7873
Compare
1fe7873 to
2084605
Compare
|
Thank you for checking. I'm not sure if this will help with #2049. It seems like solving 2049 might require implementing a new feature, such as an option to specify a custom partial. For now, I’ve rebased on the latest |
2084605 to
5027f67
Compare
5027f67 to
d756627
Compare
|
rebased again |
|
Thank you again. I have been playing with it today and have pushed some changes to my fork: main...pablobm:administrate:feature/inherit_partial. What do you think? Some comments: Re: We could do something like the Re: I was also wondering if we need some sort of back-compatibility for users or plugins who implement |
|
Thank you for your review. I fully agreed with your suggestions and have merged the changes.
Understood. I also came up with a use case for
OK
I was also using this by copying it from the Rails source without fully understanding it. Since it doesn't seem to fit the conventions of this gem, I think it's fine to remove the prefix. My apologies.
I've seen some plugins customize this in the past, often in cases where a |
|
Sorry about that. I reviewed it again and noticed something, so I added another commit.
Please take a look. |
|
Good point 🙂 One last thing: I have removed the I took the liberty of pushing the change to your branch. What do you think? |
No problem. Thank you as always! |
|
Merging! Thank you, twice: for your contribution and for your patience 🏅 |
There is an inconsistency between the `administrate:field` generator and the custom field `HasManyVariant` present in the demo app. They use different conventions for naming and file paths. After thinking about which of the two styles is right or wrong, I think the generator is doing the right thing. This PR moves `HasManyVariant` and renames it `HasManyVariantField`, in order to follow the convention set out by the generator (which is also the one shown in the docs). Notes: - The field class is generated under `app/fields`. The location means it's autoloaded and we don't need a `require`. - The `Field` suffix may seem annoying, but it's not different from controllers, helpers, etc, and removes the need for a namespace (eg: `Field::HasManyVariant`). - This establishes a difference between the official field types (eg: `Administrate::Field::String`) and custom ones (eg: `MyStringField`), but I think this is fine. Tangentially I also noticed that, if for any reason a user puts the template files in the wrong place, this is difficult to debug as Administrate will just fail silently, rendering empty templates. This is due to the changes introduced at #2467. This should not be an issue if using the generator, but might be if creating the field manually.
Introduced partial search similar to Rails, as an alternative to to_partial_path.
Models that have an inheritance relationship often use similar or almost identical partials.
Being able to reuse partials not only makes it easier to create new fields, but also improves maintainability.
I tried deleting the HasManyVariant partial as a test, and it continues to operate normally using the HasMany partial.
Pleach check customers.log_entries field.
http://localhost:3000/admin/customers
http://localhost:3000/admin/customers/4
Please review.
refs
https://github.com/rails/rails/blob/d39db5d1891f7509cde2efc425c9d69bbb77e670/actionview/lib/action_view/view_paths.rb#L23-L29 https://github.com/rails/rails/blob/d39db5d1891f7509cde2efc425c9d69bbb77e670/actionview/lib/action_view/view_paths.rb#L72-L77