Module: Engine2::ActionFormSupport

Instance Method Summary collapse

Methods included from ActionModelSupport

#hide_pk, #node_defined, #show_pk, #unsupported_association

Methods included from ActionAPISupport

#config, #decorate, #field_filter, #fields, #fields!, #hide_fields, #loc!, #render, #show_fields

Methods included from ActionTabSupport

#select_tabs, #tab

Methods included from ActionPanelSupport

#modal_action, #panel, #panel_class, #panel_footer, #panel_header, #panel_panel_template, #panel_template, #panel_title

Methods included from ActionMenuSupport

#menu, #menu?

Methods included from ActionAngularSupport

#ng_call, #ng_execute, #ng_info!, #ng_record, #ng_record!

Methods included from ActionOnChangeSupport

#on_change

Instance Method Details

#field_tabs(hash) ⇒ Object



973
974
975
976
# File 'lib/engine2/action.rb', line 973

def field_tabs hash
    super
    panel_template 'scaffold/form_tabs'
end

#field_template(template) ⇒ Object



956
957
958
# File 'lib/engine2/action.rb', line 956

def field_template template
    panel[:field_template] = template
end

#hr_after(field, message = '-') ⇒ Object



1025
1026
1027
# File 'lib/engine2/action.rb', line 1025

def hr_after field, message = '-'
    fields! field, hr: message
end

#post_processObject



981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
# File 'lib/engine2/action.rb', line 981

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]] # .merge(default: true)
                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
            # fields.select{|f| assoc[:keys].include? f}.each do |key|
            #     # hide_fields(key) if self[:fields, key, :hidden] == nil
            #     fields! key, disabled: true
            # end
            assoc[:keys].each do |key|
                fields! key, disabled: true if fields.include? key
            end
        end
    end

    super
end

#post_runObject



1016
1017
1018
1019
# File 'lib/engine2/action.rb', line 1016

def post_run
    super
    @meta[:primary_fields] = assets[:model].primary_keys
end

#pre_runObject



960
961
962
963
964
965
966
967
968
969
970
971
# File 'lib/engine2/action.rb', line 960

def pre_run
    super
    panel_template 'scaffold/form'
    field_template 'scaffold/fields'
    panel_class 'modal-large'
    top = node.parent.parent == nil
    menu :panel_menu do
        option :approve, icon: "ok", disabled: "action.action_pending()" # text: true,
        option :cancel, icon: "remove" unless top # text: true,
    end
    # modal_action false
end

#record(handler, record) ⇒ Object



978
979
# File 'lib/engine2/action.rb', line 978

def record handler, record
end

#templateObject



1021
1022
1023
# File 'lib/engine2/action.rb', line 1021

def template
    Templates
end