spree_multi_vendor 2.4.1 → 2.5.0

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: 956455a7ff13df68945b50b576880f345e2dbd4f5c4c32dc99420f0a1c5698e7
4
- data.tar.gz: 8daf1f4488fad039a96e4c43a2211521d5b15297c5e628f018368d38fca70121
3
+ metadata.gz: 739faebda6a3b0fea3e9bb528131c08de2dde2f692dbca6b7346e8eaf0b5d9a1
4
+ data.tar.gz: 656938bba90616428bd534d7e64d94d2673e99a3ced0a8a2dfc0515d6eb4c0c6
5
5
  SHA512:
6
- metadata.gz: 6b10eaa1316ee480d4b8b2e456e1648b3da2b01561effa253c65671de1963e3cb7369c1a061a4a298d443f5be4c018a7d9fff45d0a0514a2115f17f400f4fbf6
7
- data.tar.gz: ad4aac2625a258d534c9fa553a8261907601443a53859ef55e4e76523c6868c59083dac7904026741dc040b3b80b1da42a6aca9e35060fe82f17579ad111f0af
6
+ metadata.gz: 639389fb453a10c7fc98328a6bcf1f8b4d834063f1be4983a5177a00e2dafcb447afc6d2f67095dd80ba716214546b645481703f131bffca8abd1214fd007125
7
+ data.tar.gz: 4d8c28520b08cc36c0fb130e77d566ff4aaeee9a63d971c52b8af6c61443047cddb2f18df2543c3b35b47e22c461f9d65b1d89a82825cf1c7c82ec5b6199aebf
@@ -1,6 +1,7 @@
1
1
  module Spree
2
2
  module Admin
3
3
  class VendorsController < ResourceController
4
+ include Translatable
4
5
 
5
6
  def create
6
7
  if permitted_resource_params[:image]
@@ -13,7 +14,6 @@ module Spree
13
14
  if permitted_resource_params[:image]
14
15
  @vendor.create_image(attachment: permitted_resource_params.delete(:image))
15
16
  end
16
- format_translations if defined? SpreeGlobalize
17
17
  super
18
18
  end
19
19
 
@@ -51,18 +51,6 @@ module Spree
51
51
  products: []
52
52
  }
53
53
  end
54
-
55
- def format_translations
56
- return if params[:vendor][:translations_attributes].blank?
57
- params[:vendor][:translations_attributes].each do |_, data|
58
- translation = @vendor.translations.find_or_create_by(locale: data[:locale])
59
- translation.name = data[:name]
60
- translation.about_us = data[:about_us]
61
- translation.contact_us = data[:contact_us]
62
- translation.slug = data[:slug]
63
- translation.save!
64
- end
65
- end
66
54
  end
67
55
  end
68
56
  end
@@ -1,6 +1,11 @@
1
1
  module Spree
2
2
  class Vendor < Spree::Base
3
3
  extend FriendlyId
4
+ include TranslatableResource
5
+ include TranslatableResourceSlug
6
+
7
+ TRANSLATABLE_FIELDS = %i[name about_us contact_us slug].freeze
8
+ translates(*TRANSLATABLE_FIELDS)
4
9
 
5
10
  acts_as_paranoid
6
11
  acts_as_list column: :priority
@@ -48,16 +53,6 @@ module Spree
48
53
  update(notification_email: email)
49
54
  end
50
55
 
51
- # Spree Globalize support
52
- # https://github.com/spree-contrib/spree_multi_vendor/issues/104
53
- if defined?(SpreeGlobalize)
54
- attr_accessor :translations_attributes
55
- translates :name,
56
- :about_us,
57
- :contact_us,
58
- :slug, fallbacks_for_empty_translations: true
59
- end
60
-
61
56
  private
62
57
 
63
58
  def create_stock_location
@@ -66,9 +66,9 @@
66
66
  <!-- Add translation icon support -->
67
67
  <%= link_to_with_icon 'translate',
68
68
  nil,
69
- spree.admin_translations_path('vendor', vendor.id),
69
+ spree.translations_admin_vendor_path(vendor.id),
70
70
  title: Spree.t(:'i18n.translations'),
71
- class: 'btn btn-sm btn-primary' if defined? (SpreeGlobalize)%>
71
+ class: 'btn btn-sm btn-primary' %>
72
72
  </td>
73
73
  </tr>
74
74
  <% end %>
@@ -0,0 +1,3 @@
1
+ <div class="row" style="display: block">
2
+ <%= render 'spree/admin/translations/form', resource: @object %>
3
+ </div>
data/config/routes.rb CHANGED
@@ -1,6 +1,11 @@
1
1
  Spree::Core::Engine.routes.draw do
2
2
  namespace :admin do
3
3
  resources :vendors do
4
+ member do
5
+ get :translations
6
+ post :translations, to: 'vendors#edit_translations'
7
+ end
8
+
4
9
  collection do
5
10
  post :update_positions
6
11
  end
@@ -0,0 +1,25 @@
1
+ class AddMobilityTranslationsToVendor < ActiveRecord::Migration[6.1]
2
+ def change
3
+ if ActiveRecord::Base.connection.table_exists?('spree_vendor_translations')
4
+ if ActiveRecord::Migration.connection.index_exists?(:spree_vendors_translations, :spree_vendor_id)
5
+ remove_index :spree_vendor_translations, column: :spree_vendor_id, if_exists: true
6
+ end
7
+ else
8
+ create_table :spree_vendor_translations do |t|
9
+ # Translated attribute(s)
10
+ t.string :name
11
+ t.text :about_us
12
+ t.text :contact_us
13
+ t.string :slug
14
+
15
+ t.string :locale, null: false
16
+ t.references :spree_vendor, null: false, foreign_key: true, index: false
17
+
18
+ t.timestamps null: false
19
+ end
20
+
21
+ add_index :spree_vendor_translations, :locale, name: :index_spree_vendor_translations_on_locale
22
+ add_index :spree_vendor_translations, [:locale, :slug], unique: true, name: 'vendor_unique_slug_per_locale'
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,11 @@
1
+ class TransferVendorDataToTranslatableTables < ActiveRecord::Migration[6.1]
2
+ TRANSLATION_MIGRATION = Spree::TranslationMigrations.new(Spree::Vendor, 'en')
3
+
4
+ def up
5
+ TRANSLATION_MIGRATION.transfer_translation_data
6
+ end
7
+
8
+ def down
9
+ TRANSLATION_MIGRATION.revert_translation_data_transfer
10
+ end
11
+ end
@@ -1,5 +1,5 @@
1
1
  module SpreeMultiVendor
2
- VERSION = '2.4.1'
2
+ VERSION = '2.5.0'
3
3
 
4
4
  module_function
5
5
 
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
29
29
  s.require_path = 'lib'
30
30
  s.requirements << 'none'
31
31
 
32
- spree_version = '>= 4.3.0.rc1'
32
+ spree_version = '>= 4.6.0'
33
33
  s.add_dependency 'spree', spree_version
34
34
  s.add_dependency 'spree_backend', spree_version
35
35
  s.add_dependency 'spree_emails', spree_version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_multi_vendor
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spark Solutions
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.3.0.rc1
19
+ version: 4.6.0
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: 4.3.0.rc1
26
+ version: 4.6.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: spree_backend
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 4.3.0.rc1
33
+ version: 4.6.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 4.3.0.rc1
40
+ version: 4.6.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: spree_emails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 4.3.0.rc1
47
+ version: 4.6.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 4.3.0.rc1
54
+ version: 4.6.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: spree_extension
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -162,7 +162,6 @@ files:
162
162
  - app/overrides/spree/admin/orders/index.rb
163
163
  - app/overrides/spree/admin/products/form.rb
164
164
  - app/overrides/spree/admin/products/new.rb
165
- - app/overrides/spree/admin/shared/_main_menu.rb
166
165
  - app/overrides/spree/admin/shared/_order_summary.rb
167
166
  - app/overrides/spree/admin/users/_form.rb
168
167
  - app/serializers/spree/v2/storefront/vendor_image_serializer.rb
@@ -177,6 +176,7 @@ files:
177
176
  - app/views/spree/admin/vendors/edit.html.erb
178
177
  - app/views/spree/admin/vendors/index.html.erb
179
178
  - app/views/spree/admin/vendors/new.html.erb
179
+ - app/views/spree/admin/vendors/translations.html.erb
180
180
  - app/views/spree/api/v1/vendors/index.rabl
181
181
  - app/views/spree/api/v1/vendors/show.rabl
182
182
  - app/views/spree/vendor_mailer/vendor_notification_email.html.erb
@@ -204,6 +204,8 @@ files:
204
204
  - db/migrate/20210728120649_change_vendorized_models_vendor_id_type.rb
205
205
  - db/migrate/20210728120910_change_vendor_id_and_user_id_type_for_spree_vendor_users.rb
206
206
  - db/migrate/20210728121024_change_vendor_id_and_order_id_type_for_spree_order_commissions.rb
207
+ - db/migrate/20231114090744_add_mobility_translations_to_vendor.rb
208
+ - db/migrate/20231114093444_transfer_vendor_data_to_translatable_tables.rb
207
209
  - lib/generators/spree_multi_vendor/install/install_generator.rb
208
210
  - lib/generators/spree_multi_vendor/mailers_preview/mailers_preview_generator.rb
209
211
  - lib/generators/spree_multi_vendor/mailers_preview/templates/mailers/previews/vendor_notification_preview.rb
@@ -250,9 +252,9 @@ licenses:
250
252
  - BSD-3-Clause
251
253
  metadata:
252
254
  bug_tracker_uri: https://github.com/spree-contrib/spree_multi_vendor/issues
253
- changelog_uri: https://github.com/spree-contrib/spree_multi_vendor/releases/tag/v2.4.1
255
+ changelog_uri: https://github.com/spree-contrib/spree_multi_vendor/releases/tag/v2.5.0
254
256
  documentation_uri: https://guides.spreecommerce.org/
255
- source_code_uri: https://github.com/spree-contrib/spree_multi_vendor/tree/v2.4.1
257
+ source_code_uri: https://github.com/spree-contrib/spree_multi_vendor/tree/v2.5.0
256
258
  post_install_message:
257
259
  rdoc_options: []
258
260
  require_paths:
@@ -1,6 +0,0 @@
1
- Deface::Override.new(
2
- virtual_path: 'spree/admin/shared/_main_menu',
3
- name: 'Display configuration tab for vendors',
4
- replace: 'erb[silent]:contains("current_store")',
5
- text: '<% if can?(:admin, current_store) || current_spree_user&.vendors&.any? %>'
6
- )