Develop embargo date form based on grant funder data
See parent ticket #6 (closed)
This can be in the same component as #27 (closed) or in a new component.
The minimum funder max embargo date from the GRIST API must be used to create a dropdown where a user can select their paper's embargo date. The form should appear on the same page as the grant search but should be disabled until a grant is selected.
Steps:
- The user will select a grant using the search built by Zhan (#27 (closed)). The user may select more than one grant. Each will be saved in the version metadata as:
metadata.fundingGroup = [
{
fundingSource: Grant.Funder.Name
awardId: Grant.Id
}
]
-
Create a list of funder names from the grants selected (no duplicates—a Set might be useful for this).
-
Call the following from the GRIST API: https://www.ebi.ac.uk/europepmc/GristAPI/rest/api/get/funders
-
For each funder, use the funder name to retrieve the correct
releaseDelay
from the API response. If there was more than one funder, compare the release delays and find the lowest number. The following code did this in ruby:
@terms.split(',').map {|term|
funder = json['funderInfoList'].select {|funders| funders['name'] == term}.first
funder['releaseDelay'].to_i
}.min
- Create a range, from 0 to the lowest release delay number. Create a select, and map the range to options. Here's the HTML from Aperta as an example of this section—make sure to use pubsweet/ui elements instead
<div class="flex-element inset-form-control">
<div class="inset-form-control-text-select">
<label>Select publication embargo period</label>
</div>
<select id="select-publication-embargo-period" class="inset-form-control-select" onchange={{action "selectEmbargo" value="target.value"}}>
{{#each embargoRange as |months|}}
<option value="{{months}}" selected={{eq task.paper.release_delay months}}>{{months}} months</option>
{{/each}}
</select>
</div>
- The user's selection should be sent up the parent via the following object
{releaseDelay: NUMBER}