Browse Source

Merge branch 'master' of github.com:spacemunkay/velocipede

topic-sass
Jason Denney 11 years ago
parent
commit
4c8f74acf2
  1. 1
      app/components/bike_brands.rb
  2. 3
      app/components/bike_logs.rb
  3. 1
      app/components/bike_models.rb
  4. 12
      app/components/bikes.rb
  5. 1
      app/components/check_ins.rb
  6. 1
      app/components/customers.rb
  7. 1
      app/components/logs.rb
  8. 1
      app/components/tasks.rb
  9. 3
      app/components/transaction_logs.rb
  10. 1
      app/components/transactions.rb
  11. 1
      app/components/user_logs.rb
  12. 1
      app/components/user_profiles.rb
  13. 5
      app/components/user_role_joins.rb
  14. 1
      app/components/user_transactions.rb
  15. 3
      app/components/users.rb

1
app/components/bike_brands.rb

@ -3,6 +3,7 @@ class BikeBrands < Netzke::Basepack::Grid
super super
c.model = "BikeBrand" c.model = "BikeBrand"
c.title = "Brands" c.title = "Brands"
c.force_fit = true
c.prohibit_update = true if cannot? :update, BikeBrand c.prohibit_update = true if cannot? :update, BikeBrand
c.prohibit_create = true if cannot? :create, BikeBrand c.prohibit_create = true if cannot? :create, BikeBrand

3
app/components/bike_logs.rb

