Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Add search with indication to what you are searching.

Matthew Kennedy3d85c1070d9f
diff --git a/backend/app/assets/javascripts/spree/backend/global/ransack.js b/backend/app/assets/javascripts/spree/backend/global/ransack.js
index fdf9922477..92588d593e 100644
--- a/backend/app/assets/javascripts/spree/backend/global/ransack.js
+++ b/backend/app/assets/javascripts/spree/backend/global/ransack.js
@@ -1,4 +1,12 @@
+/* eslint-disable no-var */
document.addEventListener('DOMContentLoaded', function() {
+ var QuickSearchInput = document.getElementById('quick_search')
+ var QuickSearchPlaceHolder = QuickSearchInput.placeholder
+ var TargetSearchFieldId = document.querySelector('input.js-quick-search-target').id
+ var AssociatedLabelName = document.querySelector(`label[for="${TargetSearchFieldId}"]`).innerHTML
+
+ QuickSearchInput.placeholder = `${QuickSearchPlaceHolder} ${AssociatedLabelName}`
+
$('.js-show-index-filters').click(function() {
$('.filter-well').slideToggle()
$(this).parents('.filter-wrap').toggleClass('collapsed')
@@ -8,6 +16,7 @@ document.addEventListener('DOMContentLoaded', function() {
// Temp quick search
// When there was a search term, copy it
$('.js-quick-search').val($('.js-quick-search-target').val())
+
// Catch the quick search form submit and submit the real form
$('#quick-search').submit(function() {
$('.js-quick-search-target').val($('.js-quick-search').val())
diff --git a/backend/app/views/spree/admin/orders/index.html.erb b/backend/app/views/spree/admin/orders/index.html.erb
index 160dc82717..6754caca9c 100644
--- a/backend/app/views/spree/admin/orders/index.html.erb
+++ b/backend/app/views/spree/admin/orders/index.html.erb
@@ -54,7 +54,7 @@
</div>
<div class="col-12 col-lg-4">
<div class="form-group">
- <%= label_tag :q_number_cont, Spree.t(:order_number, number: '') %>
+ <%= label_tag :q_number_cont, Spree.t(:order_number, number: 'Number') %>
<%= f.text_field :number_cont, class: 'form-control js-quick-search-target js-filterable' %>
</div>
</div>
diff --git a/backend/app/views/spree/admin/products/index.html.erb b/backend/app/views/spree/admin/products/index.html.erb
index 1864036234..62ddae7bd1 100644
--- a/backend/app/views/spree/admin/products/index.html.erb
+++ b/backend/app/views/spree/admin/products/index.html.erb
@@ -14,7 +14,7 @@
<div data-hook="admin_products_index_search" class="row">
<div class="col-12 col-lg-6">
<div class="form-group">
- <%= f.label :search_by_name, Spree.t(:name) %>
+ <%= f.label :search_by_name, Spree.t(:product_name) %>
<%= f.text_field :search_by_name, size: 15, class: "form-control js-quick-search-target js-filterable" %>
</div>
</div>
diff --git a/backend/app/views/spree/admin/return_index/return_authorizations.html.erb b/backend/app/views/spree/admin/return_index/return_authorizations.html.erb
index 43a7a5f2ef..5785570264 100644
--- a/backend/app/views/spree/admin/return_index/return_authorizations.html.erb
+++ b/backend/app/views/spree/admin/return_index/return_authorizations.html.erb
@@ -26,7 +26,7 @@
<div class="row">
<div class="col-12 col-lg-6">
<div class="form-group">
- <%= f.label :number_cont, Spree.t(:number) %>
+ <%= f.label :number_cont, Spree.t(:return_number) %>
<%= f.text_field :number_cont, class: "form-control js-quick-search-target js-filterable" %>
</div>
</div>
diff --git a/backend/app/views/spree/admin/shared/_table_filter.html.erb b/backend/app/views/spree/admin/shared/_table_filter.html.erb
index 1ed8274298..e0e83c1968 100644
--- a/backend/app/views/spree/admin/shared/_table_filter.html.erb
+++ b/backend/app/views/spree/admin/shared/_table_filter.html.erb
@@ -9,7 +9,7 @@
</button>
</span>
<%= form_tag request.fullpath, id: "quick-search", class: 'flex-grow-1' do %>
- <%= text_field_tag :quick_search, nil, class: "form-control js-quick-search", placeholder: Spree.t(:quick_search) %>
+ <%= text_field_tag :quick_search, nil, class: "form-control js-quick-search", placeholder: Spree.t(:search_by) %>
<% end %>
</div>
<% unless defined?(simple) %>
diff --git a/backend/app/views/spree/admin/stock_transfers/index.html.erb b/backend/app/views/spree/admin/stock_transfers/index.html.erb
index 5fa4ea93f7..a7fb013561 100644
--- a/backend/app/views/spree/admin/stock_transfers/index.html.erb
+++ b/backend/app/views/spree/admin/stock_transfers/index.html.erb
@@ -9,12 +9,11 @@
<% content_for :table_filter do %>
<div data-hook="admin_orders_index_search">
<%= search_form_for @q, url: admin_stock_transfers_path do |f| %>
-
<div class="row mb-0">
<div class="col-12 col-lg-4">
<div class="form-group">
<%= f.label :reference_cont, Spree.t(:reference_contains) %>
- <%= f.text_field :reference_cont, class: 'form-control' %>
+ <%= f.text_field :reference_cont, class: 'form-control js-filterable js-quick-search-target' %>
</div>
</div>
diff --git a/core/config/locales/en.yml b/core/config/locales/en.yml
index 87c8985846..a84da6c25c 100644
--- a/core/config/locales/en.yml
+++ b/core/config/locales/en.yml
@@ -1281,6 +1281,7 @@ en:
price_sack: Price Sack
process: Process
product: Product
+ product_name: Product Name
product_details: Product Details
product_has_no_description: This product has no description
product_not_available_in_this_currency: This product is not available in the selected currency.
@@ -1457,6 +1458,7 @@ en:
say_yes: 'Yes'
scope: Scope
search: Search
+ search_by: 'Search by:'
search_results: Search results for '%{keywords}'
searching: Searching
secure_connection_type: Secure Connection Type
@@ -1623,7 +1625,6 @@ en:
customer_support_email_help: "This email is visible to your Store visitors in the Footer section"
new_order_notifications_email_help: "If you want to receive an email notification every time someone places an Order please provide an email address for that notification to be sent to"
seo_robots: "Please check <a href='https://developers.google.com/search/reference/robots_meta_tag' target='_blank'>this page for more help</a>"
- store_set_default_button: Set as default
stores: Stores
store_credit_name: Store Credit
store_credit: