mirror of
https://github.com/fspc/BikeShed-1.git
synced 2026-09-16 08:31:36 -04:00
Almost usable, still a lot of work left
-Moved bikes to User model instead of profile -User can copy user log to a bike log with new actsasloggable -Added user stats -some css was messing up checkboxes, need to figure out which stylesheet was doing that
This commit is contained in:
@@ -11,7 +11,9 @@ class BikeLogs < Netzke::Basepack::Grid
|
||||
c.strong_default_attrs = {
|
||||
:loggable_type => 'Bike',
|
||||
:loggable_id => session[:selected_bike_id],
|
||||
:log_action_type => 'ActsAsLoggable::BikeAction'
|
||||
:log_action_type => 'ActsAsLoggable::BikeAction',
|
||||
:logger_type => 'User',
|
||||
:logger_id => controller.current_user.id
|
||||
}
|
||||
|
||||
c.columns = [
|
||||
@@ -21,7 +23,12 @@ class BikeLogs < Netzke::Basepack::Grid
|
||||
:description,
|
||||
{ :name => :bike_action__action, :text => 'Action'},
|
||||
{ :name => :created_at, :read_only => true},
|
||||
{ :name => :updated_at, :read_only => true}
|
||||
{ :name => :updated_at, :read_only => true},
|
||||
{ :name => :logged_by, :getter => lambda{ |rec|
|
||||
user = User.find_by_id(rec.logger_id)
|
||||
user.nil? ? "" : "#{user.first_name} #{user.last_name}"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
if controller.current_user.user?
|
||||
@@ -36,15 +43,17 @@ class BikeLogs < Netzke::Basepack::Grid
|
||||
[
|
||||
{ :name => :start_date},
|
||||
{ :name => :end_date},
|
||||
:description,
|
||||
{ :name => :description},
|
||||
{ :name => :bike_action__action, :field_label => 'Action'}
|
||||
]
|
||||
end
|
||||
|
||||
=begin
|
||||
#override with nil to remove actions
|
||||
def default_bbar
|
||||
bbar = [ :search ]
|
||||
bbar.concat [ :apply, :add_in_form ] if not controller.current_user.user?
|
||||
bbar
|
||||
end
|
||||
=end
|
||||
end
|
||||
|
||||
@@ -22,13 +22,18 @@ class Bikes < Netzke::Basepack::Grid
|
||||
:wheel_size,
|
||||
:value,
|
||||
{ :name => :bike_condition__condition, :text => 'Condition'},
|
||||
{ :name => :bike_status__status, :text => 'Status'}
|
||||
{ :name => :bike_status__status, :text => 'Status'},
|
||||
{ :name => :owner, :getter => lambda { |rec|
|
||||
user = rec.owner
|
||||
user.nil? ? "" : "#{user.first_name} #{user.last_name}"
|
||||
}
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
#override with nil to remove actions
|
||||
def default_bbar
|
||||
[ :apply, :add_in_form ]
|
||||
[ :apply, :add_in_form, :search ]
|
||||
end
|
||||
|
||||
js_configure do |c|
|
||||
|
||||
@@ -6,7 +6,10 @@ class UserLogs < Netzke::Basepack::Grid
|
||||
#all users
|
||||
user_log_strong_default_attrs = {
|
||||
:loggable_type => 'User',
|
||||
:log_action_type => 'ActsAsLoggable::UserAction'
|
||||
:log_action_type => 'ActsAsLoggable::UserAction',
|
||||
:copy_type => 'Bike',
|
||||
:copy_action_type => 'ActsAsLoggable::BikeAction',
|
||||
:copy_action_id => 3
|
||||
}
|
||||
|
||||
#just users
|
||||
@@ -40,11 +43,21 @@ class UserLogs < Netzke::Basepack::Grid
|
||||
end
|
||||
|
||||
def default_fields_for_forms
|
||||
#figure out a better way to do this
|
||||
bike_store = Bike.all.map { |b| [b.id, b.serial_number] }
|
||||
current_user ||= User.find_by_id(session[:selected_user_id]) || controller.current_user
|
||||
bike_id = current_user.bike.nil? ? nil : current_user.bike.id
|
||||
puts "YOOOOO BIKE: #{bike_id}"
|
||||
[
|
||||
{ :name => :start_date},
|
||||
{ :name => :end_date},
|
||||
:description,
|
||||
{ :name => :user_action__action, :field_label => 'Action'}
|
||||
{ :name => :description},
|
||||
{ :name => :user_action__action, :field_label => 'Action'},
|
||||
{ :name => :for_bike, :title => "Copy description to a Bike's History?", :xtype => 'fieldset', :collapsible => true, :collapsed => true, :items => [
|
||||
{:xtype => 'checkbox', :name => :copy_log, :inputValue => true, :read_only => false},
|
||||
{:xtype => 'combo', :name => :copy_id, :fieldLabel => 'Bike', :store => bike_store, :value => bike_id}
|
||||
]
|
||||
}
|
||||
]
|
||||
end
|
||||
|
||||
@@ -52,4 +65,5 @@ class UserLogs < Netzke::Basepack::Grid
|
||||
def default_bbar
|
||||
[ :apply, :add_in_form, :search ]
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -2,6 +2,7 @@ class UserProfileBorder < Netzke::Base
|
||||
# Remember regions collapse state and size
|
||||
include Netzke::Basepack::ItemPersistence
|
||||
component :user_logs
|
||||
component :user_stats
|
||||
component :user_profiles
|
||||
|
||||
def configure(c)
|
||||
@@ -9,6 +10,7 @@ class UserProfileBorder < Netzke::Base
|
||||
c.title = "Profile"
|
||||
c.items = [
|
||||
{ netzke_component: :user_logs, region: :center, split: true},
|
||||
{ netzke_component: :user_stats, region: :east, width: 350, split: true},
|
||||
{ netzke_component: :user_profiles, region: :south, height: 150, split: true }
|
||||
]
|
||||
end
|
||||
|
||||
@@ -15,7 +15,6 @@ class UserProfiles < Netzke::Basepack::Grid
|
||||
c.data_store = user_profiles_data_store
|
||||
c.scope = user_profiles_scope
|
||||
c.columns = [
|
||||
{ :name => :bike__serial_number},
|
||||
:addrStreet1,
|
||||
:addrStreet2,
|
||||
:addrCity,
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
class UserStats < Netzke::Base
|
||||
|
||||
js_configure do |c|
|
||||
c.body_padding = 15
|
||||
c.title = "User Stats"
|
||||
bike = controller.current_user.bike
|
||||
c.html = %Q(
|
||||
<div id="user_stats_page">
|
||||
<p>Total Hours Worked: #{controller.current_user.total_hours}</p>
|
||||
<p>Hours worked in #{Time.now.strftime('%B')}: #{controller.current_user.current_month_hours}</p>
|
||||
<p>Current bike ID: #{bike.id if bike}</p>
|
||||
<p>Current bike S/N: #{bike.serial_number if bike}</p>
|
||||
</div>
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,7 +8,8 @@ class Users < Netzke::Basepack::Grid
|
||||
:last_name,
|
||||
:nickname,
|
||||
:email,
|
||||
:user_role__role
|
||||
:user_role__role,
|
||||
:bike__serial_number
|
||||
]
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user