Sha256: 0726b0eb3692ed579f9b091c45bf890847c2e99f8269fe5bef7bd249075e0f79

Contents?: true

Size: 785 Bytes

Versions: 3

Compression:

Stored size: 785 Bytes

Contents

# frozen_string_literal: true

module SolidusAdmin
  class ZonesController < SolidusAdmin::BaseController
    include SolidusAdmin::ControllerHelpers::Search

    def index
      zones = apply_search_to(
        Spree::Zone.order(id: :desc),
        param: :q
      )

      set_page_and_extract_portion_from(zones)

      respond_to do |format|
        format.html { render component('zones/index').new(page: @page) }
      end
    end

    def destroy
      @zones = Spree::Zone.where(id: params[:id])

      Spree::Zone.transaction { @zones.destroy_all }

      flash[:notice] = t('.success')
      redirect_back_or_to zones_path, status: :see_other
    end

    private

    def zone_params
      params.require(:zone).permit(:zone_id, permitted_zone_attributes)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solidus_admin-0.3.2 app/controllers/solidus_admin/zones_controller.rb
solidus_admin-0.3.1 app/controllers/solidus_admin/zones_controller.rb
solidus_admin-0.3.0 app/controllers/solidus_admin/zones_controller.rb