Class: Wco::OfficeActionTemplatesController
Instance Method Summary
collapse
#home, #tinymce
#my_truthy?, #obfuscate, #pp_amount, #pp_currency, #pp_date, #pp_datetime, #pp_money, #pp_percent, #pp_time, #pretty_date
Instance Method Details
#edit ⇒ Object
6
7
8
9
10
|
# File 'app/controllers/wco/office_action_templates_controller.rb', line 6
def edit
@oat = OAT.find params[:id]
@oat.ties.push Wco::OfficeActionTemplateTie.new
authorize! :edit, @oat
end
|
#index ⇒ Object
12
13
14
15
16
17
|
# File 'app/controllers/wco/office_action_templates_controller.rb', line 12
def index
authorize! :index, OAT
@oats = OAT.all
@new_oat = OAT.new
@new_oat.ties.push Wco::OfficeActionTemplateTie.new
end
|
#new ⇒ Object
19
20
21
22
23
|
# File 'app/controllers/wco/office_action_templates_controller.rb', line 19
def new
@oat = OAT.new
@oat.ties.push Wco::OfficeActionTemplateTie.new
authorize! :new, @oat
end
|
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'app/controllers/wco/office_action_templates_controller.rb', line 25
def perform
@oat = OAT.find params[:id]
authorize! :run, @oat
@conversations = WcoEmail::Conversation.find( params[:conversation_ids] ) if params[:conversation_ids].present?
if 'rb' == @oat.action_type
out = eval( @oat.action_exe )
elsif 'sh' == @oat.action_type
out = `#{@oat.action_exe}`
end
flash_notice out
redirect_to action: :index
end
|
#show ⇒ Object
38
39
40
41
|
# File 'app/controllers/wco/office_action_templates_controller.rb', line 38
def show
@oat = OAT.find params[:id]
authorize! :show, @oat
end
|
#update ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'app/controllers/wco/office_action_templates_controller.rb', line 43
def update
params[:oat][:ties_attributes].permit! rescue nil
if params[:id]
@oat = OAT.find params[:id]
else
@oat = OAT.new
end
authorize! :upsert, @oat
if params[:oat][:ties_attributes]
params[:oat][:ties_attributes].each do |k, v|
if !v[:next_office_action_template_id].present?
params[:oat][:ties_attributes].delete( k )
end
if v[:to_delete] == "1"
OATT.find( v[:id] ).delete
params[:oat][:ties_attributes].delete( k )
end
end
end
if @oat.update params[:oat].permit!
flash_notice @oat
else
flash_alert @oat
end
redirect_to action: :index
end
|