Sha256: 8098c23e4bdc1541d63308e02b942a7e52eb79034b00a38763de1a8b41ace7c9

Contents?: true

Size: 1.86 KB

Versions: 19

Compression:

Stored size: 1.86 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",
    }
  ]

  subrow_headers = ["Quarter", "Month", "Day"]
%>

<%= 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, subrow_headers: subrow_headers, enable_toggle_expansion: "all" }) %>
<% end %>

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
playbook_ui-14.9.0 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.9.0.pre.rc.18 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.9.0.pre.rc.18 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.9.0.pre.rc.17 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.9.0.pre.rc.17 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.9.0.pre.rc.16 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.9.0.pre.rc.16 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.9.0.pre.rc.15 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.9.0.pre.rc.15 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.9.0.pre.rc.14 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.9.0.pre.rc.14 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.9.0.pre.rc.13 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.9.0.pre.rc.13 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.9.0.pre.rc.12 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.9.0.pre.rc.12 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.9.0.pre.rc.11 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.9.0.pre.rc.11 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.9.0.pre.rc.10 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.9.0.pre.rc.10 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb