Skip to content

Allow for multiple is_default templates / Set is_default = true for "Alliance Simplified..." template #1230

@aaronskiba

Description

@aaronskiba

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:
    # 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
    The issue with the above code, is that unwanted behaviour will be encountered if 'Alliance Simplified Template (Funding Application Stage)' is ever renamed.

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))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions