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

Version Path
typus-3.1.0.rc11 app/helpers/admin/resources/data_types/position_helper.rb
typus-3.1.0.rc10 app/helpers/admin/resources/data_types/position_helper.rb
typus-3.1.0.rc9 app/helpers/admin/resources/data_types/position_helper.rb
typus-3.1.0.rc8 app/helpers/admin/resources/data_types/position_helper.rb
typus-3.1.0.rc7 app/helpers/admin/resources/data_types/position_helper.rb