<commit_before>defmodule ExAdmin.Theme.ActiveAdmin.Index do
  @moduledoc false
  import Kernel, except: [div: 2]
  import Xain
  import ExAdmin.Utils
  import ExAdmin.Index
  require Integer
  import ExAdmin.Helpers
  import ExAdmin.Gettext
  require Logger
  alias ExAdmin.Schema

  def wrap_index_grid(fun) do
    div ".box", style: "min-height: 400px" do
      fun.()
    end
  end

  def wrap_index_table(fun) do
    div ".box", style: "min-height: 400px" do
      fun.()
    end
  end

  def blank_slate_page(conn, %{defn: defn, label: label}) do
    div ".blank_slate_container" do
      span ".blank_slate" do
        unless is_nil(conn.params["q"]) and is_nil(conn.params["scope"]) do
          text (gettext"No %{label} found.", label: (humanize label))
        else
          text (gettext"There are no %{label} yet. ", label: (humanize label))
          if ExAdmin.has_action?(conn, defn, :new) do
            a (gettext "Create one"), href: admin_resource_path(conn, :new)
          end
        end
      end
    end
  end

  def paginated_collection_table(conn, opts) do
    resources = opts[:resources]
    selectable = opts[:selectable_column]
    columns = opts[:column_list]
    page = opts[:page]
    order = opts[:order]
    markup do
      div ".box-body.table-responsive.no-padding" do
        div ".paginated_collection" do
          table(".table-striped.index.table.index_table") do
            ExAdmin.Table.table_head(columns, %{selectable: true, path_prefix: opts[:href],
              sort: "desc", order: order, fields: opts[:fields], page: page,
              filter: build_filter_href("", conn.params["q"]),
              selectable_column: selectable})
            build_table_body(conn, resources, columns, %{selectable_column: selectable})
          end # table
        end
      end
      do_footer(conn, opts)
    end
  end

  def paginated_collection_grid(conn, opts) do
    columns = opts[:columns]
    page = opts[:page]
    div ".paginated_collection" do
      div ".paginated_collection_contents" do
        div ".index_content" do
          div ".index_as_grid.index" do
            table(".index_grid", border: "0", cellspacing: "0",
                cellpadding: "0", paginator: "true") do
              tbody do
                Enum.chunk(page.entries, columns, columns, [nil])
                |> Enum.map(fn(list) ->
                  tr do
                    Enum.map(list, fn(item) ->
                      td do
                        if item do
                          opts[:cell].(item)
                        end
                      end
                    end)
                  end
                end)
              end
            end
          end
        end # .index_content
      end
      do_footer(conn, opts)
    end
  end

  def do_footer(conn, opts) do
    page = opts[:page]
    div ".box-footer.clearfix" do
      opts[:href]
      |> build_scope_href(conn.params["scope"])
      |> build_order_href(opts[:order])
      |> build_filter_href(conn.params["q"])
      |> ExAdmin.Paginate.paginate(page.page_number, page.page_size, page.total_pages, opts[:count], opts[:name])
      download_links(conn)
    end
  end

  def handle_action_links(list, resource)  do
    base_class = "member_link"
    list
    |> Enum.reduce([], fn(item, acc) ->
      link = case item do
        :show ->
          a((gettext "View"), href: admin_resource_path(resource, :show), class: base_class <> " view_link")
        :edit ->
          a((gettext "Edit"), href: admin_resource_path(resource, :edit), class: base_class <> " edit_link")
        :destroy ->
          a((gettext "Delete"), href: admin_resource_path(resource, :destroy),
              class: base_class <> " delete_link", "data-confirm": confirm_message,
              "data-remote": true,
              "data-method": :delete, rel: :nofollow )
      end
      [link | acc]
    end)
    |> Enum.reverse
  end
