-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added logic to account for columns in column_definitions
- Loading branch information
Showing
7 changed files
with
134 additions
and
14 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
playbook/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<% column_definitions = [ | ||
{ | ||
accessor: "year", | ||
label: "Year", | ||
cellAccessors: ["quarter", "month", "day"], | ||
}, | ||
{ | ||
label: "Enrollment Data", | ||
columns: [ | ||
{ | ||
accessor: "newEnrollments", | ||
label: "New Enrollments", | ||
}, | ||
{ | ||
accessor: "scheduledMeetings", | ||
label: "Scheduled Meetings", | ||
}, | ||
], | ||
}, | ||
{ | ||
label: "Performance Data", | ||
columns: [ | ||
{ | ||
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: { id: "beta_table_with_headers", table_data: @table_data, column_definitions: column_definitions }) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 19 additions & 13 deletions
32
playbook/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
<%= pb_content_tag do %> | ||
<%= pb_rails("table/table_row", props: { tag: "div" }) do %> | ||
<% object.column_definitions.each_with_index do |item, index| %> | ||
<%= pb_rails("table/table_header", props: { tag: "div", id: item[:accessor], classname: object.th_classname, sort_menu: item[:sort_menu] }) do %> | ||
<%= pb_rails("flex", props:{ align: "center", justify: index.zero? ? "start" : "end", text_align: "end" }) do %> | ||
<% if index.zero? && (object.enable_toggle_expansion == "header" || object.enable_toggle_expansion == "all") %> | ||
<button | ||
class="gray-icon toggle-all-icon" | ||
onclick="expandAllRows(this); event.preventDefault();"> | ||
<%= pb_rails("icon", props: { icon: "arrows-from-line", cursor: "pointer", fixed_width: true, padding_right: "xs" }) %> | ||
</button> | ||
<% end %> | ||
<%= item[:label] %> | ||
<% object.header_rows.each_with_index do |header_row, row_index| %> | ||
<%= pb_rails("table/table_row", props: { tag: "div" }) do %> | ||
<% header_row.each_with_index do |cell, cell_index| %> | ||
|
||
<% header_id = cell[:accessor].present? ? cell[:accessor] : "header_#{row_index}_#{cell_index}" %> | ||
|
||
<%= pb_rails("table/table_header", props: { tag: "div", id: header_id, classname: object.th_classname, sort_menu: cell[:accessor] ? cell[:sort_menu] : nil }) do %> | ||
<%= pb_rails("flex", props:{ align: "center", justify: row_index.zero? ? "start" : "end", text_align: "end" }) do %> | ||
<% if cell_index.zero? && (object.enable_toggle_expansion == "header" || object.enable_toggle_expansion == "all") %> | ||
<button | ||
class="gray-icon toggle-all-icon" | ||
onclick="expandAllRows(this); event.preventDefault();"> | ||
<%= pb_rails("icon", props: { icon: "arrows-from-line", cursor: "pointer", fixed_width: true, padding_right: "xs" }) %> | ||
</button> | ||
<% end %> | ||
<%= cell[:label] %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
|
||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
playbook/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters