Sha256: d4778ca336f1a81af746e57b201da3f2fe820fcf3a68d0a618f94a1fffb57c8b

Contents?: true

Size: 1.86 KB

Versions: 735

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

Version data entries

735 entries across 735 versions & 2 rubygems

Version Path
playbook_ui_docs-14.9.0.pre.rc.0 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.9.0.pre.rc.0 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.7.0.pre.alpha.dependabotnpmandyarnfloatinguireact026284532 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.7.0.pre.alpha.dependabotnpmandyarnfloatinguireact026284532 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.8.0 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.7.0.pre.alpha.revert3916revert3893PBNTR667railstypeaheadformintegration4523 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.7.0.pre.alpha.revert3916revert3893PBNTR667railstypeaheadformintegration4523 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.8.0.pre.rc.8 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.8.0.pre.rc.8 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.8.0.pre.rc.7 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.8.0.pre.rc.7 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.8.0.pre.rc.6 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.8.0.pre.rc.6 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.8.0.pre.rc.5 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.8.0.pre.rc.5 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.8.0.pre.rc.4 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.8.0.pre.rc.4 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.8.0.pre.rc.3 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui-14.8.0.pre.rc.3 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb
playbook_ui_docs-14.7.0.pre.alpha.PBNTR637quickpickdefaultdate4492 app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb