Sha256: 5b2ccb1c100a9a78355d2a3724e883a3b526f840db8f8d3d15a49d548cffa616

Contents?: true

Size: 1.13 KB

Versions: 15

Compression:

Stored size: 1.13 KB

Contents

require 'builder'

module RailsAdmin
  module MainHelper
    def rails_admin_form_for(*args, &block)
      options = args.extract_options!.reverse_merge(:builder => RailsAdmin::FormBuilder)
      form_for(*(args << options), &block) << after_nested_form_callbacks
    end

    def get_indicator(percent)
      return "" if percent < 0          # none
      return "info" if percent < 34   # < 1/100 of max
      return "success" if percent < 67  # < 1/10 of max
      return "warning" if percent < 84  # < 1/3 of max
      return "important"                # > 1/3 of max
    end

    def get_column_sets(properties)
      sets = []
      property_index = 0
      set_index = 0

      while (property_index < properties.length)
        current_set_width = 0
        begin
          sets[set_index] ||= []
          sets[set_index] << properties[property_index]
          current_set_width += (properties[property_index].column_width || 120)
          property_index += 1
        end while (current_set_width < RailsAdmin::Config.total_columns_width) && (property_index < properties.length)
        set_index += 1
      end
      sets
    end
  end
end

Version data entries

15 entries across 15 versions & 4 rubygems

Version Path
rails_admin-0.2.0 app/helpers/rails_admin/main_helper.rb
rails_admin-0.1.2 app/helpers/rails_admin/main_helper.rb
rails_admin-0.1.1 app/helpers/rails_admin/main_helper.rb
rails_admin-0.1.0 app/helpers/rails_admin/main_helper.rb
rails_admin-0.0.5 app/helpers/rails_admin/main_helper.rb
rails_admin-0.0.4 app/helpers/rails_admin/main_helper.rb
rails_admin-0.0.3 app/helpers/rails_admin/main_helper.rb
rails_admin-0.0.2 app/helpers/rails_admin/main_helper.rb
upstream-rails_admin-1.0.2 app/helpers/rails_admin/main_helper.rb
rails_admin-0.0.1 app/helpers/rails_admin/main_helper.rb
obitum-rails_admin-0.0.5 app/helpers/rails_admin/main_helper.rb
drewda_rails_admin-0.0.1 app/helpers/rails_admin/main_helper.rb
obitum-rails_admin-0.0.4 app/helpers/rails_admin/main_helper.rb
obitum-rails_admin-0.0.3 app/helpers/rails_admin/main_helper.rb
obitum-rails_admin-0.0.2 app/helpers/rails_admin/main_helper.rb