class Engine2::StarToManyFieldAction
*_to_many_field
Public Instance Methods
list_context(query, handler)
click to toggle source
Calls superclass method
Engine2::StarToManyListAction#list_context
# 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()
click to toggle source
Calls superclass method
Engine2::StarToManyListAction#pre_run
# File lib/engine2/action/list.rb, line 282 def pre_run super modal_action false panel_panel_template false end