From 39246da893a6946413960f925c660cd337afb8d5 Mon Sep 17 00:00:00 2001 From: Jason Denney Date: Thu, 27 Dec 2012 02:15:39 -0500 Subject: [PATCH] Added default times to log forms --- app/components/bike_logs.rb | 13 ++++++++----- app/components/user_logs.rb | 12 +++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/components/bike_logs.rb b/app/components/bike_logs.rb index 5c6ed44..8050e8b 100644 --- a/app/components/bike_logs.rb +++ b/app/components/bike_logs.rb @@ -1,4 +1,6 @@ class BikeLogs < Netzke::Basepack::Grid + + def configure(c) super @@ -13,10 +15,11 @@ class BikeLogs < Netzke::Basepack::Grid } c.columns = [ - { :name => :start_date, :format => "g:ia - D, M j - Y", :width => 165 }, + { :name => :start_date, :format => "g:ia - D, M j - Y", :width => 165, :default_value => Time.now.to_formatted_s(:db) }, + { :name => :end_date, :hidden => true, :default_value => Time.now.to_formatted_s(:db) }, { :name => :hours, :getter => lambda { |rec| (rec.end_date - rec.start_date)/3600 }, :sorting_scope => :sort_by_duration}, :description, - { :name => :bike_action__action}, + { :name => :bike_action__action, :text => 'Action'}, { :name => :created_at, :read_only => true}, { :name => :updated_at, :read_only => true} ] @@ -25,10 +28,10 @@ class BikeLogs < Netzke::Basepack::Grid def default_fields_for_forms [ - :start_date, - { :name => :end_date, :xtype => 'datetime', :value => Time.now.to_s }, + { :name => :start_date}, + { :name => :end_date}, :description, - { :name => :bike_action__action} + { :name => :bike_action__action, :field_label => 'Action'} ] end diff --git a/app/components/user_logs.rb b/app/components/user_logs.rb index 627bbe9..73df1d5 100644 --- a/app/components/user_logs.rb +++ b/app/components/user_logs.rb @@ -1,4 +1,5 @@ class UserLogs < Netzke::Basepack::Grid + def configure(c) super @@ -12,10 +13,11 @@ class UserLogs < Netzke::Basepack::Grid :log_action_type => 'ActsAsLoggable::UserAction' } c.columns = [ - { :name => :start_date, :format => "g:ia - D, M j - Y", :width => 165 }, + { :name => :start_date, :format => "g:ia - D, M j - Y", :width => 165, :default_value => Time.now.to_formatted_s(:db) }, + { :name => :end_date, :hidden => true, :default_value => Time.now.to_formatted_s(:db) }, { :name => :hours, :getter => lambda { |rec| (rec.end_date - rec.start_date)/3600 }, :sorting_scope => :sort_by_duration}, :description, - { :name => :user_action__action }, + { :name => :user_action__action, :text => 'Action' }, :created_at, :updated_at ] @@ -23,10 +25,10 @@ class UserLogs < Netzke::Basepack::Grid def default_fields_for_forms [ - :start_date, - :end_date, + { :name => :start_date}, + { :name => :end_date}, :description, - { :name => :user_action__action} + { :name => :user_action__action, :field_label => 'Action'} ] end