spree_vendor_brand 0.0.1
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 +7 -0
- data/.github/workflows/ci.yml +49 -0
- data/.gitignore +23 -0
- data/.rspec +3 -0
- data/Gemfile +13 -0
- data/LICENSE +26 -0
- data/README.md +60 -0
- data/Rakefile +21 -0
- data/app/.gitkeep +0 -0
- data/app/controllers/.gitkeep +0 -0
- data/app/controllers/spree_vendor_brand/admin/taxons_controller_decorator.rb +13 -0
- data/app/controllers/spree_vendor_brand/api/v2/platform/taxons_controller_decorator.rb +15 -0
- data/app/controllers/spree_vendor_brand/api/v2/storefront/taxons_controller_decorator.rb +16 -0
- data/app/models/.gitkeep +0 -0
- data/app/models/spree_vendor_brand/configuration.rb +13 -0
- data/app/models/spree_vendor_brand/spree/product_decorator.rb +30 -0
- data/app/models/spree_vendor_brand/spree/taxon_decorator.rb +37 -0
- data/app/models/spree_vendor_brand/spree/taxonomy_decorator.rb +7 -0
- data/app/models/spree_vendor_brand/spree/vendor_decorator.rb +16 -0
- data/app/serializers/.gitkeep +0 -0
- data/app/serializers/spree_vendor_brand/v2/storefront/taxon_serializer_decorator.rb +7 -0
- data/app/services/.gitkeep +0 -0
- data/app/views/spree/admin/products/_form.html.erb +294 -0
- data/app/views/spree/admin/taxons/_form.html.erb +78 -0
- data/bin/rails +8 -0
- data/config/locales/en.yml +14 -0
- data/config/locales/ja.yml +11 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20211209050605_add_vendor_id_for_spree_taxons.rb +7 -0
- data/db/migrate/20211221072648_add_hiragana_for_spree_taxons.rb +7 -0
- data/lib/generators/spree_vendor_brand/install/install_generator.rb +20 -0
- data/lib/spree_vendor_brand/engine.rb +24 -0
- data/lib/spree_vendor_brand/factories.rb +6 -0
- data/lib/spree_vendor_brand/version.rb +11 -0
- data/lib/spree_vendor_brand.rb +4 -0
- data/spree_vendor_brand.gemspec +34 -0
- metadata +204 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 6c0f2b85f362ec0ed1a3a0c8e3dc3debf7c0b481640e7a7cda3a6325d9b848ed
|
|
4
|
+
data.tar.gz: 96aa1dd3fd10bd30ae24da65a5e04c590aa08d2263f1ed4f544aa107d86cf8ca
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 69b324e8b6a5386f79705c11888d9fed01cba318f2aa7952a2e44fdd361433d614086243dfd0b888f969ee78bf0677b5ba63ff35f6454be1eb970371bc61cb34
|
|
7
|
+
data.tar.gz: 9d7c54f9f4eea536bee4df3649c46995710e173d8161e6e8e0129d2cee47fcfba74a669eeebd470ef9ff42e9a519d1d09925af92527856a9e509fb7646cd4981
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on: push
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
ci:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
timeout-minutes: 30
|
|
9
|
+
env:
|
|
10
|
+
DATABASE_HOST: 0.0.0.0
|
|
11
|
+
DATABASE_PASSWORD: mysql123
|
|
12
|
+
RAILS_ENV: test
|
|
13
|
+
REDIS_URL: redis://0.0.0.0:6379
|
|
14
|
+
TZ: Asia/Tokyo
|
|
15
|
+
|
|
16
|
+
services:
|
|
17
|
+
mysql:
|
|
18
|
+
image: mysql:8.0.23
|
|
19
|
+
options: --health-cmd "mysqladmin ping -h localhost" --health-interval 20s --health-timeout 10s --health-retries 10
|
|
20
|
+
env:
|
|
21
|
+
MYSQL_ROOT_PASSWORD: ${{ env.DATABASE_PASSWORD }}
|
|
22
|
+
ports:
|
|
23
|
+
- 3306:3306
|
|
24
|
+
redis:
|
|
25
|
+
image: redis:6.2-alpine
|
|
26
|
+
options: --health-cmd "redis-cli -h localhost ping" --health-interval 10s --health-timeout 5s --health-retries 15
|
|
27
|
+
ports:
|
|
28
|
+
- 6379:6379
|
|
29
|
+
webdriver_chrome:
|
|
30
|
+
image: selenium/standalone-chrome:95.0
|
|
31
|
+
ports:
|
|
32
|
+
- 4444:4444
|
|
33
|
+
options: "--shm-size 2g"
|
|
34
|
+
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@v2
|
|
37
|
+
- uses: ruby/setup-ruby@v1
|
|
38
|
+
with:
|
|
39
|
+
bundler-cache: true
|
|
40
|
+
ruby-version: 3.0.3
|
|
41
|
+
|
|
42
|
+
- name: Exec tests 👚
|
|
43
|
+
env:
|
|
44
|
+
DB_HOST: 127.0.0.1
|
|
45
|
+
DB_PASSWORD: ${{ env.DATABASE_PASSWORD }}
|
|
46
|
+
DB_USERNAME: root
|
|
47
|
+
run: |
|
|
48
|
+
bundle exec rake test_app
|
|
49
|
+
bundle exec rake spec
|
data/.gitignore
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
\#*
|
|
2
|
+
*~
|
|
3
|
+
.#*
|
|
4
|
+
.DS_Store
|
|
5
|
+
.idea
|
|
6
|
+
.localeapp/locales
|
|
7
|
+
.project
|
|
8
|
+
.vscode
|
|
9
|
+
coverage
|
|
10
|
+
default
|
|
11
|
+
Gemfile.lock
|
|
12
|
+
tmp
|
|
13
|
+
nbproject
|
|
14
|
+
pkg
|
|
15
|
+
*.sw?
|
|
16
|
+
spec/dummy
|
|
17
|
+
.rvmrc
|
|
18
|
+
.sass-cache
|
|
19
|
+
public/spree
|
|
20
|
+
.ruby-version
|
|
21
|
+
.ruby-gemset
|
|
22
|
+
*.gem
|
|
23
|
+
*/*.gem
|
data/.rspec
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
git_source(:github) do |repo_name|
|
|
4
|
+
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
|
|
5
|
+
"https://github.com/#{repo_name}.git"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
gem 'spree'
|
|
9
|
+
# gem 'spree_backend', github: 'spree/spree', branch: 'main'
|
|
10
|
+
gem 'spree_multi_vendor', require: ['spree_emails', 'spree_multi_vendor']
|
|
11
|
+
gem 'rails-controller-testing'
|
|
12
|
+
|
|
13
|
+
gemspec
|
data/LICENSE
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Copyright (c) 2022 ROUTE06, Inc.
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
5
|
+
are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
|
8
|
+
this list of conditions and the following disclaimer.
|
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
|
11
|
+
and/or other materials provided with the distribution.
|
|
12
|
+
* Neither the name Spree nor the names of its contributors may be used to
|
|
13
|
+
endorse or promote products derived from this software without specific
|
|
14
|
+
prior written permission.
|
|
15
|
+
|
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
20
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
21
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
22
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
23
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
24
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
25
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# SpreeVendorBrand
|
|
2
|
+
|
|
3
|
+
A Spree extension that implement brand with multi vendor.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
1. Add this extension to your Gemfile with this line:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'spree_vendor_brand'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
2. Install the gem using Bundler
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
bundle install
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
3. Copy & run migrations
|
|
20
|
+
|
|
21
|
+
```ruby
|
|
22
|
+
bundle exec rails g spree_vendor_brand:install
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
4. Restart your server
|
|
26
|
+
|
|
27
|
+
If your server was running, restart it so that it can find the assets properly.
|
|
28
|
+
|
|
29
|
+
## Testing
|
|
30
|
+
|
|
31
|
+
First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs. The dummy app can be regenerated by using `rake test_app`.
|
|
32
|
+
|
|
33
|
+
```shell
|
|
34
|
+
bundle update
|
|
35
|
+
bundle exec rake
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
When testing your applications integration with this extension you may use it's factories.
|
|
39
|
+
Simply add this require statement to your spec_helper:
|
|
40
|
+
|
|
41
|
+
```ruby
|
|
42
|
+
require 'spree_vendor_brand/factories'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Releasing
|
|
46
|
+
|
|
47
|
+
```shell
|
|
48
|
+
bundle exec gem bump -p -t
|
|
49
|
+
bundle exec gem release
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
For more options please see [gem-release REAMDE](https://github.com/svenfuchs/gem-release)
|
|
53
|
+
|
|
54
|
+
## Contributing
|
|
55
|
+
|
|
56
|
+
If you'd like to contribute, please take a look at the
|
|
57
|
+
[instructions](CONTRIBUTING.md) for installing dependencies and crafting a good
|
|
58
|
+
pull request.
|
|
59
|
+
|
|
60
|
+
Copyright (c) 2022 ROUTE06, Inc., released under the New BSD License
|
data/Rakefile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require 'bundler'
|
|
2
|
+
Bundler::GemHelper.install_tasks
|
|
3
|
+
|
|
4
|
+
require 'rspec/core/rake_task'
|
|
5
|
+
require 'spree/testing_support/extension_rake'
|
|
6
|
+
|
|
7
|
+
RSpec::Core::RakeTask.new
|
|
8
|
+
|
|
9
|
+
task :default do
|
|
10
|
+
if Dir['spec/dummy'].empty?
|
|
11
|
+
Rake::Task[:test_app].invoke
|
|
12
|
+
Dir.chdir('../../')
|
|
13
|
+
end
|
|
14
|
+
Rake::Task[:spec].invoke
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc 'Generates a dummy app for testing'
|
|
18
|
+
task :test_app do
|
|
19
|
+
ENV['LIB_NAME'] = 'spree_vendor_brand'
|
|
20
|
+
Rake::Task['extension:test_app'].invoke
|
|
21
|
+
end
|
data/app/.gitkeep
ADDED
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @see https://github.com/spree/spree/blob/v4.3.0/backend/app/controllers/spree/admin/taxons_controller.rb
|
|
2
|
+
module SpreeVendorBrand::Admin::TaxonsControllerDecorator
|
|
3
|
+
private
|
|
4
|
+
|
|
5
|
+
# @override
|
|
6
|
+
def permitted_taxon_attributes
|
|
7
|
+
attributes = super
|
|
8
|
+
attributes += [:vendor_id, :hiragana]
|
|
9
|
+
attributes
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
Spree::Admin::TaxonsController.prepend(SpreeVendorBrand::Admin::TaxonsControllerDecorator) unless Spree::Admin::TaxonsController.included_modules.include?(SpreeVendorBrand::Admin::TaxonsControllerDecorator)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module SpreeVendorBrand
|
|
2
|
+
module Api
|
|
3
|
+
module V2
|
|
4
|
+
module Platform
|
|
5
|
+
module TaxonsControllerDecorator
|
|
6
|
+
def scope
|
|
7
|
+
super.without_brand
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
Spree::Api::V2::Platform::TaxonsController.prepend(SpreeVendorBrand::Api::V2::Platform::TaxonsControllerDecorator) unless Spree::Api::V2::Platform::TaxonsController.included_modules.include?(SpreeVendorBrand::Api::V2::Platform::TaxonsControllerDecorator)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# The API was not sortable, so we override it to allow sorting.
|
|
2
|
+
module SpreeVendorBrand::Api::V2::Storefront::TaxonsControllerDecorator
|
|
3
|
+
private
|
|
4
|
+
|
|
5
|
+
# @override
|
|
6
|
+
def paginated_collection
|
|
7
|
+
@paginated_collection ||= collection_paginator.new(sorted_collection, params).call
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# @override
|
|
11
|
+
def allowed_sort_attributes
|
|
12
|
+
[:hiragana]
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
Spree::Api::V2::Storefront::TaxonsController.prepend(SpreeVendorBrand::Api::V2::Storefront::TaxonsControllerDecorator) unless Spree::Api::V2::Storefront::TaxonsController.included_modules.include?(SpreeVendorBrand::Api::V2::Storefront::TaxonsControllerDecorator)
|
data/app/models/.gitkeep
ADDED
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module SpreeVendorBrand
|
|
2
|
+
class Configuration < Spree::Preferences::Configuration
|
|
3
|
+
|
|
4
|
+
# Some example preferences are shown below, for more information visit:
|
|
5
|
+
# https://dev-docs.spreecommerce.org/internals/preferences
|
|
6
|
+
|
|
7
|
+
preference :enabled, :boolean, default: true
|
|
8
|
+
# preference :dark_chocolate, :boolean, default: true
|
|
9
|
+
# preference :color, :string, default: 'Red'
|
|
10
|
+
# preference :favorite_number, :integer
|
|
11
|
+
# preference :supported_locales, :array, default: [:en]
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module SpreeVendorBrand::Spree::ProductDecorator
|
|
2
|
+
def self.prepended(base)
|
|
3
|
+
base.attr_accessor :brand_id
|
|
4
|
+
base.validate :ensure_vendor_includes_brand, if: -> { brand_id.present? }
|
|
5
|
+
base.before_save :save_brand_as_taxon, if: -> { brand_id.present? }
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# @override
|
|
9
|
+
def brand
|
|
10
|
+
@brand ||= taxons.joins(:taxonomy).find_by(spree_taxonomies: { name: Spree::Taxonomy::BRAND_NAME })
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
private
|
|
14
|
+
|
|
15
|
+
def save_brand_as_taxon
|
|
16
|
+
brand = Spree::Taxon.find(brand_id)
|
|
17
|
+
self.taxons << brand
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def ensure_vendor_includes_brand
|
|
21
|
+
brand = Spree::Taxon.find(brand_id)
|
|
22
|
+
return if brand.taxonomy.name == ::Spree::Taxonomy::BRAND_NAME && brand.vendor == vendor
|
|
23
|
+
|
|
24
|
+
errors.add(:brand_id, :invalid)
|
|
25
|
+
rescue ActiveRecord::RecordNotFound
|
|
26
|
+
errors.add(:brand_id, :invalid)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
Spree::Product.prepend(SpreeVendorBrand::Spree::ProductDecorator) unless Spree::Product.included_modules.include?(SpreeVendorBrand::Spree::ProductDecorator)
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'nkf'
|
|
2
|
+
|
|
3
|
+
module SpreeVendorBrand::Spree::TaxonDecorator
|
|
4
|
+
def self.prepended(base)
|
|
5
|
+
base.belongs_to :vendor, class_name: "Spree::Vendor", optional: true
|
|
6
|
+
base.before_validation :katakana_to_hiragana
|
|
7
|
+
|
|
8
|
+
base.validates :hiragana, presence: true, if: :has_vendor?
|
|
9
|
+
base.validate :hiragana_must_be_hiragana
|
|
10
|
+
|
|
11
|
+
base.scope :without_brand, -> { joins(:taxonomy).where.not(spree_taxonomies: { name: Spree::Taxonomy::BRAND_NAME }) }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# @return [Boolean]
|
|
15
|
+
def brand?
|
|
16
|
+
taxonomy&.name == Spree::Taxonomy::BRAND_NAME
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def has_vendor?
|
|
20
|
+
vendor.present?
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def hiragana_must_be_hiragana
|
|
24
|
+
return if hiragana.blank?
|
|
25
|
+
return if hiragana.match?(/\A(\p{Hiragana}|ー)+\z/)
|
|
26
|
+
|
|
27
|
+
errors.add(:hiragana, :must_be_hiragana)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def katakana_to_hiragana
|
|
31
|
+
return if hiragana.blank?
|
|
32
|
+
converted_string = NKF.nkf("--hiragana -w", hiragana)
|
|
33
|
+
self.hiragana = converted_string
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
Spree::Taxon.prepend(SpreeVendorBrand::Spree::TaxonDecorator) unless Spree::Taxon.included_modules.include?(SpreeVendorBrand::Spree::TaxonDecorator)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
module SpreeVendorBrand::Spree::TaxonomyDecorator
|
|
2
|
+
# rubocop:disable Lint/OrAssignmentToConstant
|
|
3
|
+
BRAND_NAME ||= "brand"
|
|
4
|
+
# rubocop:enable Lint/OrAssignmentToConstant
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
Spree::Taxonomy.prepend(SpreeVendorBrand::Spree::TaxonomyDecorator) unless Spree::Taxonomy.included_modules.include?(SpreeVendorBrand::Spree::TaxonomyDecorator)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module SpreeVendorBrand
|
|
2
|
+
module Spree
|
|
3
|
+
module VendorDecorator
|
|
4
|
+
def self.prepended(base)
|
|
5
|
+
base.has_many :taxons, class_name: "Spree::Taxon"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# @return [Spree::Taxon::ActiveRecord_AssociationRelation]
|
|
9
|
+
def brands
|
|
10
|
+
taxons.joins(:taxonomy).where(taxonomy: { name: ::Spree::Taxonomy::BRAND_NAME })
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
Spree::Vendor.prepend(SpreeVendorBrand::Spree::VendorDecorator) unless Spree::Vendor.included_modules.include?(SpreeVendorBrand::Spree::VendorDecorator)
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
module SpreeVendorBrand::V2::Storefront::TaxonSerializerDecorator
|
|
2
|
+
def self.prepended(base)
|
|
3
|
+
base.attributes :hiragana
|
|
4
|
+
end
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
Spree::V2::Storefront::TaxonSerializer.prepend(SpreeVendorBrand::V2::Storefront::TaxonSerializerDecorator) if Spree::V2::Storefront::TaxonSerializer.included_modules.exclude?(SpreeVendorBrand::V2::Storefront::TaxonSerializerDecorator)
|
|
File without changes
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
<%# origin: https://github.com/spree/spree/blob/v4.3.0/backend/app/views/spree/admin/products/_form.html.erb %>
|
|
2
|
+
<div data-hook="admin_product_form_fields">
|
|
3
|
+
<div class="row">
|
|
4
|
+
|
|
5
|
+
<div class="col-12 col-md-8" data-hook="admin_product_form_left">
|
|
6
|
+
<div data-hook="admin_product_form_name">
|
|
7
|
+
<%= f.field_container :name, class: ['form-group'] do %>
|
|
8
|
+
<%= f.label :name, raw(Spree.t(:name) + required_span_tag) %>
|
|
9
|
+
<%= f.text_field :name, class: 'form-control title' %>
|
|
10
|
+
<%= f.error_message_on :name %>
|
|
11
|
+
<% end %>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
<div data-hook="admin_product_form_brand">
|
|
15
|
+
<%= f.field_container :brand, class: ['form-group'] do %>
|
|
16
|
+
<%= f.label :brand_id, Spree.t(:brand) %>
|
|
17
|
+
<%= f.select :brand_id, options_from_collection_for_select(@product.vendor&.brands || [], :id, :name, @product.brand&.id), { include_blank: true }, { class: 'select2' } %>
|
|
18
|
+
<%= f.error_message_on :brand_id %>
|
|
19
|
+
<% end %>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<div data-hook="admin_product_form_slug">
|
|
23
|
+
<%= f.field_container :slug, class: ['form-group'] do %>
|
|
24
|
+
<%= f.label :slug, raw(Spree.t(:slug) + required_span_tag) %>
|
|
25
|
+
<%= f.text_field :slug, class: 'form-control title' %>
|
|
26
|
+
<%= f.error_message_on :slug %>
|
|
27
|
+
<% end %>
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<div data-hook="admin_product_form_description">
|
|
31
|
+
<%= f.field_container :description, class: ['form-group'] do %>
|
|
32
|
+
<%= f.label :description, Spree.t(:description) %>
|
|
33
|
+
<%= f.text_area :description, { rows: "#{unless @product.has_variants? then '29' else '30' end}", class: "form-control #{"spree-rte" if product_wysiwyg_editor_enabled? }" } %>
|
|
34
|
+
<%= f.error_message_on :description %>
|
|
35
|
+
<% end %>
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<div class="col-12 col-md-4" data-hook="admin_product_form_right">
|
|
40
|
+
<div data-hook="admin_product_form_price">
|
|
41
|
+
<%= f.field_container :price, class: ['form-group'] do %>
|
|
42
|
+
<%= f.label :price, raw(Spree.t(:master_price) + required_span_tag) %>
|
|
43
|
+
<div class="input-group">
|
|
44
|
+
<div class="input-group-prepend">
|
|
45
|
+
<span class="input-group-text"><%= currency_symbol(current_currency) %></span>
|
|
46
|
+
</div>
|
|
47
|
+
<%= f.text_field :price, value: number_to_currency(@product.amount_in(current_currency), unit: ''), class: 'form-control', disabled: (cannot? :update, @product.master.default_price) %>
|
|
48
|
+
</div>
|
|
49
|
+
<%= f.error_message_on :price %>
|
|
50
|
+
<% end %>
|
|
51
|
+
</div>
|
|
52
|
+
|
|
53
|
+
<div>
|
|
54
|
+
<%= f.field_container :compare_at_price, class: ['form-group'] do %>
|
|
55
|
+
<%= f.label :compare_at_price, Spree.t(:compare_at_price) %>
|
|
56
|
+
<div class="input-group">
|
|
57
|
+
<div class="input-group-prepend">
|
|
58
|
+
<span class="input-group-text"><%= currency_symbol(current_currency) %></span>
|
|
59
|
+
</div>
|
|
60
|
+
<%= f.text_field :compare_at_price, value: number_to_currency(@product.compare_at_amount_in(current_currency), unit: ''), class: 'form-control' %>
|
|
61
|
+
</div>
|
|
62
|
+
<%= f.error_message_on :compare_at_price %>
|
|
63
|
+
<% end %>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<div data-hook="admin_product_form_cost_price" class="alpha two columns">
|
|
67
|
+
<%= f.field_container :cost_price, class: ['form-group'] do %>
|
|
68
|
+
<%= f.label :cost_price, Spree.t(:cost_price) %>
|
|
69
|
+
<%= f.text_field :cost_price, value: number_to_currency(@product.cost_price, unit: ''), class: 'form-control' %>
|
|
70
|
+
<%= f.error_message_on :cost_price %>
|
|
71
|
+
<% end %>
|
|
72
|
+
</div>
|
|
73
|
+
<div data-hook="admin_product_form_cost_currency" class="omega two columns">
|
|
74
|
+
<%= f.field_container :cost_currency, class: ['form-group'] do %>
|
|
75
|
+
<%= f.label :cost_currency, Spree.t(:cost_currency) %>
|
|
76
|
+
<%= f.select :cost_currency, currency_options(@product.cost_currency), {}, { class: 'select2' } %>
|
|
77
|
+
<%= f.error_message_on :cost_currency %>
|
|
78
|
+
<% end %>
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
<div data-hook="admin_product_form_available_on">
|
|
82
|
+
<%= f.field_container :available_on, class: ['form-group'] do %>
|
|
83
|
+
<%= f.label :available_on, Spree.t(:available_on) %>
|
|
84
|
+
<%= f.error_message_on :available_on %>
|
|
85
|
+
|
|
86
|
+
<div class="input-group datePickerFrom"
|
|
87
|
+
data-wrap="true"
|
|
88
|
+
data-alt-format="<%= Spree.t(:fpr_human_friendly_date_format, scope: 'date_picker', default: 'M j, Y') %>"
|
|
89
|
+
data-max-date="<%= @product.discontinue_on %>">
|
|
90
|
+
|
|
91
|
+
<%= f.text_field :available_on,
|
|
92
|
+
value: datepicker_field_value(@product.available_on),
|
|
93
|
+
placeholder: Spree.t(:select_a_date),
|
|
94
|
+
class: 'form-control shadow-none ',
|
|
95
|
+
'data-input':'' %>
|
|
96
|
+
|
|
97
|
+
<%= render partial: 'spree/admin/shared/cal_close' %>
|
|
98
|
+
</div>
|
|
99
|
+
<% end %>
|
|
100
|
+
</div>
|
|
101
|
+
|
|
102
|
+
<div data-hook="admin_product_form_discontinue_on">
|
|
103
|
+
<%= f.field_container :discontinue_on, class: ['form-group'] do %>
|
|
104
|
+
<%= f.label :discontinue_on, Spree.t(:discontinue_on) %>
|
|
105
|
+
<%= f.error_message_on :discontinue_on %>
|
|
106
|
+
|
|
107
|
+
<div class="input-group datePickerTo"
|
|
108
|
+
data-wrap="true"
|
|
109
|
+
data-alt-format="<%= Spree.t(:fpr_human_friendly_date_format, scope: 'date_picker', default: 'M j, Y') %>"
|
|
110
|
+
data-min-date="<%= @product.available_on %>">
|
|
111
|
+
|
|
112
|
+
<%= f.text_field :discontinue_on,
|
|
113
|
+
value: datepicker_field_value(@product.discontinue_on),
|
|
114
|
+
placeholder: Spree.t(:select_a_date),
|
|
115
|
+
class: 'form-control shadow-none ',
|
|
116
|
+
'data-input':'' %>
|
|
117
|
+
|
|
118
|
+
<%= render partial: 'spree/admin/shared/cal_close' %>
|
|
119
|
+
</div>
|
|
120
|
+
<% end %>
|
|
121
|
+
</div>
|
|
122
|
+
|
|
123
|
+
<div data-hook="admin_product_form_promotionable">
|
|
124
|
+
<%= f.field_container :promotionable, class: ['form-group'] do %>
|
|
125
|
+
<%= f.check_box :promotionable %>
|
|
126
|
+
<%= f.label :promotionable, Spree.t(:promotionable) %>
|
|
127
|
+
<%= f.error_message_on :promotionable %>
|
|
128
|
+
<% end %>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<div data-hook="admin_product_form_sku">
|
|
132
|
+
<%= f.field_container :master_sku, class: ['form-group'] do %>
|
|
133
|
+
<%= f.label :master_sku, Spree.t(:master_sku) %>
|
|
134
|
+
<%= f.text_field :sku, size: 16, class: 'form-control' %>
|
|
135
|
+
<% end %>
|
|
136
|
+
</div>
|
|
137
|
+
|
|
138
|
+
<% if @product.has_variants? %>
|
|
139
|
+
<div data-hook="admin_product_form_multiple_variants" class="card bg-light mb-3">
|
|
140
|
+
<div class="card-body">
|
|
141
|
+
<h5 class="card-title"><%= f.label :skus, Spree.t(:sku).pluralize %></h5>
|
|
142
|
+
<h6 class="card-subtitle mb-2 text-muted"><%= Spree.t(:info_product_has_multiple_skus, count: @product.variants.size) %> </h6>
|
|
143
|
+
<ul class="list-unstyled">
|
|
144
|
+
<% @product.variants.first(5).each do |variant| %>
|
|
145
|
+
<li><%= variant.sku %></li>
|
|
146
|
+
<% end %>
|
|
147
|
+
</ul>
|
|
148
|
+
<% if @product.variants.size > 5 %>
|
|
149
|
+
<em>
|
|
150
|
+
<%= Spree.t(:info_number_of_skus_not_shown, count: @product.variants.size - 5) %>
|
|
151
|
+
</em>
|
|
152
|
+
<% end %>
|
|
153
|
+
<div class="info-actions">
|
|
154
|
+
<% if can?(:admin, Spree::Variant) %>
|
|
155
|
+
<%= link_to_with_icon 'adjust.svg', Spree.t(:manage_variants), spree.admin_product_variants_url(@product), class: "btn btn-outline-secondary" %>
|
|
156
|
+
<% end %>
|
|
157
|
+
</div>
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
<% else %>
|
|
161
|
+
<div id="shipping_specs" class="row">
|
|
162
|
+
<div class="col-12 col-md-6">
|
|
163
|
+
<div id="shipping_specs_weight_field" data-hook="admin_product_form_weight" class="form-group">
|
|
164
|
+
<%= f.label :weight, Spree.t(:weight) %>
|
|
165
|
+
<%= f.text_field :weight, value: number_with_precision(@product.weight, precision: 2), size: 4, class: 'form-control' %>
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
|
|
169
|
+
<div class="col-12 col-md-6">
|
|
170
|
+
<div id="shipping_specs_height_field" data-hook="admin_product_form_height" class="form-group">
|
|
171
|
+
<%= f.label :height, Spree.t(:height) %>
|
|
172
|
+
<%= f.text_field :height, value: number_with_precision(@product.height, precision: 2), size: 4, class: 'form-control' %>
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
|
|
176
|
+
<div class="col-12 col-md-6">
|
|
177
|
+
<div id="shipping_specs_width_field" data-hook="admin_product_form_width" class="form-group">
|
|
178
|
+
<%= f.label :width, Spree.t(:width) %>
|
|
179
|
+
<%= f.text_field :width, value: number_with_precision(@product.width, precision: 2), size: 4, class: 'form-control' %>
|
|
180
|
+
</div>
|
|
181
|
+
</div>
|
|
182
|
+
|
|
183
|
+
<div class="col-12 col-md-6">
|
|
184
|
+
<div id="shipping_specs_depth_field" data-hook="admin_product_form_depth" class="form-group">
|
|
185
|
+
<%= f.label :depth, Spree.t(:depth) %>
|
|
186
|
+
<%= f.text_field :depth, value: number_with_precision(@product.depth, precision: 2), size: 4, class: 'form-control' %>
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
<% end %>
|
|
191
|
+
|
|
192
|
+
<div data-hook="admin_product_form_shipping_categories">
|
|
193
|
+
<%= f.field_container :shipping_category, class: ['form-group'] do %>
|
|
194
|
+
<%= f.label :shipping_category_id, Spree.t(:shipping_category) %>
|
|
195
|
+
<%= f.collection_select(:shipping_category_id, @shipping_categories, :id, :name, { include_blank: Spree.t('match_choices.none') }, { class: 'select2' }) %>
|
|
196
|
+
<%= f.error_message_on :shipping_category %>
|
|
197
|
+
<% end %>
|
|
198
|
+
</div>
|
|
199
|
+
|
|
200
|
+
<div data-hook="admin_product_form_tax_category">
|
|
201
|
+
<%= f.field_container :tax_category, class: ['form-group'] do %>
|
|
202
|
+
<%= f.label :tax_category_id, Spree.t(:tax_category) %>
|
|
203
|
+
<%= f.collection_select(:tax_category_id, @tax_categories, :id, :name, { include_blank: Spree.t('match_choices.none') }, { class: 'select2' }) %>
|
|
204
|
+
<%= f.error_message_on :tax_category %>
|
|
205
|
+
<% end %>
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
|
|
209
|
+
</div>
|
|
210
|
+
|
|
211
|
+
<div data-hook="admin_product_form_taxons">
|
|
212
|
+
<%= f.field_container :taxons, class: ['form-group'] do %>
|
|
213
|
+
<%= f.label :taxon_ids, Spree.t(:taxons) %>
|
|
214
|
+
|
|
215
|
+
<% if can? :modify, Spree::Classification %>
|
|
216
|
+
<%= f.select :taxon_ids, options_from_collection_for_select(@product.taxons.without_brand, :id, :pretty_name, @product.taxons.without_brand.ids),
|
|
217
|
+
{ include_hidden: true },
|
|
218
|
+
multiple: true,
|
|
219
|
+
data: { autocomplete_url_value: 'taxons_api_v2',
|
|
220
|
+
autocomplete_return_attr_value: 'pretty_name',
|
|
221
|
+
autocomplete_multiple_value: true } %>
|
|
222
|
+
<% elsif @product.taxons.any? %>
|
|
223
|
+
<ul class="text_list">
|
|
224
|
+
<% @product.taxons.each do |taxon| %>
|
|
225
|
+
<li><%= taxon.name %></li>
|
|
226
|
+
<% end %>
|
|
227
|
+
</ul>
|
|
228
|
+
<% else %>
|
|
229
|
+
<div class="alert alert-info"><%= Spree.t(:no_resource_found, resource: :taxons) %></div>
|
|
230
|
+
<% end %>
|
|
231
|
+
|
|
232
|
+
<% end %>
|
|
233
|
+
</div>
|
|
234
|
+
|
|
235
|
+
<div data-hook="admin_product_form_option_types">
|
|
236
|
+
<%= f.field_container :option_types, class: ['form-group'] do %>
|
|
237
|
+
<%= f.label :option_type_ids, Spree.t(:option_types) %>
|
|
238
|
+
|
|
239
|
+
<% if can? :modify, Spree::ProductOptionType %>
|
|
240
|
+
<%= f.select :option_type_ids, options_from_collection_for_select(@product.option_types, :id, :name, @product.option_type_ids),
|
|
241
|
+
{ include_hidden: true },
|
|
242
|
+
multiple: true,
|
|
243
|
+
class: 'select2-hidden-accessible',
|
|
244
|
+
data: { autocomplete_url_value: 'option_types_api_v2',
|
|
245
|
+
autocomplete_return_attr_value: 'name',
|
|
246
|
+
autocomplete_multiple_value: true } %>
|
|
247
|
+
<% elsif @product.option_types.any? %>
|
|
248
|
+
<ul class="text_list">
|
|
249
|
+
<% @product.option_types.each do |type| %>
|
|
250
|
+
<li><%= type.presentation %> (<%= type.name %>)</li>
|
|
251
|
+
<% end %>
|
|
252
|
+
</ul>
|
|
253
|
+
<% else %>
|
|
254
|
+
<div class="alert alert-info"><%= Spree.t(:no_resource_found, resource: :option_types) %></div>
|
|
255
|
+
<% end %>
|
|
256
|
+
|
|
257
|
+
<% end %>
|
|
258
|
+
</div>
|
|
259
|
+
|
|
260
|
+
<% if @stores.count > 1 %>
|
|
261
|
+
<div data-hook="admin_product_form_stores">
|
|
262
|
+
<%= f.field_container :stores, class: ['form-group'] do %>
|
|
263
|
+
<%= f.label :product_stores, Spree.t(:stores) %>
|
|
264
|
+
<%= collection_select(:product, :store_ids, @stores, :id, :unique_name, {}, { multiple: true, class: 'select2' }) %>
|
|
265
|
+
<% end %>
|
|
266
|
+
</div>
|
|
267
|
+
<% end %>
|
|
268
|
+
|
|
269
|
+
<div data-hook="admin_product_form_meta">
|
|
270
|
+
<div data-hook="admin_product_form_meta_title">
|
|
271
|
+
<%= f.field_container :meta_title, class: ['form-group'] do %>
|
|
272
|
+
<%= f.label :meta_title, Spree.t(:meta_title) %>
|
|
273
|
+
<%= f.text_field :meta_title, class: 'form-control' %>
|
|
274
|
+
<% end %>
|
|
275
|
+
</div>
|
|
276
|
+
|
|
277
|
+
<div data-hook="admin_product_form_meta_keywords">
|
|
278
|
+
<%= f.field_container :meta_keywords, class: ['form-group'] do %>
|
|
279
|
+
<%= f.label :meta_keywords, Spree.t(:meta_keywords) %>
|
|
280
|
+
<%= f.text_field :meta_keywords, class: 'form-control' %>
|
|
281
|
+
<% end %>
|
|
282
|
+
</div>
|
|
283
|
+
|
|
284
|
+
<div data-hook="admin_product_form_meta_description">
|
|
285
|
+
<%= f.field_container :meta_description, class: ['form-group'] do %>
|
|
286
|
+
<%= f.label :meta_description, Spree.t(:meta_description) %>
|
|
287
|
+
<%= f.text_area :meta_description, class: 'form-control' %>
|
|
288
|
+
<% end %>
|
|
289
|
+
</div>
|
|
290
|
+
|
|
291
|
+
<div data-hook="admin_product_form_additional_fields"></div>
|
|
292
|
+
|
|
293
|
+
</div>
|
|
294
|
+
</div>
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<%# https://github.com/spree/spree/blob/v4.3.0/backend/app/views/spree/admin/taxons/_form.html.erb %>
|
|
2
|
+
|
|
3
|
+
<div data-hook="admin_inside_taxon_form">
|
|
4
|
+
<%= f.field_container :name, class: ['form-group'] do %>
|
|
5
|
+
<%= f.label :name, raw(Spree.t(:name) + required_span_tag) %>
|
|
6
|
+
<%= text_field :taxon, :name, class: 'form-control' %>
|
|
7
|
+
<%= f.error_message_on :name, class: 'error-message' %>
|
|
8
|
+
<% end %>
|
|
9
|
+
|
|
10
|
+
<% if @taxon.brand? %>
|
|
11
|
+
<%= f.field_container :vendor, class: ['form-group'] do %>
|
|
12
|
+
<%= f.label :vendor, Spree.t(:vendor) %>
|
|
13
|
+
<%= f.select :vendor_id,
|
|
14
|
+
options_from_collection_for_select(spree_current_user.vendors || [], :id, :name, @taxon.vendor&.id),
|
|
15
|
+
{ include_blank: true },
|
|
16
|
+
{ class: 'select2' } %>
|
|
17
|
+
<% end %>
|
|
18
|
+
<% end %>
|
|
19
|
+
|
|
20
|
+
<%= f.field_container :hiragana, class: ['form-group'] do %>
|
|
21
|
+
<%= f.label :hiragana %>
|
|
22
|
+
<%= text_field :taxon, :hiragana, class: 'form-control' %>
|
|
23
|
+
<%= f.error_message_on :hiragana, class: 'error-message' %>
|
|
24
|
+
<small>※店舗指定時は必須</small>
|
|
25
|
+
<% end %>
|
|
26
|
+
|
|
27
|
+
<%= f.field_container :permalink, class: ['form-group'] do %>
|
|
28
|
+
<%= label_tag :permalink_part, raw(Spree.t(:permalink) + required_span_tag) %>
|
|
29
|
+
<div class="input-group mb-3">
|
|
30
|
+
<div class="input-group-prepend">
|
|
31
|
+
<span class="input-group-text" id="basic-addon3">
|
|
32
|
+
<%= [current_store.formatted_url, 't', @parent_permalink].join('/') %>
|
|
33
|
+
</span>
|
|
34
|
+
</div>
|
|
35
|
+
<%= text_field_tag :permalink_part, @permalink_part, class: 'form-control', required: true %>
|
|
36
|
+
</div>
|
|
37
|
+
<% end %>
|
|
38
|
+
|
|
39
|
+
<%= f.field_container :hide_from_nav, class: ['form-group'] do %>
|
|
40
|
+
<%= f.label :hide_from_nav do %>
|
|
41
|
+
<%= Spree.t(:hide_from_subcategories_nav) %>
|
|
42
|
+
<br>
|
|
43
|
+
<%= f.check_box :hide_from_nav, { checked: @taxon.hide_from_nav } %>
|
|
44
|
+
<small><%= Spree.t(:say_yes) %></small>
|
|
45
|
+
<% end %>
|
|
46
|
+
<% end %>
|
|
47
|
+
|
|
48
|
+
<%= f.field_container :icon, class: ['form-group'] do %>
|
|
49
|
+
<%= f.label :icon, Spree.t(:header_banner) %>
|
|
50
|
+
<%= image_tag(main_app.url_for(@taxon.icon.try(:attachment)), class: 'w-100') if @taxon.icon %>
|
|
51
|
+
<%= f.file_field :icon %>
|
|
52
|
+
<% if @taxon.icon.present? %>
|
|
53
|
+
<%= link_to Spree.t(:remove_image),
|
|
54
|
+
remove_icon_admin_taxonomy_taxon_url(@taxonomy.id, @taxon.id),
|
|
55
|
+
method: :delete %>
|
|
56
|
+
<% end %>
|
|
57
|
+
<% end %>
|
|
58
|
+
|
|
59
|
+
<%= f.field_container :description, class: ['form-group'] do %>
|
|
60
|
+
<%= f.label :description, Spree.t(:description) %>
|
|
61
|
+
<%= f.text_area :description, class: "form-control #{'spree-rte' if taxon_wysiwyg_editor_enabled? }", rows: 20 %>
|
|
62
|
+
<% end %>
|
|
63
|
+
|
|
64
|
+
<%= f.field_container :meta_title, class: ['form-group'] do %>
|
|
65
|
+
<%= f.label :meta_title, Spree.t(:meta_title) %>
|
|
66
|
+
<%= f.text_field :meta_title, class: 'form-control', rows: 6 %>
|
|
67
|
+
<% end %>
|
|
68
|
+
|
|
69
|
+
<%= f.field_container :meta_description, class: ['form-group'] do %>
|
|
70
|
+
<%= f.label :meta_description, Spree.t(:meta_description) %>
|
|
71
|
+
<%= f.text_area :meta_description, class: 'form-control', rows: 6 %>
|
|
72
|
+
<% end %>
|
|
73
|
+
|
|
74
|
+
<%= f.field_container :meta_keywords, class: ['form-group'] do %>
|
|
75
|
+
<%= f.label :meta_keywords, Spree.t(:meta_keywords) %>
|
|
76
|
+
<%= f.text_field :meta_keywords, class: 'form-control', rows: 6 %>
|
|
77
|
+
<% end %>
|
|
78
|
+
</div>
|
data/bin/rails
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# This command will automatically be run when you run "rails" from the root of your extension
|
|
3
|
+
|
|
4
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
|
5
|
+
ENGINE_PATH = File.expand_path('../../lib/spree_vendor_brand/engine', __FILE__)
|
|
6
|
+
|
|
7
|
+
require 'rails/all'
|
|
8
|
+
require 'rails/engine/commands'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Sample localization file for English. Add more files in this directory for other locales.
|
|
2
|
+
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
|
3
|
+
|
|
4
|
+
ja:
|
|
5
|
+
activerecord:
|
|
6
|
+
attributes:
|
|
7
|
+
spree/taxon:
|
|
8
|
+
hiragana: "Hiragana"
|
|
9
|
+
spree:
|
|
10
|
+
brand: "Brand"
|
|
11
|
+
taxonomy_brands_name: "Brands"
|
|
12
|
+
errors:
|
|
13
|
+
messages:
|
|
14
|
+
must_be_hiragana: "must be hiragana"
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module SpreeVendorBrand
|
|
2
|
+
module Generators
|
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
|
4
|
+
class_option :migrate, type: :boolean, default: true
|
|
5
|
+
|
|
6
|
+
def add_migrations
|
|
7
|
+
run 'bundle exec rake railties:install:migrations FROM=spree_vendor_brand'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def run_migrations
|
|
11
|
+
run_migrations = options[:migrate] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]'))
|
|
12
|
+
if run_migrations
|
|
13
|
+
run 'bundle exec rails db:migrate'
|
|
14
|
+
else
|
|
15
|
+
puts 'Skipping rails db:migrate, don\'t forget to run it!'
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module SpreeVendorBrand
|
|
2
|
+
class Engine < Rails::Engine
|
|
3
|
+
require 'spree/core'
|
|
4
|
+
isolate_namespace Spree
|
|
5
|
+
engine_name 'spree_vendor_brand'
|
|
6
|
+
|
|
7
|
+
# use rspec for tests
|
|
8
|
+
config.generators do |g|
|
|
9
|
+
g.test_framework :rspec
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
initializer 'spree_vendor_brand.environment', before: :load_config_initializers do |_app|
|
|
13
|
+
SpreeVendorBrand::Config = SpreeVendorBrand::Configuration.new
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.activate
|
|
17
|
+
Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
|
|
18
|
+
Rails.configuration.cache_classes ? require(c) : load(c)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
config.to_prepare(&method(:activate).to_proc)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
FactoryBot.define do
|
|
2
|
+
# Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them.
|
|
3
|
+
#
|
|
4
|
+
# Example adding this to your spec_helper will load these Factories for use:
|
|
5
|
+
# require 'spree_vendor_brand/factories'
|
|
6
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
lib = File.expand_path('../lib/', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
|
|
4
|
+
|
|
5
|
+
require 'spree_vendor_brand/version'
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |s|
|
|
8
|
+
s.platform = Gem::Platform::RUBY
|
|
9
|
+
s.name = 'spree_vendor_brand'
|
|
10
|
+
s.version = SpreeVendorBrand.version
|
|
11
|
+
s.summary = 'Add Spree extension that implement brand with multi vendor'
|
|
12
|
+
s.description = ''
|
|
13
|
+
s.required_ruby_version = '>= 2.5'
|
|
14
|
+
|
|
15
|
+
s.author = 'ROUTE06'
|
|
16
|
+
s.email = 'development+rubygems@route06.co.jp'
|
|
17
|
+
s.homepage = 'https://github.com/route06/spree_vendor_brand'
|
|
18
|
+
s.license = 'BSD-3-Clause'
|
|
19
|
+
|
|
20
|
+
s.files = `git ls-files`.split("\n").reject { |f| f.match(/^spec/) && !f.match(/^spec\/fixtures/) }
|
|
21
|
+
s.require_path = 'lib'
|
|
22
|
+
s.requirements << 'none'
|
|
23
|
+
|
|
24
|
+
s.add_dependency 'spree', '~> 4.3.1'
|
|
25
|
+
s.add_dependency 'rails', '~> 6.1'
|
|
26
|
+
s.add_dependency 'spree_backend'
|
|
27
|
+
s.add_dependency 'spree_extension'
|
|
28
|
+
s.add_dependency 'spree_multi_vendor'
|
|
29
|
+
|
|
30
|
+
s.add_development_dependency 'spree_dev_tools', '~> 0.1.12'
|
|
31
|
+
s.add_development_dependency 'net-smtp'
|
|
32
|
+
s.add_development_dependency 'mysql2'
|
|
33
|
+
s.add_development_dependency 'shoulda-matchers'
|
|
34
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: spree_vendor_brand
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- ROUTE06
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2022-03-01 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: spree
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 4.3.1
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 4.3.1
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rails
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '6.1'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '6.1'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: spree_backend
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: spree_extension
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: spree_multi_vendor
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: spree_dev_tools
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: 0.1.12
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: 0.1.12
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: net-smtp
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: mysql2
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: shoulda-matchers
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
type: :development
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - ">="
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0'
|
|
139
|
+
description: ''
|
|
140
|
+
email: development+rubygems@route06.co.jp
|
|
141
|
+
executables: []
|
|
142
|
+
extensions: []
|
|
143
|
+
extra_rdoc_files: []
|
|
144
|
+
files:
|
|
145
|
+
- ".github/workflows/ci.yml"
|
|
146
|
+
- ".gitignore"
|
|
147
|
+
- ".rspec"
|
|
148
|
+
- Gemfile
|
|
149
|
+
- LICENSE
|
|
150
|
+
- README.md
|
|
151
|
+
- Rakefile
|
|
152
|
+
- app/.gitkeep
|
|
153
|
+
- app/controllers/.gitkeep
|
|
154
|
+
- app/controllers/spree_vendor_brand/admin/taxons_controller_decorator.rb
|
|
155
|
+
- app/controllers/spree_vendor_brand/api/v2/platform/taxons_controller_decorator.rb
|
|
156
|
+
- app/controllers/spree_vendor_brand/api/v2/storefront/taxons_controller_decorator.rb
|
|
157
|
+
- app/models/.gitkeep
|
|
158
|
+
- app/models/spree_vendor_brand/configuration.rb
|
|
159
|
+
- app/models/spree_vendor_brand/spree/product_decorator.rb
|
|
160
|
+
- app/models/spree_vendor_brand/spree/taxon_decorator.rb
|
|
161
|
+
- app/models/spree_vendor_brand/spree/taxonomy_decorator.rb
|
|
162
|
+
- app/models/spree_vendor_brand/spree/vendor_decorator.rb
|
|
163
|
+
- app/serializers/.gitkeep
|
|
164
|
+
- app/serializers/spree_vendor_brand/v2/storefront/taxon_serializer_decorator.rb
|
|
165
|
+
- app/services/.gitkeep
|
|
166
|
+
- app/views/spree/admin/products/_form.html.erb
|
|
167
|
+
- app/views/spree/admin/taxons/_form.html.erb
|
|
168
|
+
- bin/rails
|
|
169
|
+
- config/locales/en.yml
|
|
170
|
+
- config/locales/ja.yml
|
|
171
|
+
- config/routes.rb
|
|
172
|
+
- db/migrate/20211209050605_add_vendor_id_for_spree_taxons.rb
|
|
173
|
+
- db/migrate/20211221072648_add_hiragana_for_spree_taxons.rb
|
|
174
|
+
- lib/generators/spree_vendor_brand/install/install_generator.rb
|
|
175
|
+
- lib/spree_vendor_brand.rb
|
|
176
|
+
- lib/spree_vendor_brand/engine.rb
|
|
177
|
+
- lib/spree_vendor_brand/factories.rb
|
|
178
|
+
- lib/spree_vendor_brand/version.rb
|
|
179
|
+
- spree_vendor_brand.gemspec
|
|
180
|
+
homepage: https://github.com/route06/spree_vendor_brand
|
|
181
|
+
licenses:
|
|
182
|
+
- BSD-3-Clause
|
|
183
|
+
metadata: {}
|
|
184
|
+
post_install_message:
|
|
185
|
+
rdoc_options: []
|
|
186
|
+
require_paths:
|
|
187
|
+
- lib
|
|
188
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
189
|
+
requirements:
|
|
190
|
+
- - ">="
|
|
191
|
+
- !ruby/object:Gem::Version
|
|
192
|
+
version: '2.5'
|
|
193
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
|
+
requirements:
|
|
195
|
+
- - ">="
|
|
196
|
+
- !ruby/object:Gem::Version
|
|
197
|
+
version: '0'
|
|
198
|
+
requirements:
|
|
199
|
+
- none
|
|
200
|
+
rubygems_version: 3.1.2
|
|
201
|
+
signing_key:
|
|
202
|
+
specification_version: 4
|
|
203
|
+
summary: Add Spree extension that implement brand with multi vendor
|
|
204
|
+
test_files: []
|