Sha256: 510e5b2ad40759a7d1ac5991daf2c24451c02fb4f4849bf3f22703f8b003fce1

Contents?: true

Size: 1.78 KB

Versions: 46

Compression:

Stored size: 1.78 KB

Contents

<%# Example sort method for demonstration purposes %>
<% if params["sort"] %>
  <% sort_param = params["sort"].gsub(/_(asc|desc)\z/, "") %>
  <% sort_direction = params["sort"].end_with?("_asc") ? 1 : -1 %>
  <% @table_data.sort! do |a, b|
    value_a = a[sort_param]
    value_b = b[sort_param]

    value_a = value_a.to_i if value_a.is_a?(String) && value_a.match?(/^\d+$/)
    value_b = value_b.to_i if value_b.is_a?(String) && value_b.match?(/^\d+$/)

    sort_direction * (value_a <=> value_b)
  end %>
<% end %>

<% 
  column_definitions = [
    {
      accessor: "year",
      label: "Year",
      cellAccessors: ["quarter", "month", "day"],
      sort_menu: [
        { item: "Year", link: "?sort=year_asc#table-sort", active: params["sort"] == "year_asc", direction: "asc" },
        { item: "Year", link: "?sort=year_desc#table-sort", active: params["sort"] == "year_desc", direction: "desc" }
      ],
    },
    {
      accessor: "newEnrollments",
      label: "New Enrollments",
    },
    {
      accessor: "scheduledMeetings",
      label: "Scheduled Meetings",
    },
    {
      accessor: "attendanceRate",
      label: "Attendance Rate",
    },
    {
      accessor: "completedClasses",
      label: "Completed Classes",
    },
    {
      accessor: "classCompletionRate",
      label: "Class Completion Rate",
    },
    {
      accessor: "graduatedStudents",
      label: "Graduated Students",
    }
  ]
%>

<%= pb_rails("advanced_table", props: { table_data: @table_data, column_definitions: column_definitions }) do %>
  <%= pb_rails("advanced_table/table_header", props: { column_definitions: column_definitions }) %>
  <%= pb_rails("advanced_table/table_body", props: { id: "beta_sort", table_data: @table_data, column_definitions: column_definitions, enable_toggle_expansion: "all" }) %>
<% end %>

Version data entries

46 entries across 46 versions & 2 rubygems

Version Path
playbook_ui-14.11.1 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.11.0.pre.rc.17 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.11.0.pre.rc.17 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.11.0 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.11.0.pre.rc.16 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.11.0.pre.rc.16 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.10.0.pre.alpha.play16825301 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.10.0.pre.alpha.play16825301 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.11.0.pre.rc.15 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.11.0.pre.rc.15 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.11.0.pre.rc.14 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.11.0.pre.rc.14 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.11.0.pre.rc.13 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.11.0.pre.rc.13 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.11.0.pre.rc.12 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.11.0.pre.rc.12 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5274 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.10.0.pre.alpha.PLAY1774timelinelabelstepspacing5274 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.10.0.pre.alpha.play1465attempt25272 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.10.0.pre.alpha.play1465attempt25272 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb