Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify the rails 3.0 branch of rails_admin based on github pull request #866

Merged
merged 1 commit into from Nov 29, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/rails_admin/main/list.html.haml
Expand Up @@ -130,7 +130,7 @@
- other_left = rails_admin_list_path(params.except("set").merge(:model_name => @abstract_model.to_param, :set => params[:set].to_i - 1))
%td.other.left{ :style => "#{'display: none' if @other.include?("left")}" }= link_to "...", other_left, :remote => true
- properties.map{|property| property.bind(:object, object)}.each do |property|
%td{:class => "#{property.css_class}"}= ([:text, :string].include?(property.type) && property.truncated?) ? property.pretty_value.truncate(40) : property.pretty_value
%td{:class => "#{property.css_class}"}= property.pretty_value
- other_right = rails_admin_list_path(params.except("set").merge(:model_name => @abstract_model.to_param, :set => params[:set].to_i + 1))
%td.other.right{ :style => "#{'display: none' if @other.include?("right")}" }= link_to "...", other_right, :remote => true
%td.last
Expand Down
2 changes: 1 addition & 1 deletion lib/rails_admin/config/fields/base.rb
Expand Up @@ -55,7 +55,7 @@ def column_css_class(*args, &block)
end

register_instance_option(:truncated?) do
true
ActiveSupport::Deprecation.warn("'#{self.name}.truncated?' is deprecated, use '#{self.name}.pretty_value' instead", caller)
end

register_instance_option(:sortable) do
Expand Down
4 changes: 4 additions & 0 deletions lib/rails_admin/config/fields/types/string.rb
Expand Up @@ -27,6 +27,10 @@ class String < RailsAdmin::Config::Fields::Base
text
end

register_instance_option(:pretty_value) do
bindings[:view].truncate(formatted_value.to_s, :length => 60)
end

register_instance_option(:html_attributes) do
{
:class => "#{css_class} #{has_errors? ? "errorField" : nil} #{color? ? 'color' : nil}",
Expand Down
4 changes: 4 additions & 0 deletions lib/rails_admin/config/fields/types/text.rb
Expand Up @@ -21,6 +21,10 @@ class Text < RailsAdmin::Config::Fields::Base
"/javascripts/ckeditor/config.js"
end

register_instance_option(:pretty_value) do
bindings[:view].truncate(formatted_value.to_s, :length => 60)
end

register_instance_option(:html_attributes) do
{
:class => "#{css_class} #{has_errors? ? "errorField" : nil}",
Expand Down