Browse Source

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

eperez-timeinput
Jason Denney 11 years ago
parent
commit
835e73ea97
  1. 13
      app/components/bikes.rb
  2. 11
      app/components/bikes/javascripts/init_component.js
  3. 2
      app/components/user_logs.rb
  4. 13
      app/components/user_logs/javascripts/init_component.js
  5. 2
      app/components/users.rb
  6. 7
      app/components/users/javascripts/init_component.js

13
app/components/bikes.rb

@ -2,11 +2,14 @@ class Bikes < Netzke::Basepack::Grid
def configure(c)
super
c.model = "Bike"
# columns with :id set, have :min_chars set in init_component
# See: http://stackoverflow.com/questions/17738962/netzke-grid-filtering
c.columns = [
{ :name => :shop_id, :text => 'Shop ID'},
:serial_number,
{ :name => :bike_brand__brand, :text => 'Brand' },
{ :name => :bike_model__model, :text => 'Model',
{ :id => :bike_brand__brand, :name => :bike_brand__brand, :text => 'Brand'},
{ :id => :bike_model__model, :name => :bike_model__model, :text => 'Model',
:scope => lambda { |rel|
if session[:selected_bike_brand_id]
rel.where(:bike_brand_id => session[:selected_bike_brand_id])
@ -17,13 +20,13 @@ class Bikes < Netzke::Basepack::Grid
},
#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 => :bike_style__style, :text => 'Style' },
{ :id => :bike_style__style, :name => :bike_style__style, :text => 'Style' },
{ :name => :seat_tube_height, :text => 'Seat Tube (in)'},
{ :name => :top_tube_length, :text => 'Top Tube (in)'},
{ :name => :wheel_size, :text => 'Wheel Size (in)'},
:value,
{ :name => :bike_condition__condition, :text => 'Condition'},
{ :name => :bike_status__status, :text => 'Status'},
{ :id => :bike_condition__condition, :name => :bike_condition__condition, :text => 'Condition'},
{ :id => :bike_status__status, :name => :bike_status__status, :text => 'Status'},
{ :name => :owner, :getter => lambda { |rec|
user = rec.owner
user.nil? ? "" : "#{user.first_name} #{user.last_name}"

11
app/components/bikes/javascripts/init_component.js

@ -3,6 +3,17 @@
// calling superclass's initComponent
this.callParent();
//due to Netzke bug, :min_chars attribute doesn't work
var min_char_columns = [
"bike_brand__brand",
"bike_model__model",
"bike_style__style",
"bike_condition__condition",
"bike_status__status"]
Ext.each(min_char_columns, function(column, index) {
Ext.ComponentManager.get(column).editor.minChars = 1;
});
// setting the 'rowclick' event
var view = this.getView();
view.on('itemclick', function(view, record){

2
app/components/user_logs.rb

@ -43,7 +43,7 @@ class UserLogs < Netzke::Basepack::Grid
{ :name => :end_date, :format => "g:ia - D, M j - Y", :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, :text => 'Action', :default_value => ::ActsAsLoggable::UserAction.all.first.id },
{ :id => :user_action__action, :name => :user_action__action, :text => 'Action', :default_value => ::ActsAsLoggable::UserAction.all.first.id },
{ :name => :logged_by, :getter => lambda{ |rec|
user = User.find_by_id(rec.logger_id)
user.nil? ? "" : "#{user.first_name} #{user.last_name}"

13
app/components/user_logs/javascripts/init_component.js

@ -0,0 +1,13 @@
{
initComponent: function(){
// calling superclass's initComponent
this.callParent();
//due to Netzke bug, :min_chars attribute doesn't work
var min_char_columns = [
"user_action__status"]
Ext.each(min_char_columns, function(column, index) {
Ext.ComponentManager.get(column).editor.minChars = 1;
});
}
}

2
app/components/users.rb

@ -18,7 +18,7 @@ class Users < Netzke::Basepack::Grid
:first_name,
:last_name,
:email,
:bike__shop_id
{ :id => :bike__shop_id, :name => :bike__shop_id}
]
c.columns << :reset if can? :manage, User

7
app/components/users/javascripts/init_component.js

@ -2,6 +2,13 @@
initComponent: function(){
// calling superclass's initComponent
this.callParent();
//due to Netzke bug, :min_chars attribute doesn't work
var min_char_columns = ["bike__shop_id"]
Ext.each(min_char_columns, function(column, index) {
Ext.ComponentManager.get(column).editor.minChars = 1;
});
this.getView().on('itemclick', function(view, record){
// The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
this.selectCustomer({customer_id: record.get('id'), customer_type: 'User'});

Loading…
Cancel
Save