solidus_promotions 4.4.0 → 4.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: db60a6f38884af89ad6588b3b6306f7bda9b9d67170ffeee5b171ed72a0ddafb
4
- data.tar.gz: 756a0ef51fc6355fa90f5b7824d30d96701b3e9f672da33bf92fa05d845addd3
3
+ metadata.gz: 8d6349051a6426b230165c4ddb9d0f3e3dc90ea2c27ed9e80b5968757135fe67
4
+ data.tar.gz: d51b5804b5bcdcfed387a4508bc4cbd7593ee311284b51886cde909423fab6e6
5
5
  SHA512:
6
- metadata.gz: f8a85cbf84e94bae9702b35cb2dfc376bf5c86f7b144dadfe553637ac51ea8392711cf6fd828773ca358a452f48361a7be5866546a1133fa17cecd46188c75dd
7
- data.tar.gz: 0fc83043628ca2454361030801fdd08484a638b9e9a0241d422cd453e40bc6d322cde88c0076741cab1371864a9c75ed1b109c981a762daed816399eefceaec6
6
+ metadata.gz: 014bfa7ca43f1c7033656d059e26dd7822188b3c024e5e8ca80ef88c981d6569b5abba6712a230ecb15129baf9f94757af9c6bb2b98b5450d63a18c5c2ce1434
7
+ data.tar.gz: b5e9de86e525f26598e37514f2314e3ee47d5ce9c03cfcfae618f92e18f75ef540da6aa43d36e31dd5a4eafc0491c1003b6a6dff82878eec40a4916962bcdee4
@@ -2,13 +2,15 @@
2
2
  # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
3
 
4
4
  en:
5
+ solidus_admin:
6
+ menu_item:
7
+ promotions: Promotions (new)
8
+ promotion_categories: Promotion Categories (new)
5
9
  spree:
6
10
  admin:
7
11
  tab:
8
- promotions: Promotions
9
- promotion_categories: Promotion Categories
10
- legacy_promotions: Legacy Promotions
11
- legacy_promotion_categories: Legacy Promotion Categories
12
+ promotions: Promotions (new)
13
+ promotion_categories: Promotion Categories (new)
12
14
  hints:
13
15
  solidus_promotions/promotion:
14
16
  expires_at: This determines when the promotion expires. <br> If no value is specified, the promotion will never expire.
@@ -10,8 +10,4 @@ class SolidusAdmin::Orders::Show::Adjustments::Index::Source::SolidusPromotionsB
10
10
  def promotion_name
11
11
  source.promotion.name
12
12
  end
13
-
14
- def solidus_promotions
15
- @solidus_promotions ||= SolidusPromotions::Engine.routes.url_helpers
16
- end
17
13
  end
@@ -1,3 +1,5 @@
1
1
  en:
2
2
  filters:
3
3
  promotions: Promotions
4
+ scopes:
5
+ promotions: Promotions
@@ -101,8 +101,4 @@ class SolidusPromotions::Promotions::Index::Component < SolidusAdmin::UI::Pages:
101
101
  }
102
102
  ]
103
103
  end
104
-
105
- def solidus_promotions
106
- @solidus_promotions ||= SolidusPromotions::Engine.routes.url_helpers
107
- end
108
104
  end
@@ -13,7 +13,7 @@ module SolidusPromotions
13
13
  set_page_and_extract_portion_from(promotion_categories)
14
14
 
15
15
  respond_to do |format|
16
- format.html { render component("promotion_categories/index").new(page: @page) }
16
+ format.html { render component("solidus_promotions/categories/index").new(page: @page) }
17
17
  end
18
18
  end
19
19
 
@@ -19,7 +19,7 @@ module SolidusPromotions
19
19
  set_page_and_extract_portion_from(promotions)
20
20
 
21
21
  respond_to do |format|
22
- format.html { render component("promotions/index").new(page: @page) }
22
+ format.html { render component("solidus_promotions/promotions/index").new(page: @page) }
23
23
  end
24
24
  end
25
25
 
@@ -52,64 +52,71 @@ module SolidusPromotions
52
52
  end
53
53
  end
54
54
 
55
- initializer "solidus_promotions.add_admin_order_index_component", after: "solidus_legacy_promotions.add_admin_order_index_component" do
55
+ initializer "solidus_promotions.add_admin_order_index_component", after: "spree.load_config_initializers" do
56
56
  if SolidusSupport.admin_available?
57
- SolidusAdmin::Config.components["orders/index"] = "SolidusPromotions::Orders::Index::Component"
58
- SolidusAdmin::Config.components["promotions/index"] = "SolidusPromotions::Promotions::Index::Component"
59
- SolidusAdmin::Config.components["promotion_categories/index"] = "SolidusPromotions::PromotionCategories::Index::Component"
57
+ if Spree::Config.promotions.is_a?(SolidusPromotions::Configuration)
58
+ SolidusAdmin::Config.components["orders/index"] = "SolidusPromotions::Orders::Index::Component"
59
+ end
60
+
61
+ SolidusAdmin::Config.components["solidus_promotions/promotions/index"] = "SolidusPromotions::Promotions::Index::Component"
62
+ SolidusAdmin::Config.components["solidus_promotions/categories/index"] = "SolidusPromotions::PromotionCategories::Index::Component"
60
63
  end
61
64
  end
62
65
 
63
- initializer "solidus_promotions.add_backend_menus", after: "spree.backend.environment" do
64
- if SolidusSupport.backend_available?
65
- # Replace the promotions menu from core with ours
66
- Spree::Backend::Config.configure do |config|
67
- config.menu_items = config.menu_items.flat_map do |item|
68
- next item unless item.label.to_sym == :promotions
69
-
70
- [
71
- Spree::BackendConfiguration::MenuItem.new(
72
- label: :promotions,
73
- icon: config.admin_updated_navbar ? "ri-megaphone-line" : "bullhorn",
74
- condition: -> { can?(:admin, SolidusPromotions::Promotion) },
75
- url: -> { SolidusPromotions::Engine.routes.url_helpers.admin_promotions_path },
76
- data_hook: :admin_solidus_promotion_sub_tabs,
77
- children: [
78
- Spree::BackendConfiguration::MenuItem.new(
79
- label: :promotions,
80
- url: -> { SolidusPromotions::Engine.routes.url_helpers.admin_promotions_path },
81
- condition: -> { can?(:admin, SolidusPromotions::Promotion) }
82
- ),
83
- Spree::BackendConfiguration::MenuItem.new(
84
- label: :promotion_categories,
85
- url: -> { SolidusPromotions::Engine.routes.url_helpers.admin_promotion_categories_path },
86
- condition: -> { can?(:admin, SolidusPromotions::PromotionCategory) }
87
- )
88
- ]
89
- ),
90
- Spree::BackendConfiguration::MenuItem.new(
91
- label: :legacy_promotions,
92
- icon: config.admin_updated_navbar ? "ri-megaphone-line" : "bullhorn",
93
- condition: -> { can?(:admin, SolidusPromotions::Promotion) },
94
- url: -> { Spree::Core::Engine.routes.url_helpers.admin_promotions_path },
95
- data_hook: :admin_promotion_sub_tabs,
96
- children: [
97
- Spree::BackendConfiguration::MenuItem.new(
98
- label: :legacy_promotions,
99
- condition: -> { can?(:admin, Spree::Promotion && Spree::Promotion.any?) },
100
- url: -> { Spree::Core::Engine.routes.url_helpers.admin_promotions_path },
101
- ),
102
- Spree::BackendConfiguration::MenuItem.new(
103
- label: :legacy_promotion_categories,
104
- condition: -> { can?(:admin, Spree::PromotionCategory && Spree::Promotion.any?) },
105
- url: -> { Spree::Core::Engine.routes.url_helpers.admin_promotion_categories_path },
106
- )
107
- ]
108
- )
66
+ initializer "solidus_promotions.add_solidus_admin_menu_items", after: "spree.load_config_initializers" do
67
+ if SolidusSupport.admin_available?
68
+ SolidusAdmin::Config.configure do |config|
69
+ config.menu_items << {
70
+ key: "promotions",
71
+ route: -> { solidus_promotions.admin_promotions_path },
72
+ icon: "megaphone-line",
73
+ position: 1.6,
74
+ children: [
75
+ {
76
+ key: "promotions",
77
+ route: -> { solidus_promotions.admin_promotions_path },
78
+ position: 1
79
+ },
80
+ {
81
+ key: "promotion_categories",
82
+ route: -> { solidus_promotions.admin_promotion_categories_path },
83
+ position: 1
84
+ }
109
85
  ]
110
- end
86
+ }
111
87
  end
112
88
  end
113
89
  end
90
+
91
+ initializer "solidus_promotions.add_backend_menus", after: "spree.backend.environment" do
92
+ if SolidusSupport.backend_available?
93
+ promotions_menu_item = Spree::BackendConfiguration::MenuItem.new(
94
+ label: :promotions,
95
+ icon: Spree::Backend::Config.admin_updated_navbar ? "ri-megaphone-line" : "bullhorn",
96
+ condition: -> { can?(:admin, SolidusPromotions::Promotion) },
97
+ url: -> { SolidusPromotions::Engine.routes.url_helpers.admin_promotions_path },
98
+ data_hook: :admin_solidus_promotion_sub_tabs,
99
+ children: [
100
+ Spree::BackendConfiguration::MenuItem.new(
101
+ label: :promotions,
102
+ url: -> { SolidusPromotions::Engine.routes.url_helpers.admin_promotions_path },
103
+ condition: -> { can?(:admin, SolidusPromotions::Promotion) }
104
+ ),
105
+ Spree::BackendConfiguration::MenuItem.new(
106
+ label: :promotion_categories,
107
+ url: -> { SolidusPromotions::Engine.routes.url_helpers.admin_promotion_categories_path },
108
+ condition: -> { can?(:admin, SolidusPromotions::PromotionCategory) }
109
+ )
110
+ ]
111
+ )
112
+
113
+ # We want to appear after the legacy promotions menu item if it exists, otherwise after the products menu item
114
+ product_menu_item_index = Spree::Backend::Config.menu_items.find_index { |item| item.label == :products }
115
+ legacy_promotions_menu_item = Spree::Backend::Config.menu_items.find_index { |item| item.label == :legacy_promotions }
116
+ promotions_menu_index = [product_menu_item_index, legacy_promotions_menu_item].compact.max + 1
117
+
118
+ Spree::Backend::Config.menu_items.insert(promotions_menu_index, promotions_menu_item)
119
+ end
120
+ end
114
121
  end
115
122
  end
@@ -17,12 +17,12 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.metadata["homepage_uri"] = spec.homepage
19
19
 
20
- spec.required_ruby_version = ">= 3.0.0"
20
+ spec.required_ruby_version = ">= 3.1.0"
21
21
 
22
22
  # Specify which files should be added to the gem when it is released.
23
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
24
  files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0") }
25
- spec.files = files.grep_v(%r{^(test|spec|features)/})
25
+ spec.files = files.grep_v(%r{^(spec|bin)/})
26
26
 
27
27
  spec.add_dependency "importmap-rails", "~> 1.2"
28
28
  spec.add_dependency "ransack-enum", "~> 1.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_promotions
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.0
4
+ version: 4.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Meyerhoff
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-11-12 00:00:00.000000000 Z
12
+ date: 2024-11-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: importmap-rails
@@ -204,7 +204,6 @@ files:
204
204
  - app/models/solidus_promotions/promotion_handler/page.rb
205
205
  - app/models/solidus_promotions/shipping_rate_discount.rb
206
206
  - app/subscribers/solidus_promotions/order_promotion_subscriber.rb
207
- - bin/rails
208
207
  - config/importmap.rb
209
208
  - config/locales/en.yml
210
209
  - config/locales/promotion_categories.en.yml
@@ -352,7 +351,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
352
351
  requirements:
353
352
  - - ">="
354
353
  - !ruby/object:Gem::Version
355
- version: 3.0.0
354
+ version: 3.1.0
356
355
  required_rubygems_version: !ruby/object:Gem::Requirement
357
356
  requirements:
358
357
  - - ">="
data/bin/rails DELETED
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails gems
3
- # installed from the root of your application.
4
-
5
- ENGINE_ROOT = File.expand_path('..', __dir__)
6
- ENGINE_PATH = File.expand_path('../lib/solidus_promotions/engine', __dir__)
7
-
8
- # Set up gems listed in the Gemfile.
9
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
10
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
11
-
12
- require 'rails/all'
13
- require 'rails/engine/commands'