From f50e745826b52b5d40bbde640a982f2b208aa9ae Mon Sep 17 00:00:00 2001 From: Pau Perez Date: Wed, 6 Sep 2017 18:30:17 +0200 Subject: [PATCH] Change title when navigating to new product page We navigate to it by replacing the content of the page through an ajax call, so we also need change the section title with JS. --- app/views/spree/admin/products/new.js.erb | 12 ++++++++++++ config/locales/en.yml | 2 ++ 2 files changed, 14 insertions(+) create mode 100644 app/views/spree/admin/products/new.js.erb diff --git a/app/views/spree/admin/products/new.js.erb b/app/views/spree/admin/products/new.js.erb new file mode 100644 index 0000000000..0a3711620d --- /dev/null +++ b/app/views/spree/admin/products/new.js.erb @@ -0,0 +1,12 @@ +<%# This chunk is just a copy of Spree's core/app/views/spree/admin/products/new.js.erb %> +$("#new_product").html('<%= escape_javascript(render :template => "spree/admin/products/new", :formats => [:html], :handlers => [:erb]) %>'); +handle_date_picker_fields(); +<% unless Rails.env.test? %> + $('.select2').select2(); +<% end %> +$("#table-filter").hide(); +$("#admin_new_product").parent().hide(); + +<%# We need to replace the page's title as well. We're navigating to a new page + although through ajax %> +$('#content-header .page-title').html('<%= t('.title') %>'); diff --git a/config/locales/en.yml b/config/locales/en.yml index 18db5812dc..d84550df35 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2056,6 +2056,8 @@ Please follow the instructions there to make your enterprise visible on the Open other: "You have %{count} active order cycles." manage_order_cycles: "MANAGE ORDER CYCLES" products: + new: + title: 'New Product' unit_name_placeholder: 'eg. bunches' bulk_edit: header: