Sha256: 35a0e023aba8b05729b505add5cb6bce685b95c7de4175798351d6ea07b0f821

Contents?: true

Size: 668 Bytes

Versions: 7

Compression:

Stored size: 668 Bytes

Contents

module AbAdmin
  module Controllers
    module Tree

      def rebuild
        parent_id = params[:parent_id].to_i
        prev_id = params[:prev_id].to_i
        next_id = params[:next_id].to_i

        render :text => 'Do nothing' and return if parent_id.zero? && prev_id.zero? && next_id.zero?

        if prev_id.zero? && next_id.zero?
          resource.move_to_child_of resource_class.find(parent_id)
        elsif !prev_id.zero?
          resource.move_to_right_of resource_class.find(prev_id)
        elsif !next_id.zero?
          resource.move_to_left_of resource_class.find(next_id)
        end

        render(:nothing => true)
      end

    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ab_admin-0.2.3 lib/ab_admin/controllers/tree.rb
ab_admin-0.2.2 lib/ab_admin/controllers/tree.rb
ab_admin-0.2.1 lib/ab_admin/controllers/tree.rb
ab_admin-0.2.0 lib/ab_admin/controllers/tree.rb
ab_admin-0.1.2 lib/ab_admin/controllers/tree.rb
ab_admin-0.1.1 lib/ab_admin/controllers/tree.rb
ab_admin-0.1.0 lib/ab_admin/controllers/tree.rb