Sha256: bb6a72d1c9fd2165f5315732f55ea76c5f77bd74e88d51a4c7dfdd1446cfed7d

Contents?: true

Size: 827 Bytes

Versions: 5

Compression:

Stored size: 827 Bytes

Contents

module Adminpanel
  module GalleryzableActions
    extend ActiveSupport::Concern

    included do
      skip_authorize_resource :move_gallery_better, :move_gallery_worst
    end

    def move_gallery_better
      @resource_instance = @model.find(params[:id])
      @resource_instance.move_to_better_position
      respond

    end

    def move_gallery_worst
      @resource_instance = @model.find(params[:id])
      @resource_instance.move_to_worst_position
      respond
    end

  private
    def respond
      respond_to do |format|
        format.js do
          render 'adminpanel/shared/gallery_entries', locals: {
            collection: @model.ordered.where(
              @model.relation_field.to_sym => @resource_instance.send(@model.relation_field)
            )
          }
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
adminpanel-2.4.2 app/controllers/concerns/adminpanel/galleryzable_actions.rb
adminpanel-2.4.1 app/controllers/concerns/adminpanel/galleryzable_actions.rb
adminpanel-2.4.0 app/controllers/concerns/adminpanel/galleryzable_actions.rb
adminpanel-2.3.1 app/controllers/concerns/adminpanel/galleryzable_actions.rb
adminpanel-2.3.0 app/controllers/concerns/adminpanel/galleryzable_actions.rb