<commit_msg>fix index page error for no :delete clause<commit_after>defmodule ExAdmin.Theme.ActiveAdmin.Index do
  @moduledoc false
  import Kernel, except: [div: 2]
  import Xain
  import ExAdmin.Utils
  import ExAdmin.Index
  require Integer
  import ExAdmin.Helpers
  import ExAdmin.Gettext
  require Logger
  alias ExAdmin.Schema

  def wrap_index_grid(fun) do
    div ".box", style: "min-height: 400px" do
      fun.()
    end
  end

  def wrap_index_table(fun) do
    div ".box", style: "min-height: 400px" do
      fun.()
    end
  end

  def blank_slate_page(conn, %{defn: defn, label: label}) do
    div ".blank_slate_container" do
      span ".blank_slate" do
        unless is_nil(conn.params["q"]) and is_nil(conn.params["scope"]) do
          text (gettext"No %{label} found.", label: (humanize label))
        else
          text (gettext"There are no %{label} yet. ", label: (humanize label))
          if ExAdmin.has_action?(conn, defn, :new) do
            a (gettext "Create one"), href: admin_resource_path(conn, :new)
          end
        end
      end
    end
  end

  def paginated_collection_table(conn, opts) do
    resources = opts[:resources]
    selectable = opts[:selectable_column]
    columns = opts[:column_list]
    page = opts[:page]
    order = opts[:order]
    markup do
      div ".box-body.table-responsive.no-padding" do
        div ".paginated_collection" do
          table(".table-striped.index.table.index_table") do
            ExAdmin.Table.table_head(columns, %{selectable: true, path_prefix: opts[:href],
              sort: "desc", order: order, fields: opts[:fields], page: page,
              filter: build_filter_href("", conn.params["q"]),
              selectable_column: selectable})
            build_table_body(conn, resources, columns, %{selectable_column: selectable})
          end # table
        end
      end
      do_footer(conn, opts)
    end
  end

  def paginated_collection_grid(conn, opts) do
    columns = opts[:columns]
    page = opts[:page]
    div ".paginated_collection" do
      div ".paginated_collection_contents" do
        div ".index_content" do
          div ".index_as_grid.index" do
            table(".index_grid", border: "0", cellspacing: "0",
                cellpadding: "0", paginator: "true") do
              tbody do
                Enum.chunk(page.entries, columns, columns, [nil])
                |> Enum.map(fn(list) ->
                  tr do
                    Enum.map(list, fn(item) ->
                      td do
                        if item do
                          opts[:cell].(item)
                        end
                      end
                    end)
                  end
                end)
              end
            end
          end
        end # .index_content
      end
      do_footer(conn, opts)
    end
  end

  def do_footer(conn, opts) do
    page = opts[:page]
    div ".box-footer.clearfix" do
      opts[:href]
      |> build_scope_href(conn.params["scope"])
      |> build_order_href(opts[:order])
      |> build_filter_href(conn.params["q"])
      |> ExAdmin.Paginate.paginate(page.page_number, page.page_size, page.total_pages, opts[:count], opts[:name])
      download_links(conn)
    end
  end

  def handle_action_links(list, resource)  do
    base_class = "member_link"
    list
    |> Enum.reduce([], fn(item, acc) ->
      link = case item do
        :show ->
          a((gettext "View"), href: admin_resource_path(resource, :show), class: base_class <> " view_link")
        :edit ->
          a((gettext "Edit"), href: admin_resource_path(resource, :edit), class: base_class <> " edit_link")
        :delete ->
          a((gettext "Delete"), href: admin_resource_path(resource, :destroy),
              class: base_class <> " delete_link", "data-confirm": confirm_message,
              "data-remote": true,
              "data-method": :delete, rel: :nofollow )
      end
      [link | acc]
    end)
    |> Enum.reverse
  end

{'fraction_non_alphanumeric': 0.11719342604298356, 'fraction_numerical': 0.0025284450063211127, 'mean_word_length': 2.0615325077399382, 'pattern_counts': {'":': 6, '<': 9, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3004708', 'n_tokens_mistral': 2439, 'n_tokens_neox': 2354, 'n_words': 597}