Newer
Older
dmpopidor / app / views / templates / admin_index.html.erb
<div class="row">
  <div class="col-md-12">
    <h1><%= _('Templates') %></h1>
    <p class="text-justify">
      <%= _("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.") %>
    </p>
    <p class="text-justify">
      <%= _("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">
    <h2>
      <%= _('Own templates') %>
    </h2>
    <!-- List of own templates -->
    <% if @org_templates.length > 0 then %>
      <div class="table-responsive">
        <table class="table table-hover table-bordered">
          <thead>
            <tr>
              <th><%= _('Title') %></th>
              <th><%= _('Description') %></th>
              <th><%= _('Status') %></th>
              <th><%= _('Last updated') %></th>
              <th></th>
            </tr>
          </thead>
          <tbody>
          <% @org_templates.each do |hash| %>
            <tr>
              <td>
                <%= hash[:current].title %>
              </td>
                <td>
                  <%= raw hash[:current].description.truncate(90, omission: _('... (continued)')) unless hash[:current].description.nil? %>
                </td>
                <td>
                  <% if hash[:live].nil? %>
                    <%= _('Unpublished') %>
                
                  <% elsif hash[:current].dirty? %>
                    <%= _('Unpublished changes') %>
                
                  <% else %>
                    <%= _('Published') %>
                  <% end %>
                </td>
                <td>
                  <% last_temp_updated = hash[:current].updated_at %>
                    <%= l last_temp_updated.to_date, formats: :short %>
                </td>
                <td>
                <div class="dropdown">
                <button class="btn btn-link dropdown-toggle" type="button"
                        data-toggle="dropdown"
                        aria-haspopup="true" aria-expanded="true">
                  <%= _('Actions') %><span class="caret"></span>
                </button>
                <ul class="dropdown-menu">
                  <li><%= link_to _('Edit'), admin_template_template_path(id: hash[:current].id, edit: "true") %></li>
                  <li><%= link_to _('History'), admin_template_history_template_path(id: hash[:current].id) %></li>
                  <!-- If the template has never been published or it has changed -->
                  <% if hash[:live].nil? %>
                    <li><%= link_to _('Publish'), admin_publish_template_path(hash[:current]), method: :put %></li>
                  <% elsif hash[:current].dirty? %>
                    <li><%= link_to _('Publish changes'), admin_publish_template_path(hash[:current]), method: :put %></li>
                  <% else %>
                    <li><%= link_to _('Unpublish'), admin_unpublish_template_path(hash[:current]), method: :put %></li>
                  <% end %>
                  <li><%= link_to _('Copy'), admin_copy_template_path(id: hash[:current].id), method: :put %></li>
                </ul>
              </td>
             </tr>
            <% end %>
          </tbody>
        </table>
      </div>
    <% end %>
    <!-- link button to add new template -->
    <a href="<%= admin_new_template_path %>" class="btn btn-primary" role="button">
      <%= _('Create a template') %>
    </a>
    <%= render partial: '/templates/list_template', locals: { title: n_('Default template', 'Default templates', @organisation_templates.length), templates: @organisation_templates } %>
    <!-- display this only if the organisation is not a funder-->
    <% if !current_user.org.funder? %>
      <%= render partial: '/templates/list_template', locals: { title: _('Funders templates'), templates: @funder_templates } %>
    <% end %>
  </div>
</div>