Class: SolidusAdmin::AdjustmentsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/solidus_admin/adjustments_controller.rb

Instance Method Summary collapse

Methods included from ComponentsHelper

#component

Instance Method Details

#destroyObject



36
37
38
39
40
41
42
# File 'app/controllers/solidus_admin/adjustments_controller.rb', line 36

def destroy
  @adjustments = @order.all_adjustments.where(id: params[:id])
  @adjustments.destroy_all
  flash[:success] = t('.success')

  redirect_to order_adjustments_path(@order), status: :see_other
end

#indexObject



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/solidus_admin/adjustments_controller.rb', line 6

def index
  load_adjustments
  set_page_and_extract_portion_from(@adjustments)

  respond_to do |format|
    format.html do
      render component('orders/show/adjustments/index').new(
        order: @order,
        adjustments: @adjustments,
      )
    end
  end
end

#lockObject



20
21
22
23
24
25
26
# File 'app/controllers/solidus_admin/adjustments_controller.rb', line 20

def lock
  @adjustments = @order.all_adjustments.not_finalized.where(id: params[:id])
  @adjustments.each(&:finalize!)
  flash[:success] = t('.success')

  redirect_to order_adjustments_path(@order), status: :see_other
end

#unlockObject



28
29
30
31
32
33
34
# File 'app/controllers/solidus_admin/adjustments_controller.rb', line 28

def unlock
  @adjustments = @order.all_adjustments.finalized.where(id: params[:id])
  @adjustments.each(&:unfinalize!)
  flash[:success] = t('.success')

  redirect_to order_adjustments_path(@order), status: :see_other
end