Permalink
Browse files

Changed active? method to enabled?

  • Loading branch information...
1 parent 67c4fe4 commit ae63950fb630b7b6916ba77f6a442684c92ef63d Ionatan Wiznia committed Mar 6, 2014
Showing with 20 additions and 20 deletions.
  1. +1 −1 Readme.markdown
  2. +14 −14 lib/datagrid/columns.rb
  3. +5 −5 lib/datagrid/columns/column.rb
View
@@ -132,7 +132,7 @@ Datagrid supports different type of filters including:
Each column is represented by name and code block to calculate the value.
``` ruby
-column(:activated, :header => "Active", :order => "activated", :after => :name, :if => :show_activated_coumn?, :unless => :hide_activated_coumn?) do
+column(:activated, :header => "Active", :order => "activated", :after => :name) do
self.activated?
end
```
View
@@ -88,23 +88,23 @@ def columns(*args)
end
# Defines new datagrid column
- #
+ #
# Arguments:
#
# * <tt>name</tt> - column name
# * <tt>options</tt> - hash of options
# * <tt>block</tt> - proc to calculate a column value
#
# Available options:
- #
+ #
# * <tt>:html</tt> - determines if current column should be present in html table and how is it formatted
- # * <tt>:order</tt> - determines if this column could be sortable and how.
- # The value of order is explicitly passed to ORM ordering method.
+ # * <tt>:order</tt> - determines if this column could be sortable and how.
+ # The value of order is explicitly passed to ORM ordering method.
# Ex: <tt>"created_at, id"</tt> for ActiveRecord, <tt>[:created_at, :id]</tt> for Mongoid
- # * <tt>:order_desc</tt> - determines a descending order for given column
+ # * <tt>:order_desc</tt> - determines a descending order for given column
# (only in case when <tt>:order</tt> can not be easily reversed by ORM)
- # * <tt>:order_by_value</tt> - used in case it is easier to perform ordering at ruby level not on database level.
- # Warning: using ruby to order large datasets is very unrecommended.
+ # * <tt>:order_by_value</tt> - used in case it is easier to perform ordering at ruby level not on database level.
+ # Warning: using ruby to order large datasets is very unrecommended.
# If set to true - datagrid will use column value to order by this column
# If block is given - datagrid will use value returned from block
# * <tt>:mandatory</tt> - if true, column will never be hidden with #column_names selection
@@ -150,7 +150,7 @@ def format(value, &block)
end
end
else
- # Ruby Object#format exists.
+ # Ruby Object#format exists.
# We don't want to change the behaviour and overwrite it.
super
end
@@ -214,7 +214,7 @@ def data(*column_names)
self.rows(*column_names).unshift(self.header(*column_names))
end
- # Return Array of Hashes where keys are column names and values are column values
+ # Return Array of Hashes where keys are column names and values are column values
# for each row in filtered datagrid relation.
#
# Example:
@@ -269,13 +269,13 @@ def to_csv(*column_names)
# Returns all columns selected in grid instance
#
# Examples:
- #
+ #
# MyGrid.new.columns # => all defined columns
# grid = MyGrid.new(:column_names => [:id, :name])
# grid.columns # => id and name columns
# grid.columns(:id, :category) # => id and category column
def columns(*args)
- self.class.columns(*args).select {|column| column.visible?(self)}
+ self.class.columns(*args).select {|column| column.enabled?(self)}
end
# Returns all columns that can be represented in plain data(non-html) way
@@ -303,15 +303,15 @@ def column_by_name(name)
# Gives ability to have a different formatting for CSV and HTML column value.
#
# Example:
- #
+ #
# column(:name) do |model|
# format(model.name) do |value|
# content_tag(:strong, value)
# end
# end
#
# column(:company) do |model|
- # format(model.company.name) do
+ # format(model.company.name) do
# render :partial => "company_with_logo", :locals => {:company => model.company }
# end
# end
@@ -327,7 +327,7 @@ def format(value, &block)
# Allows to access column values
#
# Example:
- #
+ #
# class MyGrid
# scope { User }
# column(:id)
@@ -56,7 +56,7 @@ def label
end
def header
- self.options[:header] ||
+ self.options[:header] ||
I18n.translate(self.name, :scope => "datagrid.#{self.grid_class.param_name}.columns", :default => self.name.to_s.humanize )
end
@@ -86,22 +86,22 @@ def order_by_value?
def order_desc
return nil unless order
- self.options[:order_desc]
+ self.options[:order_desc]
end
def html?
options[:html] != false
end
-
+
def data?
self.data_block != nil
end
-
+
def mandatory?
!! options[:mandatory]
end
- def visible?(grid)
+ def enabled?(grid)
(!options[:if] || (options[:if] && options[:if].call(grid))) && !options[:unless] || (options[:unless] && !options[:unless].call(grid))
end

0 comments on commit ae63950

Please sign in to comment.