@ -6,6 +6,7 @@ class BikeLogs < Netzke::Basepack::Grid
c.model = "ActsAsLoggable::Log" c.model = "ActsAsLoggable::Log"
c.title = "Bike History" c.title = "Bike History"
c.force_fit = true
c.data_store = {auto_load: false} c.data_store = {auto_load: false}
c.scope = lambda { |rel| rel.where(:loggable_type => 'Bike',:loggable_id => session[:selected_bike_id]);} c.scope = lambda { |rel| rel.where(:loggable_type => 'Bike',:loggable_id => session[:selected_bike_id]);}
c.strong_default_attrs = { c.strong_default_attrs = {
@ -20,7 +21,7 @@ class BikeLogs < Netzke::Basepack::Grid
{ :name => :start_date, :format => "g:ia - D, M j - Y", :width => 165, :default_value => Time.now.to_formatted_s(:db) }, { :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 => :end_date, :hidden => true, :default_value => Time.now.to_formatted_s(:db) },
:description, :description,
{ :name => :bike_action__action, :text => 'Action'}, { :name => :bike_action__action, :text => 'Action', :default_value => ::ActsAsLoggable::BikeAction.first.id},
{ :name => :logged_by, :getter => lambda{ |rec| { :name => :logged_by, :getter => lambda{ |rec|
user = User.find_by_id(rec.logger_id) user = User.find_by_id(rec.logger_id)
user.nil? ? "" : "#{user.first_name} #{user.last_name}" user.nil? ? "" : "#{user.first_name} #{user.last_name}"

1
app/components/bike_models.rb

@ -4,6 +4,7 @@ class BikeModels < Netzke::Basepack::Grid
c.model = "BikeModel" c.model = "BikeModel"
c.title = "Models" c.title = "Models"
c.force_fit = true
c.data_store = {auto_load: false} c.data_store = {auto_load: false}
c.scope = lambda { |rel| rel.where(:bike_brand_id => session[:selected_bike_brand_id]);} c.scope = lambda { |rel| rel.where(:bike_brand_id => session[:selected_bike_brand_id]);}
c.strong_default_attrs = { c.strong_default_attrs = {

12
app/components/bikes.rb

@ -2,11 +2,12 @@ class Bikes < Netzke::Basepack::Grid
def configure(c) def configure(c)
super super
c.model = "Bike" c.model = "Bike"
c.force_fit = true
# columns with :id set, have :min_chars set in init_component # columns with :id set, have :min_chars set in init_component
# See: http://stackoverflow.com/questions/17738962/netzke-grid-filtering # See: http://stackoverflow.com/questions/17738962/netzke-grid-filtering
c.columns = [ c.columns = [
{ :name => :shop_id, :text => 'Shop ID'}, { :name => :shop_id, :text => 'Shop ID', :default_value => Bike.last.id.to_i + 1},
:serial_number, :serial_number,
{ :id => :bike_brand__brand, :name => :bike_brand__brand, :text => 'Brand'}, { :id => :bike_brand__brand, :name => :bike_brand__brand, :text => 'Brand'},
{ :name => :model, :text => 'Model', { :name => :model, :text => 'Model',
@ -19,14 +20,15 @@ class Bikes < Netzke::Basepack::Grid
} }
}, },
#needs to have type :action or else won't work in grid, because... netzke #needs to have type :action or else won't work in grid, because... netzke
{ :name => "color", :text => "Frame Color", :type => :action, :editor => { :xtype => "xcolorcombo"}, :renderer => :color_block}, { :name => "color", :text => "Frame Color", :type => :action, :editor => { :xtype => "xcolorcombo"}, :renderer => :color_block,
{ :id => :bike_style__style, :name => :bike_style__style, :text => 'Style' }, :default_value => '000000'},
{ :id => :bike_style__style, :name => :bike_style__style, :text => 'Style', :default_value => BikeStyle.first.id},
{ :name => :seat_tube_height, :text => 'Seat Tube (in)'}, { :name => :seat_tube_height, :text => 'Seat Tube (in)'},
{ :name => :top_tube_length, :text => 'Top Tube (in)'}, { :name => :top_tube_length, :text => 'Top Tube (in)'},
{ :name => :wheel_size, :text => 'Wheel Size (in)'}, { :name => :wheel_size, :text => 'Wheel Size (in)'},
:value, :value,
{ :id => :bike_condition__condition, :name => :bike_condition__condition, :text => 'Condition'}, { :id => :bike_condition__condition, :name => :bike_condition__condition, :text => 'Condition', :default_value => BikeCondition.first.id},
{ :id => :bike_purpose__purpose, :name => :bike_purpose__purpose, :text => 'Purpose'}, { :id => :bike_purpose__purpose, :name => :bike_purpose__purpose, :text => 'Purpose', :default_value => BikePurpose.first.id},
{ :name => :owner, :getter => lambda { |rec| { :name => :owner, :getter => lambda { |rec|
user = rec.owner user = rec.owner
user.nil? ? "" : "#{user.first_name} #{user.last_name}" user.nil? ? "" : "#{user.first_name} #{user.last_name}"

1
app/components/check_ins.rb

@ -4,6 +4,7 @@ class CheckIns < Netzke::Basepack::Grid
super super
c.header = false c.header = false
c.model = "ActsAsLoggable::Log" c.model = "ActsAsLoggable::Log"
c.force_fit = true
c.scope = lambda { |rel| rel.where(:log_action_type => ::ActsAsLoggable::UserAction). c.scope = lambda { |rel| rel.where(:log_action_type => ::ActsAsLoggable::UserAction).
where(:loggable_type => "User"). where(:loggable_type => "User").
where(:log_action_id => ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")). where(:log_action_id => ::ActsAsLoggable::UserAction.find_by_action("CHECKIN")).

1
app/components/customers.rb

@ -1,6 +1,7 @@
class Customers < Netzke::Basepack::Grid class Customers < Netzke::Basepack::Grid
def configure(c) def configure(c)
c.model = "Customer" c.model = "Customer"
c.force_fit = true
end end
#override with nil to remove actions #override with nil to remove actions

1
app/components/logs.rb

@ -4,6 +4,7 @@ class Logs < Netzke::Basepack::Grid
super super
c.header = false c.header = false
c.model = "ActsAsLoggable::Log" c.model = "ActsAsLoggable::Log"
c.force_fit = true
c.columns = [ c.columns = [
:loggable_id, :loggable_id,
:loggable_type, :loggable_type,

1
app/components/tasks.rb

@ -9,6 +9,7 @@ class Tasks < Netzke::Basepack::Grid
c.header = false c.header = false
c.model = "Task" c.model = "Task"
c.force_fit = true
c.scope = lambda{ |rel| c.scope = lambda{ |rel|
if session[:selected_bike_id] if session[:selected_bike_id]
rel.where(:task_list_id => Bike.find_by_id(session[:selected_bike_id]).task_list.id) rel.where(:task_list_id => Bike.find_by_id(session[:selected_bike_id]).task_list.id)

3
app/components/transaction_logs.rb

@ -5,6 +5,7 @@ class TransactionLogs < Netzke::Basepack::Grid
c.model = "ActsAsLoggable::Log" c.model = "ActsAsLoggable::Log"
c.title = "Transaction Payments" c.title = "Transaction Payments"
c.force_fit = true
c.data_store = {auto_load: false} c.data_store = {auto_load: false}
c.scope = lambda { |rel| rel.where(:loggable_type => 'Transaction',:loggable_id => session[:selected_transaction_id]);} c.scope = lambda { |rel| rel.where(:loggable_type => 'Transaction',:loggable_id => session[:selected_transaction_id]);}
c.strong_default_attrs = { c.strong_default_attrs = {
@ -20,7 +21,7 @@ class TransactionLogs < Netzke::Basepack::Grid
c.columns = [ c.columns = [
{ :name => :start_date, :format => "g:ia - D, M j - Y", :width => 165, :default_value => Time.now.to_formatted_s(:db), :text => 'Date' }, { :name => :start_date, :format => "g:ia - D, M j - Y", :width => 165, :default_value => Time.now.to_formatted_s(:db), :text => 'Date' },
{ :name => :description, :text => "Amount"} , { :name => :description, :text => "Amount"} ,
{ :name => :transaction_action__action, :text => 'Method'}, { :name => :transaction_action__action, :text => 'Method', :default_value => ::ActsAsLoggable::TransactionAction.first.id},
{ :name => :logged_by, :getter => lambda{ |rec| { :name => :logged_by, :getter => lambda{ |rec|
user = User.find_by_id(rec.logger_id) user = User.find_by_id(rec.logger_id)
user.nil? ? "" : "#{user.first_name} #{user.last_name}" user.nil? ? "" : "#{user.first_name} #{user.last_name}"

1
app/components/transactions.rb

@ -2,6 +2,7 @@ class Transactions < Netzke::Basepack::Grid
def configure(c) def configure(c)
super super
c.model = "Transaction" c.model = "Transaction"
c.force_fit = true
c.strong_default_attrs = { c.strong_default_attrs = {
:vendor_id => controller.current_user.id, :vendor_id => controller.current_user.id,
:customer_id => session[:selected_customer_id], :customer_id => session[:selected_customer_id],

1
app/components/user_logs.rb

@ -34,6 +34,7 @@ class UserLogs < Netzke::Basepack::Grid
c.model = "ActsAsLoggable::Log" c.model = "ActsAsLoggable::Log"
c.title = "User Timesheet" c.title = "User Timesheet"
c.force_fit = true
c.data_store = user_log_data_store c.data_store = user_log_data_store
c.scope = user_log_scope c.scope = user_log_scope
c.strong_default_attrs = user_log_strong_default_attrs c.strong_default_attrs = user_log_strong_default_attrs

1
app/components/user_profiles.rb

@ -19,6 +19,7 @@ class UserProfiles < Netzke::Basepack::Grid
c.model = "UserProfile" c.model = "UserProfile"
c.title = "Profile" c.title = "Profile"
c.force_fit = true
c.data_store = user_profiles_data_store c.data_store = user_profiles_data_store
c.scope = user_profiles_scope c.scope = user_profiles_scope
c.strong_default_attrs = user_profile_strong_default_attrs c.strong_default_attrs = user_profile_strong_default_attrs

5
app/components/user_role_joins.rb

@ -2,6 +2,7 @@ class UserRoleJoins < Netzke::Basepack::Grid
def configure(c) def configure(c)
super super
c.model = "UserRoleJoin" c.model = "UserRoleJoin"
c.force_fit = true
c.header = false c.header = false
c.title = "User Roles" c.title = "User Roles"
c.data_store.sorters = [{ :property => :user__username, :direction => :ASC}] c.data_store.sorters = [{ :property => :user__username, :direction => :ASC}]
@ -10,9 +11,9 @@ class UserRoleJoins < Netzke::Basepack::Grid
{ :name => :name, :getter => lambda{ |rec| { :name => :name, :getter => lambda{ |rec|
user = User.find_by_id(rec.user_id) user = User.find_by_id(rec.user_id)
user.nil? ? "" : "#{user.first_name} #{user.last_name}" user.nil? ? "" : "#{user.first_name} #{user.last_name}"
}
}, },
{ :name => :role__role, :text => "Role"}, },
{ :name => :role__role, :text => "Role", :default_value => Role.exists? ? Role.first.id : nil},
:created_at, :created_at,
:updated_at, :updated_at,
:ends ] :ends ]

1
app/components/user_transactions.rb

@ -5,6 +5,7 @@ class UserTransactions < Netzke::Basepack::Grid
c.model = "Transaction" c.model = "Transaction"
c.title = "Transactions" c.title = "Transactions"
c.force_fit = true
c.scope = lambda { |rel| rel.where(:customer_id => controller.current_user.id, :customer_type => 'User');} c.scope = lambda { |rel| rel.where(:customer_id => controller.current_user.id, :customer_type => 'User');}
c.data_store = { auto_load: true } c.data_store = { auto_load: true }
c.columns = [ c.columns = [

3
app/components/users.rb

@ -12,13 +12,14 @@ class Users < Netzke::Basepack::Grid
super super
c.header = false c.header = false
c.model = "User" c.model = "User"
c.force_fit = true
c.columns = [ c.columns = [
{ :name => :username, :read_only => true }, { :name => :username, :read_only => true },
:first_name, :first_name,
:last_name, :last_name,
:email, :email,
{ :id => :bike__shop_id, :name => :bike__shop_id} { :text => "Bike - Shop ID", :id => :bike__shop_id, :name => :bike__shop_id, :default_value => Bike.exists? ? Bike.first.id : nil }
] ]
c.columns << :reset if can? :manage, User c.columns << :reset if can? :manage, User

Loading…
Cancel
Save