Sha256: 7f3a5f9cc299dfe03dc1b58947fe296ef63084b811e251e5638ff082a049135d

Contents?: true

Size: 1.2 KB

Versions: 15

Compression:

Stored size: 1.2 KB

Contents

class Admin::ImagesController < Admin::BaseController
  resource_controller
  before_filter :load_data
  
  new_action.response do |wants|
    wants.html {render :action => :new, :layout => false}
  end

  create.response do |wants|
    wants.html {redirect_to admin_product_images_url(@product)}
  end

  update.response do |wants|
    wants.html {redirect_to admin_product_images_url(@product)}
  end
  
  create.before :set_viewable
  update.before :set_viewable
  destroy.before :destroy_before
  
  destroy.response do |wants| 
    wants.html do
      render :text => ""
    end
  end
 
  private

  def load_data
    @product = Product.find_by_permalink(params[:product_id])
    @variants = @product.variants.collect do |variant| 
      [variant.options_text, variant.id ]
    end
    @variants.insert(0, [I18n.t("all"), "All"])
  end

  def set_viewable
    if params[:image].has_key? :viewable_id
      if params[:image][:viewable_id] == "All"
        object.viewable = @product
      else
        object.viewable_type = 'Variant'
        object.viewable_id = params[:image][:viewable_id]
      end
    else
      object.viewable = @product
    end
  end
  
  def destroy_before 
    @viewable = object.viewable
  end

end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
spree-0.11.4 app/controllers/admin/images_controller.rb
spree-0.11.3 app/controllers/admin/images_controller.rb
spree_core-0.30.2 app/controllers/admin/images_controller.rb
spree_core-0.40.4 app/controllers/admin/images_controller.rb
spree_core-0.40.3 app/controllers/admin/images_controller.rb
spree_core-0.40.2 app/controllers/admin/images_controller.rb
spree_core-0.40.1 app/controllers/admin/images_controller.rb
spree_core-0.40.0 app/controllers/admin/images_controller.rb
spree_core-0.30.1 app/controllers/admin/images_controller.rb
spree_core-0.30.0 app/controllers/admin/images_controller.rb
spree-0.11.2 app/controllers/admin/images_controller.rb
spree-0.11.1 app/controllers/admin/images_controller.rb
spree_core-0.30.0.beta1 app/controllers/admin/images_controller.rb
spree-0.11.0 app/controllers/admin/images_controller.rb
spree-0.10.2 app/controllers/admin/images_controller.rb