Module: Crm::WorkflowsHelper
- Defined in:
- app/helpers/crm/workflows_helper.rb
Instance Method Summary collapse
- #available_events_links(context_object, link_options = {}, confirm_options = {}, exclude_events = [], parent_object = nil) ⇒ Object
-
#dynamic_status_drop_down(context_object, return_path: nil, parent_object: nil, btn_class: nil) ⇒ Object
A Hybrid combo button displaying the current state and possible events.
- #state_workflow_button(object) ⇒ Object
Instance Method Details
#available_events_links(context_object, link_options = {}, confirm_options = {}, exclude_events = [], parent_object = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/crm/workflows_helper.rb', line 7 def available_events_links(context_object, = {}, = {}, exclude_events = [], parent_object = nil) = .dup # Ensures we only operate on a copy include_link_icon = .delete(:include_link_icon).to_b return_path = .delete(:return_path) available_events = possible_events(context_object) available_events.map do |evt| next if exclude_events.include?(evt.to_s) = {} = { turbo_confirm: [:prompt] } if [:event] and [:event] == evt link_title = include_link_icon ? fa_icon('right-to-bracket', text: evt.to_s.titleize) : evt.to_s.titleize link_to(link_title.html_safe, polymorphic_path([:workflow_action, *([parent_object, context_object].compact)], wf_action: evt.to_s, return_path:), class: 'state_machine_event', title: context_object.try(:event_description, evt), data: , **) end end |
#dynamic_status_drop_down(context_object, return_path: nil, parent_object: nil, btn_class: nil) ⇒ Object
A Hybrid combo button displaying the current state and possible events
3 4 5 |
# File 'app/helpers/crm/workflows_helper.rb', line 3 def dynamic_status_drop_down(context_object, return_path: nil, parent_object: nil, btn_class: nil) render partial: '/shared/dynamic_status', locals: { context_object:, return_path:, parent_object:, btn_class: } end |
#state_workflow_button(object) ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/helpers/crm/workflows_helper.rb', line 28 def (object) actions = [] actions << object.human_state_name.titleize actions += available_events_links(object, data: { turbo_confirm: 'Are you sure?' }) actions << { content: object.try(:state_description) } if object.try(:state_description).present? render_simple_drop_down actions, dropdown_options: { right_menu: true } end |