app/controllers/runs_controller.rb
# adding new assoced member with its template to input
adding new assoced member with its template to input
adding new assoced member with its template to input
def adding_assoc_target
    params.symbolize_keys!
    controller = params[:controller]
    prefix            = params[:prefix]
    base_div_id       = params[:base_div_id]    
    template          = params[:template]     
    options           = params[:options].to_h
    single            = options[:single] ? 'yes' : 'no'
    uuid              = random_id  
    pre_assoc_items    = pre_assoc_items_from_prefix(prefix)
    assoc_entity_name  = pre_assoc_items[-2]
    assoc_name         = pre_assoc_items[-1]
    assoc_entity       = find_entity(assoc_entity_name)
    @root_entity_since = assoc_entity.since || @show_time
    assoc              = assoc_entity.send(assoc_name)
    assoc_target_type  = assoc.assoc_target_type
    assoc_target       = assoc_target_type == :dependee ? assoc_entity.send("build_#{assoc_name}") : assoc.build(Run::Since => @root_entity_since)
    prepare_for_adding_assoc_target(assoc_target, pre_assoc_items)
    render :update do |page|
       page.insert_html :bottom, base_div_id, 
            :partial => template, 
            :locals  => {:uuid => uuid,
                         :prefix => prefix,
                         :assoc_name => assoc_name,
                         :assoc_target => assoc_target,
                         :options => options},
            :object  => assoc_target
        page << "recount_assoc_target_counters('#{base_div_id}', '#{single}')"
    end
  end
def adding_assoc_target params . symbolize_keys! controller = params [ :controller ] prefix = params [ :prefix ] base_div_id = params [ :base_div_id ] template = params [ :template ] options = params [ :options ] . to_h single = options [ :single ] ? 'yes' : 'no' uuid = random_id pre_assoc_items = pre_assoc_items_from_prefix ( prefix ) assoc_entity_name = pre_assoc_items [ - 2 ] assoc_name = pre_assoc_items [ - 1 ] assoc_entity = find_entity ( assoc_entity_name ) @root_entity_since = assoc_entity . since || @show_time assoc = assoc_entity . send ( assoc_name ) assoc_target_type = assoc . assoc_target_type assoc_target = assoc_target_type == :dependee ? assoc_entity . send ( "build_#{assoc_name}" ) : assoc . build ( Run :: Since => @root_entity_since ) prepare_for_adding_assoc_target ( assoc_target , pre_assoc_items ) render :update do | page | page . insert_html :bottom , base_div_id , :partial => template , :locals => { :uuid => uuid , :prefix => prefix , :assoc_name => assoc_name , :assoc_target => assoc_target , :options => options } , :object => assoc_target page << "recount_assoc_target_counters('#{base_div_id}', '#{single}')" end end
adding new assoced member with its template to input
adding new assoced member with its template to input
# id of div to add # assoc'ed entity template to add # generate random id (should be unique). # recover association from params[:prefix] # prepare for adding new assoc_target. # add assoc target entity template. # set counter value of each assoc_target.