You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

51 lines
3.1 KiB

<% # hide "Replace with new" for SOA record
begin
remote_controller = active_scaffold_controller_for(column.association.klass)
rescue ActiveScaffold::ControllerNotFound
remote_controller = nil
end
@record = parent_record
show_add_existing = column_show_add_existing(column, parent_record)
show_add_new = column_show_add_new(column, associated, parent_record)
return unless show_add_new or show_add_existing
temporary_id = generated_id(parent_record) if parent_record.new_record?
controller_path = active_scaffold_controller_for(parent_record.class).controller_path
edit_associated_url = params_for(:controller => controller_path, :action => 'edit_associated', :child_association => column.name, :associated_id => '--ID--', :scope => scope, :id => parent_record.to_param, :generated_id => temporary_id, :parent_controller => controller.controller_path) if show_add_existing
add_new_url = params_for(:controller => controller_path, :action => 'edit_associated', :child_association => column.name, :scope => scope, :id => parent_record.to_param, :generated_id => temporary_id, :parent_controller => controller.controller_path) if show_add_new
-%>
<div class="footer-wrapper">
<div class="footer">
<% if show_add_new && column.name != :soa_record -%>
<% if column.plural_association?
add_label = as_(:create_another, :model => column.association.klass.model_name.human)
add_class = 'as_create_another'
else
add_label = as_(:replace_with_new)
add_class = 'as_replace_with_new'
end
create_another_id = "#{sub_form_id(:association => column.name, :id => parent_record.id || temporary_id || 99999999999)}-create-another" %>
<%= link_to add_label, add_new_url, :id => create_another_id, :remote => true, :class => add_class, :style=> "display: none;" %>
<%= javascript_tag("ActiveScaffold.show('#{create_another_id}');") %>
<% end -%>
<%= '|' if show_add_new and show_add_existing %>
<% if show_add_existing -%>
<% if remote_controller and remote_controller.respond_to? :uses_record_select? and remote_controller.uses_record_select? -%>
<%= link_to_record_select as_(:add_existing), remote_controller.controller_path, :onselect => "ActiveScaffold.record_select_onselect(#{url_for(edit_associated_url).to_json}, #{active_scaffold_id.to_json}, id);" -%>
<% else -%>
<% select_options = options_from_collection_for_select(sorted_association_options_find(column.association, nil, parent_record), :to_param, :to_label)
add_existing_id = "#{sub_form_id(:association => column.name, :id => parent_record.id || temporary_id || 99999999999)}-add-existing"
add_existing_label = column.plural_association? ? :add_existing : :replace_existing %>
<%= select_tag 'associated_id', '<option value="">'.html_safe + as_(:_select_) + '</option>'.html_safe + select_options %>
<%= link_to as_(add_existing_label), edit_associated_url, :id => add_existing_id, :remote => true, :class=> "as_#{add_existing_label}", :style => "display: none;" %>
<%= javascript_tag("ActiveScaffold.show('#{add_existing_id}');") %>
<% end -%>
<% end -%>
</div>
</div>