Sha256: d5bfd6d4bb07a0d0f77d44f372769115b1a8cca91ec88b686138c212877e9aa3

Contents?: true

Size: 1.05 KB

Versions: 10

Compression:

Stored size: 1.05 KB

Contents

module Admin::Kitsune::RecordsHelper
  def url_for_record(record)
    record.new_record? ? admin_kitsune_model_records_path(record.class.to_s) : admin_kitsune_model_record_path(record.class.to_s, record.id)
  end
  
  def sort_link_to(resource, column)
    if resource.column_sortable(column)
      ascending = params[:sort] == column.name && params[:sort_dir] == 'DESC'
      options = {
        :model => resource.object,
        :sort => column.name, 
        :sort_dir => (ascending ? 'ASC' : 'DESC')
      }
      link_to column.name.to_s.titleize + (ascending ? ' ↓' : ' ↑'), options
    else
      column.name.to_s.titleize
    end
  end

	def additional_content_for(model, record, column)
		if model.field_type(column.name) == :file_field && (file = record.send(column.name)).present?
			"<p><strong>Current File</strong>: " + link_to(file.to_s, file.to_s) + "</p>"
		elsif model.field_type(column.name) == :image_field && (file = record.send(column.name)).present?
			"<p><strong>Current File</strong>: " + image_tag(file.to_s) + "</p>"
		end
	end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
kitsune-0.0.16 app/helpers/admin/kitsune/records_helper.rb
kitsune-0.0.14 app/helpers/admin/kitsune/records_helper.rb
kitsune-0.0.13 app/helpers/admin/kitsune/records_helper.rb
kitsune-0.0.12 app/helpers/admin/kitsune/records_helper.rb
kitsune-0.0.11 app/helpers/admin/kitsune/records_helper.rb
kitsune-0.0.10 app/helpers/admin/kitsune/records_helper.rb
kitsune-0.0.9 app/helpers/admin/kitsune/records_helper.rb
kitsune-0.0.8 app/helpers/admin/kitsune/records_helper.rb
kitsune-0.0.7 app/helpers/admin/kitsune/records_helper.rb
kitsune-0.0.6 app/helpers/admin/kitsune/records_helper.rb