<commit_before>:ruby
  query = params[:query]
  params = request.params.except(:authenticity_token, :action, :controller, :model_name, :utf8, :bulk_export)
  sort = params[:sort]
  sort_reverse = params[:sort_reverse]
  properties = @model_config.list.visible_fields.map{|property| property.with(:view => self)}
  # columns paginate
  @filterable_fields = @model_config.list.fields.select(&:filterable?)
  @style, @other, properties = get_column_set(properties)
  @index = 0
  @ordered_filters = (params[:filters] || @model_config.list.filters).inject({}) { |memo, filter|
    field_name = filter.is_a?(Array) ? filter.first : filter
  (filter.is_a?(Array) ? filter.last : { (@index += 1) => { "value" => '' } }) .each do |index, filter_hash|
      memo[index] = { field_name => filter_hash } unless filter_hash['disabled']
    end
    memo
  }.to_a.sort_by(&:first)

  @ordered_filter_string = @ordered_filters.map do |duplet|
    filter_index = duplet[0]
    filter_for_field = duplet[1]
    filter_name = filter_for_field.keys.first
    filter_hash = filter_for_field.values.first
    field = @filterable_fields.find{ |field| field.name == filter_name.to_sym }

    field_options = case field.type
    when :enum
      CGI.escapeHTML options_for_select(field.with(:object => @abstract_model.model.new).enum, filter_hash['value']).gsub("\n", '')
    else
      ''
    end
    "$.filters.append('#{field.label}', '#{field.name}', '#{field.type}', '#{filter_hash['value']}', '#{filter_hash['operator']}', '#{field_options}', #{filter_index});"
  end.join if @ordered_filters

- head_style do
  - @style.each do |key, value|
    \.grid thead #{".#{key}"}{
    width: #{value[:width]}px;
    }

- head_javascript do
  :plain
    $j(document).ready(function($) {
      $(this).one("ajax:success", function(e, data, status, xhr) {
        $("#content").html(data);
      });

      #{@ordered_filter_string}
    });

- can_create      = authorized? :new,         @abstract_model
- can_export      = authorized? :export,      @abstract_model
- can_delete      = authorized? :delete,      @abstract_model
- can_see_history = authorized? :see_history, @abstract_model
- can_bulk_action = can_export || can_delete


