<commit_before><%#
Copyright 2011-2019, The Trustees of Indiana University and Northwestern
  University.  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.

You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed
  under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  CONDITIONS OF ANY KIND, either express or implied. See the License for the
  specific language governing permissions and limitations under the License.
---  END LICENSE_HEADER BLOCK  ---
%>
<% @page_title = t('collections.title', :application_name => application_name) %>

<% unless @collections.empty? %>
<div class="row display-flex page-title-wrapper">
  <div class="col-xs-6">
    <h1 class="page-title">My Collections</h1>
  </div>
  <div class="col-xs-6 collection-btn">
    <%= button_tag("Create Collection", class: 'btn btn-primary btn-large', data: {toggle:"modal", target:"#new_collection"}) unless cannot? :create, Admin::Collection %>
  </div>
</div>


<div class="collections-list-wrapper">
  <table class='table table-striped'>
    <thead>
      <tr>
        <th>Title</th>
        <th>Items</th>
        <th>Managers</th>
        <th>Description</th>
        <th></th>
      </tr>
    </thead>
    <tbody>
      <% @collections.to_a.each do |collection| %>
      <tr>
        <td> <strong><%= link_to collection.name, admin_collection_path(collection.id) %></strong> </td>
        <td>
          <%= link_to(pluralize(collection.media_object_count, 'item'), search_catalog_path('f[collection_ssim][]' => collection.name)) %>
          <% if collection.unpublished_media_object_count > 0 %>
          <%=link_to("(#{collection.unpublished_media_object_count} unpublished)", search_catalog_path('f[collection_ssim][]' => collection.name, 'f[workflow_published_sim][]' => "Unpublished")) %>
          <% end %>
        </td>
        <td> <%= pluralize(collection.manager_count, 'manager') %> </td>
        <td> <%= collection.description&.truncate(100, separator: ' ') %> </td>
        <td class="text-right">
          <% if can?(:destroy, collection) %>
          <div class="btn-group">
            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true"
              aria-expanded="false">
              Action <span class="caret"></span>
            </button>
            <ul class="dropdown-menu dropdown-menu-right">
              <li><a href="#">View</a></li>
              <li><a href="#">Edit</a></li>
              <li><%= link_to('Delete', remove_admin_collection_path(collection.id)) %></li>
            </ul>
          </div>
          <% else %>
          &nbsp;
          <% end %>
        </td>
      </tr>
      <% end %>
    </tbody>
  </table>
</div>

<% else %>
<div class="hero-unit">
  <h2>You don't have any collections yet</h2>

  <% if can? :create, Admin::Collection %>
  <p>Would you like to create one?</p>
  <div class="whitespace"></div>
  <p>
    <%= button_tag("Create Collection", class: 'btn btn-primary btn-large', data: {toggle:"modal", target:"#new_collection"}) %>
  </p>
  <% else %>
  <p>You'll need to be assigned to one</p>
  <% end %>

</div>
<% end %>



<% @collection = Admin::Collection.new %>
<%= render "form", modal_title: "Create Collection" %>
<commit_msg>Only delete action for admin collection index<commit_after><%#
Copyright 2011-2019, The Trustees of Indiana University and Northwestern
  University.  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.

You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed
  under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  CONDITIONS OF ANY KIND, either express or implied. See the License for the
  specific language governing permissions and limitations under the License.
---  END LICENSE_HEADER BLOCK  ---
%>
<% @page_title = t('collections.title', :application_name => application_name) %>

<% unless @collections.empty? %>
<div class="row display-flex page-title-wrapper">
  <div class="col-xs-6">
    <h1 class="page-title">My Collections</h1>
  </div>
  <div class="col-xs-6 collection-btn">
    <%= button_tag("Create Collection", class: 'btn btn-primary btn-large', data: {toggle:"modal", target:"#new_collection"}) unless cannot? :create, Admin::Collection %>
  </div>
</div>


<div class="collections-list-wrapper">
  <table class='table table-striped'>
    <thead>
      <tr>
        <th>Title</th>
        <th>Items</th>
        <th>Managers</th>
        <th>Description</th>
        <th></th>
      </tr>
    </thead>
    <tbody>
      <% @collections.to_a.each do |collection| %>
      <tr>
        <td> <strong><%= link_to collection.name, admin_collection_path(collection.id) %></strong> </td>
        <td>
          <%= link_to(pluralize(collection.media_object_count, 'item'), search_catalog_path('f[collection_ssim][]' => collection.name)) %>
          <% if collection.unpublished_media_object_count > 0 %>
          <%=link_to("(#{collection.unpublished_media_object_count} unpublished)", search_catalog_path('f[collection_ssim][]' => collection.name, 'f[workflow_published_sim][]' => "Unpublished")) %>
          <% end %>
        </td>
        <td> <%= pluralize(collection.manager_count, 'manager') %> </td>
        <td> <%= collection.description&.truncate(100, separator: ' ') %> </td>
        <td class="text-right">
          <% if can?(:destroy, collection) %>
          <div class="btn-group">
            <%= link_to('Delete', remove_admin_collection_path(collection.id), class: 'btn btn-danger btn-sm')%>
          </div>
          <% else %>
          &nbsp;
          <% end %>
        </td>
      </tr>
      <% end %>
    </tbody>
  </table>
</div>

<% else %>
<div class="hero-unit">
  <h2>You don't have any collections yet</h2>

  <% if can? :create, Admin::Collection %>
  <p>Would you like to create one?</p>
  <div class="whitespace"></div>
  <p>
    <%= button_tag("Create Collection", class: 'btn btn-primary btn-large', data: {toggle:"modal", target:"#new_collection"}) %>
  </p>
  <% else %>
  <p>You'll need to be assigned to one</p>
  <% end %>

</div>
<% end %>



<% @collection = Admin::Collection.new %>
<%= render "form", modal_title: "Create Collection" %>

{'fraction_non_alphanumeric': 0.16714828897338402, 'fraction_numerical': 0.0066920152091254756, 'mean_word_length': 3.167300380228137, 'pattern_counts': {'":': 0, '<': 181, '<?xml version=': 0, '>': 191, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7546447', 'n_tokens_mistral': 2152, 'n_tokens_neox': 2002, 'n_words': 524}