Class: Engine2::StarToManyFieldAction
- Inherits:
-
StarToManyListAction
- Object
- Action
- ListAction
- StarToManyListAction
- Engine2::StarToManyFieldAction
- Defined in:
- lib/engine2/action/list.rb
Overview
*_to_many_field
Direct Known Subclasses
Instance Attribute Summary
Attributes included from ActionListSupport
#default_order_field, #filters, #orders
Attributes inherited from Action
#assets, #invokable, #meta, #node, #static
Instance Method Summary collapse
Methods inherited from StarToManyListAction
Methods inherited from ListAction
#invoke, #list_order, #list_search, #page_frame, #post_run
Methods included from ActionListSupport
#default_order, #field_tabs, #filter, #filter_case_insensitive, #order, #post_process, #post_run, #search_live, #search_template, #searchable, #searchable_tabs, #select_toggle_menu, #sortable, #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, #post_run
Methods included from ActionMenuSupport
Methods included from ActionOnChangeSupport
Methods included from ActionDraggableSupport
Methods included from ActionQuerySupport
#find_record, #get_query, #post_run, #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, #post_run, #repeat, #request, #request_action_proc_params, #split_keys
Constructor Details
This class inherits a constructor from Engine2::Action
Instance Method Details
#list_context(query, handler) ⇒ Object
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/engine2/action/list.rb', line 288 def list_context query, handler changes = handler.param_to_json(:changes) model = assets[:model] unlinked = changes[:unlink].to_a + changes[:delete].to_a + changes[:modify].to_a.map{|m|join_keys(model.primary_keys.map{|k|m[k]})} linked = changes[:link] query = super(query, handler) pks = model.primary_keys_qualified if handler.params[:negate] query = unlinked.reduce(query){|q, unl|q.or pks.zip(split_keys(unl))} query = linked.reduce(query){|q, ln|q.where(pks.zip(split_keys(ln)).sql_negate)} else query = unlinked.reduce(query){|q, unl|q.where(pks.zip(split_keys(unl)).sql_negate)} query = case assets[:assoc][:type] when :one_to_many linked.reduce(query){|q, ln|q.or pks.zip(split_keys(ln))} when :many_to_many linked.reduce(query){|q, ln|q.or pks.zip(split_keys(ln))}.distinct else unsupported_association end unless linked.empty? end added = changes[:create].to_a + changes[:modify].to_a cols = get_query.columns query = added.reduce query do |q, a| q.union(model.db.select(*cols.map{|c|a[c]}), all: true, alias: model.table_name) end query end |
#pre_run ⇒ Object
282 283 284 285 286 |
# File 'lib/engine2/action/list.rb', line 282 def pre_run super modal_action false panel_panel_template false end |