#block-tables.block
  = breadcrumbs_for :list, @abstract_model

  .content
    .content-header
      .control
        %span(style="margin: 3px 6px")
          %select#filter_select.small-uniform
            %option{:value => ""}= t('admin.list.add_filter')+"..."
            - @filterable_fields.each do |field|
              - field_options = case field.type
              - when :enum
                - CGI.escapeHTML options_for_select(field.with(:object => @abstract_model.model.new).enum).gsub("\n", '')
              - else
                - ''
              %option{"data-field-label" => field.label, "data-field-name" => field.name, "data-field-options" => field_options, "data-field-type" => field.type, "data-field-value" => ""}= field.label

        - if can_create
          = action_button new_path, t("admin.list.add_new"), :add

        - if can_delete
          = action_button '#', t("admin.list.delete_selected"), :cross, :onclick => "$j('#bulk_action').val('delete'); $j('#bulk_form').submit(); return false;"

        = form_tag(list_post_path(params.merge(:model_name => @abstract_model.to_param).except(*%w[page filters query])), :method => :post, :remote => true, :class => "form", :style => "display:inline") do
          %span.search
            %input#search.search_box{:name => "query", :type => "text", :value => query, :placeholder => "#{t("admin.list.search")}"}
            %input.search_submit{:type => "submit", :value => ""}
          #filters_box
      %h2.title= @page_name
    .inner
      = render(:partial => 'layouts/rails_admin/flash', :locals => {:flash => flash})
      = form_tag bulk_action_path(:model_name => @abstract_model.to_param), :method => :post, :id => "bulk_form", :class => "form" do
        = hidden_field_tag :bulk_action
        %table.table.grid
          %thead
            %tr
              %th.first
                - if can_bulk_action
                  %input.checkbox.toggle{:type => "checkbox"}
              %th.other.left{ :style => "#{'display: none' if @other.include?("left")}" }...
              - properties.each do |property|
                - property_name = property.name
                - property_pretty_name = property.label
                - selected = sort == property_name.to_s
                %th{:class => "#{property.css_class} #{selected ? "selected" : nil}"}
                  - if property.sortable
                    - sort_location = list_path(params.merge(:model_name => @abstract_model.to_param, :sort => property_name).except("sort_reverse").merge(selected && sort_reverse != "true" ? {:sort_reverse => "true"} : {:sort_reverse => "false"}))
                    - sort_direction = selected ? (sort_reverse == 'true' ? "ascending" : "descending") : nil
                    = link_to(property_pretty_name, sort_location, :class => sort_direction, :remote => true)
                  - else
                    = property_pretty_name
              %th.other.right{ :style => "#{'display: none' if @other.include?("right")}" }...

              %th.last

          %tbody
            - @objects.each do |object|
              - can_show   = authorized? :show,   @abstract_model, object
              - can_edit   = authorized? :edit,   @abstract_model, object
              - can_delete = authorized? :delete, @abstract_model, object
              - edit_path   = edit_path(  :model_name => @abstract_model.to_param, :id => object.id) if can_edit
              - show_path   = show_path(  :model_name => @abstract_model.to_param, :id => object.id) if can_show
              - delete_path = delete_path(:model_name => @abstract_model.to_param, :id => object.id) if can_delete
              - row_class = "#{cycle("odd", "even")}#{" link" if can_edit}"

              %tr{:class => row_class, :"data-link" => can_show ? show_path : (can_edit ? edit_path : nil)}
                %td.action.select
                  - if can_bulk_action
                    = check_box_tag "bulk_ids[]", object.id, false, :id => "bulk_ids_#{object.id}", :class => "checkbox"
                - other_left = list_path(params.except("set").merge(:model_name => @abstract_model.to_param, :set => params[:set].to_i - 1))
                %td.other.left{ :style => "#{'display: none' if @other.include?("left")}" }= link_to "...", other_left, :remote => true
                - properties.map{|property| property.bind(:object, object)}.each do |property|
                  %td{:class => "#{property.css_class}"}= property.pretty_value
                - other_right = list_path(params.except("set").merge(:model_name => @abstract_model.to_param, :set => params[:set].to_i + 1))
                %td.other.right{ :style => "#{'display: none' if @other.include?("right")}" }= link_to "...", other_right, :remote => true
                %td.last
                  = action_icon(show_path,   :show,  t("admin.list.show_action"))   if can_show
                  = action_icon(edit_path,   :edit,  t("admin.list.edit_action"))   if can_edit
                  = action_icon(delete_path, :cross, t("admin.list.delete_action")) if can_delete

        .pagination
          - if @page_count.to_i > 1
            = paginate(@current_page, @page_count, :url => params).html_safe
          - if @record_count.to_i <= 100 && @page_count.to_i > 1
            = link_to(t("admin.list.show_all"), list_path(params.merge(:model_name => @abstract_model.to_param, :all => true, :class => "showall")), :method => :get, :remote => true)
        .left(style="white-space: nowrap; padding-top:0.7em;")
          = @record_count
          = @model_config.abstract_model.model.model_name.human(:count => @record_count, :default => @record_count != 1 ? @model_config.label.downcase.pluralize : @model_config.label.downcase)

        .columns.wat-cf
          .column.right
            - if can_export
              = action_button export_path(params.except("page")), t("admin.list.export_action"), :pdf, :method => :post
              = action_button '#', t("admin.list.export_selected"), :pdf, :onclick => "$j('#bulk_action').val('export'); $j('#bulk_form').submit(); return false;"
            - if can_see_history
              = action_button history_model_path, t("admin.history.name"), :'calendar-hover'
      .wat-cf

