spree_admin 5.4.2 → 5.4.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2f9e9301b1be27a3349cfc4eaef27ca076dff3e8131a8a88fc926abba84b40a1
4
- data.tar.gz: 49e0257fda4a3ffb5a6b8da0ea1623b2e3c323c07d2c47eafc986fd0b1485ce2
3
+ metadata.gz: 9a5af2b78a13b13f570093bfe92c6d6c6b3ade67ec72e294fbf0f1ffd9c121d6
4
+ data.tar.gz: 6dfa405d89717625d66b270fe16f7343bb8ec532f8ba673ee856361eb3682e92
5
5
  SHA512:
6
- metadata.gz: e38c5fcb1d9c9205f67203ecfbc7dd0c862fc80bae7152d918f0ebec47af68f78f0ab7141d03219e4547c3ff1633bdc05355353ef74bdbc55a7e82f10ddba5b1
7
- data.tar.gz: 46fa0bd908105098e55528c5691e38ea7d275bacd780f14f09f17062c81f15d8d91ddeb2fbd2bdaa3c18ef1dcabed2f60fea28242d763e1b4402ade26c6be53d
6
+ metadata.gz: 9172a34304882f931b1bf56502ffd09121ca3497d8e3b24b5520dc03cf6cebf5a70c6e284615098dc4c70462f153aa204899911f152902e75317b5130760222d
7
+ data.tar.gz: 91f7065af97ecddea447d6add3cd60ab8d36ceb6590ced8ca3e74bbe65a26eeded78625209b38e5b5ad9f26e43605bdc05fb594664f0d1aad1fbe51af22f17b9
@@ -29,6 +29,10 @@ module Spree
29
29
  table = Spree.admin.tables.get(table_key)
30
30
  table.find_bulk_action(key.to_sym)
31
31
  end
32
+
33
+ def authorize_admin
34
+ params[:kind] == 'set_active' ? authorize!(:bulk_activate, Spree::Product) : super
35
+ end
32
36
  end
33
37
  end
34
38
  end
@@ -63,8 +63,7 @@ module Spree
63
63
  redirect_to spree.new_admin_admin_user_path(token: @invitation.token), status: :see_other
64
64
  end
65
65
  rescue ActiveRecord::RecordNotFound
66
- redirect_to spree.root_path, alert: Spree.t('invalid_or_expired_invitation')
67
- nil
66
+ render :expired, status: :not_found
68
67
  end
69
68
 
70
69
  # PUT /admin/invitations/:id/accept
@@ -279,8 +279,7 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
279
279
 
280
280
  params[:q][:s] ||= collection_default_sort if collection_default_sort.present?
281
281
 
282
- date_range_params = %i[created_at_gt created_at_lt updated_at_gt updated_at_lt]
283
- date_range_params.each do |param|
282
+ %i[created_at_gt updated_at_gt].each do |param|
284
283
  if params[:q][param].present?
285
284
  params[:q][param] = begin
286
285
  params[:q][param].to_date&.in_time_zone(current_timezone)&.beginning_of_day
@@ -290,6 +289,16 @@ class Spree::Admin::ResourceController < Spree::Admin::BaseController
290
289
  end
291
290
  end
292
291
 
292
+ %i[created_at_lt updated_at_lt].each do |param|
293
+ if params[:q][param].present?
294
+ params[:q][param] = begin
295
+ params[:q][param].to_date&.in_time_zone(current_timezone)&.end_of_day
296
+ rescue StandardError
297
+ ''
298
+ end
299
+ end
300
+ end
301
+
293
302
  params[:q]
294
303
  end
295
304
 
@@ -0,0 +1,13 @@
1
+ module Spree
2
+ module Admin
3
+ class StatesController < ResourceController
4
+ belongs_to 'spree/country', find_by: :id
5
+
6
+ def select_options
7
+ states = @country.states.accessible_by(current_ability).order(:name)
8
+
9
+ render json: states.to_tom_select_json
10
+ end
11
+ end
12
+ end
13
+ end
@@ -23,7 +23,6 @@ module Spree
23
23
  current_store.default_country
24
24
  end
25
25
  @countries = Country.order(:name)
26
- @states = @selected_country&.states&.order(:name) || Spree::State.none
27
26
  @zones = Zone.order(:name)
28
27
  end
29
28
 
@@ -92,6 +92,7 @@ import TooltipController from 'spree/admin/controllers/tooltip_controller'
92
92
  import TurboSubmitButtonController from 'spree/admin/controllers/turbo_submit_button_controller'
93
93
  import UnitSystemController from 'spree/admin/controllers/unit_system_controller'
94
94
  import VariantsFormController from 'spree/admin/controllers/variants_form_controller'
95
+ import ZoneStateSelectController from 'spree/admin/controllers/zone_state_select_controller'
95
96
  import BulkEditorController from 'spree/admin/controllers/bulk_editor_controller'
96
97
  import AddressAutocompleteController from 'spree/core/controllers/address_autocomplete_controller'
97
98
  import AddressFormController from 'spree/core/controllers/address_form_controller'
@@ -166,6 +167,7 @@ application.register('turbo-submit-button', TurboSubmitButtonController)
166
167
  application.register('textarea-autogrow', TextareaAutogrow)
167
168
  application.register('unit-system', UnitSystemController)
168
169
  application.register('variants-form', VariantsFormController)
170
+ application.register('zone-state-select', ZoneStateSelectController)
169
171
  application.register('bulk-editor', BulkEditorController)
170
172
 
171
173
  LocalTime.start()
@@ -0,0 +1,31 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+ import { get } from '@rails/request.js'
3
+
4
+ export default class extends Controller {
5
+ static values = {
6
+ url: String
7
+ }
8
+
9
+ static targets = ["statesSelect"]
10
+
11
+ async countryChanged(event) {
12
+ const countryId = event.target.value
13
+ const statesInput = this.statesSelectTarget.querySelector('select')
14
+ if (!statesInput || !statesInput.tomselect) return
15
+
16
+ const tomSelect = statesInput.tomselect
17
+ tomSelect.clear()
18
+ tomSelect.clearOptions()
19
+
20
+ if (!countryId) return
21
+
22
+ const url = this.urlValue.replace(':country_id', countryId)
23
+ const response = await get(url, { contentType: 'application/json' })
24
+
25
+ if (response.ok) {
26
+ const states = await response.json
27
+ states.forEach(state => tomSelect.addOption(state))
28
+ tomSelect.refreshOptions(false)
29
+ }
30
+ }
31
+ }
@@ -1,7 +1,7 @@
1
1
  <div class="card mb-6">
2
2
  <div class="card-body">
3
3
  <% unless f.object.persisted? %>
4
- <%= f.spree_text_field :code, required: true, help_bubble: Spree.t('admin.gift_cards.code_help_text'), autofocus: true %>
4
+ <%= f.spree_text_field :code, help_bubble: Spree.t('admin.gift_cards.code_help_text'), autofocus: true %>
5
5
  <% end %>
6
6
 
7
7
  <%= f.spree_money_field :amount, currency: f.object.currency, required: true %>
@@ -0,0 +1,4 @@
1
+ <div class="text-center">
2
+ <h1 class="text-2xl font-semibold mb-2"><%= Spree.t('invitation_expired.heading') %></h1>
3
+ <p class="text-gray-500"><%= Spree.t('invitation_expired.body') %></p>
4
+ </div>
@@ -30,12 +30,12 @@
30
30
  <%= dropdown_menu do %>
31
31
  <%= link_to_with_icon "edit",
32
32
  Spree.t(:edit),
33
- spree.edit_admin_order_line_item_path(@order, line_item),
33
+ spree.edit_admin_order_line_item_path(line_item.order, line_item),
34
34
  class: "dropdown-item" %>
35
35
  <% if line_item.digital_links.any? %>
36
36
  <%= link_to_with_icon "refresh",
37
37
  Spree.t("admin.reset_digital_link_download_limits"),
