merging master

This commit is contained in:
Jason Denney
2013-05-30 22:17:18 -04:00
28 changed files with 393 additions and 29 deletions
+10 -3
View File
@@ -3,7 +3,7 @@ class AppTabPanel < Netzke::Basepack::TabPanel
action :sign_out do |c|
c.icon = :door_out
c.text = "Sign out #{controller.current_user.email}" if controller.current_user
c.text = "Exit"
end
action :check_out do |c|
@@ -11,6 +11,11 @@ class AppTabPanel < Netzke::Basepack::TabPanel
c.text = "CHECK OUT" if controller.current_user
end
action :change_account_info do |c|
c.icon = :user_edit
c.text = "Change Email/Password"
end
def configure(c)
#all users
@@ -48,7 +53,9 @@ class AppTabPanel < Netzke::Basepack::TabPanel
if can? :manage, Role
@@app_tab_panel_items.concat [{ layout: :fit,
wrappedComponent: :user_role_joins,
title: "User Roles"}]
title: "User Roles"},
:check_ins
]
end
@@app_tab_panel_items.each do |item|
@@ -59,7 +66,7 @@ class AppTabPanel < Netzke::Basepack::TabPanel
end
end
c.prevent_header = true
c.tbar = [:sign_out, :check_out]
c.tbar = [:sign_out, :check_out, :change_account_info]
c.items = @@app_tab_panel_items
super
end
@@ -17,5 +17,8 @@
});
}
});
},
onChangeAccountInfo: function(){
window.location.href="users/edit";
}
}
+19 -1
View File
@@ -16,7 +16,8 @@ class Bikes < Netzke::Basepack::Grid
end
}
},
:color,
#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' },
{ :name => :seat_tube_height, :text => 'Seat Tube (in)'},
{ :name => :top_tube_length, :text => 'Top Tube (in)'},
@@ -32,6 +33,23 @@ class Bikes < Netzke::Basepack::Grid
]
end
def default_fields_for_forms
[
{ :name => :shop_id, :field_label => 'Shop ID'},
:serial_number,
{ :name => :bike_brand__brand, :field_label => 'Brand' },
{ :name => :bike_model__model, :field_label => 'Model'},
{ :name => "color", :xtype => "xcolorcombo"},
{ :name => :bike_style__style, :field_label => 'Style' },
{ :name => :seat_tube_height, :field_label => 'Seat Tube (in)'},
{ :name => :top_tube_length, :field_label => 'Top Tube (in)'},
{ :name => :wheel_size, :field_label => 'Wheel Size (in)'},
:value,
{ :name => :bike_condition__condition, :field_label => 'Condition'},
{ :name => :bike_status__status, :field_label => 'Status'}
]
end
#override with nil to remove actions
def default_bbar
[ :apply, :add_in_form, :search ]
@@ -9,5 +9,8 @@
// The beauty of using Ext.Direct: calling 3 endpoints in a row, which results in a single call to the server!
this.selectBikeBrand({bike_brand_id: record.get('bike_brand__brand')});
}, this);
},
colorBlock: function(value){
return Ext.String.format('<div style="display:inline-block">{1}</div><div style="background-color:#{0};width:50px;height:10px;display:inline-block;margin:0 5px 0 5px;border:solid;border-color:gray;border-width:1px;"></div>', value, value);
}
}
+23
View File
@@ -0,0 +1,23 @@
class CheckIns < Netzke::Basepack::Grid
def configure(c)
super
c.header = false
c.model = "ActsAsLoggable::Log"
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 = [
{ :name => :name, :getter => lambda{ |rec|
user = User.find_by_id(rec.loggable_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
+1
View File
@@ -4,6 +4,7 @@ class UserStats < Netzke::Base
bike = user.bike
%Q(
<div id="user_stats_page">
<p>Username: #{user.username}</p>
<p>Total Hours Worked: #{user.total_hours}</p>
<p>Hours worked in #{Time.now.strftime('%B')}: #{user.current_month_hours}</p>
<p>Current bike Shop ID: #{bike.shop_id if bike}</p>
+12
View File
@@ -1,16 +1,28 @@
class Users < Netzke::Basepack::Grid
include Netzke::Basepack::ActionColumn
column :reset do |c|
c.type = :action
c.actions = [{name: :reset_password, icon: :lock_break}]
c.header = ""
c.width = 20
end
def configure(c)
super
c.header = false
c.model = "User"
c.columns = [
:username,
:first_name,
:last_name,
:nickname,
:email,
:bike__shop_id
]
c.columns << :reset if can? :manage, User
end
#override with nil to remove actions
@@ -4,8 +4,32 @@
this.callParent();
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!
console.log("user: " + record.get('id') );
this.selectCustomer({customer_id: record.get('id'), customer_type: 'User'});
}, this);
},
onResetPassword: function(record){
user = record.data;
Ext.Msg.confirm(
"Reset Password",
"Are you sure you want to reset "+user.first_name+" "+user.last_name+"'s password?",
function(butt_id){
if( butt_id === "yes" ){
$.ajax({
type: 'POST',
url: '/api/v1/reset',
dataType: 'json',
contentType: 'application/json',
processData: false,
data: JSON.stringify({"user_id": user.id}),
complete: function() { },
success: function(data) {
Ext.Msg.alert("Success", "New Password: "+data.password);
},
error: function(data,textStatus) {
Ext.Msg.alert( "Error", JSON.parse(data.responseText)["error"]);
}
});
}
});
}
}
+2 -2
View File
@@ -9,7 +9,7 @@ class UsersAndProfilesBorder < Netzke::Base
super
c.header = false
c.items = [
{ netzke_component: :users, header: "Users", region: :center, width: 300, split: true },
{ netzke_component: :users, header: "Users", region: :center, width: 350, split: true },
{ netzke_component: :user_profiles, region: :south, height: 150, split: true},
{ netzke_component: :user_logs, region: :east, split: true}
]
@@ -25,5 +25,5 @@ class UsersAndProfilesBorder < Netzke::Base
# store selected boss id in the session for this component's instance
session[:selected_user_id] = params[:user_id]
end
end