<% # locals: funder_templates, org_templates, current_user, current_org, orgs %>
<div class="row">
<div class="col-md-12">
<h1><%= _('Templates') %></h1>
</div>
<% if current_user.can_super_admin? %>
<div class="col-md-12">
<p><%= _('If you would like to modify one of the templates below, you must first change your organisation affiliation.') %></p>
</div>
<div class="col-md-6">
<%= form_for current_user, url: org_swap_user_path(current_user), html: {method: :put, id: 'super-admin-switch-org'} do |f| %>
<%= render partial: "shared/my_org", locals: {f: f, default_org: current_org, orgs: orgs, allow_other_orgs: false} %>
<%= f.submit _('Change affiliation'), class: 'btn btn-default' %>
<% end %>
</div>
<% end %>
<div class="col-md-12">
<p>
<%= _('If you wish to add an institutional template for a Data Management Plan, use the \'create template\' button. You can create more than one template if desired e.g. one for researchers and one for PhD students. Your template will be presented to users within your institution when no funder templates apply. If you want to add questions to funder templates use the \'customise template\' options below.') %>
</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<ul class="nav nav-tabs" role="tablist">
<li role="organisation-templates" class="active">
<a href="#organisation-templates" role="tab" aria-controls="organisation-templates" data-toggle="tab"><%= _('Organisation Templates') %></a>
</li>
<li role="funder-templates">
<a href="#funder-templates" role="tab" aria-controls="funder-templates" data-toggle="tab"><%= current_user.can_super_admin? ? _('Funder Templates') : _('Customizable Templates') %></a>
</li>
</ul>
<div class="tab-content">
<div id="organisation-templates" role="tabpanel" class="tab-pane active">
<h2><%= _('Organisation Templates') %></h2>
<% if org_templates.length > 0 %>
<%= paginable_renderise(
partial: 'templates_list',
controller: 'org_admin/templates',
action: 'orgs',
scope: org_templates,
locals: {current_org: current_org.id, published: published}) %>
<% else %>
<p><%= _('There are currently no templates defined for your organisation.') %>
<% end %>
</div>
<div id="funder-templates" role="tabpanel" class="tab-pane">
<h2><%= current_user.can_super_admin? ? _('Funder Templates') : _('Customizable Templates') %></h2>
<% if funder_templates.length > 0 %>
<%= paginable_renderise(
partial: 'funder_templates_list',
controller: 'org_admin/templates',
action: 'funders',
scope: funder_templates,
locals: {current_org: current_org.id, customizations: customized_templates, published: published}) %>
<% else %>
<p><%= _('There are currently no funder templates.') %>
<% end %>
</div>
</div>
<a href="<%= new_org_admin_template_path %>" class="btn btn-primary" role="button">
<%= _('Create a template') %>
</a>
</div>
</div>