Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PBNTR-861] Advanced Table: Selectable Rows for Rails #4408

Merged
merged 6 commits into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"year": "2021",
"id": "1",
"newEnrollments": "20",
"scheduledMeetings": "10",
"attendanceRate": "51%",
"completedClasses": "3",
"classCompletionRate": "33%",
"graduatedStudents": "19"
},
{
"year": "2022",
"id": "8",
"newEnrollments": "25",
"scheduledMeetings": "17",
"attendanceRate": "75%",
"completedClasses": "5",
"classCompletionRate": "45%",
"graduatedStudents": "32"
},
{
"year": "2023",
"id": "15",
"newEnrollments": "10",
"scheduledMeetings": "15",
"attendanceRate": "65%",
"completedClasses": "4",
"classCompletionRate": "49%",
"graduatedStudents": "29"
},
{
"year": "2024",
"id": "14",
"newEnrollments": "15",
"scheduledMeetings": "34",
"attendanceRate": "32%",
"completedClasses": "6",
"classCompletionRate": "67%",
"graduatedStudents": "65"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,299 @@
[
{
"year": "2021",
"id": "1",
"quarter": null,
"month": null,
"day": null,
"newEnrollments": "20",
"scheduledMeetings": "10",
"attendanceRate": "51%",
"completedClasses": "3",
"classCompletionRate": "33%",
"graduatedStudents": "19",
"children": [
{
"year": "2021",
"id": "2",
"quarter": "Q1",
"month": null,
"day": null,
"newEnrollments": "2",
"scheduledMeetings": "35",
"attendanceRate": "32%",
"completedClasses": "15",
"classCompletionRate": "52%",
"graduatedStudents": "36",
"children": [
{
"year": "2021",
"id": "3",
"quarter": "Q1",
"month": "January",
"day": null,
"newEnrollments": "16",
"scheduledMeetings": "20",
"attendanceRate": "11%",
"completedClasses": "13",
"classCompletionRate": "47%",
"graduatedStudents": "28",
"children": [
{
"year": "2021",
"id": "4",
"quarter": "Q1",
"month": "January",
"day": "10",
"newEnrollments": "34",
"scheduledMeetings": "28",
"attendanceRate": "97%",
"completedClasses": "20",
"classCompletionRate": "15%",
"graduatedStudents": "17"
},
{
"year": "2021",
"id": "5",
"quarter": "Q1",
"month": "January",
"day": "20",
"newEnrollments": "43",
"scheduledMeetings": "23",
"attendanceRate": "66%",
"completedClasses": "26",
"classCompletionRate": "47%",
"graduatedStudents": "9"
}
]
},
{
"year": "2021",
"id": "6",
"quarter": "Q1",
"month": "February",
"day": null,
"newEnrollments": "20",
"scheduledMeetings": "41",
"attendanceRate": "95%",
"completedClasses": "26",
"classCompletionRate": "83%",
"graduatedStudents": "43",
"children": [
{
"year": "2021",
"id": "7",
"quarter": "Q1",
"month": "February",
"day": "15",
"newEnrollments": "19",
"scheduledMeetings": "35",
"attendanceRate": "69%",
"completedClasses": "8",
"classCompletionRate": "75%",
"graduatedStudents": "23"
}
]
}
]
}
]
},
{
"year": "2022",
"id": "8",
"quarter": null,
"month": null,
"day": null,
"newEnrollments": "25",
"scheduledMeetings": "17",
"attendanceRate": "75%",
"completedClasses": "5",
"classCompletionRate": "45%",
"graduatedStudents": "32",
"children": [
{
"year": "2022",
"id": "9",
"quarter": "Q1",
"month": null,
"day": null,
"newEnrollments": "2",
"scheduledMeetings": "35",
"attendanceRate": "32%",
"completedClasses": "15",
"classCompletionRate": "52%",
"graduatedStudents": "36",
"children": [
{
"year": "2022",
"id": "10",
"quarter": "Q1",
"month": "January",
"day": null,
"newEnrollments": "16",
"scheduledMeetings": "20",
"attendanceRate": "11%",
"completedClasses": "13",
"classCompletionRate": "47%",
"graduatedStudents": "28",
"children": [
{
"year": "2022",
"id": "11",
"quarter": "Q1",
"month": "January",
"day": "15",
"newEnrollments": "34",
"scheduledMeetings": "28",
"attendanceRate": "97%",
"completedClasses": "20",
"classCompletionRate": "15%",
"graduatedStudents": "17"
},
{
"year": "2022",
"id": "12",
"quarter": "Q1",
"month": "January",
"day": "25",
"newEnrollments": "43",
"scheduledMeetings": "23",
"attendanceRate": "66%",
"completedClasses": "26",
"classCompletionRate": "47%",
"graduatedStudents": "9"
}
]
},
{
"year": "2022",
"id": "13",
"quarter": "Q1",
"month": "May",
"day": null,
"newEnrollments": "20",
"scheduledMeetings": "41",
"attendanceRate": "95%",
"completedClasses": "26",
"classCompletionRate": "83%",
"graduatedStudents": "43",
"children": [
{
"year": "2022",
"id": "14",
"quarter": "Q1",
"month": "May",
"day": "2",
"newEnrollments": "19",
"scheduledMeetings": "35",
"attendanceRate": "69%",
"completedClasses": "8",
"classCompletionRate": "75%",
"graduatedStudents": "23"
}
]
}
]
}
]
},
{
"year": "2023",
"id": "15",
"quarter": null,
"month": null,
"day": null,
"newEnrollments": "10",
"scheduledMeetings": "15",
"attendanceRate": "65%",
"completedClasses": "4",
"classCompletionRate": "49%",
"graduatedStudents": "29",
"children": [
{
"year": "2023",
"id": "16",
"quarter": "Q1",
"month": null,
"day": null,
"newEnrollments": "2",
"scheduledMeetings": "35",
"attendanceRate": "32%",
"completedClasses": "15",
"classCompletionRate": "52%",
"graduatedStudents": "36",
"children": [
{
"year": "2023",
"id": "17",
"quarter": "Q1",
"month": "March",
"day": null,
"newEnrollments": "16",
"scheduledMeetings": "20",
"attendanceRate": "11%",
"completedClasses": "13",
"classCompletionRate": "47%",
"graduatedStudents": "28",
"children": [
{
"year": "2023",
"id": "18",
"quarter": "Q1",
"month": "March",
"day": "10",
"newEnrollments": "34",
"scheduledMeetings": "28",
"attendanceRate": "97%",
"completedClasses": "20",
"classCompletionRate": "15%",
"graduatedStudents": "17"
},
{
"year": "2023",
"id": "19",
"quarter": "Q1",
"month": "March",
"day": "11",
"newEnrollments": "43",
"scheduledMeetings": "23",
"attendanceRate": "66%",
"completedClasses": "26",
"classCompletionRate": "47%",
"graduatedStudents": "9"
}
]
},
{
"year": "2023",
"id": "20",
"quarter": "Q1",
"month": "April",
"day": null,
"newEnrollments": "20",
"scheduledMeetings": "41",
"attendanceRate": "95%",
"completedClasses": "26",
"classCompletionRate": "83%",
"graduatedStudents": "43",
"children": [
{
"year": "2023",
"id": "21",
"quarter": "Q1",
"month": "April",
"day": "15",
"newEnrollments": "19",
"scheduledMeetings": "35",
"attendanceRate": "69%",
"completedClasses": "8",
"classCompletionRate": "75%",
"graduatedStudents": "23"
}
]
}
]
}
]
}
]
16 changes: 16 additions & 0 deletions playbook-website/app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,17 @@ def kits
@type = params[:type]
@users = Array.new(9) { Faker::Name.name }.paginate(page: params[:page], per_page: 2)
@table_data = advanced_table_mock_data
@table_data_with_id = advanced_table_mock_data_with_id
@table_data_no_subrows = advanced_table_mock_data_no_subrows
end

def kit_category_show_rails
params[:type] ||= "rails"
@type = params[:type]
@users = Array.new(9) { Faker::Name.name }.paginate(page: params[:page], per_page: 2)
@table_data = advanced_table_mock_data
@table_data_with_id = advanced_table_mock_data_with_id
@table_data_no_subrows = advanced_table_mock_data_no_subrows
render template: "pages/kit_category_show"
end

Expand All @@ -143,6 +147,8 @@ def kit_show_rails
@type = "rails"
@users = Array.new(9) { Faker::Name.name }.paginate(page: params[:page], per_page: 2)
@table_data = advanced_table_mock_data if @kit == "advanced_table"
@table_data_with_id = advanced_table_mock_data_with_id if @kit == "advanced_table"
@table_data_no_subrows = advanced_table_mock_data_no_subrows if @kit == "advanced_table"
render "pages/kit_show"
end

Expand Down Expand Up @@ -507,6 +513,16 @@ def advanced_table_mock_data
JSON.parse(advanced_table_mock_data, object_class: OpenStruct)
end

def advanced_table_mock_data_with_id
advanced_table_mock_data_with_id = File.read(Rails.root.join("app/components/playbook/pb_docs/advanced_table_mock_data_with_id.json"))
JSON.parse(advanced_table_mock_data_with_id, object_class: OpenStruct)
end

def advanced_table_mock_data_no_subrows
advanced_table_mock_data_no_subrows = File.read(Rails.root.join("app/components/playbook/pb_docs/advanced_table_mock_data_no_subrows.json"))
JSON.parse(advanced_table_mock_data_no_subrows, object_class: OpenStruct)
end

def page_not_found
redirect_to root_path, flash: { error: "The kit (#{params[:name]}) was not found." }
end
Expand Down
Loading
Loading