<commit_msg>refactoring<commit_after>:ruby
  query = params[:query]
  params = request.params.except(:authenticity_token, :action, :controller, :utf8, :bulk_export)
  sort = params[:sort]
  sort_reverse = params[:sort_reverse]
  properties = @model_config.list.visible_fields.map{|property| property.with(:view => self)}
  # columns paginate
  @filterable_fields = @model_config.list.fields.select(&:filterable?)
  @style, @other, properties = get_column_set(properties)
  @index = 0
  @ordered_filters = (params[:filters] || @model_config.list.filters).inject({}) { |memo, filter|
    field_name = filter.is_a?(Array) ? filter.first : filter
  (filter.is_a?(Array) ? filter.last : { (@index += 1) => { "value" => '' } }) .each do |index, filter_hash|
      memo[index] = { field_name => filter_hash } unless filter_hash['disabled']
    end
    memo
  }.to_a.sort_by(&:first)

  @ordered_filter_string = @ordered_filters.map do |duplet|
    filter_index = duplet[0]
    filter_for_field = duplet[1]
    filter_name = filter_for_field.keys.first
    filter_hash = filter_for_field.values.first
    field = @filterable_fields.find{ |field| field.name == filter_name.to_sym }

    field_options = case field.type
    when :enum
      CGI.escapeHTML options_for_select(field.with(:object => @abstract_model.model.new).enum, filter_hash['value']).gsub("\n", '')
    else
      ''
    end
    "$.filters.append('#{field.label}', '#{field.name}', '#{field.type}', '#{filter_hash['value']}', '#{filter_hash['operator']}', '#{field_options}', #{filter_index});"
  end.join if @ordered_filters

- head_style do
  - @style.each do |key, value|
    \.grid thead #{".#{key}"}{
    width: #{value[:width]}px;
    }

- head_javascript do
  :plain
    $j(document).ready(function($) {
      $(this).one("ajax:success", function(e, data, status, xhr) {
        $("#content").html(data);
      });

      #{@ordered_filter_string}
    });

- can_create      = authorized? :new,         @abstract_model
- can_export      = authorized? :export,      @abstract_model
- can_delete      = authorized? :delete,      @abstract_model
- can_see_history = authorized? :see_history, @abstract_model
- can_bulk_action = can_export || can_delete
- show_label    = t("admin.list.show_action")
- delete_label  = t("admin.list.delete_action")
- edit_label    = t("admin.list.edit_action")

