Class: Greedo::GridHelper::Grid::Field

Inherits:
Struct
  • Object
show all
Defined in:
lib/greedo/grid_helper.rb

Instance Method Summary collapse

Instance Method Details

#klassObject



112
113
114
# File 'lib/greedo/grid_helper.rb', line 112

def klass
  label.parameterize.underscore
end

#order_asc_classObject



148
149
150
151
152
153
154
# File 'lib/greedo/grid_helper.rb', line 148

def order_asc_class
  if ordered_by? && order == "asc"
    "glyphicon-triangle-top"
  else
    "glyphicon-chevron-up"
  end
end

#order_asc_pathObject



132
133
134
135
136
137
138
# File 'lib/greedo/grid_helper.rb', line 132

def order_asc_path
  if ordered_by? && order == "asc"
    view_context.url_for(params.merge(order: nil, order_by: nil))
  else
    view_context.url_for(params.merge(order: :asc, order_by: name))
  end
end

#order_desc_classObject



140
141
142
143
144
145
146
# File 'lib/greedo/grid_helper.rb', line 140

def order_desc_class
  if ordered_by? && order == "desc"
    "glyphicon-triangle-bottom"
  else
    "glyphicon-chevron-down"
  end
end

#order_desc_pathObject



124
125
126
127
128
129
130
# File 'lib/greedo/grid_helper.rb', line 124

def order_desc_path
  if ordered_by? && order == "desc"
    view_context.url_for(params.merge(order: nil, order_by: nil))
  else
    view_context.url_for(params.merge(order: :desc, order_by: name))
  end
end

#ordered_by?Boolean

Returns:

  • (Boolean)


116
117
118
# File 'lib/greedo/grid_helper.rb', line 116

def ordered_by?
  order_by == name.to_s && %w(asc desc).include?(order)
end

#paramsObject



120
121
122
# File 'lib/greedo/grid_helper.rb', line 120

def params
  view_context.params.merge(path_params)
end

#value(record) ⇒ Object



108
109
110
# File 'lib/greedo/grid_helper.rb', line 108

def value(record)
  renderer.call(record)
end