workarea-reviews 3.1.0
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/.eslintignore +2 -0
- data/.eslintrc +24 -0
- data/.eslintrc.json +35 -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/.github/workflows/ci.yml +60 -0
- data/.gitignore +15 -0
- data/.rubocop.yml +3 -0
- data/.scss-lint.yml +188 -0
- data/.stylelintrc.json +8 -0
- data/.yardopts +1 -0
- data/CHANGELOG.md +745 -0
- data/CODE_OF_CONDUCT.md +3 -0
- data/CONTRIBUTING.md +3 -0
- data/Gemfile +8 -0
- data/LICENSE +52 -0
- data/README.md +107 -0
- data/Rakefile +53 -0
- data/app/assets/images/workarea/admin/icons/star.svg +1 -0
- data/app/assets/images/workarea/storefront/icons/empty_star.svg +1 -0
- data/app/assets/images/workarea/storefront/icons/half_star.svg +1 -0
- data/app/assets/images/workarea/storefront/icons/star.svg +1 -0
- data/app/assets/javascripts/workarea/storefront/reviews/modules/product_review_ajax_submit.js +39 -0
- data/app/assets/javascripts/workarea/storefront/reviews/modules/product_reviews_sort_menus.js +82 -0
- data/app/assets/javascripts/workarea/storefront/reviews/modules/rating_buttons.js +103 -0
- data/app/assets/javascripts/workarea/storefront/reviews/templates/sort_by_property.jst.ejs +11 -0
- data/app/assets/stylesheets/workarea/storefront/reviews/components/_rating.scss +28 -0
- data/app/assets/stylesheets/workarea/storefront/reviews/components/_reviews.scss +59 -0
- data/app/assets/stylesheets/workarea/storefront/reviews/components/_reviews_aggregate.scss +38 -0
- data/app/assets/stylesheets/workarea/storefront/reviews/components/_write_review.scss +63 -0
- data/app/controllers/workarea/admin/catalog_products_controller.decorator +9 -0
- data/app/controllers/workarea/admin/reports_controller.decorator +10 -0
- data/app/controllers/workarea/admin/reviews_controller.rb +51 -0
- data/app/controllers/workarea/storefront/review_requests_controller.rb +50 -0
- data/app/controllers/workarea/storefront/reviews_controller.rb +53 -0
- data/app/helpers/workarea/admin/reviews_helper.rb +13 -0
- data/app/helpers/workarea/storefront/reviews_helper.rb +22 -0
- data/app/helpers/workarea/storefront/reviews_schema_org_helper.rb +34 -0
- data/app/mailers/workarea/admin/status_report_mailer.decorator +8 -0
- data/app/mailers/workarea/storefront/review_mailer.rb +23 -0
- data/app/models/workarea/catalog/product.decorator +15 -0
- data/app/models/workarea/fulfillment.decorator +11 -0
- data/app/models/workarea/insights/most_active_reviewers.rb +34 -0
- data/app/models/workarea/insights/most_reviewed_products.rb +33 -0
- data/app/models/workarea/insights/top_rated_products.rb +33 -0
- data/app/models/workarea/review.rb +124 -0
- data/app/models/workarea/review/request.rb +62 -0
- data/app/models/workarea/search/admin/review.rb +72 -0
- data/app/models/workarea/search/storefront/product.decorator +9 -0
- data/app/models/workarea/sort.decorator +17 -0
- data/app/queries/workarea/reports/reviews_by_product.rb +86 -0
- data/app/queries/workarea/reports/reviews_by_user.rb +71 -0
- data/app/queries/workarea/review_request_params.rb +47 -0
- data/app/queries/workarea/review_summary.rb +11 -0
- data/app/queries/workarea/search/admin_reviews.rb +40 -0
- data/app/queries/workarea/search/category_browse.decorator +9 -0
- data/app/queries/workarea/search/product_search.decorator +9 -0
- data/app/seeds/workarea/review_seeds.rb +49 -0
- data/app/services/workarea/create_review.rb +99 -0
- data/app/view_models/workarea/admin/dashboards/reports_view_model.decorator +11 -0
- data/app/view_models/workarea/admin/product_view_model.decorator +7 -0
- data/app/view_models/workarea/admin/reports/reviews_by_product_view_model.rb +27 -0
- data/app/view_models/workarea/admin/review_view_model.rb +23 -0
- data/app/view_models/workarea/admin/reviews_search_view_model.rb +46 -0
- data/app/view_models/workarea/storefront/product_view_model.decorator +13 -0
- data/app/view_models/workarea/storefront/review_view_model.rb +14 -0
- data/app/views/workarea/admin/activities/_review_create.html.haml +12 -0
- data/app/views/workarea/admin/activities/_review_destroy.html.haml +10 -0
- data/app/views/workarea/admin/activities/_review_update.html.haml +10 -0
- data/app/views/workarea/admin/dashboards/_reviews_by_product_card.html.haml +17 -0
- data/app/views/workarea/admin/insights/_most_active_reviewers.html.haml +22 -0
- data/app/views/workarea/admin/insights/_most_reviewed_products.html.haml +22 -0
- data/app/views/workarea/admin/insights/_top_rated_products.html.haml +22 -0
- data/app/views/workarea/admin/reports/reviews_by_product.html.haml +44 -0
- data/app/views/workarea/admin/reviews/_aux_navigation.html.haml +5 -0
- data/app/views/workarea/admin/reviews/_catalog_products_aux_link.html.haml +5 -0
- data/app/views/workarea/admin/reviews/_dashboard_navigation.html.haml +1 -0
- data/app/views/workarea/admin/reviews/_menu.html.haml +3 -0
- data/app/views/workarea/admin/reviews/_summary.html.haml +12 -0
- data/app/views/workarea/admin/reviews/edit.html.haml +77 -0
- data/app/views/workarea/admin/reviews/index.html.haml +74 -0
- data/app/views/workarea/admin/status_report_mailer/_reviews.html.haml +5 -0
- data/app/views/workarea/storefront/products/_rating.html.haml +9 -0
- data/app/views/workarea/storefront/products/_reviews.html.haml +23 -0
- data/app/views/workarea/storefront/products/_reviews_aggregate.html.haml +22 -0
- data/app/views/workarea/storefront/products/_reviews_summary.html.haml +2 -0
- data/app/views/workarea/storefront/review_mailer/review_request.html.haml +24 -0
- data/app/views/workarea/storefront/review_requests/show.html.haml +45 -0
- data/app/views/workarea/storefront/reviews/new.html.haml +68 -0
- data/app/views/workarea/storefront/style_guides/_reviews_product_summary_docs.html.haml +13 -0
- data/app/views/workarea/storefront/style_guides/components/_reviews.html.haml +17 -0
- data/app/workers/workarea/create_review_requests.rb +33 -0
- data/app/workers/workarea/schedule_review_requests.rb +44 -0
- data/app/workers/workarea/send_review_requests.rb +12 -0
- data/app/workers/workarea/update_product_review_data.rb +26 -0
- data/bin/rails +18 -0
- data/config/initializers/append_points.rb +75 -0
- data/config/initializers/assets.rb +1 -0
- data/config/initializers/configuration.rb +31 -0
- data/config/initializers/rack_attack.rb +11 -0
- data/config/initializers/recaptcha.rb +19 -0
- data/config/initializers/scheduled_jobs.rb +8 -0
- data/config/locales/en.yml +150 -0
- data/config/routes.rb +25 -0
- data/lib/tasks/verify.rake +16 -0
- data/lib/workarea/mailer_previews/storefront/review_mailer_preview.rb +10 -0
- data/lib/workarea/reviews.rb +13 -0
- data/lib/workarea/reviews/engine.rb +16 -0
- data/lib/workarea/reviews/version.rb +5 -0
- data/package.json +9 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/config/manifest.js +4 -0
- data/test/dummy/app/assets/images/.keep +0 -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/controllers/concerns/.keep +0 -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/models/concerns/.keep +0 -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 +34 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/config.ru +5 -0
- data/test/dummy/config/application.rb +25 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +9 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +55 -0
- data/test/dummy/config/environments/production.rb +86 -0
- data/test/dummy/config/environments/test.rb +43 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +11 -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/new_framework_defaults.rb +21 -0
- data/test/dummy/config/initializers/session_store.rb +5 -0
- data/test/dummy/config/initializers/workarea.rb +5 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/puma.rb +47 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/db/seeds.rb +2 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/factories/reviews.rb +32 -0
- data/test/fixtures/reviews.csv +5 -0
- data/test/helpers/workarea/storefront/reviews_helper_test.rb +20 -0
- data/test/integration/workarea/admin/reviews_integration_test.rb +37 -0
- data/test/integration/workarea/storefront/review_requests_integration_test.rb +63 -0
- data/test/integration/workarea/storefront/reviews_integration_test.rb +82 -0
- data/test/javascripts/fixtures/product_review_ajax_submit.html.haml +4 -0
- data/test/javascripts/product_review_ajax_submit_spec.js +28 -0
- data/test/javascripts/spec_helper.js +23 -0
- data/test/models/workarea/insights/most_active_reviewers_test.rb +32 -0
- data/test/models/workarea/insights/most_reviewed_products_test.rb +32 -0
- data/test/models/workarea/insights/top_rated_products_test.rb +49 -0
- data/test/models/workarea/review/request_test.rb +18 -0
- data/test/models/workarea/review_test.rb +105 -0
- data/test/models/workarea/search/storefront/product_test.decorator +14 -0
- data/test/queries/workarea/reports/reviews_by_product_test.rb +104 -0
- data/test/queries/workarea/reports/reviews_by_user_test.rb +102 -0
- data/test/queries/workarea/review_request_params_test.rb +64 -0
- data/test/services/workarea/create_review_test.rb +131 -0
- data/test/system/workarea/admin/review_system_test.rb +96 -0
- data/test/system/workarea/admin/reviews_by_product_system_test.rb +60 -0
- data/test/system/workarea/storefront/review_request_system_test.rb +34 -0
- data/test/system/workarea/storefront/review_system_test.rb +113 -0
- data/test/teaspoon_env.rb +10 -0
- data/test/test_helper.rb +11 -0
- data/test/workers/workarea/create_review_requests_test.rb +38 -0
- data/test/workers/workarea/schedule_review_requests_test.rb +115 -0
- data/test/workers/workarea/send_review_requests_test.rb +30 -0
- data/workarea-reviews.gemspec +22 -0
- data/yarn.lock +3265 -0
- metadata +265 -0
data/CODE_OF_CONDUCT.md
ADDED
data/CONTRIBUTING.md
ADDED
data/Gemfile
ADDED
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,107 @@
|
|
1
|
+
Workarea Reviews
|
2
|
+
================================================================================
|
3
|
+
|
4
|
+
A Workarea Commerce plugin that enables product reviews.
|
5
|
+
|
6
|
+
|
7
|
+
Overview
|
8
|
+
--------------------------------------------------------------------------------
|
9
|
+
|
10
|
+
* Consumers can write product reviews in the Storefront
|
11
|
+
* Admins can edit those reviews in the Admin, which includes approving them
|
12
|
+
* Approved reviews are reflected in product summaries and displayed on product detail pages
|
13
|
+
* Consumers can sort products by rating in the Storefront
|
14
|
+
* Admins can list, show, edit, and delete reviews in the Admin
|
15
|
+
* Admins can view and navigate to a product's reviews when administrating a product in the Admin
|
16
|
+
* The Admin daily status report email includes a summary of reviews
|
17
|
+
* The system emails consumers who place orders to request they write reviews
|
18
|
+
* Developers can seed reviews for all products
|
19
|
+
* Developers can preview review-related emails
|
20
|
+
* Admins can view a reviews by product report
|
21
|
+
* The system generates top rated and most reviewed product insights
|
22
|
+
* The system generates most active reviewers insight
|
23
|
+
|
24
|
+
Getting Started
|
25
|
+
--------------------------------------------------------------------------------
|
26
|
+
|
27
|
+
Add the gem to your application's Gemfile:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
# ...
|
31
|
+
gem 'workarea-reviews'
|
32
|
+
# ...
|
33
|
+
```
|
34
|
+
|
35
|
+
Update your application's bundle.
|
36
|
+
|
37
|
+
```bash
|
38
|
+
cd path/to/application
|
39
|
+
bundle
|
40
|
+
```
|
41
|
+
|
42
|
+
Features
|
43
|
+
--------------------------------------------------------------------------------
|
44
|
+
|
45
|
+
|
46
|
+
### Writing Reviews
|
47
|
+
|
48
|
+
* Reviews are written in the Storefront; users may be logged in or anonymous (requires reCAPTCHA)
|
49
|
+
* Developers can set `Workarea.config.require_purchase_to_write_review` to `true` to require the reviewer to have a `total_spent` greater than zero for the review to be valid
|
50
|
+
* The "write review" form is presented as a dialog, which closes after the review is submitted
|
51
|
+
* The reviewer uses a rating star UI (with underlying values of 1 through 5) to select a rating
|
52
|
+
* The reviewer may also provide a title and body, along with their first name, last name, and email
|
53
|
+
* The reviewer receives an email to confirm the review was submitted and is awaiting admin approval
|
54
|
+
|
55
|
+
|
56
|
+
### Displaying Reviews
|
57
|
+
|
58
|
+
* In the Storefront, reviews are presented without pagination
|
59
|
+
* Reviews can be sorted, which is handled client-side (values are oldest, newest, and highest)
|
60
|
+
* Each review may include a title, a body, and the following metadata: author, date, verified
|
61
|
+
* A review is considered verified if the reviewer was logged in and has the ID of the reviewed product in their order history
|
62
|
+
|
63
|
+
|
64
|
+
### Administrating Reviews
|
65
|
+
|
66
|
+
* Admins with marketing permission may access the reviews admin
|
67
|
+
* The reviews admin is accessible from the Marketing section of the primary navigation and from the Marketing dashboard
|
68
|
+
* Admins can also jump to the reviews admin by searching for "Product Reviews"
|
69
|
+
* Products and reviews are cross referenced within the auxillary navigation of each
|
70
|
+
* Admins can list, show, edit, and delete reviews, which includes approving them (Admins can edit a review before approving)
|
71
|
+
|
72
|
+
|
73
|
+
### Requesting Reviews
|
74
|
+
|
75
|
+
* For each order, the system will send up to _n_ review requests (Workarea.config.review_requests_per_order)
|
76
|
+
* Each request is for a different order item (selected by most expensive)
|
77
|
+
* Each request expires after a configurable duration (Workarea.config.review_request_ttl)
|
78
|
+
* The first request is sent after a configurable duration has passed (Workarea.config.review_request_initial_delivery_delay)
|
79
|
+
* Each consecutive request is sent at a configurable duration (Workarea.config.review_request_secondary_delivery_delay)
|
80
|
+
|
81
|
+
reCAPTCHA Configuration
|
82
|
+
--------------------------------------------------------------------------------
|
83
|
+
|
84
|
+
Workarea Reviews utilizes [reCAPTCHA](https://github.com/ambethia/recaptcha) in the review form to prevent abuse. You'll need to configure each environment's secrets file to provide recaptcha keys. For testing and development, the plugin will use the [google provided](https://developers.google.com/recaptcha/docs/faq) testing keys if none are specified in your secrets.
|
85
|
+
|
86
|
+
```yaml
|
87
|
+
production:
|
88
|
+
recaptcha:
|
89
|
+
site_key: YOUR_SITE_KEY
|
90
|
+
secret_key: YOUR_SECRET_KEY
|
91
|
+
```
|
92
|
+
|
93
|
+
reCAPTCHA sends its HTTP requests through the proxy automatically if the
|
94
|
+
`$HTTP_PROXY` environment variable is set. This is set for you in hosted
|
95
|
+
environments.
|
96
|
+
|
97
|
+
[Obtain your keys from the reCAPTCHA site](https://www.google.com/recaptcha/admin)
|
98
|
+
|
99
|
+
Workarea Commerce Documentation
|
100
|
+
--------------------------------------------------------------------------------
|
101
|
+
|
102
|
+
See [https://developer.workarea.com](https://developer.workarea.com) for Workarea Commerce documentation.
|
103
|
+
|
104
|
+
License
|
105
|
+
--------------------------------------------------------------------------------
|
106
|
+
|
107
|
+
Workarea Reviews is released under the [Business Software License](LICENSE)
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
|
8
|
+
APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
|
9
|
+
load 'rails/tasks/engine.rake'
|
10
|
+
load 'rails/tasks/statistics.rake'
|
11
|
+
load 'workarea/changelog.rake'
|
12
|
+
|
13
|
+
require 'rake/testtask'
|
14
|
+
|
15
|
+
Rake::TestTask.new(:test) do |t|
|
16
|
+
t.libs << 'lib'
|
17
|
+
t.libs << 'test'
|
18
|
+
t.pattern = 'test/**/*_test.rb'
|
19
|
+
t.verbose = false
|
20
|
+
end
|
21
|
+
|
22
|
+
task default: :test
|
23
|
+
|
24
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
25
|
+
require 'workarea/reviews/version'
|
26
|
+
|
27
|
+
desc "Release version #{Workarea::Reviews::VERSION} of the gem"
|
28
|
+
task :release do
|
29
|
+
host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
|
30
|
+
|
31
|
+
Rake::Task['workarea:changelog'].execute
|
32
|
+
system 'git add CHANGELOG.md'
|
33
|
+
system 'git commit -m "Update CHANGELOG"'
|
34
|
+
system 'git push origin HEAD'
|
35
|
+
|
36
|
+
system "git tag -a v#{Workarea::Reviews::VERSION} -m 'Tagging #{Workarea::Reviews::VERSION}'"
|
37
|
+
system 'git push --tags'
|
38
|
+
|
39
|
+
system 'gem build workarea-reviews.gemspec'
|
40
|
+
system "gem push workarea-reviews-#{Workarea::Reviews::VERSION}.gem --host #{host}"
|
41
|
+
system "rm workarea-reviews-#{Workarea::Reviews::VERSION}.gem"
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'Run the JavaScript tests'
|
45
|
+
ENV['TEASPOON_RAILS_ENV'] = File.expand_path('../test/dummy/config/environment', __FILE__)
|
46
|
+
task teaspoon: 'app:teaspoon'
|
47
|
+
|
48
|
+
desc 'Start a server at http://localhost:3000/teaspoon for JavaScript tests'
|
49
|
+
task :teaspoon_server do
|
50
|
+
Dir.chdir('test/dummy')
|
51
|
+
teaspoon_env = File.expand_path('../test/teaspoon_env.rb', __FILE__)
|
52
|
+
system "RAILS_ENV=test TEASPOON_ENV=#{teaspoon_env} rails s"
|
53
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>star</title><path d="M12 19.41l-7.33 3.84 1.43-8.13L.17 9.36l8.18-1.2L12 .75l3.65 7.41 8.19 1.2-5.94 5.76 1.42 8.13L12 19.41z"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>empty_star</title><path d="M12 3l2.75 5.6.23.47.52.08 6.18.91-4.48 4.34-.38.37.09.52L18 21.42l-5.52-2.9-.48-.24-.46.24L6 21.42l1.08-6.13.09-.52-.37-.37-4.48-4.34 6.18-.91.5-.08.23-.47L12 3m0-2.25L8.35 8.16.17 9.36l5.93 5.76-1.43 8.13L12 19.41l7.32 3.84-1.42-8.13 5.94-5.76-8.19-1.2L12 .75z"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>half_star</title><path d="M12 19.41V.75L8.35 8.16.17 9.36l5.93 5.76-1.43 8.13L12 19.41z"/><path d="M12 3l2.75 5.6.23.47.52.08 6.18.91-4.48 4.34-.38.37.09.52L18 21.42l-5.52-2.9-.48-.24-.46.24L6 21.42l1.08-6.13.09-.52-.37-.37-4.48-4.34 6.18-.91.5-.08.23-.47L12 3m0-2.25L8.35 8.16.17 9.36l5.93 5.76-1.43 8.13L12 19.41l7.32 3.84-1.42-8.13 5.94-5.76-8.19-1.2L12 .75z"/></svg>
|
@@ -0,0 +1 @@
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>star</title><path d="M12 19.41l-7.33 3.84 1.43-8.13L.17 9.36l8.18-1.2L12 .75l3.65 7.41 8.19 1.2-5.94 5.76 1.42 8.13L12 19.41z"/></svg>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
/**
|
2
|
+
* @namespace WORKAREA.productReviewAjaxSubmit
|
3
|
+
*/
|
4
|
+
WORKAREA.registerModule('productReviewAjaxSubmit', (function () {
|
5
|
+
'use strict';
|
6
|
+
|
7
|
+
var submitForm = function ($form, event) {
|
8
|
+
if ($form.valid() === false) { return; }
|
9
|
+
|
10
|
+
event.preventDefault();
|
11
|
+
|
12
|
+
$.ajax({
|
13
|
+
url: $form.attr('action'),
|
14
|
+
type: $form.attr('method'),
|
15
|
+
data: $form.serialize()
|
16
|
+
}).done(_.partial(WORKAREA.dialog.closeClosest, $form));
|
17
|
+
},
|
18
|
+
|
19
|
+
formNotInDialog = function ($form) {
|
20
|
+
return _.isEmpty($form.closest('.ui-dialog'));
|
21
|
+
},
|
22
|
+
|
23
|
+
/**
|
24
|
+
* @method
|
25
|
+
* @name init
|
26
|
+
* @memberof WORKAREA.productReviewAjaxSubmit
|
27
|
+
*/
|
28
|
+
init = function ($scope) {
|
29
|
+
var $form = $('[data-product-review-ajax-submit]', $scope);
|
30
|
+
|
31
|
+
if (formNotInDialog($form)) { return; }
|
32
|
+
|
33
|
+
$form.on('submit', _.partial(submitForm, $form));
|
34
|
+
};
|
35
|
+
|
36
|
+
return {
|
37
|
+
init: init
|
38
|
+
};
|
39
|
+
}()));
|
@@ -0,0 +1,82 @@
|
|
1
|
+
/**
|
2
|
+
* @namespace WORKAREA.productReviewsSortMenus
|
3
|
+
*/
|
4
|
+
WORKAREA.registerModule('productReviewsSortMenus', (function () {
|
5
|
+
'use strict';
|
6
|
+
|
7
|
+
var insertSortSelectBox = function (index, section) {
|
8
|
+
$('.reviews__header', section).after(
|
9
|
+
JST['workarea/storefront/reviews/templates/sort_by_property']()
|
10
|
+
);
|
11
|
+
},
|
12
|
+
|
13
|
+
sortNewToOld = function ($reviews) {
|
14
|
+
return _.sortBy($reviews, function (review) {
|
15
|
+
return -($(review).data('productReviewSectionEntry').createdAt);
|
16
|
+
});
|
17
|
+
},
|
18
|
+
|
19
|
+
sortOldToNew = function ($reviews) {
|
20
|
+
return _.sortBy($reviews, function (review) {
|
21
|
+
return $(review).data('productReviewSectionEntry').createdAt;
|
22
|
+
});
|
23
|
+
},
|
24
|
+
|
25
|
+
|
26
|
+
sortHighToLow = function ($reviews) {
|
27
|
+
return _.sortBy($reviews, function (review) {
|
28
|
+
return -($(review).data('productReviewSectionEntry').rating);
|
29
|
+
});
|
30
|
+
},
|
31
|
+
|
32
|
+
sortLowToHigh = function ($reviews) {
|
33
|
+
return _.sortBy($reviews, function (review) {
|
34
|
+
return $(review).data('productReviewSectionEntry').rating;
|
35
|
+
});
|
36
|
+
},
|
37
|
+
|
38
|
+
handleSortSelectChange = function (event) {
|
39
|
+
var $reviews = $(
|
40
|
+
'[data-product-review-section-entry]', event.delegateTarget
|
41
|
+
),
|
42
|
+
|
43
|
+
action = $(event.currentTarget).val(),
|
44
|
+
|
45
|
+
actions = {
|
46
|
+
oldest: function () {
|
47
|
+
return sortOldToNew($reviews);
|
48
|
+
},
|
49
|
+
newest: function () {
|
50
|
+
return sortNewToOld($reviews);
|
51
|
+
},
|
52
|
+
lowest: function () {
|
53
|
+
return sortLowToHigh($reviews);
|
54
|
+
},
|
55
|
+
highest: function () {
|
56
|
+
return sortHighToLow($reviews);
|
57
|
+
}
|
58
|
+
};
|
59
|
+
|
60
|
+
$('.reviews__review-group', event.delegateTarget)
|
61
|
+
.html(actions[action]());
|
62
|
+
},
|
63
|
+
|
64
|
+
/**
|
65
|
+
* @method
|
66
|
+
* @name init
|
67
|
+
* @memberof WORKAREA.productReviewsSortMenus
|
68
|
+
*/
|
69
|
+
init = function ($scope) {
|
70
|
+
$('.reviews', $scope)
|
71
|
+
.each(insertSortSelectBox)
|
72
|
+
.on(
|
73
|
+
'change',
|
74
|
+
'[data-product-reviews-sort-menu]',
|
75
|
+
handleSortSelectChange
|
76
|
+
);
|
77
|
+
};
|
78
|
+
|
79
|
+
return {
|
80
|
+
init: init
|
81
|
+
};
|
82
|
+
}()));
|
@@ -0,0 +1,103 @@
|
|
1
|
+
/**
|
2
|
+
* @namespace WORKAREA.ratingButtons
|
3
|
+
*/
|
4
|
+
WORKAREA.registerModule('ratingButtons', (function () {
|
5
|
+
'use strict';
|
6
|
+
|
7
|
+
var activateLabels = function (radioButton, originalIndex, $scope) {
|
8
|
+
var $allButtons = getAllRatingButtons($(document)),
|
9
|
+
|
10
|
+
updateState = function (index, button) {
|
11
|
+
var $label = getAssociatedLabel(button, $scope);
|
12
|
+
|
13
|
+
$label.removeClass('write-review__star--hovered write-review__star--active');
|
14
|
+
|
15
|
+
if ($label.data('index') <= originalIndex) {
|
16
|
+
$label.addClass('write-review__star--active');
|
17
|
+
}
|
18
|
+
};
|
19
|
+
|
20
|
+
if ($(radioButton).is(':checked')) {
|
21
|
+
$allButtons.each(updateState);
|
22
|
+
}
|
23
|
+
},
|
24
|
+
|
25
|
+
getAllRatingButtons = function ($scope) {
|
26
|
+
return $('[data-rating-button]', $scope);
|
27
|
+
},
|
28
|
+
|
29
|
+
getAssociatedLabel = function (button, $scope) {
|
30
|
+
return $('label[for=' + $(button).attr('id') + ']', $scope);
|
31
|
+
},
|
32
|
+
|
33
|
+
removeHoverClass = function ($label) {
|
34
|
+
$label.removeClass('write-review__star--hovered');
|
35
|
+
},
|
36
|
+
|
37
|
+
addHoverClass = function ($label) {
|
38
|
+
$label.addClass('write-review__star--hovered');
|
39
|
+
},
|
40
|
+
|
41
|
+
removeHoverStateFromLabel = function ($scope) {
|
42
|
+
var $buttons = getAllRatingButtons($scope),
|
43
|
+
|
44
|
+
removeState = function (index, button) {
|
45
|
+
var $label = getAssociatedLabel(button, $scope);
|
46
|
+
|
47
|
+
removeHoverClass($label);
|
48
|
+
};
|
49
|
+
|
50
|
+
$buttons.each(removeState);
|
51
|
+
},
|
52
|
+
|
53
|
+
addHoverStateToLabels = function ($scope, originalIndex) {
|
54
|
+
var $buttons = getAllRatingButtons($scope),
|
55
|
+
|
56
|
+
addState = function (index, button) {
|
57
|
+
var $label = getAssociatedLabel(button, $scope);
|
58
|
+
|
59
|
+
if ($label.data('index') <= originalIndex) {
|
60
|
+
addHoverClass($label);
|
61
|
+
}
|
62
|
+
};
|
63
|
+
|
64
|
+
$buttons.each(addState);
|
65
|
+
},
|
66
|
+
|
67
|
+
setupLabels = function ($scope, index, button) {
|
68
|
+
var $label = getAssociatedLabel(button, $scope),
|
69
|
+
labelTitle = $('.write-review__star-text', $label).text();
|
70
|
+
|
71
|
+
/**
|
72
|
+
* 1. per http://www.workarea.com/labs/touching-on-html-labels/
|
73
|
+
*/
|
74
|
+
|
75
|
+
$label
|
76
|
+
.attr('title', labelTitle)
|
77
|
+
.data('index', index)
|
78
|
+
.on('click', $.noop) /* [1] */
|
79
|
+
.on('mouseenter', _.partial(addHoverStateToLabels, $scope, index))
|
80
|
+
.on('mouseleave', _.partial(removeHoverStateFromLabel, $scope));
|
81
|
+
|
82
|
+
activateLabels(button, index, $scope);
|
83
|
+
|
84
|
+
$(button)
|
85
|
+
.on('click', _.partial(activateLabels, button, index, $scope))
|
86
|
+
.on('focus', _.partial(addHoverClass, $label))
|
87
|
+
.on('blur', _.partial(removeHoverClass, $label));
|
88
|
+
},
|
89
|
+
|
90
|
+
/**
|
91
|
+
* @method
|
92
|
+
* @name init
|
93
|
+
* @memberof WORKAREA.ratingButtons
|
94
|
+
*/
|
95
|
+
init = function ($scope) {
|
96
|
+
$('[data-rating-button]', $scope)
|
97
|
+
.each(_.partial(setupLabels, $scope));
|
98
|
+
};
|
99
|
+
|
100
|
+
return {
|
101
|
+
init: init
|
102
|
+
};
|
103
|
+
}()));
|