Newer
Older
dmpopidor / app / views / paginable / templates / _funders.html.erb
<% # locals: templates, current_org %>

<div class="table-responsive">
  <table class="table table-hover table-bordered">
    <thead>
      <% if scopes.present? %>
        <tr><th colspan="5" class="sorter-false table-scope"><ul class="nav navbar-nav">
          <% scopes.keys.each do |k| %>
            <% unless k == :dmptemplate_ids %>
              <% label = (['published', 'unpublished'].include?(k.to_s) ? _('Customization %{publication_status}') % { publication_status: k } : k.capitalize) %>
              <li><%= link_to "#{label} (#{scopes[k]})", "#{funders_paginable_templates_path(1)}?scope=#{k}", class: 'template-scope', 'data-remote': true %></li>
            <% end %>
          <% end %>
        </ul></th></tr>
      <% end %>
      <tr>
        <th><%= _('Template Name') %>&nbsp;<%= paginable_sort_link('templates.title') %></th>
        <th><%= _('Funder') %>&nbsp;<%= paginable_sort_link('orgs.name') %></th>
        <th><%= _('Status') %></th>
        <th><%= _('Edited Date') %>&nbsp;<%= paginable_sort_link('templates.updated_at') %></th>
        <th></th>
      </tr>
    </thead>
    <tbody>
    <% scope.each do |template| %>
      <% customization = customizations[template.dmptemplate_id] %>
      <tr>
        <td>
          <%= "#{template.is_default? ? '* ' : ''}#{template.title}" %>
        </td>
          <td>
            <%= raw template.org.name %>
          </td>
          <td>
            <% if customization.present? %>
              <!-- If the original funder template has been changed -->
              <% if customization.updated_at < template.updated_at %>
                <%= _('Original funder template has changed!')%>
              <% elsif !template.published? %>
                <!-- The template does not have a live version -->
                <%= b_label = _('Funder version is unpublished') %>
              <% elsif customization.dirty? %>
                <%= _('You have unpublished changes') %>
              <% elsif customization.published? %>
                <%= _('Published') %>
              <% else %>
                <%= _('Unpublished') %>
              <% end %>
            <% else %>
              <%= _('Not Customised') %>
            <% end %>
          </td>
          <td>
            <% last_temp_updated = template.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">
                <% if !customization.present? %>
                  <li><%= link_to _('Customise'), customize_org_admin_template_path(template) %></li>
                <% else %>
                  <% if customization.updated_at < template.updated_at %>
                    <li><%= link_to _('Transfer customisation'), transfer_customization_org_admin_template_path(template) %></li>
                  <% else %>
                    <li><%= link_to _('Edit customisation'), edit_org_admin_template_path(id: customization.id, edit: "true", r: 'funder-templates') %></li>
                    <% if !customization.published? %>
                      <li><%= link_to _('Publish'), publish_org_admin_template_path(customization, r: 'funder-templates') %></li>
                    <% else %>
                      <li><%= link_to _('Unpublish'), unpublish_org_admin_template_path(customization, r: 'funder-templates') %></li>
                    <% end %>
                    <% if customization.plans.length <= 0 %>
                      <li>
                        <%= link_to _('Remove'), org_admin_template_path(id: customization.id, r: 'funder-templates'), 
                                    'data-method': 'delete', rel: 'nofollow',
                                    'data-confirm': _('Are you sure you want to remove your customization of "%{template_title}"?') % { template_title: customization.title} %>
                      </li>
                    <% end %>
                  <% end %>
                <% end %>
              </ul>
            </div>
         </td>
       </tr>
      <% end %>
    </tbody>
  </table>
</div>