From 0f89cf057a8d526817c1400577b678030ba71283 Mon Sep 17 00:00:00 2001 From: Jason Denney Date: Tue, 11 Jun 2013 00:34:45 -0400 Subject: [PATCH] Display User roles by username, then full name Also set the default_fields_for_forms --- app/components/user_role_joins.rb | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/components/user_role_joins.rb b/app/components/user_role_joins.rb index ba61e66..92ab247 100644 --- a/app/components/user_role_joins.rb +++ b/app/components/user_role_joins.rb @@ -5,14 +5,26 @@ class UserRoleJoins < Netzke::Basepack::Grid c.header = false c.title = "User Roles" c.columns = [ - { :name => :user__first_name, :text => "First"}, - { :name => :user__last_name, :text => "Last"}, + { :name => :user__username, :text => "Username"}, + { :name => :name, :getter => lambda{ |rec| + user = User.find_by_id(rec.user_id) + user.nil? ? "" : "#{user.first_name} #{user.last_name}" + } + }, { :name => :role__role, :text => "Role"}, :created_at, :updated_at, :ends ] end + def default_fields_for_forms + [ + { :name => :user__username, :field_label => 'Username' }, + { :name => :role__role, :field_label => 'Role' }, + { :name => :ends } + ] + end + #override with nil to remove actions def default_bbar [ :apply, :add_in_form, :search ]