Sha256: d1e959148a23254e3311a1c59ae83a8ec295956b53e18291e3497ccf1327b08e

Contents?: true

Size: 873 Bytes

Versions: 3

Compression:

Stored size: 873 Bytes

Contents

module Workarea
  decorate Admin::CatalogVariantsController, with: :product_additional_details do

    def update
      @variant = @product.variants.find(params[:id])
      set_details
      set_additional_details

      if @variant.update_attributes(params[:variant])
        flash[:success] = t('workarea.admin.catalog_variants.flash_messages.saved')
        redirect_to catalog_product_variants_path(@product)
      else
        flash[:error] = t('workarea.admin.catalog_variants.flash_messages.changes_error')
        render :edit
      end
    end

    def set_additional_details
      @variant.additional_details = HashUpdate.new(
        original: @product.additional_details,
        adds: params[:new_additional_details],
        updates: params[:additional_details],
        removes: params[:additional_details_to_remove]
      ).result_grouped
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
workarea-product_additional_details-2.0.31 app/controllers/workarea/admin/catalog_variants_controller.decorator
workarea-product_additional_details-2.0.3 app/controllers/workarea/admin/catalog_variants_controller.decorator
workarea-product_additional_details-2.0.2 app/controllers/workarea/admin/catalog_variants_controller.decorator