Sha256: ded9d9382f15df2e74db5abe4008301b714408df4a16f30207707bb061c9e11c
Contents?: true
Size: 1.28 KB
Versions: 14
Compression:
Stored size: 1.28 KB
Contents
module Godmin module Helpers module Tables def column_header(attribute) if @resource_class.column_names.include?(attribute.to_s) direction = if params[:order] if params[:order].split("_").first == attribute.to_s params[:order].split("_").last == "desc" ? "asc" : "desc" else params[:order].split("_").last end else "desc" end link_to @resource_class.human_attribute_name(attribute.to_s), url_for(params.merge(order: "#{attribute}_#{direction}")) else @resource_class.human_attribute_name(attribute.to_s) end end def column_value(resource, attribute) if lookup_context.exists?("columns/#{attribute}", nil, true) render partial: "columns/#{attribute}", locals: { resource: resource } else column_value = resource.send(attribute) if column_value.is_a?(Date) || column_value.is_a?(Time) column_value = l(column_value, format: :long) end if column_value.is_a?(TrueClass) || column_value.is_a?(FalseClass) column_value = t(column_value.to_s) end column_value end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems