:ruby query = params[:query] params = request.params.except(:authenticity_token, :action, :controller, :utf8, :bulk_export, :_pjax) params.delete(:query) if params[:query].blank? params.delete(:sort_reverse) unless params[:sort_reverse] == 'true' sort_reverse = params[:sort_reverse] sort = params[:sort] params.delete(:sort) if params[:sort] == @model_config.list.sort_by.to_s export_action = RailsAdmin::Config::Actions.find(:export, { controller: self.controller, abstract_model: @abstract_model }) export_action = nil unless export_action && authorized?(export_action.authorization_key, @abstract_model) description = RailsAdmin.config(@abstract_model.model_name).description properties = @model_config.list.with(controller: self.controller, view: self, object: @abstract_model.model.new).visible_fields - content_for :contextual_tabs do = bulk_menu %style - properties.select{ |p| p.column_width.present? }.each do |property| = "#list th.#{property.css_class} { width: #{property.column_width}px; min-width: #{property.column_width}px; }" = "#list td.#{property.css_class} { max-width: #{property.column_width}px; }" #list .well.well-sm - if filterable_fields.present? || !@model_config.list.scopes.empty? .dropdown.pull-right{style: "margin-left:0.5em"} %button.btn.btn-primary.dropdown-toggle#dropdownFilters{type: "button", :"data-toggle" => "dropdown", :"aria-haspopup" => "true", :"aria-expanded" => "true"} = t('admin.misc.add_filter') %b.caret %ul.dropdown-menu#filters{:"aria-labelledby" => "dropdownFilters"} - if filterable_fields.present? - filterable_fields.each do |field| - field_options = case field.type - when :enum - options_for_select(field.with(object: @abstract_model.model.new).enum) - else - '' %li %a{href: '#', :"data-field-label" => field.label, :"data-field-name" => field.name, :"data-field-options" => field_options.html_safe, :"data-field-type" => field.type, :"data-field-value" => "", :"data-field-datetimepicker-format" => (field.try(:parser) && field.parser.to_momentjs)}= capitalize_first_letter(field.label) - if !@model_config.list.scopes.empty? %li %a{href: '#'}= "--" - @model_config.list.scopes.each_with_index do |scope, index| - scope = '_all' if scope.nil? %li{class: "#{'active' if scope.to_s == params[:scope] || (params[:scope].blank? && index == 0)}"} %a{href: index_path(params.merge(scope: scope, page: nil)), class: 'pjax'}= I18n.t("admin.scopes.#{@abstract_model.to_param}.#{scope}", default: I18n.t("admin.scopes.#{scope}", default: scope.to_s.titleize)) .dropdown.pull-right{style: "margin-left:0.5em"} %button.btn.btn-primary.dropdown-toggle#dropdownOrder{type: "button", :"data-toggle" => "dropdown", :"aria-haspopup" => "true", :"aria-expanded" => "true"} = t('admin.misc.order_by') %b.caret %ul.dropdown-menu{:"aria-labelledby" => "dropdownOrder"} - properties.each do |property| - selected = (sort == property.name.to_s) - if property.sortable - sort_location = index_path params.except('sort_reverse').except('page').merge(sort: property.name).merge(selected && sort_reverse != "true" ? {sort_reverse: "true"} : {}) - sort_direction = (sort_reverse == 'true' ? "sort-alpha-asc" : "sort-alpha-desc" if selected) %li %a{href:"#", class: "#{property.sortable && "header pjax" || nil} #{sort_direction if property.sortable && sort_direction} #{property.css_class} #{property.type_css_class}", :'data-href' => (property.sortable && sort_location), rel: "tooltip", title: "#{property.hint}"} %span{class: "fa fa-#{sort_direction}"} = capitalize_first_letter(property.label) -# -# Export filtered -# - if export_action -# .pull-right{style: "margin-left:0.5em"} -# %a.btn.btn-primary{href: export_path(params.except('set').except('page'))} -# = t("admin.export.found") -unless @objects.blank? .pull-right{style: "margin-left:0.5em"} %a.btn.btn-primary#select-all = t("admin.select.toggle") = form_tag(index_path(params.except(*%w[page f query])), method: :get, class: "pjax-form form-inline") do .input-group %input.form-control.input-small{name: "query", type: "search", value: query, placeholder: t("admin.misc.filter")} %span.input-group-btn %button.btn.btn-primary{type: 'submit', :'data-disable-with' => ' '.html_safe + t('admin.misc.refresh')} %i.icon-white.icon-refresh = t('admin.misc.refresh') %button#remove_filter.btn.btn-info{title: "Reset filters"} %i.icon-white.icon-remove %a.btn.btn-primary{href: export_path(params.except('set').except('page')), style: "margin-left:0.5em"} = t("admin.export.found") %hr.filters_box{style: "display:#{ordered_filters.empty? ? 'none' : 'block'}"} %span#filters_box = form_tag bulk_action_path(model_name: @abstract_model.to_param), method: :post, id: "bulk_form", class: "form" do = hidden_field_tag :bulk_action - if description.present? %p %strong= description - @objects.each do |object| = render partial: "card", locals: {object: object, properties: properties, sort: sort, sort_reverse: sort_reverse} - if @objects.respond_to?(:total_count) - total_count = @objects.total_count.to_i .row .col-md-6= paginate(@objects, theme: 'ra-twitter-bootstrap', remote: true) .row .col-md-6= link_to(t("admin.misc.show_all"), index_path(params.merge(all: true)), class: "show-all btn btn-default clearfix pjax") unless total_count > 100 || total_count <= @objects.to_a.size .clearfix.total-count= "#{total_count} #{@model_config.pluralize(total_count).downcase}" - else .clearfix.total-count= "#{@objects.size} #{@model_config.pluralize(@objects.size).downcase}" :javascript jQuery(function($) { #{ordered_filter_string} }); $("#select-all").click(_ => $("input[name='bulk_ids[]']").each((index, chkBox) => { console.log(chkBox); $(chkBox).prop('checked', !$(chkBox).is(':checked')); }));