forked from DMPRoadmap/roadmap
-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Description
DMP Assistant currently only has one default template ("Alliance Template").
- The "Alliance Template" and "Alliance Simplified Template (Funding Application Stage)" comprise the "priority templates" that populate the templates dropdown. It might make sense to also set the "Alliance Simplified Template (Funding Application Stage)" as a default template.
- One advantage, is that it would strengthen the current code used to populate the templates dropdown:
The issue with the above code, is that unwanted behaviour will be encountered if 'Alliance Simplified Template (Funding Application Stage)' is ever renamed.# app/controllers/template_options_controller.rb # Returns a JSON payload with the following structure: # - templates: # - org_templates: [All non-funder templates] # - priority_templates: [The simplified and default funder templates] # - other_templates: [All non-priority funder templates] # - total_templates: Count of all templates def build_templates_payload(templates) funder_templates = templates.select { |t| t.org_id == DEFAULT_FUNDER_ID } simplified = funder_templates.find { |t| t.title == _('Alliance Simplified Template (Funding Application Stage)') } default = funder_templates.find(&:is_default) priority_templates = [simplified, default].compact { templates: { org_templates: templates - funder_templates, priority_templates: priority_templates, other_templates: funder_templates - priority_templates }, total_templates: templates.size } end
Proposed Solution
Update the codebase to allow for multiple templates where is_default == true and set template.is_default = true for the 'Alliance Simplified Template (Funding Application Stage)' template.
From there the above code be simplified and strengthened (e.g. priority_templates = funder_templates.select(&:is_default))
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels