Class: Spree::Admin::StoresController

Inherits:
BaseController show all
Includes:
SettingsConcern
Defined in:
app/controllers/spree/admin/stores_controller.rb

Instance Method Summary collapse

Methods included from SettingsConcern

#choose_layout

Methods included from BreadcrumbConcern

#add_breadcrumb_icon_instance_var

Instance Method Details

#editObject



11
12
13
14
15
16
17
18
19
# File 'app/controllers/spree/admin/stores_controller.rb', line 11

def edit
  if params[:section] == 'emails'
    add_breadcrumb Spree.t(:emails), spree.edit_admin_store_path(section: params[:section])
  elsif params[:section] == 'checkout'
    add_breadcrumb Spree.t(:checkout), spree.edit_admin_store_path(section: params[:section])
  else
    add_breadcrumb Spree.t(:store_details), spree.edit_admin_store_path(section: params[:section])
  end
end

#edit_emailsObject



21
# File 'app/controllers/spree/admin/stores_controller.rb', line 21

def edit_emails; end

#updateObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/spree/admin/stores_controller.rb', line 23

def update
  @store.assign_attributes(permitted_store_params)

  if @store.save
    remove_assets(%w[logo mailer_logo], object: @store)
    respond_to do |format|
      format.turbo_stream { flash.now[:success] = flash_message_for(@store, :successfully_updated) }
      format.html { flash[:success] = flash_message_for(@store, :successfully_updated) }
    end
  else
    flash[:error] = "#{Spree.t('store_errors.unable_to_update')}: #{@store.errors.full_messages.join(', ')}"
  end

  if @store.saved_changes? && permitted_store_params[:code].present? && spree.respond_to?(:admin_custom_domains_url)
    redirect_to spree.admin_custom_domains_url(host: @store.url), allow_other_host: true
  else
    respond_to do |format|
      format.turbo_stream
      format.html { redirect_to spree.edit_admin_store_path(section: params[:section]) }
    end
  end
end