Module: Engine2::ActionModifySupport

Includes:
ActionFormSupport
Included in:
ArrayModifyAction, ModifyAction
Defined in:
lib/engine2/action.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ActionFormSupport

#create?, #field_tabs, #field_template, #hr_after, #modify?, #post_process, #template

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

#field_tabs, #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?, #post_process

Methods included from ActionAngularSupport

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

Methods included from ActionOnChangeSupport

#on_change

Class Method Details

.included(action) ⇒ Object



1092
1093
1094
# File 'lib/engine2/action.rb', line 1092

def self.included action
    action.action_type :modify
end

Instance Method Details

#invoke(handler) ⇒ Object



1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
# File 'lib/engine2/action.rb', line 1109

def invoke handler
    handler.permit id = handler.params[:id]
    record = find_record(handler, id)

    if record
        static.record(handler, record)
        {record: record}
    else
        handler.halt_not_found LOCS[:no_entry]
    end
end

#modify_record(handler, record) ⇒ Object



1106
1107
# File 'lib/engine2/action.rb', line 1106

def modify_record handler, record
end

#post_runObject



1121
1122
1123
1124
1125
1126
# File 'lib/engine2/action.rb', line 1121

def post_run
    super
    assets[:model].primary_keys.each do |key| # pre_run ?
        fields! key, disabled: true
    end
end

#pre_runObject



1096
1097
1098
1099
1100
# File 'lib/engine2/action.rb', line 1096

def pre_run
    super
    panel_title "#{LOCS[:modify_title]} - #{LOCS[assets[:model].table_name]}"
    node.parent.*.menu(:item_menu).option node.name, icon: "pencil", button_loc: false
end

#record(handler, record) ⇒ Object



1102
1103
1104
# File 'lib/engine2/action.rb', line 1102

def record handler, record
    modify_record(handler, record)
end