Skip to content

Commit

Permalink
productions
Browse files Browse the repository at this point in the history
  • Loading branch information
yigefaxian committed Sep 8, 2024
1 parent 7ce60bc commit cb67e29
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/controllers/factory/admin/component_parts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ class Admin::ComponentPartsController < Admin::BaseController
before_action :set_new_component_part, only: [:new, :create]

def index
@component_parts = @component.component_parts.order(part_id: :asc).page(params[:page])
@component_parts = @component.component_parts.order(part_id: :asc)
@productions = @component.part_taxon.productions.where.not(id: @component_parts.pluck(:part_id)).includes(:product)
end

private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@
</div>
</td>
</tr>
<%= render partial: 'production', layout: 'production_tr', collection: model.productions, as: :model %>
5 changes: 4 additions & 1 deletion app/views/factory/admin/component_parts/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
<% end %>

<%= render layout: 'product_table' do %>
<%= render partial: 'product_tbody', layout: 'product_tr', collection: @component.part_taxon.products, as: :model %>
<% @productions.group_by(&:product).each do |product, productions| %>
<%= render partial: 'product_tbody', layout: 'product_tr', locals: { model: product } %>
<%= render partial: 'production', layout: 'production_tr', collection: productions, as: :model %>
<% end %>
<% end %>

0 comments on commit cb67e29

Please sign in to comment.