From 18bb26a7f2f1dd83a3b5c01df2fd32839b5d7c84 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Thu, 24 Nov 2022 14:21:32 +0100 Subject: [PATCH] feat(team_account): add procedures count --- app/controllers/manager/team_accounts_controller.rb | 7 +++++++ app/dashboards/team_account_dashboard.rb | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/controllers/manager/team_accounts_controller.rb b/app/controllers/manager/team_accounts_controller.rb index 633bc2fa6..8999c80d0 100644 --- a/app/controllers/manager/team_accounts_controller.rb +++ b/app/controllers/manager/team_accounts_controller.rb @@ -7,6 +7,13 @@ module Manager .order(created_at: :asc) .page(params[:_page]) .per(@records_per_page) + + resources.each do |resource| + def resource.procedures_count + administrateur.procedures.with_discarded.count + end + end + page = Administrate::Page::Collection.new(dashboard) render locals: { diff --git a/app/dashboards/team_account_dashboard.rb b/app/dashboards/team_account_dashboard.rb index dd963ed2c..d392c8109 100644 --- a/app/dashboards/team_account_dashboard.rb +++ b/app/dashboards/team_account_dashboard.rb @@ -15,7 +15,8 @@ class TeamAccountDashboard < Administrate::BaseDashboard current_sign_in_at: Field::DateTime, last_sign_in_at: Field::DateTime, dossiers: Field::HasMany, - procedures: Field::HasMany + procedures: Field::HasMany, + procedures_count: Field::Number }.freeze # COLLECTION_ATTRIBUTES @@ -26,7 +27,8 @@ class TeamAccountDashboard < Administrate::BaseDashboard COLLECTION_ATTRIBUTES = [ :email, :last_sign_in_at, - :current_sign_in_at + :current_sign_in_at, + :procedures_count ].freeze # SHOW_PAGE_ATTRIBUTES