Newer
Older
dmpopidor / app / views / org_admin / templates / index.html.erb
<% # 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">
      <% if current_user.can_super_admin? %>
        <li role="all-templates" class="active">
          <a href="#all-templates" role="tab" aria-controls="all-templates" data-toggle="tab"><%= _('All Templates') %></a>
        </li>
      <% end %>
      <li role="organisation-templates" class="<%= !current_user.can_super_admin? ? 'active' : '' %>">
        <a href="#organisation-templates" role="tab" aria-controls="organisation-templates" data-toggle="tab"><%= current_user.can_super_admin? ? _('%{org_name} Templates') % { org_name: current_user.org.name } : _('Own Templates') %></a>
      </li>
      <li role="funder-templates">
        <a href="#funder-templates" role="tab" aria-controls="funder-templates" data-toggle="tab"><%= _('Customizable Templates') %></a>
      </li>
    </ul>
  
    <div class="tab-content">
      <% if current_user.can_super_admin? %>
        <div id="all-templates" role="tabpanel" class="tab-pane active">
          <h2><%= _('All Templates') %></h2>
          <% if all_templates.length > 0 %>
            <%= paginable_renderise(
              partial: 'templates_list',
              controller: 'org_admin/templates',
              action: 'all', 
              scope: all_templates,
              locals: {current_org: current_org.id, published: published, scopes: scopes[:all], hide_actions: true}) %>
          <% else %>
            <p><%= _('There are currently no templates.') %></p>
          <% end %>
        </div>
      <% end %>
      <div id="organisation-templates" role="tabpanel" class="tab-pane<%= !current_user.can_super_admin? ? ' active' : '' %>">
        <h2><%= current_user.can_super_admin? ? _('%{org_name} Templates') % { org_name: current_user.org.name } : _('Own Templates') %></h2>
        <% if own_templates.length > 0 %>
          <%= paginable_renderise(
            partial: 'templates_list',
            controller: 'org_admin/templates',
            action: 'orgs', 
            scope: own_templates,
            locals: {current_org: current_org.id, published: published, scopes: scopes[:orgs], hide_actions: false}) %>
        <% else %>
          <p><%= _('There are currently no templates defined for your organisation.') %></p>
        <% end %>
      </div>
      <!-- If the Org is not just a funder then show the customizations table -->
      <div id="funder-templates" role="tabpanel" class="tab-pane">
        <h2><%= _('Customizable Templates') %></h2>
        <% if customizable_templates.length > 0 %>
          <%= paginable_renderise(
            partial: 'funder_templates_list',
            controller: 'org_admin/templates',
            action: 'funders', 
            scope: customizable_templates,
            locals: {current_org: current_org.id, customizations: customized_templates, published: published, scopes: scopes[:funders]}) %>
        <% else %>
          <p><%= _('There are currently no customisable templates.') %></p>
        <% end %>
      </div>
    </div>

    <a href="<%= new_org_admin_template_path %>" class="btn btn-primary" role="button">
      <%= _('Create a template') %>
    </a>
  </div>
</div>