Class: RailsWorkflow::OperationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rails_workflow/operations_controller.rb

Overview

Operations controller. Allows to pickup (start), skip, postpone, cancel, complete operations.

Instance Method Summary collapse

Instance Method Details

#completeObject



74
75
76
77
78
79
80
81
82
# File 'app/controllers/rails_workflow/operations_controller.rb', line 74

def complete
  operation = current_operation
  if operation.present?
    operation.complete
    clear_current_operation

    redirect_to main_app.root_path
  end
end

#continueObject



49
50
51
52
53
54
55
56
57
58
59
# File 'app/controllers/rails_workflow/operations_controller.rb', line 49

def continue
  if @operation.present? && @operation.assigned_to?(current_user)
    set_current_operation
    redirect_to main_app.send(
      @operation.data[:url_path],
      *@operation.data[:url_params]
    )
  else
    redirect_to operations_path
  end
end

#createObject



21
22
23
24
# File 'app/controllers/rails_workflow/operations_controller.rb', line 21

def create
  @operation = Operation.create(permitted_params)
  redirect_to process_operation_url
end

#destroyObject



91
92
93
94
# File 'app/controllers/rails_workflow/operations_controller.rb', line 91

def destroy
  @operation.destroy
  redirect_to process_operation_url
end

#indexObject



26
27
28
29
30
31
32
# File 'app/controllers/rails_workflow/operations_controller.rb', line 26

def index
  @operations = OperationDecorator.decorate_collection(
    parent.try(:operations) || Operation.waiting.order(created_at: :desc)
  )

  respond_with @operations
end


39
40
41
42
43
44
45
46
47
# File 'app/controllers/rails_workflow/operations_controller.rb', line 39

def navigate_to
  return if current_operation.nil?
  @operation = current_operation.object

  redirect_to main_app.send(
    @operation.data[:url_path],
    *@operation.data[:url_params]
  )
end

#pickupObject



61
62
63
64
65
66
67
68
69
70
71
72
# File 'app/controllers/rails_workflow/operations_controller.rb', line 61

def pickup
  if @operation.assign(current_user)

    set_current_operation
    redirect_to main_app.send(
      @operation.data[:url_path],
      *@operation.data[:url_params]
    )
  else
    redirect_to operations_path
  end
end

#postponeObject



84
85
86
87
88
89
# File 'app/controllers/rails_workflow/operations_controller.rb', line 84

def postpone
  operation = current_operation
  clear_current_operation if operation.present?

  redirect_to main_app.root_path
end

#updateObject



34
35
36
37
# File 'app/controllers/rails_workflow/operations_controller.rb', line 34

def update
  @operation.update(permitted_params)
  redirect_to process_operation_url
end