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
73 74 75 76 77 78 79 80 81 |
# File 'app/controllers/rails_workflow/operations_controller.rb', line 73 def complete operation = current_operation if operation.present? operation.complete clear_current_operation redirect_to main_app.root_path end end |
#continue ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/rails_workflow/operations_controller.rb', line 48 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
22 23 24 25 |
# File 'app/controllers/rails_workflow/operations_controller.rb', line 22 def create @operation = Operation.create(permitted_params) redirect_to process_operation_url end |
#destroy ⇒ Object
90 91 92 93 |
# File 'app/controllers/rails_workflow/operations_controller.rb', line 90 def destroy @operation.destroy redirect_to process_operation_url end |
#index ⇒ Object
27 28 29 30 31 |
# File 'app/controllers/rails_workflow/operations_controller.rb', line 27 def index @operations = OperationDecorator.decorate_collection( parent.try(:operations) || Operation.waiting.order(created_at: :desc) ) end |
#navigate_to ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'app/controllers/rails_workflow/operations_controller.rb', line 38 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
60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/rails_workflow/operations_controller.rb', line 60 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
83 84 85 86 87 88 |
# File 'app/controllers/rails_workflow/operations_controller.rb', line 83 def postpone operation = current_operation clear_current_operation if operation.present? redirect_to main_app.root_path end |
#update ⇒ Object
33 34 35 36 |
# File 'app/controllers/rails_workflow/operations_controller.rb', line 33 def update @operation.update(permitted_params) redirect_to process_operation_url end |