38
- spree.reset_digital_links_limit_admin_order_line_item_path(@order, line_item),
38
+ spree.reset_digital_links_limit_admin_order_line_item_path(line_item.order, line_item),
39
39
  data: {
40
40
  turbo_method: :post,
41
41
  turbo_confirm: Spree.t(:are_you_sure),
@@ -46,7 +46,7 @@
46
46
 
47
47
  <% if can?(:destroy, line_item) %>
48
48
  <div class="dropdown-divider"></div>
49
- <%= link_to_with_icon "trash", Spree.t('actions.destroy'), spree.admin_order_line_item_path(@order, line_item), data: { turbo_method: :delete, turbo_frame: '_top', turbo_confirm: Spree.t(:are_you_sure )}, class: 'dropdown-item text-red-600 hover:bg-red-100' %>
49
+ <%= link_to_with_icon "trash", Spree.t('actions.destroy'), spree.admin_order_line_item_path(line_item.order, line_item), data: { turbo_method: :delete, turbo_frame: '_top', turbo_confirm: Spree.t(:are_you_sure )}, class: 'dropdown-item text-red-600 hover:bg-red-100' %>
50
50
  <% end %>
51
51
  <% end %>
52
52
  <% end %>
@@ -87,7 +87,7 @@
87
87
  <% if can_ship?(shipment) %>
88
88
  <div class="card-footer flex justify-end border-t bg-gray-25">
89
89
  <% if shipment.tracked? %>
90
- <%= link_to_with_icon 'send.svg', Spree.t(:ship), spree.ship_admin_order_shipment_path(order, shipment), class: 'ml-auto btn btn-primary mb-0', data: {turbo_method: :post, turbo_confirm: Spree.t(:are_you_sure)} %>
90
+ <%= link_to_with_icon 'send.svg', Spree.t(:ship), spree.ship_admin_order_shipment_path(order, shipment), class: 'ml-auto btn btn-primary mb-0', data: {turbo_method: :post, turbo_confirm: Spree.t(:are_you_sure), turbo_frame: '_top'} %>
91
91
  <% elsif !shipment.digital? %>
92
92
  <span class="ship ml-auto btn btn-primary disabled mb-0" data-controller="tooltip" data-tooltip-placement-value="left">
93
93
  <%= icon 'send' %>
@@ -1,4 +1,4 @@
1
- <div id="state_members">
1
+ <div id="state_members" data-controller="zone-state-select" data-zone-state-select-url-value="<%= spree.select_options_admin_country_states_path(':country_id') %>">
2
2
  <div class="card mb-6">
3
3
  <div class="card-header">
4
4
  <h5 class="card-title">
@@ -9,12 +9,22 @@
9
9
  <div class="card-body">
10
10
  <div class="form-group">
11
11
  <%= label_tag :states_country_id, Spree.t(:country) %>
12
- <%= tom_select_tag :states_country_id, class: 'w-full', options: Spree::Country.joins(:states).to_tom_select_json, active_option: @selected_country&.id, select_data: {action: "auto-submit#submit"} %>
12
+ <%= tom_select_tag :states_country_id,
13
+ class: 'w-full',
14
+ options: Spree::Country.joins(:states).distinct.to_tom_select_json,
15
+ active_option: @selected_country&.id,
16
+ select_data: {action: "change->zone-state-select#countryChanged"}
17
+ %>
13
18
  </div>
14
19
 
15
- <div class="form-group">
20
+ <div class="form-group" data-zone-state-select-target="statesSelect">
16
21
  <%= zone_form.label :state_ids, Spree.t(:states) %>
17
- <%= tom_select_tag 'zone[state_ids]', multiple: true, class: 'w-full', options: @states.to_tom_select_json, active_option: @zone.state_ids %>
22
+ <%= tom_select_tag 'zone[state_ids]',
23
+ multiple: true,
24
+ class: 'w-full',
25
+ url: @selected_country ? spree.select_options_admin_country_states_path(@selected_country) : nil,
26
+ active_option: @zone.state_ids
27
+ %>
18
28
  </div>
19
29
  </div>
20
30
  </div>
@@ -135,7 +135,7 @@ Rails.application.config.after_initialize do
135
135
  action_path: ->(view_context) { view_context.spree.bulk_status_update_admin_products_path(status: 'active') },
136
136
  body: 'admin.bulk_ops.products.body.set_active',
137
137
  position: 10,
138
- condition: -> { can?(:activate, Spree::Product) }
138
+ condition: -> { can?(:bulk_activate, Spree::Product) }
139
139
 
140
140
  Spree.admin.tables.products.add_bulk_action :set_draft,
141
141
  label: 'admin.bulk_ops.products.title.set_draft',
@@ -462,7 +462,7 @@ Rails.application.config.after_initialize do
462
462
  position: 30,
463
463
  ransack_attribute: 'addresses_country_name',
464
464
  operators: %i[eq],
465
- search_url: ->(view_context) { view_context.spree.admin_countries_select_options_path(format: :json) },
465
+ search_url: ->(view_context) { view_context.spree.select_options_admin_countries_path(format: :json) },
466
466
  partial: 'spree/admin/tables/columns/user_location'
467
467
 
468
468
  # Number of orders
data/config/routes.rb CHANGED
@@ -62,9 +62,18 @@ Spree::Core::Engine.add_routes do
62
62
  end
63
63
  get '/taxons/select_options' => 'taxons#select_options', as: :taxons_select_options, defaults: { format: :json }
64
64
  get '/tags/select_options' => 'tags#select_options', as: :tags_select_options, defaults: { format: :json }
65
- get '/countries/select_options' => 'countries#select_options', as: :countries_select_options, defaults: { format: :json }
66
65
  get '/users/select_options' => 'users#select_options', as: :users_select_options, defaults: { format: :json }
67
66
  get '/stock_locations/select_options' => 'stock_locations#select_options', as: :stock_locations_select_options, defaults: { format: :json }
67
+ resources :countries, only: [] do
68
+ collection do
69
+ get :select_options, defaults: { format: :json }
70
+ end
71
+ resources :states, only: [] do
72
+ collection do
73
+ get :select_options, defaults: { format: :json }
74
+ end
75
+ end
76
+ end
68
77
 
69
78
  # media library
70
79
  resources :assets, only: [:create, :edit, :update, :destroy] do
@@ -43,7 +43,7 @@ module Spree
43
43
 
44
44
  def spree_engines
45
45
  Rails::Engine.subclasses.select do |engine|
46
- engine.name&.start_with?("Spree::")
46
+ engine.name&.start_with?("Spree")
47
47
  end
48
48
  end
49
49
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.2
4
+ version: 5.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vendo Connect Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-04-27 00:00:00.000000000 Z
11
+ date: 2026-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spree
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 5.4.2
19
+ version: 5.4.3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 5.4.2
26
+ version: 5.4.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: active_link_to
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -364,6 +364,7 @@ files:
364
364
  - app/controllers/spree/admin/shipments_controller.rb
365
365
  - app/controllers/spree/admin/shipping_categories_controller.rb
366
366
  - app/controllers/spree/admin/shipping_methods_controller.rb
367
+ - app/controllers/spree/admin/states_controller.rb
367
368
  - app/controllers/spree/admin/stock_items_controller.rb
368
369
  - app/controllers/spree/admin/stock_locations_controller.rb
369
370
  - app/controllers/spree/admin/stock_movements_controller.rb
@@ -479,6 +480,7 @@ files:
479
480
  - app/javascript/spree/admin/controllers/turbo_submit_button_controller.js
480
481
  - app/javascript/spree/admin/controllers/unit_system_controller.js
481
482
  - app/javascript/spree/admin/controllers/variants_form_controller.js
483
+ - app/javascript/spree/admin/controllers/zone_state_select_controller.js
482
484
  - app/javascript/spree/admin/helpers/index.js
483
485
  - app/javascript/spree/admin/helpers/tinymce.js
484
486
  - app/javascript/spree/admin/helpers/trix/video_embed.js
@@ -621,6 +623,7 @@ files:
621
623
  - app/views/spree/admin/integrations/new.html.erb
622
624
  - app/views/spree/admin/invitations/_invitation.html.erb
623
625
  - app/views/spree/admin/invitations/create.turbo_stream.erb
626
+ - app/views/spree/admin/invitations/expired.html.erb
624
627
  - app/views/spree/admin/invitations/index.html.erb
625
628
  - app/views/spree/admin/invitations/new.html.erb
626
629
  - app/views/spree/admin/invitations/show.html.erb
@@ -1161,9 +1164,9 @@ licenses:
1161
1164
  - BSD-3-Clause
1162
1165
  metadata:
1163
1166
  bug_tracker_uri: https://github.com/spree/spree/issues
1164
- changelog_uri: https://github.com/spree/spree/releases/tag/v5.4.2
1167
+ changelog_uri: https://github.com/spree/spree/releases/tag/v5.4.3
1165
1168
  documentation_uri: https://docs.spreecommerce.org/
1166
- source_code_uri: https://github.com/spree/spree/tree/v5.4.2
1169
+ source_code_uri: https://github.com/spree/spree/tree/v5.4.3
1167
1170
  post_install_message:
1168
1171
  rdoc_options: []
1169
1172
  require_paths: