This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module ApplicationHelper | |
| def show_back_to_operation_button | |
| current_operation && !@skip_current_operation_button | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body | |
| ... | |
| main[role="main"] | |
| == render 'layouts/messages' | |
| - if show_back_to_operation_button | |
| .btn-group | |
| / And just add a button right to layout. | |
| / I know I need to add a helper for that - will do that shortly | |
| = button_to "Back to #{current_operation.title}", | |
| RailsWorkflow::Engine.routes.url_helpers.navigate_to_operations_path, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body | |
| header | |
| ... | |
| main[role="main"] | |
| ... | |
| / Checking if we have some active current operation | |
| - if current_operation | |
| .btn-group | |
| / And just add a button right to layout. | |
| / I know I need to add a helper for that - will do that shortly |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RailsWorkflow::ProcessManager.start_process( | |
| template.id, | |
| { user: self, url_path: 'current_operation_path', url_params: self } | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CollectUserDataTemplate < RailsWorkflow::OperationTemplate | |
| def after_operation_create(new_operation) | |
| new_operation.data[:new_key] = 'new_value' | |
| # new_operation.process.operations | |
| new_operation.title += " [#{new_operation.data[:user].email}]" | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # app/views/operations/collect_user_data.html.erb | |
| <% user = current_operation.data[:user] %> | |
| <% if current_operation.present? %> | |
| <h1><%= current_operation.title %></h1> | |
| <% end %> | |
| <h3>User</h3> | |
| <p>Email: <%= user.email if user.email %></p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class User < ApplicationRecord | |
| ... | |
| after_create :start_newcomer_process | |
| def start_newcomer_process | |
| template = RailsWorkflow::ProcessTemplate.find_by_title('New User Process') | |
| # we using current_operation_path to navigate to a new endpoint | |
| # when user picks up operation | |
| RailsWorkflow::ProcessManager.start_process( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # app/controllers/operations_controller.rb | |
| class OperationsController < ApplicationController | |
| def current | |
| render current_operation.tag | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Rails.application.routes.draw do | |
| ... | |
| resource :operation do | |
| get :current | |
| end | |
| ... | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UsersController < ApplicationController | |
| ... | |
| def update | |
| if current_operation | |
| current_operation.complete | |
| redirect_to users_path | |
| end | |
| end | |
| end |