diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index e1192e4..eca156d 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -1,2 +1,31 @@ class DashboardController < ApplicationController + def index + joint_column = 'joint' + # Grab distinct values for dropdown filters + @available_joints = Joint.distinct.pluck(joint_column) + + # Fetch initial records + @records = filter_records + + respond_to do |format| + format.html # Renders app/views/dashboards/index.html.erb + format.json { render json: @records } # Returns filtered data as JSON for JS + end + end + + private + + def filter_records + records = Joint.all + records = records.where(joint: params[:joint]) if params[:joint].present? + records + end + + # old broken: def index + # old broken: @joint = Joint.distinct.pluck(:Joint) + # old broken: + # old broken: @records = Joint.all + # old broken: + # old broken: @records = @records.where(Joint: params[joint]) if params[:joint].present? + # old broken: end end diff --git a/app/models/joint.rb b/app/models/joint.rb index e4645c4..1e7e135 100644 --- a/app/models/joint.rb +++ b/app/models/joint.rb @@ -1,2 +1,5 @@ class Joint < ApplicationRecord + def readonly? + true + end end diff --git a/app/models/joints_info.rb b/app/models/joints_info.rb index c8ef247..eceaad6 100644 --- a/app/models/joints_info.rb +++ b/app/models/joints_info.rb @@ -1,2 +1,5 @@ class JointsInfo < ApplicationRecord + def readonly? + true + end end diff --git a/app/models/special_test.rb b/app/models/special_test.rb index 55ce1b6..6d1f5a9 100644 --- a/app/models/special_test.rb +++ b/app/models/special_test.rb @@ -1,2 +1,5 @@ class SpecialTest < ApplicationRecord + def readonly? + true + end end diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb new file mode 100644 index 0000000..6ef7f0e --- /dev/null +++ b/app/views/dashboard/index.html.erb @@ -0,0 +1,88 @@ +