ruby on rails - Override Spree Admin views with Deface -
i'm trying add few lines spree admin.
file override:
backend/app/views/spree/admin/orders/_shipment.html.erb
i want add here:
<tr class="show-tracking total"> <td colspan="5" class="tracking-value"> <% if shipment.tracking.present? %> <strong><%= spree.t(:tracking) %>:</strong> <%= shipment.tracking %> <% else %> <%= spree.t(:no_tracking_present) %> <% end %> </td> </tr>
my override is:
<!-- insert_after '.tracking-value' --> </br> <strong><%= spree.t(:is_delivered) %>: </strong><%= shipment.is_delivered %></br> <% if shipment.date_delivered? %> <strong><%= spree.t(:date_delivered) %>: </strong><%= shipment.date_delivered %></br> <% end %>
located in app/overrides/spree/admin/orders/shipment/add_tracking_info.html.erb.deface
content:
</br> <strong><%= spree.t(:is_delivered) %>: </strong><%= shipment.is_delivered %></br> <% if shipment.date_delivered? %> <strong><%= spree.t(:date_delivered) %>: </strong><%= shipment.date_delivered %></br> <% end %>
i render:
<tr class="show-tracking total"> <td colspan="5" class="tracking-value"> <% if shipment.tracking.present? %> <strong><%= spree.t(:tracking) %>:</strong> <%= shipment.tracking %> </br> <strong><%= spree.t(:is_delivered) %>: </strong><%= shipment.is_delivered %</br> <% if shipment.date_delivered? %> <strong><%= spree.t(:date_delivered) %>: </strong><%= shipment.date_delivered %></br> <% end %> <% else %> <%= spree.t(:no_tracking_present) %> <% end %> </td> </tr>
any regarding issue appreciated, thank much!
you missing step. in abstract fashion need tell spree , need insert.
deface::override.new( virtual_path: 'spree/admin/shared/_order_summary', name: 'admin_order_custom_details', insert_after: 'header#order_tab_summary > dl.additional-info', partial: 'spree/admin/shared/admin_order_custom_details' )
the following copied project working till yesterday. instructs deface
add partial 'spree/admin/shared/admin_order_custom_detailsjust after dom element identified by
header#order_tab_summary > dl.additional-info`.
so see need is
- change
html.erb.deface
html.erb
, move suchapp/views/spree/admin/orders/add_order_detials_to_shipment.html.erb
- create new file in
app/overides/
(spoiler alert, make meaningful alert or regret later) - find identifier (just looking @ think thing
erb[silent]:contains('if shipment.tracking.present?')
- use
insert_bottom
instead ofinsert_after
i have not run this, believe looking for.
deface::override.new( virtual_path: 'app/views/spree/admin/orders/_shipment', name: 'add_order_detials_to_shipment', # or fancy unique name insert_bottom: "erb[silent]:contains('if shipment.tracking.present?')", partial: 'app/views/spree/admin/orders/add_order_detials_to_shipment' )
ps
after reading section of doc, wasn't aware there dsl deface, think need update dsl such that
<!-- insert_bottom "erb[silent]:contains('if shipment.tracking.present?')" --> </br> <strong><%= spree.t(:is_delivered) %>: </strong><%= shipment.is_delivered %></br> <% if shipment.date_delivered? %> <strong><%= spree.t(:date_delivered) %>: </strong><%= shipment.date_delivered %></br> <% end %>
Comments
Post a Comment