Sha256: e1eae367e9456be1bc80749cfe9cf65d57d64bd0be95e68ee4cd611d9acfe604

Contents?: true

Size: 1.28 KB

Versions: 29

Compression:

Stored size: 1.28 KB

Contents

class Admin::PositionablesController < Admin::BaseController    
  
  class ::Admin::Positionable
     extend ActiveModel::Naming
     include ActiveModel::Conversion
     include ActiveModel::Validations
     extend ActiveModel::Translation
   
    attr_accessor :positionables
    def initialize(positionables)
      @positionables = positionables
    end

    def persisted?
      true
    end
  
    def id
      @positionables.klass.name
    end

  end
  
  
  def index
    @positionable_class = Positionable.get(params[:type])
    
    raise "NotFound" unless @positionable_class && @positionable_class.columns_hash["position"]
    
    @positionables = ::Admin::Positionable.new(@positionable_class.unscoped.order("position"))
    @skip_filter = true
    @title = t('fullstack.admin.sort', :default => "Sort") + " - " + t("fullstack.admin.resources.#{@positionable_class.name.underscore.pluralize}", :default => @positionable_class.name.humanize)
  end
  
  def sort
    if subject.can_sort?(@positionable_class)
      @positionable_class = Positionable.get(params[:type])
      @positionable_class.update_positions(params[:positionables])
      redirect_to [:admin, params[:type]], :flash => { :notice => I18n.t("fullstack.admin.flash.success.generic") }
    end
  end  

  def fetch_object
    
  end

end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
fullstack-admin-0.2.26 app/controllers/admin/positionables_controller.rb
fullstack-admin-0.2.25 app/controllers/admin/positionables_controller.rb
fullstack-admin-0.2.24 app/controllers/admin/positionables_controller.rb
fullstack-admin-0.2.23 app/controllers/admin/positionables_controller.rb
fullstack-admin-0.2.22 app/controllers/admin/positionables_controller.rb
fullstack-admin-0.2.21 app/controllers/admin/positionables_controller.rb
fullstack-admin-0.2.20 app/controllers/admin/positionables_controller.rb
fullstack-admin-0.2.19 app/controllers/admin/positionables_controller.rb
fullstack-admin-0.2.18 app/controllers/admin/positionables_controller.rb
fullstack-admin-0.2.17 app/controllers/admin/positionables_controller.rb
fullstack-admin-0.2.16 app/controllers/admin/positionables_controller.rb
fullstack-admin-0.2.15 app/controllers/admin/positionables_controller.rb
fullstack-admin-0.2.14 app/controllers/admin/positionables_controller.rb
fullstack-admin-0.2.13 app/controllers/admin/positionables_controller.rb
fullstack-admin-0.2.12 app/controllers/admin/positionables_controller.rb
fullstack-admin-0.2.11 app/controllers/admin/positionables_controller.rb
fullstack-admin-0.2.9 app/controllers/admin/positionables_controller.rb
fullstack-admin-0.2.8 app/controllers/admin/positionables_controller.rb
fullstack-admin-0.2.7 app/controllers/admin/positionables_controller.rb
fullstack-admin-0.2.6 app/controllers/admin/positionables_controller.rb