spree_admin 5.1.7 → 5.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/spree/admin/payment_methods_controller.rb +0 -4
- data/app/controllers/spree/admin/translations_controller.rb +27 -2
- data/app/helpers/spree/admin/orders_helper.rb +9 -1
- data/app/views/spree/admin/gift_cards/show.html.erb +1 -1
- data/app/views/spree/admin/promotion_rules/forms/_currency.html.erb +1 -4
- data/app/views/spree/admin/shared/_head.html.erb +6 -2
- data/app/views/spree/admin/store_credits/_form.html.erb +2 -2
- data/config/importmap.rb +1 -1
- data/lib/spree/admin/runtime_configuration.rb +2 -0
- data/vendor/javascript/trix@2.1.15.js +5 -0
- metadata +9 -10
- data/app/views/spree/admin/payment_methods/update.turbo_stream.erb +0 -1
- data/vendor/javascript/trix@2.1.12.js +0 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 03a3901bc63967dd9c94ffc2627c821c0470ee059a49760dc68c75c7314bcf27
|
|
4
|
+
data.tar.gz: 1ef2bb1a0444bc0f3ea01b0d47d6bfabb441d53983fd4cac9be1303c18b7f5dd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7fbf8b61e8892e876679c6cc5268fab0947bf935a973d03f28924b6af71b379d8fbe132acf10221cfe073d1d186d72af4e04f8064246efab5388fb09cefede31
|
|
7
|
+
data.tar.gz: 8f9fcb477403a5eefaa9842fea2c166ef4e604a7f43123c184bf116043886b294b1c26f52fe8f70be570eb345cbbd58f5a605c071af65a93fa13354049f2f0d1
|
|
@@ -32,10 +32,6 @@ module Spree
|
|
|
32
32
|
@collection = @search.result.page(params[:page]).per(params[:per_page])
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
def update_turbo_stream_enabled?
|
|
36
|
-
true
|
|
37
|
-
end
|
|
38
|
-
|
|
39
35
|
def require_payment_type
|
|
40
36
|
redirect_to spree.admin_payment_methods_path unless params.dig(:payment_method, :type).present?
|
|
41
37
|
end
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
module Spree
|
|
2
2
|
module Admin
|
|
3
3
|
class TranslationsController < Spree::Admin::BaseController
|
|
4
|
+
# Set the resource being translated and any related data
|
|
4
5
|
before_action :set_resource, only: [:edit, :update]
|
|
5
6
|
before_action :load_data, only: [:edit]
|
|
6
7
|
before_action :set_translation_locale, only: [:edit, :update]
|
|
7
8
|
|
|
9
|
+
helper_method :normalized_locale
|
|
10
|
+
helper_method :resource_class
|
|
11
|
+
|
|
12
|
+
# GET /admin/translations/:id/edit
|
|
13
|
+
# Renders the edit translation page for the resource
|
|
8
14
|
def edit; end
|
|
9
15
|
|
|
16
|
+
# Normalizes a locale string by replacing '-' with '_' and downcasing
|
|
17
|
+
def normalized_locale(locale)
|
|
18
|
+
locale.to_s.downcase.tr('-', '_')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# PUT /admin/translations/:id
|
|
22
|
+
# Updates the translations for the resource
|
|
23
|
+
# Sets flash messages for success or failure
|
|
10
24
|
def update
|
|
11
25
|
@resource.update!(permitted_translation_params)
|
|
12
26
|
|
|
@@ -34,10 +48,12 @@ module Spree
|
|
|
34
48
|
end
|
|
35
49
|
end
|
|
36
50
|
|
|
51
|
+
# Build translation field names with normalized locale suffix
|
|
37
52
|
def translation_fields(klass)
|
|
38
|
-
klass.translatable_fields.map { |field| "#{field}_#{@selected_translation_locale}" }
|
|
53
|
+
klass.translatable_fields.map { |field| "#{field}_#{normalized_locale(@selected_translation_locale)}" }
|
|
39
54
|
end
|
|
40
55
|
|
|
56
|
+
# Determine the class of the resource
|
|
41
57
|
def resource_class
|
|
42
58
|
@resource_class ||= begin
|
|
43
59
|
klass = params[:resource_type]
|
|
@@ -46,10 +62,12 @@ module Spree
|
|
|
46
62
|
end
|
|
47
63
|
end
|
|
48
64
|
|
|
65
|
+
# Allowed translatable resources configured in Spree
|
|
49
66
|
def allowed_resource_class
|
|
50
67
|
Rails.application.config.spree.translatable_resources
|
|
51
68
|
end
|
|
52
69
|
|
|
70
|
+
# Set the resource object using friendly find if available
|
|
53
71
|
def set_resource
|
|
54
72
|
@resource = if resource_class.respond_to?(:friendly)
|
|
55
73
|
resource_class.friendly.find(params[:id])
|
|
@@ -58,10 +76,17 @@ module Spree
|
|
|
58
76
|
end
|
|
59
77
|
end
|
|
60
78
|
|
|
79
|
+
# Determine the translation locale to use
|
|
61
80
|
def set_translation_locale
|
|
62
|
-
|
|
81
|
+
raw_locale = params[:translation_locale].presence ||
|
|
82
|
+
@locales&.first ||
|
|
83
|
+
current_store.default_locale ||
|
|
84
|
+
current_store.supported_locales_list.first
|
|
85
|
+
|
|
86
|
+
@selected_translation_locale = normalized_locale(raw_locale)
|
|
63
87
|
end
|
|
64
88
|
|
|
89
|
+
# Load available locales for this resource, excluding default
|
|
65
90
|
def load_data
|
|
66
91
|
@locales = (current_store.supported_locales_list - [@default_locale]).sort
|
|
67
92
|
@resource_name = @resource.try(:name)
|
|
@@ -20,7 +20,15 @@ module Spree
|
|
|
20
20
|
def order_payment_state(order, options = {})
|
|
21
21
|
return if order.payment_state.blank?
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
badge_class = if order.order_refunded?
|
|
24
|
+
'badge-danger'
|
|
25
|
+
elsif order.partially_refunded?
|
|
26
|
+
'badge-warning'
|
|
27
|
+
else
|
|
28
|
+
"badge-#{order.payment_state}"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
content_tag :span, class: "badge #{options[:class]} #{badge_class}" do
|
|
24
32
|
if order.order_refunded?
|
|
25
33
|
icon('credit-card-refund') + Spree.t('payment_states.refunded')
|
|
26
34
|
elsif order.partially_refunded?
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
<div class="form-group">
|
|
2
2
|
<%= f.select :preferred_currency,
|
|
3
|
-
|
|
4
|
-
f.object.preferred_currency,
|
|
5
|
-
current_store.supported_currencies.split(',')
|
|
6
|
-
),
|
|
3
|
+
options_for_select(supported_currency_options, f.object.preferred_currency),
|
|
7
4
|
{},
|
|
8
5
|
{ data: { controller: 'autocomplete-select' } }
|
|
9
6
|
%>
|
|
@@ -37,9 +37,13 @@
|
|
|
37
37
|
<%= tinymce_assets %>
|
|
38
38
|
<link rel="stylesheet" type="text/css" href="https://unpkg.com/trix@2.1.12/dist/trix.css">
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
<% if Rails.application.importmap.packages["application"].present? && Spree::Admin::RuntimeConfig.include_application_importmap %>
|
|
41
|
+
<%= javascript_importmap_tags "application" %>
|
|
42
|
+
<% else %>
|
|
43
|
+
<script async src="https://ga.jspm.io/npm:es-module-shims@1.8.2/dist/es-module-shims.js" data-turbo-track="reload"></script>
|
|
44
|
+
<% end %>
|
|
41
45
|
|
|
42
|
-
<%= javascript_importmap_tags
|
|
46
|
+
<%= javascript_importmap_tags "application-spree-admin", importmap: Rails.application.config.spree_admin.importmap %>
|
|
43
47
|
|
|
44
48
|
<%= yield :head %>
|
|
45
49
|
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
<div class="form-group">
|
|
8
8
|
<%= f.label :currency, raw(Spree.t(:currency) + required_span_tag), class: 'form-label' %>
|
|
9
|
-
<%= f.select :currency,
|
|
9
|
+
<%= f.select :currency, options_for_select(supported_currency_options, f.object.currency), {}, { data: { controller: 'autocomplete-select', enable_button_target: 'input', store_form_target: 'currency' } } %>
|
|
10
10
|
</div>
|
|
11
11
|
|
|
12
12
|
<div class="form-group">
|
|
13
13
|
<%= f.label :memo, Spree.t(:memo) %>
|
|
14
14
|
<%= f.text_area :memo, class: 'form-control' %>
|
|
15
15
|
<%= f.error_message_on :memo %>
|
|
16
|
-
</div>
|
|
16
|
+
</div>
|
data/config/importmap.rb
CHANGED
|
@@ -7,7 +7,7 @@ pin "@hotwired/stimulus-loading", to: "stimulus-loading.js"
|
|
|
7
7
|
pin '@rails/actioncable', to: 'actioncable.esm.js', preload: ['application-spree-admin']
|
|
8
8
|
pin '@rails/activestorage', to: 'activestorage.esm.js', preload: ['application-spree-admin']
|
|
9
9
|
pin '@rails/actiontext', to: '@rails--actiontext@7.2.201.js', preload: ['application-spree-admin']
|
|
10
|
-
pin 'trix', to: 'trix@2.1.
|
|
10
|
+
pin 'trix', to: 'trix@2.1.15.js', preload: ['application-spree-admin']
|
|
11
11
|
|
|
12
12
|
pin 'sortablejs', preload: ['application-spree-admin'] # @1.15.6
|
|
13
13
|
pin 'chartkick', to: 'chartkick.js', preload: ['application-spree-admin']
|
|
@@ -7,6 +7,8 @@ module Spree
|
|
|
7
7
|
preference :admin_records_per_page, :integer, default: Kaminari.config.default_per_page
|
|
8
8
|
preference :admin_products_per_page, :integer, default: Kaminari.config.default_per_page
|
|
9
9
|
preference :admin_orders_per_page, :integer, default: Kaminari.config.default_per_page
|
|
10
|
+
|
|
11
|
+
preference :include_application_importmap, :boolean, default: false
|
|
10
12
|
end
|
|
11
13
|
end
|
|
12
14
|
end
|