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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fdb74d4ec84b0983161d7e2da8a948c5e212880997231a38a5f366cf1cd069ba
|
4
|
+
data.tar.gz: 5ec7b24c2c7250c315b198821fe12461508729e1a49c2d93b132cf8cb81f44e7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3f253621d44e668356ff01e46e73ad8b3b47619b23edaf09859a462f26fbf3dbe5c9487079d9894da75ea755ff6de0ae67b4a3e720270b662b7998e0a0901326
|
7
|
+
data.tar.gz: 0d11620a5dd6310ddd61e0077da87c0da573e17216e17f192926d3f36d7c30461f58e23c6f6fe9dc615e7cfdb9b1fa0e5178b92f04b8782760c6c907ea69c12f
|
data/.editorconfig
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# editorconfig.org
|
2
|
+
root = true
|
3
|
+
|
4
|
+
[*]
|
5
|
+
charset = utf-8
|
6
|
+
indent_style = space
|
7
|
+
end_of_line = lf
|
8
|
+
trim_trailing_whitespace = true
|
9
|
+
insert_final_newline = true
|
10
|
+
|
11
|
+
[{*.rb,*.haml,*.decorator,*.yml,*.yaml,*.jbuilder}]
|
12
|
+
indent_size = 2
|
13
|
+
indent_style = space
|
14
|
+
|
15
|
+
[{*.js,*.jst,*.ejs,*.scss}]
|
16
|
+
indent_size = 4
|
17
|
+
|
18
|
+
[*.md]
|
19
|
+
indent_size = 4
|
20
|
+
trim_trailing_whitespace = false
|
@@ -0,0 +1,37 @@
|
|
1
|
+
---
|
2
|
+
name: Bug report
|
3
|
+
about: Create a report to help us improve Workarea
|
4
|
+
title: ''
|
5
|
+
labels: bug
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
⚠️**Before you create**⚠️
|
11
|
+
Please verify the issue you're experiencing is not part of your Workarea project customizations. The best way to do this is with a [vanilla Workarea installation](https://developer.workarea.com/articles/create-a-new-host-application.html). This will help us spend time on fixes/improvements for the whole community. Thank you!
|
12
|
+
|
13
|
+
**Describe the bug**
|
14
|
+
A clear and concise description of what the bug is.
|
15
|
+
|
16
|
+
**To Reproduce**
|
17
|
+
Steps to reproduce the behavior:
|
18
|
+
1. Go to '...'
|
19
|
+
2. Click on '....'
|
20
|
+
3. Scroll down to '....'
|
21
|
+
4. See error
|
22
|
+
|
23
|
+
**Expected behavior**
|
24
|
+
A clear and concise description of what you expected to happen.
|
25
|
+
|
26
|
+
**Workarea Setup (please complete the following information):**
|
27
|
+
- Workarea Version: [e.g. v3.4.6]
|
28
|
+
- Plugins [e.g. workarea-blog, workarea-sitemaps]
|
29
|
+
|
30
|
+
**Attachments**
|
31
|
+
If applicable, add any attachments to help explain your problem, things like:
|
32
|
+
- screenshots
|
33
|
+
- Gemfile.lock
|
34
|
+
- test cases
|
35
|
+
|
36
|
+
**Additional context**
|
37
|
+
Add any other context about the problem here.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
name: Documentation request
|
3
|
+
about: Suggest documentation
|
4
|
+
title: ''
|
5
|
+
labels: documentation
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**Is your documentation related to a problem? Please describe.**
|
11
|
+
A clear and concise description of what the problem is. Ex. I'm confused by [...]
|
12
|
+
|
13
|
+
**Describe the article you'd like**
|
14
|
+
A clear and concise description of what would be in the documentation article.
|
15
|
+
|
16
|
+
**Additional context**
|
17
|
+
Add any other context or screenshots about the feature request here.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
name: Feature request
|
3
|
+
about: Suggest an idea for Workarea
|
4
|
+
title: ''
|
5
|
+
labels: enhancement
|
6
|
+
assignees: ''
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
**Is your feature request related to a problem? Please describe.**
|
11
|
+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
12
|
+
|
13
|
+
**Describe the solution you'd like**
|
14
|
+
A clear and concise description of what you want to happen.
|
15
|
+
|
16
|
+
**Describe alternatives you've considered**
|
17
|
+
A clear and concise description of any alternative solutions or features you've considered.
|
18
|
+
|
19
|
+
**Additional context**
|
20
|
+
Add any other context or screenshots about the feature request here.
|
data/.gitignore
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
.bundle/
|
2
|
+
log/*.log
|
3
|
+
pkg/
|
4
|
+
.DS_Store
|
5
|
+
.byebug_history
|
6
|
+
.bundle/
|
7
|
+
.sass-cache/
|
8
|
+
Gemfile.lock
|
9
|
+
pkg/
|
10
|
+
log/*.log
|
11
|
+
test/dummy/lib
|
12
|
+
test/dummy/tmp
|
13
|
+
test/dummy/public
|
14
|
+
test/dummy/db/*.sqlite3
|
15
|
+
test/dummy/db/*.sqlite3-journal
|
16
|
+
test/dummy/log/*.log
|
17
|
+
test/dummy/tmp
|
18
|
+
node_modules
|
19
|
+
test/reports
|
20
|
+
package.json
|
21
|
+
yarn.lock
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
Workarea Swatches 1.0.5 (2019-08-21)
|
2
|
+
--------------------------------------------------------------------------------
|
3
|
+
|
4
|
+
* Open Source!
|
5
|
+
* Fix integration test against Workarea v3.4
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
Workarea Swatches 1.0.4 (2018-11-28)
|
10
|
+
--------------------------------------------------------------------------------
|
11
|
+
|
12
|
+
* Add pricing details append point to swatches product template
|
13
|
+
|
14
|
+
Adds pricing append point for PDP specfic content to appear under pricing
|
15
|
+
|
16
|
+
SWATCHES-18
|
17
|
+
Jeff Yucis
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
Workarea Swatches 1.0.3 (2018-10-30)
|
22
|
+
--------------------------------------------------------------------------------
|
23
|
+
|
24
|
+
* Correct BrowseSwatchesSystemTest class name to not conflic with other tests
|
25
|
+
|
26
|
+
SWATCHES-17
|
27
|
+
Matt Duffy
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
Workarea Swatches 1.0.2 (2018-07-24)
|
32
|
+
--------------------------------------------------------------------------------
|
33
|
+
|
34
|
+
* Add class to swatch link
|
35
|
+
|
36
|
+
Helps with theming
|
37
|
+
|
38
|
+
SWATCHES-9
|
39
|
+
Ben Crouse
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
Workarea Swatches 1.0.1 (2018-06-12)
|
44
|
+
--------------------------------------------------------------------------------
|
45
|
+
|
46
|
+
* Fix API support for swatches when browsing
|
47
|
+
|
48
|
+
API grumbles about a missing partial otherwise.
|
49
|
+
Ben Crouse
|
50
|
+
|
51
|
+
* Fix images with blank options
|
52
|
+
|
53
|
+
This caused a bug with the demo data plugin.
|
54
|
+
Ben Crouse
|
55
|
+
|
56
|
+
* Remove ID attribute on swatch selectors
|
57
|
+
|
58
|
+
This caused a duplicate ID error when a packaged product includes a
|
59
|
+
swatches product in the package. Explicitly setting the ID to `nil` for
|
60
|
+
this element gets rid of the error.
|
61
|
+
|
62
|
+
SWATCHES-13
|
63
|
+
Tom Scott
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
Workarea Swatches 1.0.0 (2018-05-24)
|
68
|
+
--------------------------------------------------------------------------------
|
69
|
+
|
70
|
+
* Add guard clause to prevent errors when no swatches are present
|
71
|
+
|
72
|
+
SWATCHES-10
|
73
|
+
Jake Beresford
|
74
|
+
|
75
|
+
* Add classes to result filters
|
76
|
+
|
77
|
+
ECOMMERCE-5830
|
78
|
+
Curt Howard
|
79
|
+
|
80
|
+
* Show swatches on category browse pages
|
81
|
+
|
82
|
+
SWATCHES-2
|
83
|
+
Matt Duffy
|
84
|
+
|
85
|
+
* Leverage Workarea Changelog task
|
86
|
+
|
87
|
+
ECOMMERCE-5355
|
88
|
+
Curt Howard
|
89
|
+
|
90
|
+
* Simplify swatch facet component
|
91
|
+
|
92
|
+
SWATCHES-1
|
93
|
+
Curt Howard
|
94
|
+
|
95
|
+
* Include empty swatch state
|
96
|
+
|
97
|
+
SWATCHES-1
|
98
|
+
Curt Howard
|
99
|
+
|
100
|
+
* Add per-product swatch overriding
|
101
|
+
|
102
|
+
Ben Crouse
|
103
|
+
|
104
|
+
* Add filters
|
105
|
+
|
106
|
+
Ben Crouse
|
107
|
+
|
108
|
+
* Add filters
|
109
|
+
|
110
|
+
Ben Crouse
|
111
|
+
|
112
|
+
* Add seeds
|
113
|
+
|
114
|
+
Ben Crouse
|
115
|
+
|
116
|
+
* Add swatches product template
|
117
|
+
|
118
|
+
Ben Crouse
|
119
|
+
|
120
|
+
|
121
|
+
|
data/CODE_OF_CONDUCT.md
ADDED
data/CONTRIBUTING.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
git_source(:github) { |repo| "git@github.com:#{repo}.git" }
|
3
|
+
|
4
|
+
# Declare your gem's dependencies in swatches.gemspec.
|
5
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
6
|
+
# development dependencies will be added by default to the :development group.
|
7
|
+
gemspec
|
8
|
+
|
9
|
+
# Declare any dependencies that are still in development here instead of in
|
10
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
11
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
12
|
+
# your gem to rubygems.org.
|
13
|
+
|
14
|
+
# To use a debugger
|
15
|
+
# gem 'byebug', group: [:development, :test]
|
16
|
+
|
17
|
+
gem 'workarea', github: 'workarea-commerce/workarea'
|
data/LICENSE
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
WebLinc
|
2
|
+
Business Source License
|
3
|
+
|
4
|
+
Licensor: WebLinc Corporation, 22 S. 3rd Street, 2nd Floor, Philadelphia PA 19106
|
5
|
+
|
6
|
+
Licensed Work: Workarea Commerce Platform
|
7
|
+
The Licensed Work is (c) 2019 WebLinc Corporation
|
8
|
+
|
9
|
+
Additional Use Grant:
|
10
|
+
You may make production use of the Licensed Work without an additional license agreement with WebLinc so long as you do not use the Licensed Work for a Commerce Service.
|
11
|
+
|
12
|
+
A "Commerce Service" is a commercial offering that allows third parties (other than your employees and contractors) to access the functionality of the Licensed Work by creating or managing commerce functionality, the products, taxonomy, assets and/or content of which are controlled by such third parties.
|
13
|
+
|
14
|
+
For information about obtaining an additional license agreement with WebLinc, contact licensing@workarea.com.
|
15
|
+
|
16
|
+
Change Date: 2019-08-20
|
17
|
+
|
18
|
+
Change License: Version 2.0 or later of the GNU General Public License as published by the Free Software Foundation
|
19
|
+
|
20
|
+
Terms
|
21
|
+
|
22
|
+
The Licensor hereby grants you the right to copy, modify, create derivative works, redistribute, and make non-production use of the Licensed Work. The Licensor may make an Additional Use Grant, above, permitting limited production use.
|
23
|
+
|
24
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly available distribution of a specific version of the Licensed Work under this License, whichever comes first, the Licensor hereby grants you rights under the terms of the Change License, and the rights granted in the paragraph above terminate.
|
25
|
+
|
26
|
+
If your use of the Licensed Work does not comply with the requirements currently in effect as described in this License, you must purchase a commercial license from the Licensor, its affiliated entities, or authorized resellers, or you must refrain from using the Licensed Work.
|
27
|
+
|
28
|
+
All copies of the original and modified Licensed Work, and derivative works of the Licensed Work, are subject to this License. This License applies separately for each version of the Licensed Work and the Change Date may vary for each version of the Licensed Work released by Licensor.
|
29
|
+
|
30
|
+
You must conspicuously display this License on each original or modified copy of the Licensed Work. If you receive the Licensed Work in original or modified form from a third party, the terms and conditions set forth in this License apply to your use of that work.
|
31
|
+
|
32
|
+
Any use of the Licensed Work in violation of this License will automatically terminate your rights under this License for the current and all other versions of the Licensed Work.
|
33
|
+
|
34
|
+
This License does not grant you any right in any trademark or logo of Licensor or its affiliates (provided that you may use a trademark or logo of Licensor as expressly required by this License). TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND TITLE. MariaDB hereby grants you permission to use this License’s text to license your works and to refer to it using the trademark "Business Source License" as long as you comply with the Covenants of Licensor below.
|
35
|
+
|
36
|
+
Covenants of Licensor
|
37
|
+
In consideration of the right to use this License’s text and the "Business Source License" name and trademark, Licensor covenants to MariaDB, and to all other recipients of the licensed work to be provided by Licensor:
|
38
|
+
|
39
|
+
To specify as the Change License the GPL Version 2.0 or any later version, or a license that is compatible with GPL Version 2.0 or a later version, where "compatible" means that software provided under the Change License can be included in a program with software provided under GPL Version 2.0 or a later version. Licensor may specify additional Change Licenses without limitation.
|
40
|
+
|
41
|
+
To either: (a) specify an additional grant of rights to use that does not impose any additional restriction on the right granted in this License, as the Additional Use Grant; or (b) insert the text "None."
|
42
|
+
|
43
|
+
To specify a Change Date.
|
44
|
+
|
45
|
+
Not to modify this License in any other way.
|
46
|
+
|
47
|
+
Notice
|
48
|
+
The Business Source License (this document, or the "License") is not an Open Source license. However, the Licensed Work will eventually be made available under an Open Source License, as stated in this License.
|
49
|
+
|
50
|
+
For more information on the use of the Business Source License generally, please visit the Adopting and Developing Business Source License FAQ.
|
51
|
+
|
52
|
+
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved. "Business Source License" is a trademark of MariaDB Corporation Ab.
|
data/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
Workarea Swatches
|
2
|
+
================================================================================
|
3
|
+
|
4
|
+
A Workarea Commerce plugin that provides swatching for product details.
|
5
|
+
|
6
|
+
Overview
|
7
|
+
--------------------------------------------------------------------------------
|
8
|
+
|
9
|
+
* Adds an administrable list of global swatches
|
10
|
+
* Allows custom swatch definition on the product level that falls back to global swatches
|
11
|
+
* Adds the `swatches` product template that builds off Workarea's `option_thumbnails` template to display swatches for each product option.
|
12
|
+
* Adds support for swatches in search facets.
|
13
|
+
|
14
|
+
Getting Started
|
15
|
+
--------------------------------------------------------------------------------
|
16
|
+
|
17
|
+
Add the gem to your application's Gemfile:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
# ...
|
21
|
+
gem 'workarea-swatches'
|
22
|
+
# ...
|
23
|
+
```
|
24
|
+
|
25
|
+
Update your application's bundle.
|
26
|
+
|
27
|
+
```bash
|
28
|
+
cd path/to/application
|
29
|
+
bundle
|
30
|
+
```
|
31
|
+
|
32
|
+
Workarea Commerce Documentation
|
33
|
+
--------------------------------------------------------------------------------
|
34
|
+
|
35
|
+
See [https://developer.workarea.com](https://developer.workarea.com) for Workarea Commerce documentation.
|
36
|
+
|
37
|
+
License
|
38
|
+
--------------------------------------------------------------------------------
|
39
|
+
|
40
|
+
Workarea Swatches is released under the [Business Software License](LICENSE)
|
data/Rakefile
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
9
|
+
rdoc.rdoc_dir = 'rdoc'
|
10
|
+
rdoc.title = 'Swatches'
|
11
|
+
rdoc.options << '--line-numbers'
|
12
|
+
rdoc.rdoc_files.include('README.md')
|
13
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
14
|
+
end
|
15
|
+
|
16
|
+
APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
|
17
|
+
load 'rails/tasks/engine.rake'
|
18
|
+
load 'rails/tasks/statistics.rake'
|
19
|
+
load 'workarea/changelog.rake'
|
20
|
+
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new(:test) do |t|
|
23
|
+
t.libs << 'lib'
|
24
|
+
t.libs << 'test'
|
25
|
+
t.pattern = 'test/**/*_test.rb'
|
26
|
+
t.verbose = false
|
27
|
+
end
|
28
|
+
task default: :test
|
29
|
+
|
30
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
31
|
+
require 'workarea/swatches/version'
|
32
|
+
|
33
|
+
desc "Release version #{Workarea::Swatches::VERSION} of the gem"
|
34
|
+
task :release do
|
35
|
+
host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
|
36
|
+
|
37
|
+
#Rake::Task['workarea:changelog'].execute
|
38
|
+
#system 'git add CHANGELOG.md'
|
39
|
+
#system 'git commit -m "Update CHANGELOG"'
|
40
|
+
#system 'git push origin HEAD'
|
41
|
+
|
42
|
+
system "git tag -a v#{Workarea::Swatches::VERSION} -m 'Tagging #{Workarea::Swatches::VERSION}'"
|
43
|
+
system 'git push --tags'
|
44
|
+
|
45
|
+
system 'gem build workarea-swatches.gemspec'
|
46
|
+
system "gem push workarea-swatches-#{Workarea::Swatches::VERSION}.gem"
|
47
|
+
system "gem push workarea-swatches-#{Workarea::Swatches::VERSION}.gem --host #{host}"
|
48
|
+
system "rm workarea-swatches-#{Workarea::Swatches::VERSION}.gem"
|
49
|
+
end
|
50
|
+
|
51
|
+
desc 'Run the JavaScript tests'
|
52
|
+
ENV['TEASPOON_RAILS_ENV'] = File.expand_path('../test/dummy/config/environment', __FILE__)
|
53
|
+
task teaspoon: 'app:teaspoon'
|
54
|
+
|
55
|
+
desc 'Start a server at http://localhost:3000/teaspoon for JavaScript tests'
|
56
|
+
task :teaspoon_server do
|
57
|
+
Dir.chdir('test/dummy')
|
58
|
+
teaspoon_env = File.expand_path('../test/teaspoon_env.rb', __FILE__)
|
59
|
+
system "RAILS_ENV=test TEASPOON_ENV=#{teaspoon_env} rails s"
|
60
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
/**
|
2
|
+
* @namespace WORKAREA.productSummarySwatches
|
3
|
+
*/
|
4
|
+
WORKAREA.registerModule('productSummarySwatches', (function () {
|
5
|
+
'use strict';
|
6
|
+
|
7
|
+
var replaceProductSummary = function ($productSummary, newSummary) {
|
8
|
+
var $newSummary = $(newSummary);
|
9
|
+
|
10
|
+
WORKAREA.initModules($newSummary);
|
11
|
+
|
12
|
+
$productSummary.empty().append($newSummary);
|
13
|
+
},
|
14
|
+
|
15
|
+
loadImage = function ($productSummary, newSummary) {
|
16
|
+
var imageSrc = $('.product-summary__media-image', newSummary)[0].src,
|
17
|
+
gettingImage = WORKAREA.image.get(imageSrc);
|
18
|
+
|
19
|
+
WORKAREA.loading.createLoadingIndicator(gettingImage, {
|
20
|
+
container: $productSummary,
|
21
|
+
cssModifiers: 'loading--fill-parent',
|
22
|
+
delay: 0
|
23
|
+
});
|
24
|
+
|
25
|
+
gettingImage.always(_.partial(replaceProductSummary, $productSummary, newSummary));
|
26
|
+
},
|
27
|
+
|
28
|
+
fallbackToUrl = function ($button) {
|
29
|
+
window.location = $button.attr('href');
|
30
|
+
},
|
31
|
+
|
32
|
+
buttonIsSelected = function ($button) {
|
33
|
+
return $button.hasClass('swatch-options__swatch-button--selected');
|
34
|
+
},
|
35
|
+
|
36
|
+
handleSwatchButtonClick = function (event) {
|
37
|
+
var $button = $(event.currentTarget),
|
38
|
+
$productSummary = $button.closest('.product-summary'),
|
39
|
+
endpoint = $button.data('productSummarySwatch').url;
|
40
|
+
|
41
|
+
event.preventDefault();
|
42
|
+
|
43
|
+
if (buttonIsSelected($button)) { return; }
|
44
|
+
|
45
|
+
$.get(endpoint)
|
46
|
+
.done(_.partial(loadImage, $productSummary))
|
47
|
+
.fail(_.partial(fallbackToUrl, $button));
|
48
|
+
},
|
49
|
+
|
50
|
+
/**
|
51
|
+
* @method
|
52
|
+
* @name init
|
53
|
+
* @memberof WORKAREA.productSummarySwatches
|
54
|
+
*/
|
55
|
+
init = function ($scope) {
|
56
|
+
$('[data-product-summary-swatch]', $scope)
|
57
|
+
.on('click', handleSwatchButtonClick);
|
58
|
+
};
|
59
|
+
|
60
|
+
return {
|
61
|
+
init: init
|
62
|
+
};
|
63
|
+
}()));
|