From b67062fb327aaf972064b8ce2de686dd8849e0c6 Mon Sep 17 00:00:00 2001 From: "John N. Milner" Date: Thu, 23 May 2013 23:56:18 -0400 Subject: [PATCH 1/3] New view to show the current day's check ins --- app/components/app_tab_panel.rb | 3 ++- app/components/check_ins.rb | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 app/components/check_ins.rb diff --git a/app/components/app_tab_panel.rb b/app/components/app_tab_panel.rb index d888c04..af1262a 100644 --- a/app/components/app_tab_panel.rb +++ b/app/components/app_tab_panel.rb @@ -44,7 +44,8 @@ class AppTabPanel < Netzke::Basepack::TabPanel :logs, { layout: :fit, wrappedComponent: :user_role_joins, - title: "User Roles"} + title: "User Roles"}, + :check_ins ] end diff --git a/app/components/check_ins.rb b/app/components/check_ins.rb new file mode 100644 index 0000000..2320b77 --- /dev/null +++ b/app/components/check_ins.rb @@ -0,0 +1,21 @@ +class CheckIns < Netzke::Basepack::Grid + + def configure(c) + super + c.header = false + c.model = "ActsAsLoggable::Log" + c.scope = lambda { |rel| rel.where(:log_action_id => ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")). + where("start_date >= ?", Time.zone.now.beginning_of_day); + } + c.columns = [ + { :name => :logged_by, :getter => lambda{ |rec| + user = User.find_by_id(rec.logger_id) + user.nil? ? "" : "#{user.first_name} #{user.last_name}" + } + }, + { :name => "Status", :getter => lambda{ |rec| rec.start_date == rec.end_date ? "Checked In" : "Checked Out" } }, + :start_date, + :end_date, + ] + end +end From adeca0e08a16eb00af05c0fdb5478fc131b00a06 Mon Sep 17 00:00:00 2001 From: "John N. Milner" Date: Thu, 30 May 2013 19:30:40 -0400 Subject: [PATCH 2/3] Corrected Check Ins view to show the checked-in user, not the user who logged the check in --- app/components/check_ins.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/components/check_ins.rb b/app/components/check_ins.rb index 2320b77..4763c7e 100644 --- a/app/components/check_ins.rb +++ b/app/components/check_ins.rb @@ -8,8 +8,8 @@ class CheckIns < Netzke::Basepack::Grid where("start_date >= ?", Time.zone.now.beginning_of_day); } c.columns = [ - { :name => :logged_by, :getter => lambda{ |rec| - user = User.find_by_id(rec.logger_id) + { :name => :name, :getter => lambda{ |rec| + user = User.find_by_id(rec.loggable_id) user.nil? ? "" : "#{user.first_name} #{user.last_name}" } }, From b25a4520f923df76b0430688ef4e80793d056c82 Mon Sep 17 00:00:00 2001 From: "John N. Milner" Date: Thu, 30 May 2013 19:52:57 -0400 Subject: [PATCH 3/3] Correct log criteria for Check Ins view --- app/components/check_ins.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/components/check_ins.rb b/app/components/check_ins.rb index 4763c7e..22b8653 100644 --- a/app/components/check_ins.rb +++ b/app/components/check_ins.rb @@ -4,7 +4,9 @@ class CheckIns < Netzke::Basepack::Grid super c.header = false c.model = "ActsAsLoggable::Log" - c.scope = lambda { |rel| rel.where(:log_action_id => ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")). + c.scope = lambda { |rel| rel.where(:log_action_type => ::ActsAsLoggable::UserAction). + where(:loggable_type => "User"). + where(:log_action_id => ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")). where("start_date >= ?", Time.zone.now.beginning_of_day); } c.columns = [