spree_backend 4.2.0.rc4 → 4.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/backend.js +1 -1
  3. data/app/assets/javascripts/spree/backend/admin.js +9 -15
  4. data/app/assets/stylesheets/spree/backend/global/_mixins.scss +19 -0
  5. data/app/assets/stylesheets/spree/backend/plugins/_flatpickr.scss +94 -76
  6. data/app/assets/stylesheets/spree/backend/shared/_base.scss +4 -0
  7. data/app/assets/stylesheets/spree/backend/spree_admin.css.scss +1 -0
  8. data/app/controllers/spree/admin/base_controller.rb +2 -0
  9. data/app/controllers/spree/admin/images_controller.rb +3 -3
  10. data/app/controllers/spree/admin/orders/customer_details_controller.rb +1 -1
  11. data/app/controllers/spree/admin/prices_controller.rb +0 -13
  12. data/app/controllers/spree/admin/stores_controller.rb +6 -13
  13. data/app/helpers/spree/admin/base_helper.rb +47 -1
  14. data/app/views/kaminari/admin-twitter-bootstrap-4/_first_page.html.erb +2 -2
  15. data/app/views/kaminari/admin-twitter-bootstrap-4/_gap.html.erb +2 -2
  16. data/app/views/kaminari/admin-twitter-bootstrap-4/_last_page.html.erb +2 -2
  17. data/app/views/kaminari/admin-twitter-bootstrap-4/_next_page.html.erb +2 -2
  18. data/app/views/kaminari/admin-twitter-bootstrap-4/_page.html.erb +2 -2
  19. data/app/views/kaminari/admin-twitter-bootstrap-4/_paginator.html.erb +2 -2
  20. data/app/views/kaminari/admin-twitter-bootstrap-4/_prev_page.html.erb +2 -2
  21. data/app/views/spree/admin/adjustments/index.html.erb +2 -2
  22. data/app/views/spree/admin/customer_returns/_return_item_decision.html.erb +48 -48
  23. data/app/views/spree/admin/customer_returns/edit.html.erb +1 -1
  24. data/app/views/spree/admin/general_settings/edit.html.erb +3 -3
  25. data/app/views/spree/admin/images/edit.html.erb +1 -1
  26. data/app/views/spree/admin/log_entries/index.html.erb +1 -1
  27. data/app/views/spree/admin/option_types/index.html.erb +1 -1
  28. data/app/views/spree/admin/orders/_adjustments.html.erb +2 -2
  29. data/app/views/spree/admin/orders/_form.html.erb +6 -10
  30. data/app/views/spree/admin/orders/_line_items.html.erb +1 -1
  31. data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +5 -8
  32. data/app/views/spree/admin/orders/_order_actions.html.erb +1 -2
  33. data/app/views/spree/admin/orders/_risk_analysis.html.erb +3 -3
  34. data/app/views/spree/admin/orders/_shipment.html.erb +0 -1
  35. data/app/views/spree/admin/orders/_shipment_manifest.html.erb +1 -1
  36. data/app/views/spree/admin/orders/cart.html.erb +1 -1
  37. data/app/views/spree/admin/orders/customer_details/_form.html.erb +1 -1
  38. data/app/views/spree/admin/orders/edit.html.erb +1 -1
  39. data/app/views/spree/admin/orders/index.html.erb +2 -0
  40. data/app/views/spree/admin/payment_methods/index.html.erb +1 -1
  41. data/app/views/spree/admin/payments/_form.html.erb +2 -3
  42. data/app/views/spree/admin/payments/show.html.erb +1 -2
  43. data/app/views/spree/admin/payments/source_forms/_gateway.html.erb +3 -4
  44. data/app/views/spree/admin/payments/source_views/_gateway.html.erb +1 -1
  45. data/app/views/spree/admin/prices/_variant_prices.html.erb +5 -5
  46. data/app/views/spree/admin/prices/index.html.erb +2 -2
  47. data/app/views/spree/admin/product_properties/index.html.erb +3 -4
  48. data/app/views/spree/admin/products/_form.html.erb +5 -6
  49. data/app/views/spree/admin/products/new.html.erb +3 -1
  50. data/app/views/spree/admin/products/stock.html.erb +2 -2
  51. data/app/views/spree/admin/promotions/_actions.html.erb +2 -3
  52. data/app/views/spree/admin/promotions/_form.html.erb +9 -10
  53. data/app/views/spree/admin/promotions/_rules.html.erb +1 -1
  54. data/app/views/spree/admin/promotions/actions/_create_adjustment.html.erb +1 -1
  55. data/app/views/spree/admin/promotions/actions/_create_item_adjustments.html.erb +1 -1
  56. data/app/views/spree/admin/promotions/index.html.erb +7 -5
  57. data/app/views/spree/admin/promotions/rules/_taxon.html.erb +2 -2
  58. data/app/views/spree/admin/prototypes/_form.html.erb +1 -1
  59. data/app/views/spree/admin/prototypes/show.html.erb +1 -1
  60. data/app/views/spree/admin/refunds/edit.html.erb +2 -2
  61. data/app/views/spree/admin/refunds/new.html.erb +2 -2
  62. data/app/views/spree/admin/reimbursements/edit.html.erb +1 -2
  63. data/app/views/spree/admin/roles/index.html.erb +1 -1
  64. data/app/views/spree/admin/shared/_account_nav.html.erb +2 -2
  65. data/app/views/spree/admin/shared/_address_form.html.erb +2 -2
  66. data/app/views/spree/admin/shared/_error_messages.html.erb +1 -1
  67. data/app/views/spree/admin/shared/_head.html.erb +2 -2
  68. data/app/views/spree/admin/shared/_header.html.erb +0 -2
  69. data/app/views/spree/admin/shared/_main_menu.html.erb +1 -1
  70. data/app/views/spree/admin/shared/_refunds.html.erb +1 -1
  71. data/app/views/spree/admin/shared/_report_order_criteria.html.erb +4 -2
  72. data/app/views/spree/admin/shared/_translations.html.erb +8 -38
  73. data/app/views/spree/admin/shipping_categories/index.html.erb +2 -2
  74. data/app/views/spree/admin/shipping_methods/index.html.erb +2 -2
  75. data/app/views/spree/admin/states/index.html.erb +2 -2
  76. data/app/views/spree/admin/stock_locations/_form.html.erb +1 -1
  77. data/app/views/spree/admin/stock_locations/_transfer_stock_form.html.erb +1 -1
  78. data/app/views/spree/admin/stock_locations/index.html.erb +4 -4
  79. data/app/views/spree/admin/stock_movements/_form.html.erb +1 -1
  80. data/app/views/spree/admin/stock_movements/index.html.erb +2 -2
  81. data/app/views/spree/admin/stock_transfers/new.html.erb +1 -1
  82. data/app/views/spree/admin/stock_transfers/show.html.erb +0 -1
  83. data/app/views/spree/admin/stores/_form.html.erb +20 -15
  84. data/app/views/spree/admin/stores/index.html.erb +4 -2
  85. data/app/views/spree/admin/tax_categories/index.html.erb +2 -2
  86. data/app/views/spree/admin/tax_rates/index.html.erb +6 -6
  87. data/app/views/spree/admin/taxonomies/_js_head.html.erb +1 -2
  88. data/app/views/spree/admin/taxonomies/_list.html.erb +1 -1
  89. data/app/views/spree/admin/taxons/_form.html.erb +1 -2
  90. data/app/views/spree/admin/taxons/_taxon_table.html.erb +2 -2
  91. data/app/views/spree/admin/users/_form.html.erb +0 -1
  92. data/app/views/spree/admin/users/edit.html.erb +1 -1
  93. data/app/views/spree/admin/users/index.html.erb +2 -2
  94. data/app/views/spree/admin/users/items.html.erb +1 -1
  95. data/app/views/spree/admin/variants/_form.html.erb +3 -1
  96. data/app/views/spree/admin/zones/_country_members.html.erb +1 -1
  97. data/app/views/spree/admin/zones/_form.html.erb +2 -2
  98. data/app/views/spree/admin/zones/new.html.erb +1 -1
  99. data/app/views/spree/layouts/admin.html.erb +2 -3
  100. data/config/initializers/assets.rb +1 -1
  101. data/spree_backend.gemspec +1 -1
  102. metadata +14 -15
  103. data/app/assets/javascripts/spree/backend/flatpickr_locals.js +0 -37
  104. data/app/helpers/spree/admin/currency_helper.rb +0 -14
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8121bf0a1967bf78b87f0e260a572238140c19948c991f8684693472b69ec15
4
- data.tar.gz: a740ec1df8fdfb18fa8558487dc413096332ef08339b4dd374c78d19f06bf458
3
+ metadata.gz: e804e7fc688fe446f8605a8921fdc7d05bb80d3882effca39ac47aa05a972715
4
+ data.tar.gz: eb0eb8ef36b0232eb0c77e744e01caa2048167bb3c69b7e9e3b40908082e1110
5
5
  SHA512:
6
- metadata.gz: 1c68a55ff4b579d488d570cf99c49bc082806fb7ef5395cbe6967a38535e4dbd395afdce0929c2916f337086bf979f70e5a5b4fb1f0ac19908d79ebfdd55d2dc
7
- data.tar.gz: 4d7db3cec1602bf2858f15f322294132522f1a55df6f2fffc4482911583720985592a60f068f3d04304b3533a79f7cfbd8da21509773864d71a2590b5861e079
6
+ metadata.gz: fdf6eb91713f904b5ba898729266e57c3af20e2d5fc1b7fb9a9cce3604af5de457048dfeefc51fee7db6757e78d5eea1ad125cb4225ebffb0470cd9ad8dee4df
7
+ data.tar.gz: 4e8867aa78411d5e9fbe0a5a3a609f94611cca323b37a1f23a1531eaffddee6906e92d33194b23bd0dedcd351c71169a99142028559428574de4a1a914f82c72
@@ -11,7 +11,7 @@
11
11
  //= require jquery.jstree/jquery.jstree
12
12
  //= require jquery_ujs
13
13
  //= require jquery-ui/widgets/autocomplete
14
- //= require select2
14
+ //= require select2-full
15
15
  //= require underscore-min.js
16
16
 
17
17
  //= require spree
@@ -5,9 +5,6 @@ Hopefully, this will evolve into a propper class.
5
5
  **/
6
6
 
7
7
  /* global AUTH_TOKEN, order_number, Sortable, flatpickr, DOMPurify */
8
-
9
- //= require spree/backend/flatpickr_locals
10
-
11
8
  jQuery(function ($) {
12
9
  // Add some tips
13
10
  $('.with-tip').each(function() {
@@ -123,7 +120,7 @@ jQuery(function ($) {
123
120
  $('.js-filterable').each(function () {
124
121
  var $this = $(this)
125
122
 
126
- if ($this.val() !== null && $this.val() !== '' && $this.val().length !== 0) {
123
+ if ($this.val() !== null && $this.val() !== '' && $this.val().length !== 0 && !$this.hasClass('flatpickr-alt-input')) {
127
124
  var ransackValue, filter
128
125
  var ransackFieldId = $this.attr('id')
129
126
  var label = $('label[for="' + ransackFieldId + '"]')
@@ -226,29 +223,26 @@ $.fn.radioControlsVisibilityOfElement = function (dependentElementSelector) {
226
223
  }
227
224
 
228
225
  document.addEventListener('DOMContentLoaded', function() {
229
- var dateFrom = flatpickr('.datePickerFrom', {
226
+ flatpickr.setDefaults({
227
+ altInput: true,
230
228
  time_24hr: true,
231
- dateFormat: Spree.translations.date_picker,
232
- monthSelectorType: 'static',
229
+ altInputClass: 'flatpickr-alt-input',
230
+ locale: Spree.translations.flatpickr_locale
231
+ })
232
+
233
+ var dateFrom = flatpickr('.datePickerFrom', {
233
234
  onChange: function(selectedDates) {
234
235
  dateTo.set('minDate', selectedDates[0])
235
236
  }
236
237
  })
237
238
 
238
239
  var dateTo = flatpickr('.datePickerTo', {
239
- monthSelectorType: 'static',
240
- time_24hr: true,
241
- dateFormat: Spree.translations.date_picker,
242
240
  onChange: function(selectedDates) {
243
241
  dateFrom.set('maxDate', selectedDates[0])
244
242
  }
245
243
  })
246
244
 
247
- flatpickr('.datepicker', {
248
- monthSelectorType: 'static',
249
- time_24hr: true,
250
- dateFormat: Spree.translations.date_picker
251
- })
245
+ flatpickr('.datepicker', { })
252
246
  })
253
247
 
254
248
  $(document).ready(function() {
@@ -0,0 +1,19 @@
1
+ // Mixin to prefix several properties at once
2
+
3
+ // EXAMPLE
4
+ // @include prefix((
5
+ // appearance: none,
6
+ // touch-callout: none,
7
+ // user-select: none
8
+ // ), webkit moz ms khtml);
9
+
10
+ @mixin prefix($declarations, $prefixes: ()) {
11
+ @each $property, $value in $declarations {
12
+ @each $prefix in $prefixes {
13
+ #{'-' + $prefix + '-' + $property}: $value;
14
+ }
15
+
16
+ // Output standard non-prefixed declaration
17
+ #{$property}: $value;
18
+ }
19
+ }
@@ -1,95 +1,113 @@
1
- // Adaptive icon from calendar to close.
2
- @mixin swith-appended-icon {
3
- &:placeholder-shown:not(:focus) + * {
4
- @content;
1
+ .flatpickr-calendar {
2
+ // Custom Flatpickr styling for Spree + BS4.
3
+ .flatpickr-current-month {
4
+ span.cur-month:hover {
5
+ background: transparent;
6
+ }
7
+ .numInputWrapper {
8
+ margin-left: 3px;
9
+ border-radius: $border-radius;
10
+ overflow: hidden;
11
+ }
12
+
13
+ .flatpickr-monthDropdown-months {
14
+ @include prefix((
15
+ appearance: none
16
+ ), webkit moz ms khtml);
17
+
18
+ padding: 0.2em;
19
+ border-radius: $border-radius;
20
+ }
5
21
  }
6
- }
7
22
 
8
- input.flatpickr-input {
9
- -webkit-appearance: none;
10
- -moz-appearance: none;
11
- appearance: none;
12
- background-color: white !important;
13
- }
23
+ .numInputWrapper span.arrowUp {
24
+ border-color: transparent;
25
+ border-radius: 0;
26
+ }
14
27
 
15
- .flatpickr-current-month .numInputWrapper {
16
- margin-left: 3px;
17
- border-radius: $border-radius;
18
- overflow: hidden;
19
- }
20
- .flatpickr-current-month span.cur-month:hover {
21
- background: transparent;
22
- }
23
- .numInputWrapper span.arrowUp {
24
- border-color: transparent;
25
- border-radius: 0;
26
- }
27
- .numInputWrapper span.arrowDown {
28
- border-color: transparent;
29
- border-radius: 0;
30
- }
28
+ .numInputWrapper span.arrowDown {
29
+ border-color: transparent;
30
+ border-radius: 0;
31
+ }
31
32
 
32
- .input-group {
33
- input.flatpickr-input{
34
- @include swith-appended-icon {
35
- opacity: 0;
36
- }
33
+ .flatpickr-day {
34
+ margin: 2px 0;
35
+ border-radius: $border-radius ;
37
36
  }
38
- }
39
37
 
40
- .append_under {
41
- position: absolute;
42
- right: 0;
43
- top: 0;
44
- z-index: 0;
45
- height: 100%;
46
- }
38
+ .flatpickr-months .flatpickr-prev-month:hover svg,
39
+ .flatpickr-months .flatpickr-next-month:hover svg {
40
+ fill: $primary;
41
+ }
47
42
 
48
- .flatpickr-day {
49
- margin: 2px 0;
50
- border-radius: $border-radius ;
51
- }
43
+ .flatpickr-time {
44
+ border-radius: 0 0 5px 5px;
45
+ &:after {
46
+ display: none;
47
+ }
48
+ .numInputWrapper {
49
+ span {
50
+ border-color: transparent;
51
+ border-radius: 0;
52
+ }
53
+ }
54
+ }
52
55
 
53
- // Fix Flatpickr bug where things jusy highlight for no reason.
54
- input.flatpickr-input[readonly] {
55
- -webkit-touch-callout: none; /* iOS Safari */
56
- -webkit-user-select: none; /* Safari */
57
- -khtml-user-select: none; /* Konqueror HTML */
58
- -moz-user-select: none; /* Old versions of Firefox */
59
- -ms-user-select: none; /* Internet Explorer/Edge */
60
- user-select: none; /* Non-prefixed version, currently
61
- supported by Chrome, Edge, Opera and Firefox */
56
+ // Required to stop an opened cal showing above the nav bar.
57
+ &.open {
58
+ z-index: $zindex-dropdown;
59
+ }
62
60
  }
63
61
 
64
- .flatpickr-months .flatpickr-prev-month:hover svg,
65
- .flatpickr-months .flatpickr-next-month:hover svg {
66
- fill: $primary;
62
+ // Mixin for calendar toggle icon show/hide.
63
+ @mixin swith-appended-icon {
64
+ &:placeholder-shown:not(:focus) + * {
65
+ @content;
66
+ }
67
67
  }
68
68
 
69
- // Force rounded corner for the toggle cal and close icons.
70
- .input-group >
71
- .input-group-append:not(:last-child) >
72
- .force-round {
73
- z-index: 5;
74
- border-top-right-radius: $border-radius !important;
75
- border-bottom-right-radius: $border-radius !important;
76
- }
69
+ .input-group.datePickerFrom,
70
+ .input-group.datePickerTo,
71
+ .input-group.datepicker {
72
+ input.flatpickr-alt-input[readonly] {
73
+ // Flatpickr alternate input is read-only,
74
+ // style it as an active input field.
75
+ background-color: white !important;
77
76
 
78
- div.flatpickr-calendar.open {
79
- z-index: $zindex-dropdown;
80
- }
77
+ // Fix a bug where occasionally the whole screen will highlight
78
+ // if you clicked the Flatpcikr input box while moving the cursor.
79
+ @include prefix((
80
+ appearance: none,
81
+ touch-callout: none,
82
+ user-select: none
83
+ ), webkit moz ms khtml);
81
84
 
82
- .flatpickr-time {
83
- border-radius: 0 0 5px 5px;
84
- &:after {
85
- display: none;
85
+ @include swith-appended-icon {
86
+ opacity: 0;
87
+ }
86
88
  }
87
- .numInputWrapper {
88
- span {
89
- border-color: transparent;
90
- border-radius: 0;
91
89
 
92
- }
90
+ // Required for calendar toggle icon show/hide.
91
+ .append_under {
92
+ position: absolute;
93
+ right: 0;
94
+ top: 0;
95
+ z-index: 0;
96
+ height: 100%;
97
+ }
98
+
99
+ // Styling for calendar toggle icon toggle
100
+ .input-group-append:not(:last-child) >
101
+ .force-round {
102
+ z-index: 5;
103
+ border-top-right-radius: $border-radius !important;
104
+ border-bottom-right-radius: $border-radius !important;
105
+ }
93
106
 
107
+ // Styling for calendar toggle icon toggle
108
+ .form-control:not(:first-child),
109
+ .input-group >.flatpickr-alt-input:not(:first-child) {
110
+ border-top-left-radius: $border-radius !important;
111
+ border-bottom-left-radius: $border-radius !important;
94
112
  }
95
113
  }
@@ -55,3 +55,7 @@
55
55
  .resize-animation-stopper * {
56
56
  transition: none !important;
57
57
  }
58
+
59
+ .button_to {
60
+ display: inline-block;
61
+ }
@@ -1,4 +1,5 @@
1
1
  @import 'global/variables';
2
+ @import 'global/mixins';
2
3
 
3
4
  @import 'bootstrap';
4
5
  @import 'glyphicons';
@@ -2,6 +2,8 @@ module Spree
2
2
  module Admin
3
3
  class BaseController < Spree::BaseController
4
4
  helper 'spree/admin/navigation'
5
+ helper 'spree/locale'
6
+ helper 'spree/currency'
5
7
  layout 'spree/layouts/admin'
6
8
 
7
9
  before_action :authorize_admin
@@ -18,15 +18,15 @@ module Spree
18
18
  end
19
19
 
20
20
  def load_index_data
21
- @product = Product.friendly.includes(*variant_index_includes).find(params[:product_id])
21
+ @product = Product.friendly.preload(*variant_index_includes).find(params[:product_id])
22
22
  end
23
23
 
24
24
  def load_edit_data
25
- @product = Product.friendly.includes(*variant_edit_includes).find(params[:product_id])
25
+ @product = Product.friendly.preload(*variant_edit_includes).find(params[:product_id])
26
26
  @variants = @product.variants.map do |variant|
27
27
  [variant.sku_and_options_text, variant.id]
28
28
  end
29
- @variants.insert(0, [Spree.t(:all), @product.master.id])
29
+ @variants.insert(0, [Spree.t(:all), @product.master_id])
30
30
  end
31
31
 
32
32
  def set_viewable
@@ -11,7 +11,7 @@ module Spree
11
11
  end
12
12
 
13
13
  def edit
14
- country_id = Address.default.country.id
14
+ country_id = Address.default.country_id
15
15
  @order.build_bill_address(country_id: country_id) if @order.bill_address.nil?
16
16
  @order.build_ship_address(country_id: country_id) if @order.ship_address.nil?
17
17
 
@@ -3,8 +3,6 @@ module Spree
3
3
  class PricesController < ResourceController
4
4
  belongs_to 'spree/product', find_by: :slug
5
5
 
6
- helper_method :supported_currencies_for_all_stores
7
-
8
6
  def create
9
7
  params.require(:vp).permit!
10
8
  params[:vp].each do |variant_id, prices|
@@ -23,17 +21,6 @@ module Spree
23
21
  flash[:success] = Spree.t('notice_messages.prices_saved')
24
22
  redirect_to admin_product_path(parent)
25
23
  end
26
-
27
- private
28
-
29
- def supported_currencies_for_all_stores
30
- @supported_currencies_for_all_stores = begin
31
- (
32
- Spree::Store.pluck(:supported_currencies).map { |c| c&.split(',') }.flatten + Spree::Store.pluck(:default_currency)
33
- ).
34
- compact.uniq.map { |code| ::Money::Currency.find(code.strip) }
35
- end
36
- end
37
24
  end
38
25
  end
39
26
  end
@@ -5,12 +5,11 @@ module Spree
5
5
  before_action :set_default_currency, only: :new
6
6
  before_action :set_default_locale, only: :new
7
7
  before_action :normalize_supported_currencies, only: [:create, :update]
8
+ before_action :normalize_supported_locales, only: [:create, :update]
8
9
  before_action :set_default_country_id, only: :new
9
10
  before_action :load_all_countries, only: [:new, :edit, :update, :create]
10
11
  before_action :load_all_zones, only: %i[new edit]
11
12
 
12
- helper_method :all_locales_options
13
-
14
13
  def index
15
14
  if params[:ids]
16
15
  load_stores_by_ids
@@ -129,20 +128,14 @@ module Spree
129
128
  end
130
129
  end
131
130
 
132
- def set_default_country_id
133
- @store.default_country_id = Spree::Config[:default_country_id]
134
- end
135
-
136
- def all_locales_options
137
- if defined?(SpreeI18n)
138
- SpreeI18n::Locale.all.map { |locale| locale_presentation(locale) }.push(['English (EN)', :en])
139
- else
140
- [['English (EN)', :en]]
131
+ def normalize_supported_locales
132
+ if params[:store][:supported_locales]&.is_a?(Array)
133
+ params[:store][:supported_locales] = params[:store][:supported_locales].compact.uniq.reject(&:blank?).join(',')
141
134
  end
142
135
  end
143
136
 
144
- def locale_presentation(locale)
145
- [Spree.t('i18n.this_file_language', locale: locale), locale]
137
+ def set_default_country_id
138
+ @store.default_country_id = Spree::Config[:default_country_id]
146
139
  end
147
140
  end
148
141
  end
@@ -1,6 +1,18 @@
1
1
  module Spree
2
2
  module Admin
3
3
  module BaseHelper
4
+ SELECT2_SUPPORTED_LOCALES = %w[
5
+ af ar az bg bn bs ca cs da de dsb el en eo es et eu fa fi fr gl he
6
+ hi hr hsb hu hy id is it ja ka km ko lt lv mk ms nb ne nl pa pl ps
7
+ pt pt-BR ro ru sk sl sq sr sr-Cyrl sv th tk tr uk vi zh-CN zh-TW
8
+ ].freeze
9
+
10
+ FLATPICKR_SUPPORTED_LOCALES = %w[
11
+ ar at az be bg bn bs cs cy da de eo es et fa fi fo fr ga gr he
12
+ hi hr hu id is it ja ka km ko kz lv mk mn ms my nl no pa pl pt ro ru
13
+ si sk sl sq sr sv th tr uk uz vn zh
14
+ ].freeze
15
+
4
16
  def flash_alert(flash)
5
17
  if flash.present?
6
18
  message = flash[:error] || flash[:notice] || flash[:success]
@@ -46,7 +58,7 @@ module Spree
46
58
 
47
59
  def datepicker_field_value(date)
48
60
  unless date.blank?
49
- l(date, format: Spree.t('date_picker.format', default: '%Y/%m/%d'))
61
+ l(date, format: '%Y/%m/%d')
50
62
  end
51
63
  end
52
64
 
@@ -201,6 +213,40 @@ module Spree
201
213
  class: 'btn-outline-secondary', icon: 'view.svg', id: 'admin_preview_taxon', target: :blank
202
214
  )
203
215
  end
216
+
217
+ def admin_logout_link
218
+ if defined?(admin_logout_path)
219
+ admin_logout_path
220
+ elsif defined?(spree_logout_path)
221
+ spree_logout_path
222
+ end
223
+ end
224
+
225
+ def select2_local_fallback
226
+ stripped_locale = I18n.locale.to_s.split('-').first
227
+
228
+ if ['zh-CN', 'zh-TW', 'sr-Cyrl', 'pt-BR'].include?(I18n.locale.to_s)
229
+ I18n.locale
230
+ elsif SELECT2_SUPPORTED_LOCALES.include? stripped_locale
231
+ stripped_locale
232
+ else
233
+ 'en'
234
+ end
235
+ end
236
+
237
+ def flatpickr_local_fallback
238
+ stripped_locale = I18n.locale.to_s.split('-').first
239
+
240
+ if I18n.locale.to_s == 'zh-TW'
241
+ # Taiwanese is a popular language in Spree,
242
+ # it has been well translated.
243
+ 'zh-tw'
244
+ elsif FLATPICKR_SUPPORTED_LOCALES.include? stripped_locale
245
+ stripped_locale
246
+ else
247
+ 'default'
248
+ end
249
+ end
204
250
  end
205
251
  end
206
252
  end