diff --git a/app/views/domains/_horizontal_subform_record.html.erb b/app/views/domains/_horizontal_subform_record.html.erb new file mode 100644 index 0000000..8d11fe2 --- /dev/null +++ b/app/views/domains/_horizontal_subform_record.html.erb @@ -0,0 +1,50 @@ +<% # hide destroy first NS on create form + + record_column = column + readonly = (@record.readonly? or not @record.authorized_for?(:crud_type => :update)) + crud_type = @record.new_record? ? :create : (readonly ? :read : :update) + show_actions = false + config = active_scaffold_config_for(@record.class) + options = active_scaffold_input_options(config.columns[@record.class.primary_key], scope) + tr_id = "association-#{options[:id]}" +-%> + +<% config.subform.columns.each :for => @record.class, :crud_type => :read, :flatten => true do |column| %> +<% + next unless in_subform?(column, parent_record) + show_actions = true + column = column.clone + column.form_ui ||= :select if column.association + + col_class = [] + col_class << 'required' if column.required? + col_class << column.css_class unless column.css_class.nil? + col_class << 'hidden' if column_renders_as(column) == :hidden +-%> + + <% unless readonly and not @record.new_record? or not @record.authorized_for?(:crud_type => crud_type, :column => column.name) -%> + <%= render :partial => form_partial_for_column(column), :locals => { :column => column, :scope => scope } -%> + <% else -%> +

<%= get_column_value(@record, column) -%>

+ <% end -%> + +<% end -%> +<% if show_actions -%> + + <% if record_column.plural_association? and (@record.authorized_for?(:crud_type => :delete) or not [:destroy, :delete_all].include?(record_column.association.options[:dependent])) %> + <% destroy_id = "#{options[:id]}-destroy" %> + <% if @record.class == NS %> + <% if @first_ns.blank? %> + <% @first_ns = true %> + <% else %> + <%= link_to as_(:remove), '#', :class => 'destroy', :id => destroy_id , :onclick => "ActiveScaffold.delete_subform_record(\"#{tr_id}\"); return false;", :style=> "display: none;" %> + <% end %> + <% end %> + <%= javascript_tag("ActiveScaffold.show('#{destroy_id}');") if !locked %> + <% end %> + <% unless @record.new_record? %> + + <% end -%> + +<% end -%> +