Add LookBook previews for Case views #67
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Context
In order to add LookBook previews for Case views, I had to convert the case views to only rely on local variables since LookBook can't easily pass in the controller context. This means that in order to use the Case views it's not quite as automagic, you need to manually define things like cases_path rather than allowing the view context from dynamically figuring it out using the model and the polymorphic_path helper.
This poses an interesting design problem. I wonder if there's a way to have the best of both worlds: Have LookBook previews, but also reduce the amount of code needed to use the views. Perhaps this could be a place where Presenters can play a role. In the meantime, I feel like even though in the short term this increases the amount of code the host application needs to use the Case views, it still seems potentially worth decoupling reusable views from controller context. I feel like there may be ways to further improve the host app experience further down the line.
Note: In this PR I organized the cases previews in a cases folder, i think that's better organization, so i'm gonna do that for application forms too in a separate PR
Testing
Tested on LookBook and on the dummy app routes:
Screenshots:
/passport_cases
/passport_cases/1
Lookbook
