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

Show box and folder metadata on search results page. #2822

Merged
merged 19 commits into from
Jan 9, 2025

Conversation

eddierubeiz
Copy link
Contributor

@eddierubeiz eddierubeiz commented Dec 16, 2024

This PR subclasses WorkComponent (which is itself a subclass of BaseComponent) with a new subclass: SearchWithinCollectionWorkComponent.

  • The subclass is only used in CollectionShowController.
  • The subclass defines a new method, box_and_folder
    • box_and_folder returns nil unless the model is a Work and has department set to 'Archives'.
    • Otherwise, box_and_folder returns a string listing the box and folder.
      • On missing or unusual box and folder metadata, the component displays what it can without errors.

@eddierubeiz eddierubeiz changed the title [WIP DO NOT MERGE] Box folder show on search results [WIP DO NOT MERGE] Show box and folder metadata on search results page. Dec 20, 2024
@eddierubeiz eddierubeiz changed the title [WIP DO NOT MERGE] Show box and folder metadata on search results page. Show box and folder metadata on search results page. Jan 7, 2025
@eddierubeiz
Copy link
Contributor Author

Here's the layout:
layout

@jrochkind
Copy link
Contributor

Looks good. Can we find a way to do this only on Collection search result pages, not every search result? (Or maybe you already have one?). Not totally sure how to appraoch this, may need to figure out how to change architecture to support.

Also make sure the line doesn't show up if there is no box/folder values (including just empty strings).

@eddierubeiz
Copy link
Contributor Author

This only shows on Collection search results, since the subclass is only used in CollectionShowController.

@eddierubeiz
Copy link
Contributor Author

Will include tests that prove the above assertions!

@jrochkind
Copy link
Contributor

Awesome!

@eddierubeiz eddierubeiz marked this pull request as ready for review January 8, 2025 13:00
@eddierubeiz
Copy link
Contributor Author

Added tests.

@jrochkind
Copy link
Contributor

Nicely done.

I don't LOVE sub-classing WorkComponent, as sub-classes can be fragile ("prefer composition over inheritance").

In an ideal world, I'd like to add this to WorkComponent, as a configuration option in initializer on WorkComponent (show_box_and_folder or something like that), and somehow have CollectionController (and its sub-classes) set up the WorkComponent with that config.

I think that could possibly result in ultimately simpler code... this is a bit spaghetti? But that might also be just spagetti too.

I guess we have tests that should catch us if we break? So maybe we'll just go with this for now!

You did do a great job of figuring out how to fit this into existing architecture, which wasn't too bad, so I guess we should count our blessings!

Approved if you feel good with moving forward even after these comments!

@eddierubeiz
Copy link
Contributor Author

That's a good idea and I don't believe it's a huge change. Hang on, let me see if I can do that...

@eddierubeiz
Copy link
Contributor Author

eddierubeiz commented Jan 9, 2025

Sorry - that approach turns out to be tricky because CollectionShowController doesn't actually instantiate any WorkComponent objects, it just defines a class to use as a view component given a type of model that will later be displayed. I think we do have to subclass WorkComponent here.

If I can figure out a way around this, I might refactor this later. For now I'm moving forward.

@eddierubeiz eddierubeiz merged commit 38b16b6 into master Jan 9, 2025
1 check passed
@eddierubeiz eddierubeiz deleted the box_folder_show_on_search_results branch January 9, 2025 19:13
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