app/views/trade/admin/trade_items/index.html.erb in rails_trade-0.0.2 vs app/views/trade/admin/trade_items/index.html.erb in rails_trade-0.0.3
- old
+ new
@@ -17,78 +17,67 @@
</div>
<div class="ui segment top attached">
<% if @user %>
<%= link_to '生成订单', new_admin_order_path(user_id: @user.id), class: 'ui red button', id: 'new_order_top' %>
- <%= link_to '生成文档', doc_admin_cart_items_path(user_id: @user.id), class: 'ui orange button', id: 'cart_items_doc' %>
+ <%= link_to '生成文档', doc_admin_trade_items_path(user_id: @user.id), class: 'ui orange button', id: 'trade_items_doc' %>
<% end %>
</div>
-<table class="ui bottom attached selectable table">
+<table class="table is-hoverable is-fullwidth">
<thead>
- <tr class="">
- <th><%= check_box_tag :all %></th>
- <th>Name</th>
- <th>报价</th>
- <th>数量</th>
- <th>原价</th>
- <th>最终价格</th>
- <th>预成单报价</th>
- <th>Actions</th>
- </tr>
+ <tr>
+ <th><%= check_box_tag :all %></th>
+ <th><%= Trade::TradeItem.human_attribute_name('good/name') %></th>
+ <th><%= Trade::TradeItem.human_attribute_name(:amount) %></th>
+ <th><%= Trade::TradeItem.human_attribute_name(:number) %></th>
+ <th><%= Trade::TradeItem.human_attribute_name(:original_amount) %></th>
+ <th><%= Trade::TradeItem.human_attribute_name(:retail_price) %></th>
+ <th><%= Trade::TradeItem.human_attribute_name(:wholesale_price) %></th>
+ <th></th>
+ </tr>
</thead>
<tbody>
- <% @cart_items.each do |cart_item| %>
- <tr class="<%= active_asserts join: false, active: cart_item.checked, positive: cart_item.good_id.to_s == params[:good_id] %>" id="cart_item_<%= cart_item.id %>">
- <td><%= check_box_tag(:cart_item_id, cart_item.id, cart_item.checked) %></td>
+ <% @trade_items.each do |trade_item| %>
+ <tr class="<%= active_asserts join: false, active: trade_item.checked?, positive: trade_item.good_id.to_s == params[:good_id] %>" id="trade_item_<%= trade_item.id %>">
+ <td><%= check_box_tag(:trade_item_id, trade_item.id, trade_item.checked?) %></td>
<td>
- <i class="child icon<%= active_assert(cart_item.myself, expected: ' green', unexpected: '') %>"></i>
- <%= cart_item.good&.name %>
- <%= link_to only_admin_cart_items_path(good_type: cart_item.good_type, good_id: cart_item.good_id) do %>
- <i class="legal icon"></i>
- <% end %>
+ <i class="child icon<%= trade_item.myself ? ' green' : '' %>"></i>
+ <%= trade_item.good&.name %>
</td>
<td>
- <% cache [cart_item, 'good_price'] do %>
- <%= render partial: 'good_price', locals: { cart_item: cart_item } %>
- <% end %>
+ <%= render partial: 'good_price', locals: { trade_item: trade_item } %>
</td>
<td>
<div class="ui left right action input">
- <div class="ui button" onclick="decrease_quantity(<%= cart_item.id %>)"><i class="minus icon"></i></div>
- <%= text_field_tag :quantity, cart_item.quantity, id: "quantity_#{cart_item.id}", onkeyup: "update_quantity(#{cart_item.id})", disabled: true %>
- <div class="ui button" onclick="increase_quantity(<%= cart_item.id %>)"><i class="fas fa-plus"></i></div>
+ <div class="ui button" onclick="decrease_quantity(<%= trade_item.id %>)"><i class="minus icon"></i></div>
+ <%= text_field_tag :number, trade_item.number, id: "quantity_#{trade_item.id}", onkeyup: "update_quantity(#{trade_item.id})", disabled: true %>
+ <div class="ui button" onclick="increase_quantity(<%= trade_item.id %>)"><i class="fas fa-plus"></i></div>
</div>
</td>
- <td id="retail_price_<%= cart_item.id %>">
- <% cache [cart_item, 'retail_price'] do %>
- <%= render partial: 'retail_price', locals: { cart_item: cart_item } %>
- <% end %>
+ <td id="retail_price_<%= trade_item.id %>">
+ <%= render partial: 'retail_price', locals: { trade_item: trade_item } %>
</td>
- <td id="single_price_<%= cart_item.id %>">
- <% cache [cart_item, 'single_price'] do %>
- <%= render partial: 'single_price', locals: { cart_item: cart_item } %>
- <% end %>
+ <td id="single_price_<%= trade_item.id %>">
+ <%= render partial: 'single_price', locals: { trade_item: trade_item } %>
</td>
- <td id="order_price_<%= cart_item.id %>">
- <% cache [cart_item, 'order_price'] do %>
- <%= render partial: 'order_price', locals: { cart_item: cart_item } %>
- <% end %>
+ <td id="order_price_<%= trade_item.id %>">
+ <%# render partial: 'order_price', locals: { trade_item: trade_item } %>
</td>
<td>
- <%= link_to 'delete', admin_cart_item_path(cart_item), method: :delete, remote: true, class: 'ui mini label' %>
+ <%= link_to 'delete', admin_trade_item_path(trade_item), method: :delete, class: 'ui mini label' %>
</td>
</tr>
<% end %>
</tbody>
<tbody id="additions_body">
- <%= render 'additions' %>
+ <%# render 'additions' %>
</tbody>
<tfoot>
<tr>
<th colspan="5"></th>
<th id="total_price">
- <%= render 'total_price' %>
+ <%# render 'total_price' %>
</th>
<th colspan="3"></th>
</tr>
<tr>
<th colspan="5"></th>
@@ -99,6 +88,6 @@
</th>
</tr>
</tfoot>
</table>
-<%= paginate @cart_items %>
+<%= paginate @trade_items %>