Skip to content

Commit 477ba28

Browse files
authored
[PBNTR-740] Advanced Table - Add Table Props to Rails kit (#4107)
**What does this PR do?** A clear and concise description with your runway ticket url. [PBNTR-740](https://runway.powerhrg.com/backlog_items/PBNTR-740) gives the rails Advanced Table kit access to all of the props of the rails Table kit under the hood via an optional `table_props` prop. I tested various table props locally, such as: container: false, sticky: true, vertical_border: true, striped: true, disable_hover: true. The doc example matches the [React kit's Table Prop doc example](https://playbook.powerapp.cloud/kits/advanced_table/react#table-props) exhibiting container: false (so no outer top and side borders) and sticky: true (so sticky header happens when scrolling past table). `table_props` appears in the prop table at the bottom of the kit page. **Screenshots:** Screenshots to visualize your addition/change <img width="1131" alt="table props doc ex container sticky" src="https://github.com/user-attachments/assets/2ad85bdb-3a4d-4aec-9470-de1a19986730" /> <img width="888" alt="prop table" src="https://github.com/user-attachments/assets/9d2e1fcc-c62b-493c-81bd-34114e42146b" /> **How to test?** Steps to confirm the desired behavior: 1. Go to review env rails Advanced Table kit [Table Props doc example](https://pr4107.playbook.beta.hq.powerapp.cloud/kits/advanced_table#table-props). 2. See Table Props doc example - currently nearly matches the React Table Props doc ex. #### Checklist: - [x] **LABELS** Add a label: `enhancement`, `bug`, `improvement`, `new kit`, `deprecated`, or `breaking`. See [Changelog & Labels](https://github.com/powerhome/playbook/wiki/Changelog-&-Labels) for details. - [x] **DEPLOY** I have added the `milano` label to show I'm ready for a review. ~~- [ ] **TESTS** I have added test coverage to my code.~~
1 parent 71d0873 commit 477ba28

File tree

6 files changed

+38
-1
lines changed

6 files changed

+38
-1
lines changed

playbook/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<%= pb_content_tag do %>
2-
<%= pb_rails("table", props: { size: "sm", data_table: true, number_spacing:"tabular", responsive:"none", dark: dark }) do %>
2+
<%= pb_rails("table", props: { size: "sm", data_table: true, number_spacing:"tabular", responsive:"none", dark: dark }.merge(object.table_props)) do %>
33
<% if content.present? %>
44
<% content.presence %>
55
<% else %>

playbook/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class AdvancedTable < Playbook::KitBase
1313
prop :responsive, type: Playbook::Props::Enum,
1414
values: %w[none scroll],
1515
default: "none"
16+
prop :table_props, type: Playbook::Props::HashProp,
17+
default: {}
1618

1719
def classname
1820
generate_classname("pb_advanced_table", responsive_classname, separator: " ")
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<% column_definitions = [
2+
{
3+
accessor: "year",
4+
label: "Year",
5+
cellAccessors: ["quarter", "month", "day"],
6+
},
7+
{
8+
accessor: "newEnrollments",
9+
label: "New Enrollments",
10+
},
11+
{
12+
accessor: "scheduledMeetings",
13+
label: "Scheduled Meetings",
14+
},
15+
{
16+
accessor: "attendanceRate",
17+
label: "Attendance Rate",
18+
},
19+
{
20+
accessor: "completedClasses",
21+
label: "Completed Classes",
22+
},
23+
{
24+
accessor: "classCompletionRate",
25+
label: "Class Completion Rate",
26+
},
27+
{
28+
accessor: "graduatedStudents",
29+
label: "Graduated Students",
30+
}
31+
] %>
32+
33+
<%= pb_rails("advanced_table", props: { id: "table_props_table", table_data: @table_data, column_definitions: column_definitions, table_props: { container: false, sticky: true }}) %>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This kit uses the [Table kit](https://playbook.powerapp.cloud/kits/table) under the hood which comes with it's own set of props. If you want to apply certain Table props to that underlying kit, you can do so by using the optional `table_props` prop. This prop must be an object that contains valid Table props. For a full list of Table props, see [here](https://playbook.powerapp.cloud/kits/table).

playbook/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props.md renamed to playbook/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_table_props_react.md

File renamed without changes.

playbook/app/pb_kits/playbook/pb_advanced_table/docs/example.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ examples:
33
- advanced_table_beta: Default (Required Props)
44
- advanced_table_beta_subrow_headers: SubRow Headers
55
- advanced_table_collapsible_trail_rails: Collapsible Trail
6+
- advanced_table_table_props: Table Props
67
- advanced_table_beta_sort: Enable Sorting
78
- advanced_table_custom_cell_rails: Custom Components for Cells
89
- advanced_table_column_headers: Multi-Header Columns

0 commit comments

Comments
 (0)