#block-tables.block
  = breadcrumbs_for :list, @abstract_model

  .content
    .content-header
      .control
        %span(style="margin: 3px 6px")
          %select#filter_select.small-uniform
            %option{:value => ""}= t('admin.list.add_filter') + "..."
            - @filterable_fields.each do |field|
              - field_options = case field.type
              - when :enum
                - CGI.escapeHTML options_for_select(field.with(:object => @abstract_model.model.new).enum).gsub("\n", '')
              - else
                - ''
              %option{"data-field-label" => field.label, "data-field-name" => field.name, "data-field-options" => field_options, "data-field-type" => field.type, "data-field-value" => ""}= field.label

        - if can_create
          = action_button new_path, t("admin.list.add_new"), :add

        - if can_delete
          = action_button '#', t("admin.list.delete_selected"), :cross, :onclick => "$j('#bulk_action').val('delete'); $j('#bulk_form').submit(); return false;"

        = form_tag(list_post_path(params.except(*%w[page filters query])), :method => :post, :remote => true, :class => "form", :style => "display:inline") do
          %span.search
            %input#search.search_box{:name => "query", :type => "text", :value => query, :placeholder => "#{t("admin.list.search")}"}
            %input.search_submit{:type => "submit", :value => ""}
          #filters_box
      %h2.title= @page_name
    .inner
      = render(:partial => 'layouts/rails_admin/flash', :locals => {:flash => flash})
      = form_tag bulk_action_path(:model_name => @abstract_model.to_param), :method => :post, :id => "bulk_form", :class => "form" do
        = hidden_field_tag :bulk_action
        %table.table.grid
          %thead
            %tr
              %th.first
                - if can_bulk_action
                  %input.checkbox.toggle{:type => "checkbox"}
              %th.other.left{ :style => "#{'display: none' if @other.include?("left")}" }...
              - properties.each do |property|
                - property_name = property.name
                - property_pretty_name = property.label
                - selected = sort == property_name.to_s
                %th{:class => "#{property.css_class} #{selected ? "selected" : nil}"}
                  - if property.sortable
                    - sort_location = list_path params.merge(:sort => property_name, :sort_reverse => (selected && sort_reverse != 'true') ? 'true' : 'false')
                    - sort_direction = selected ? (sort_reverse == 'true' ? "ascending" : "descending") : nil
                    = link_to(property_pretty_name, sort_location, :class => sort_direction, :remote => true)
                  - else
                    = property_pretty_name
              %th.other.right{ :style => "#{'display: none' if @other.include?("right")}" }...

              %th.last

          %tbody
            - @objects.each do |object|
              - can_show   = authorized? :show,   @abstract_model, object
              - can_edit   = authorized? :edit,   @abstract_model, object
              - can_delete = authorized? :delete, @abstract_model, object
              - edit_path   = edit_path(  :model_name => @abstract_model.to_param, :id => object.id) if can_edit
              - show_path   = show_path(  :model_name => @abstract_model.to_param, :id => object.id) if can_show
              - delete_path = delete_path(:model_name => @abstract_model.to_param, :id => object.id) if can_delete
              - row_class = cycle("odd", "even") + ((can_show || can_edit) ? ' link' : '')

              %tr{:class => row_class, :"data-link" => can_show && show_path || can_edit && edit_path || ''}
                %td.action.select
                  - if can_bulk_action
                    = check_box_tag "bulk_ids[]", object.id, false, :id => "bulk_ids_#{object.id}", :class => "checkbox"
                - other_left = list_path(params.merge(:set => (params[:set].to_i - 1)))
                %td.other.left{ :style => "#{'display: none' if @other.include?("left")}" }= link_to "...", other_left, :remote => true
                - properties.map{ |property| property.bind(:object, object) }.each do |property|
                  %td{:class => "#{property.css_class}"}= property.pretty_value
                - other_right = list_path(params.merge(:set => (params[:set].to_i + 1)))
                %td.other.right{ :style => "#{'display: none' if @other.include?("right")}" }= link_to "...", other_right, :remote => true
                %td.last
                  = action_icon(show_path,   :show,  show_label)   if can_show
                  = action_icon(edit_path,   :edit,  edit_label)   if can_edit
                  = action_icon(delete_path, :cross, delete_label) if can_delete
        .pagination
          - if @page_count.to_i > 1
            = paginate(@current_page, @page_count, :url => params).html_safe
          - if @record_count.to_i <= 100 && @page_count.to_i > 1
            = link_to(t("admin.list.show_all"), list_path(params.merge(:all => true)), :class => "showall", :method => :get, :remote => true)
        .left(style="white-space: nowrap; padding-top:0.7em;")
          = @record_count
          = @model_config.abstract_model.model.model_name.human(:count => @record_count, :default => @record_count != 1 ? @model_config.label.downcase.pluralize : @model_config.label.downcase)

        .columns.wat-cf
          .column.right
            - if can_export
              = action_button export_path(params.except("page")), t("admin.list.export_action"), :pdf, :method => :post
              = action_button '#', t("admin.list.export_selected"), :pdf, :onclick => "$j('#bulk_action').val('export'); $j('#bulk_form').submit(); return false;"
            - if can_see_history
              = action_button history_model_path, t("admin.history.name"), :'calendar-hover'
      .wat-cf
      
{'fraction_non_alphanumeric': 0.163456377840062, 'fraction_numerical': 0.002146818534200012, 'mean_word_length': 2.652798954476149, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 141, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '964051', 'n_tokens_mistral': 5302, 'n_tokens_neox': 5206, 'n_words': 952}