Class: RailsWorkflow::OperationsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- RailsWorkflow::OperationsController
- 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
- #complete ⇒ Object
- #continue ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #navigate_to ⇒ Object
- #pickup ⇒ Object
- #postpone ⇒ Object
- #update ⇒ Object
Instance Method Details
#complete ⇒ Object
76 77 78 79 80 81 82 83 84 |
# File 'app/controllers/rails_workflow/operations_controller.rb', line 76 def complete operation = current_operation if operation.present? operation.complete clear_current_operation redirect_to main_app.root_path end end |
#continue ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'app/controllers/rails_workflow/operations_controller.rb', line 51 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 |
#create ⇒ Object
23 24 25 26 |
# File 'app/controllers/rails_workflow/operations_controller.rb', line 23 def create @operation = Operation.create(permitted_params) redirect_to process_operation_url end |
#destroy ⇒ Object
93 94 95 96 |
# File 'app/controllers/rails_workflow/operations_controller.rb', line 93 def destroy @operation.destroy redirect_to process_operation_url end |
#index ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/controllers/rails_workflow/operations_controller.rb', line 28 def index @operations = OperationDecorator.decorate_collection( parent.try(:operations) || Operation.waiting.order(created_at: :desc) ) respond_with @operations end |
#navigate_to ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/rails_workflow/operations_controller.rb', line 41 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 |
#pickup ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/controllers/rails_workflow/operations_controller.rb', line 63 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 |
#postpone ⇒ Object
86 87 88 89 90 91 |
# File 'app/controllers/rails_workflow/operations_controller.rb', line 86 def postpone operation = current_operation clear_current_operation if operation.present? redirect_to main_app.root_path end |
#update ⇒ Object
36 37 38 39 |
# File 'app/controllers/rails_workflow/operations_controller.rb', line 36 def update @operation.update(permitted_params) redirect_to process_operation_url end |