Sha256: 6089135673b7e82d8c2d081487502fa7e86104cba6908d5d1ab2f00c9010e7bb
Contents?: true
Size: 923 Bytes
Versions: 5
Compression:
Stored size: 923 Bytes
Contents
module Admin::Resources::DataTypes::PositionHelper def table_position_field(attribute, item, connector = " / ") html_position = [] [ [:move_to_top, "Top"], [:move_higher, "Up"], [:move_lower, "Down"], [:move_to_bottom, "Bottom"] ].each do |key, value| options = { :controller => "/admin/#{item.class.to_resource}", :action => "position", :id => item.id, :go => key } should_be_inactive = (item.respond_to?(:first?) && ([:move_higher, :move_to_top].include?(key) && item.first?)) || (item.respond_to?(:last?) && ([:move_lower, :move_to_bottom].include?(key) && item.last?)) html_position << link_to_unless(should_be_inactive, Typus::I18n.t(value), params.merge(options)) do |name| %w(<span class="inactive">#{name}</span>) end end "#{item.position}<br/><br/>#{html_position.compact.join(connector)}".html_safe end end
Version data entries
5 entries across 5 versions & 1 rubygems