Class: RailsOnboarding::Admin::FlowsController
Overview
Admin flows controller
Visual editor for creating and managing onboarding flows
Constant Summary
BaseController::DEFAULT_PER_PAGE, BaseController::MAX_PER_PAGE
Instance Method Summary
collapse
Instance Method Details
#activate ⇒ Object
81
82
83
84
85
86
87
88
89
90
|
# File 'app/controllers/rails_onboarding/admin/flows_controller.rb', line 81
def activate
RailsOnboarding::Flow.activate!(@flow)
RailsOnboarding.configuration.clear_cache!
flash[:notice] = "Flow '#{@flow.name}' is now active"
redirect_to admin_flows_path
rescue StandardError => e
logger.error "Error activating flow: #{e.message}"
flash[:alert] = "Failed to activate flow"
redirect_to admin_flows_path
end
|
#create ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'app/controllers/rails_onboarding/admin/flows_controller.rb', line 28
def create
@flow = RailsOnboarding::Flow.new(flow_params)
if @flow.save
flash[:notice] = "Flow '#{@flow.name}' created successfully"
redirect_to admin_flows_path
else
flash.now[:alert] = "Failed to create flow: #{@flow.errors.full_messages.join(', ')}"
@available_icons = available_icons
render :new
end
end
|
#destroy ⇒ Object
56
57
58
59
60
61
62
63
64
65
|
# File 'app/controllers/rails_onboarding/admin/flows_controller.rb', line 56
def destroy
if @flow.active?
flash[:alert] = "Failed to delete flow. Cannot delete active flow."
elsif @flow.destroy
flash[:notice] = "Flow deleted successfully"
else
flash[:alert] = "Failed to delete flow."
end
redirect_to admin_flows_path
end
|
#duplicate ⇒ Object
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'app/controllers/rails_onboarding/admin/flows_controller.rb', line 67
def duplicate
new_flow = @flow.dup
new_flow.name = "#{@flow.name} (Copy)"
new_flow.active = false
if new_flow.save
flash[:notice] = "Flow duplicated successfully"
redirect_to admin_flow_path(new_flow)
else
flash[:alert] = "Failed to duplicate flow"
redirect_to admin_flows_path
end
end
|
#edit ⇒ Object
41
42
43
|
# File 'app/controllers/rails_onboarding/admin/flows_controller.rb', line 41
def edit
@available_icons = available_icons
end
|
#index ⇒ Object
10
11
12
13
14
15
16
|
# File 'app/controllers/rails_onboarding/admin/flows_controller.rb', line 10
def index
@pagy, @flows = paginate(flows_collection)
@active_flow = RailsOnboarding::Flow.active.first
@templates = available_templates
end
|
#new ⇒ Object
23
24
25
26
|
# File 'app/controllers/rails_onboarding/admin/flows_controller.rb', line 23
def new
@flow = RailsOnboarding::Flow.new(default_flow_structure)
@available_icons = available_icons
end
|
#preview ⇒ Object
92
93
94
95
|
# File 'app/controllers/rails_onboarding/admin/flows_controller.rb', line 92
def preview
@steps = @flow.steps || []
render layout: "rails_onboarding/application"
end
|
#show ⇒ Object
18
19
20
21
|
# File 'app/controllers/rails_onboarding/admin/flows_controller.rb', line 18
def show
@steps = @flow.steps || []
@flow_stats = calculate_flow_stats(@flow)
end
|
#update ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'app/controllers/rails_onboarding/admin/flows_controller.rb', line 45
def update
if @flow.update(flow_params)
flash[:notice] = "Flow updated successfully"
redirect_to admin_flow_path(@flow)
else
flash.now[:alert] = "Failed to update flow: #{@flow.errors.full_messages.join(', ')}"
@available_icons = available_icons
render :edit
end
end
|