workarea-swatches 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +20 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
- data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.gitignore +21 -0
- data/CHANGELOG.md +121 -0
- data/CODE_OF_CONDUCT.md +3 -0
- data/CONTRIBUTING.md +3 -0
- data/Gemfile +17 -0
- data/LICENSE +52 -0
- data/README.md +40 -0
- data/Rakefile +60 -0
- data/app/assets/javascripts/workarea/storefront/swatches/modules/product_summary_swatches.js +63 -0
- data/app/assets/stylesheets/workarea/storefront/swatches/components/_option_button.scss +17 -0
- data/app/assets/stylesheets/workarea/storefront/swatches/components/_swatch_facet.scss +25 -0
- data/app/assets/stylesheets/workarea/storefront/swatches/components/_swatch_options.scss +54 -0
- data/app/controllers/workarea/admin/catalog_product_swatches_controller.rb +47 -0
- data/app/controllers/workarea/admin/catalog_swatches_controller.rb +48 -0
- data/app/controllers/workarea/storefront/products_controller.decorator +12 -0
- data/app/helpers/workarea/storefront/swatches_helper.rb +84 -0
- data/app/models/workarea/catalog/product.decorator +7 -0
- data/app/models/workarea/catalog/product_swatch.rb +10 -0
- data/app/models/workarea/catalog/swatch.rb +37 -0
- data/app/models/workarea/search/settings.decorator +8 -0
- data/app/queries/workarea/search/category_browse.decorator +7 -0
- data/app/queries/workarea/search/product_search.decorator +7 -0
- data/app/queries/workarea/search/swatched_facets.rb +19 -0
- data/app/queries/workarea/search/swatches_facet.rb +13 -0
- data/app/seeds/workarea/swatches_seeds.rb +37 -0
- data/app/view_models/workarea/storefront/product_templates/swatches_view_model.rb +57 -0
- data/app/views/workarea/admin/activities/_catalog_product_swatch_create.html.haml +10 -0
- data/app/views/workarea/admin/activities/_catalog_product_swatch_destroy.html.haml +10 -0
- data/app/views/workarea/admin/activities/_catalog_swatch_create.html.haml +12 -0
- data/app/views/workarea/admin/activities/_catalog_swatch_destroy.html.haml +10 -0
- data/app/views/workarea/admin/catalog_product_swatches/edit.html.haml +52 -0
- data/app/views/workarea/admin/catalog_product_swatches/index.html.haml +65 -0
- data/app/views/workarea/admin/catalog_products/_swatches_card.html.haml +27 -0
- data/app/views/workarea/admin/catalog_swatches/_primary_navigation.html.haml +1 -0
- data/app/views/workarea/admin/catalog_swatches/index.html.haml +78 -0
- data/app/views/workarea/api/storefront/facets/_swatches.json.jbuilder +17 -0
- data/app/views/workarea/storefront/facets/_swatches.html.haml +14 -0
- data/app/views/workarea/storefront/products/_swatch_summary.html.haml +17 -0
- data/app/views/workarea/storefront/products/templates/_swatches.html.haml +79 -0
- data/bin/rails +19 -0
- data/config/initializers/dragonfly.rb +11 -0
- data/config/initializers/workarea.rb +40 -0
- data/config/locales/en.yml +52 -0
- data/config/routes.rb +15 -0
- data/lib/tasks/swatches_tasks.rake +4 -0
- data/lib/workarea/swatches.rb +11 -0
- data/lib/workarea/swatches/engine.rb +12 -0
- data/lib/workarea/swatches/version.rb +5 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/config/manifest.js +4 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +30 -0
- data/test/dummy/bin/update +26 -0
- data/test/dummy/bin/yarn +11 -0
- data/test/dummy/config.ru +5 -0
- data/test/dummy/config/application.rb +30 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +10 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +51 -0
- data/test/dummy/config/environments/production.rb +88 -0
- data/test/dummy/config/environments/test.rb +44 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/test/dummy/config/initializers/assets.rb +14 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/workarea.rb +5 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
- data/test/dummy/config/locales/en.yml +33 -0
- data/test/dummy/config/puma.rb +56 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/config/secrets.yml +32 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/db/seeds.rb +2 -0
- data/test/dummy/log/.keep +0 -0
- data/test/factories/workarea/swatches.rb +14 -0
- data/test/integration/workarea/admin/product_swatches_integration_test.rb +43 -0
- data/test/integration/workarea/admin/swatches_integration_test.rb +37 -0
- data/test/integration/workarea/storefront/swatches_integration_test.rb +72 -0
- data/test/system/workarea/admin/swatches_system_test.rb +58 -0
- data/test/system/workarea/storefront/browse_swatches_system_test.rb +50 -0
- data/test/system/workarea/storefront/swatches_system_test.rb +101 -0
- data/test/teaspoon_env.rb +6 -0
- data/test/test_helper.rb +10 -0
- data/test/view_models/workarea/storefront/product_templates/swatches_view_model_test.rb +74 -0
- data/workarea-swatches.gemspec +19 -0
- metadata +147 -0
data/bin/rails
ADDED
@@ -0,0 +1,19 @@
|
|
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('../..', __FILE__)
|
6
|
+
ENGINE_PATH = File.expand_path('../../lib/workarea/swatches/engine', __FILE__)
|
7
|
+
APP_PATH = File.expand_path('../../test/dummy/config/application', __FILE__)
|
8
|
+
|
9
|
+
# Set up gems listed in the Gemfile.
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
11
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
12
|
+
|
13
|
+
require 'action_controller/railtie'
|
14
|
+
require 'action_view/railtie'
|
15
|
+
require 'action_mailer/railtie'
|
16
|
+
require 'rails/test_unit/railtie'
|
17
|
+
require 'sprockets/railtie'
|
18
|
+
require 'teaspoon-mocha'
|
19
|
+
require 'rails/engine/commands'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
processors = Dragonfly.app(:workarea).processors.names
|
2
|
+
|
3
|
+
Dragonfly.app(:workarea).configure do
|
4
|
+
unless processors.include?(:facet_swatch)
|
5
|
+
processor :facet_swatch do |content|
|
6
|
+
content.process!(:encode, :jpg, Workarea.config.jpg_encode_options)
|
7
|
+
content.process!(:thumb, '20x')
|
8
|
+
content.process!(:optim)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Workarea.configure do |config|
|
2
|
+
config.product_templates << :swatches
|
3
|
+
|
4
|
+
config.seeds.insert_after(
|
5
|
+
'Workarea::ProductsSeeds',
|
6
|
+
'Workarea::SwatchesSeeds'
|
7
|
+
)
|
8
|
+
|
9
|
+
# Determines which option is used for displaying swatches on
|
10
|
+
# browse pages. Return the option you would like to be used. We pass the
|
11
|
+
# product in case there are other factors to base sorting on.
|
12
|
+
config.browse_swatch_option = ->(product, options) { options.first }
|
13
|
+
end
|
14
|
+
|
15
|
+
Workarea.append_partials(
|
16
|
+
'admin.catalog_menu',
|
17
|
+
'workarea/admin/catalog_swatches/primary_navigation'
|
18
|
+
)
|
19
|
+
|
20
|
+
Workarea.append_partials(
|
21
|
+
'admin.catalog_product_cards',
|
22
|
+
'workarea/admin/catalog_products/swatches_card'
|
23
|
+
)
|
24
|
+
|
25
|
+
Workarea::Plugin.append_stylesheets(
|
26
|
+
'storefront.components',
|
27
|
+
'workarea/storefront/swatches/components/option_button',
|
28
|
+
'workarea/storefront/swatches/components/swatch_facet',
|
29
|
+
'workarea/storefront/swatches/components/swatch_options'
|
30
|
+
)
|
31
|
+
|
32
|
+
Workarea::Plugin.append_javascripts(
|
33
|
+
'storefront.modules',
|
34
|
+
'workarea/storefront/swatches/modules/product_summary_swatches'
|
35
|
+
)
|
36
|
+
|
37
|
+
Workarea.append_partials(
|
38
|
+
'storefront.product_summary',
|
39
|
+
'workarea/storefront/products/swatch_summary'
|
40
|
+
)
|
@@ -0,0 +1,52 @@
|
|
1
|
+
en:
|
2
|
+
workarea:
|
3
|
+
admin:
|
4
|
+
activities:
|
5
|
+
catalog_product_swatch_create_html: added a swatch to %{name}
|
6
|
+
catalog_product_swatch_destroy_html: removed a swatch from %{name}
|
7
|
+
catalog_category_create_html: created the %{name} swatch
|
8
|
+
catalog_category_destroy_html: removed the %{name} swatch
|
9
|
+
fields:
|
10
|
+
color: Color
|
11
|
+
catalog_product_swatches:
|
12
|
+
edit:
|
13
|
+
edit_swatch_for: Edit swatch for %{product}
|
14
|
+
edit_swatch: Edit Swatch
|
15
|
+
swatch: Swatch
|
16
|
+
without_options: Without options
|
17
|
+
flash_messages:
|
18
|
+
saved: Your swatch has been saved
|
19
|
+
removed: Your swatch has been removed
|
20
|
+
error: There was an error saving your changes
|
21
|
+
index:
|
22
|
+
add_new_swatch: Add New Swatch
|
23
|
+
create_swatch: Create Swatch
|
24
|
+
delete_confirmation: Are you sure you want to delete this swatch?
|
25
|
+
no_product_swatches: No product swatches
|
26
|
+
product_swatches: Product Swatches
|
27
|
+
swatch: Swatch
|
28
|
+
swatches_for: Swatches for %{product}
|
29
|
+
swatches: Swatches
|
30
|
+
without_options: Without options
|
31
|
+
catalog_products:
|
32
|
+
cards:
|
33
|
+
swatches:
|
34
|
+
add_swatches: Add Swatches
|
35
|
+
description: Override or add custom swatches for this product to show on the swatches detail page template.
|
36
|
+
manage_swatches: Manage Swatches
|
37
|
+
title: Swatches
|
38
|
+
catalog_swatches:
|
39
|
+
flash_messages:
|
40
|
+
saved: Your swatch has been saved
|
41
|
+
removed: Your swatch has been removed
|
42
|
+
error: There was an error saving your changes
|
43
|
+
index:
|
44
|
+
page_title: Swatches
|
45
|
+
description: Swatches are used by the swatches product template and can be setup as filters for categories and search.
|
46
|
+
no_swatches: No swatches setup yet, add one below!
|
47
|
+
add_new: Add New
|
48
|
+
manage_filters: Manage Filters
|
49
|
+
swatch_filters: Swatch Filters
|
50
|
+
swatch_facets_info: Filters in this list will will show their values with swatches when displayed on category browse pages and search results.
|
51
|
+
primary_navigation:
|
52
|
+
swatches: Swatches
|
data/config/routes.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Workarea::Admin::Engine.routes.draw do
|
2
|
+
resources :catalog_swatches, except: [:new, :show, :edit]
|
3
|
+
|
4
|
+
resources :catalog_products, only: [] do
|
5
|
+
resources :swatches,
|
6
|
+
except: [:new, :show, :edit],
|
7
|
+
controller: 'catalog_product_swatches'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
Workarea::Storefront::Engine.routes.draw do
|
12
|
+
resources :products, only: [] do
|
13
|
+
member { get 'summary' }
|
14
|
+
end
|
15
|
+
end
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|
data/test/dummy/bin/rake
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
# path to your application root.
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
8
|
+
|
9
|
+
def system!(*args)
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
11
|
+
end
|
12
|
+
|
13
|
+
chdir APP_ROOT do
|
14
|
+
# This script is a starting point to setup your application.
|
15
|
+
# Add necessary setup steps to this file.
|
16
|
+
|
17
|
+
puts '== Installing dependencies =='
|
18
|
+
system! 'gem install bundler --conservative'
|
19
|
+
system('bundle check') || system!('bundle install')
|
20
|
+
|
21
|
+
# Install JavaScript dependencies if using Yarn
|
22
|
+
# system('bin/yarn')
|
23
|
+
|
24
|
+
|
25
|
+
puts "\n== Removing old logs and tempfiles =="
|
26
|
+
system! 'bin/rails log:clear tmp:clear'
|
27
|
+
|
28
|
+
puts "\n== Restarting application server =="
|
29
|
+
system! 'bin/rails restart'
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pathname'
|
3
|
+
require 'fileutils'
|
4
|
+
include FileUtils
|
5
|
+
|
6
|
+
# path to your application root.
|
7
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
8
|
+
|
9
|
+
def system!(*args)
|
10
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
11
|
+
end
|
12
|
+
|
13
|
+
chdir APP_ROOT do
|
14
|
+
# This script is a way to update your development environment automatically.
|
15
|
+
# Add necessary update steps to this file.
|
16
|
+
|
17
|
+
puts '== Installing dependencies =='
|
18
|
+
system! 'gem install bundler --conservative'
|
19
|
+
system('bundle check') || system!('bundle install')
|
20
|
+
|
21
|
+
puts "\n== Removing old logs and tempfiles =="
|
22
|
+
system! 'bin/rails log:clear tmp:clear'
|
23
|
+
|
24
|
+
puts "\n== Restarting application server =="
|
25
|
+
system! 'bin/rails restart'
|
26
|
+
end
|
data/test/dummy/bin/yarn
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
VENDOR_PATH = File.expand_path('..', __dir__)
|
3
|
+
Dir.chdir(VENDOR_PATH) do
|
4
|
+
begin
|
5
|
+
exec "yarnpkg #{ARGV.join(" ")}"
|
6
|
+
rescue Errno::ENOENT
|
7
|
+
$stderr.puts 'Yarn executable was not detected in the system.'
|
8
|
+
$stderr.puts 'Download Yarn at https://yarnpkg.com/en/docs/install'
|
9
|
+
exit 1
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative 'boot'
|
2
|
+
|
3
|
+
# Pick the frameworks you want:
|
4
|
+
# require "active_record/railtie"
|
5
|
+
require 'action_controller/railtie'
|
6
|
+
require 'action_view/railtie'
|
7
|
+
require 'action_mailer/railtie'
|
8
|
+
require 'active_job/railtie'
|
9
|
+
require 'action_cable/engine'
|
10
|
+
require 'rails/test_unit/railtie'
|
11
|
+
require 'sprockets/railtie'
|
12
|
+
|
13
|
+
# Workarea must be required before other gems to ensure control over Rails.env
|
14
|
+
# for running tests
|
15
|
+
require 'workarea/core'
|
16
|
+
require 'workarea/admin'
|
17
|
+
require 'workarea/storefront'
|
18
|
+
Bundler.require(*Rails.groups)
|
19
|
+
require 'workarea/swatches'
|
20
|
+
|
21
|
+
module Dummy
|
22
|
+
class Application < Rails::Application
|
23
|
+
# Initialize configuration defaults for originally generated Rails version.
|
24
|
+
config.load_defaults 5.1
|
25
|
+
|
26
|
+
# Settings in config/environments/* take precedence over those specified here.
|
27
|
+
# Application configuration should go into files in config/initializers
|
28
|
+
# -- all .rb files in that directory are automatically loaded.
|
29
|
+
end
|
30
|
+
end
|