Class: Engine2::DecodeEntryAction

Inherits:
DecodeAction show all
Defined in:
lib/engine2/action/decode.rb

Instance Attribute Summary

Attributes inherited from Action

#assets, #invokable, #meta, #node, #static

Instance Method Summary collapse

Methods inherited from DecodeAction

#decode, #post_process, #pre_run, #separator, #show_max_selected

Methods included from ActionAPISupport

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

Methods included from ActionModelSupport

#hide_pk, #node_defined, #pre_run, #show_pk, #unsupported_association

Methods included from ActionQuerySupport

#find_record, #get_query, #query, #select

Methods inherited from Action

action_type, #action_type, #arguments, #check_anonymous_action_class, #check_static_action, #define_invoke, #define_method, #dynamic?, #execute, #freeze_action, #http_method, http_method, inherit, inherited, #initialize, #invoke!, #join_keys, #lookup, #merge, #node_defined, #post_process, #pre_run, #repeat, #request, #request_action_proc_params, #split_keys

Constructor Details

This class inherits a constructor from Engine2::Action

Instance Method Details

#invoke(handler) ⇒ Object



120
121
122
# File 'lib/engine2/action/decode.rb', line 120

def invoke handler
    {entries: invoke_decode(handler, handler.param_to_json(:ids))}
end

#invoke_decode(handler, ids) ⇒ Object



124
125
126
127
128
# File 'lib/engine2/action/decode.rb', line 124

def invoke_decode handler, ids
    records = get_query.where(ids.map{|keys| Hash[assets[:model].primary_keys.zip(keys)]}.reduce{|q, c| q | c}).load_all
    # handler.halt_not_found(LOCS[:no_entry]) if records.empty?
    records
end

#post_runObject



130
131
132
133
134
135
136
137
138
139
140
# File 'lib/engine2/action/decode.rb', line 130

def post_run
    super
    if assoc = assets[:assoc]
        decode = assoc[:model].type_info[assoc[:keys].first][:decode]

        if decode[:search][:multiple] && node.parent.parent.*.is_a?(ListAction)
            node.list.*.menu(:panel_menu).option :choose, icon: :ok #, disabled: "action.selected_size() == 0"
            node.list.*.menu(:panel_menu).option :cancel, icon: "remove"
        end
    end
end