Module: Engine2::ActionFormSupport
Instance Method Summary
collapse
#hide_pk, #node_defined, #show_pk, #unsupported_association
#config, #decorate, #field_filter, #fields, #fields!, #hide_fields, #loc!, #render, #show_fields
#select_tabs, #tab
#modal_action, #panel, #panel_class, #panel_footer, #panel_header, #panel_panel_template, #panel_template, #panel_title
#menu, #menu?
#ng_call, #ng_execute, #ng_info!, #ng_record, #ng_record!
#on_change
Instance Method Details
#create? ⇒ Boolean
1044
1045
1046
|
# File 'lib/engine2/action.rb', line 1044
def create?
@action_type == :create
end
|
#field_tabs(hash) ⇒ Object
988
989
990
991
|
# File 'lib/engine2/action.rb', line 988
def field_tabs hash
super
panel_template 'scaffold/form_tabs'
end
|
#field_template(template) ⇒ Object
971
972
973
|
# File 'lib/engine2/action.rb', line 971
def field_template template
panel[:field_template] = template
end
|
#hr_after(field, message = '-') ⇒ Object
1040
1041
1042
|
# File 'lib/engine2/action.rb', line 1040
def hr_after field, message = '-'
fields! field, hr: message
end
|
#modify? ⇒ Boolean
1048
1049
1050
|
# File 'lib/engine2/action.rb', line 1048
def modify?
@action_type == :modify
end
|
#post_process ⇒ Object
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
|
# File 'lib/engine2/action.rb', line 996
def post_process
if fields = @meta[:field_list]
model = assets[:model]
fields = fields - static.meta[:field_list] if dynamic?
decorate(fields)
fields.each do |name|
type_info = model.find_type_info(name)
fields(name)[:render] ||= begin
renderer = DefaultFormRenderers[type_info[:type]] raise E2Error.new("No form renderer found for field '#{type_info[:name]}' of type '#{type_info[:type]}'") unless renderer
renderer.(self, type_info)
end
proc = FormRendererPostProcessors[type_info[:type]]
proc.(self, name, type_info) if proc
end
assoc = assets[:assoc]
if assoc && assoc[:type] == :one_to_many
assoc[:keys].each do |key|
fields! key, disabled: true if fields.include? key
end
end
end
super
end
|
1031
1032
1033
1034
|
# File 'lib/engine2/action.rb', line 1031
def post_run
super
@meta[:primary_fields] = assets[:model].primary_keys
end
|
975
976
977
978
979
980
981
982
983
984
985
986
|
# File 'lib/engine2/action.rb', line 975
def pre_run
super
panel_template 'scaffold/form'
field_template 'scaffold/fields'
panel_class 'modal-large'
top = node.parent.parent == nil
:panel_menu do
option :approve, icon: "ok", disabled: "action.action_pending()" option :cancel, icon: "remove" unless top end
end
|
#record(handler, record) ⇒ Object
993
994
|
# File 'lib/engine2/action.rb', line 993
def record handler, record
end
|
1036
1037
1038
|
# File 'lib/engine2/action.rb', line 1036
def template
Templates
end
|