This is a refactor-only PR -- no outwardly visible behavior change should happen!
It is still kind of convoluted, because it's refactoring some convoluted code. In preparation to later add differnet whole-work download options for born-digital PDF works, ref #2492
"Whole-work download options" right now are only our on-demand derivatives, ZIP and PDF, created from page images.
The DownloadDropdownComponent no longer has logic to determine proper whole-work download options. Instead, an array of DownloadOption is passed in as a dependency -- if caller doesn't want whole-work download options, it simply doesn't pass any in, also eliminating the need for the include_whole_work_options boolean option.
This is because determining whole-work download options is complicated and also potentially expensive, requiring trips to DB.
We have a new object WorkDownloadOptionsCreator which can calculate appropriate whole-work download options. This can be then be cached and re-used if needed in several places. It returns an array of DownloadOption, a model representing a download option that we already had being used!
The whole-page component WorkImageShowComponent now creates a single cached list of options, and provides it to all sub-components or partials that need to display them. Including the viewer modal; and the MemberImageShowComponent for the large "hero" image; and the WorkDownloadLinks component that displays the on-page download options. (Yes, there are a lot of confusingly similarly named objects involved here!)
factor out WorkDownloadOptions for further refactoring
WorkDownloadLinksComponent now uses WorkDownloadOptions for DRY this logic
remove now unused methods, this func is just in WorkDownloadOptions and doesn't need to be re-usable
consolidate and make consistent logic for 1-member PDF. No need to have ImageDownloadOptions have a param that knows about this, the caller has better context to take care of it.
refactor DownloadDropdownComponent to take passed in Array for whole-work download options
modal gets passed in Array work_download_options as a dependency, so it can be re-used
MemberImageComponent takes work_download_options as dependency, to re-use expesnive calculation
WorkDownloadLinksComponent takes download_options as dependency for efficiency; WorkDownloadOptions no longer has pdf_options override, we want to re-use the options so that didn't work
This is a refactor-only PR -- no outwardly visible behavior change should happen!
It is still kind of convoluted, because it's refactoring some convoluted code. In preparation to later add differnet whole-work download options for born-digital PDF works, ref #2492
"Whole-work download options" right now are only our on-demand derivatives, ZIP and PDF, created from page images.
The DownloadDropdownComponent no longer has logic to determine proper whole-work download options. Instead, an array of
DownloadOption
is passed in as a dependency -- if caller doesn't want whole-work download options, it simply doesn't pass any in, also eliminating the need for theinclude_whole_work_options
boolean option.This is because determining whole-work download options is complicated and also potentially expensive, requiring trips to DB.
We have a new object
WorkDownloadOptionsCreator
which can calculate appropriate whole-work download options. This can be then be cached and re-used if needed in several places. It returns an array ofDownloadOption
, a model representing a download option that we already had being used!The whole-page component
WorkImageShowComponent
now creates a single cached list of options, and provides it to all sub-components or partials that need to display them. Including the viewer modal; and theMemberImageShowComponent
for the large "hero" image; and theWorkDownloadLinks
component that displays the on-page download options. (Yes, there are a lot of confusingly similarly named objects involved here!)