workarea-product_documents 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +20 -0
  3. data/.github/ISSUE_TEMPLATE/bug_report.md +37 -0
  4. data/.github/ISSUE_TEMPLATE/documentation-request.md +17 -0
  5. data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
  6. data/.github/workflows/ci.yml +57 -0
  7. data/.gitignore +18 -0
  8. data/.rubocop.yml +3 -0
  9. data/CHANGELOG.md +16 -0
  10. data/CODE_OF_CONDUCT.md +3 -0
  11. data/CONTRIBUTING.md +3 -0
  12. data/Gemfile +10 -0
  13. data/LICENSE.md +3 -0
  14. data/README.md +39 -0
  15. data/Rakefile +116 -0
  16. data/app/assets/javascripts/workarea/admin/modules/sort_documents.js +68 -0
  17. data/app/assets/stylesheets/workarea/storefront/product_documents/components/product_documents.scss +22 -0
  18. data/app/controllers/workarea/.keep +0 -0
  19. data/app/controllers/workarea/admin/catalog_product_documents_controller.rb +59 -0
  20. data/app/models/workarea/catalog/product.decorator +7 -0
  21. data/app/models/workarea/catalog/product_document.rb +29 -0
  22. data/app/view_models/workarea/admin/product_view_model.decorator +7 -0
  23. data/app/view_models/workarea/storefront/product_view_model.decorator +7 -0
  24. data/app/views/workarea/.keep +0 -0
  25. data/app/views/workarea/admin/catalog_product_documents/_product_documents.html.haml +14 -0
  26. data/app/views/workarea/admin/catalog_product_documents/index.html.haml +40 -0
  27. data/app/views/workarea/admin/catalog_product_documents/new.html.haml +44 -0
  28. data/app/views/workarea/admin/catalog_products/_documents_card.haml +22 -0
  29. data/app/views/workarea/storefront/products/_product_documents.html.haml +9 -0
  30. data/bin/rails +20 -0
  31. data/config/initializers/appends.rb +21 -0
  32. data/config/initializers/workarea.rb +0 -0
  33. data/config/locales/en.yml +34 -0
  34. data/config/routes.rb +9 -0
  35. data/lib/workarea/product_documents.rb +11 -0
  36. data/lib/workarea/product_documents/engine.rb +8 -0
  37. data/lib/workarea/product_documents/version.rb +5 -0
  38. data/test/dummy/Rakefile +6 -0
  39. data/test/dummy/app/assets/config/manifest.js +4 -0
  40. data/test/dummy/app/assets/images/.keep +0 -0
  41. data/test/dummy/app/assets/javascripts/application.js +13 -0
  42. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  43. data/test/dummy/app/controllers/application_controller.rb +3 -0
  44. data/test/dummy/app/controllers/concerns/.keep +0 -0
  45. data/test/dummy/app/helpers/application_helper.rb +2 -0
  46. data/test/dummy/app/jobs/application_job.rb +2 -0
  47. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  48. data/test/dummy/app/models/concerns/.keep +0 -0
  49. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  50. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  51. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  52. data/test/dummy/bin/bundle +3 -0
  53. data/test/dummy/bin/rails +4 -0
  54. data/test/dummy/bin/rake +4 -0
  55. data/test/dummy/bin/setup +34 -0
  56. data/test/dummy/bin/update +29 -0
  57. data/test/dummy/config.ru +5 -0
  58. data/test/dummy/config/application.rb +27 -0
  59. data/test/dummy/config/boot.rb +5 -0
  60. data/test/dummy/config/cable.yml +9 -0
  61. data/test/dummy/config/environment.rb +5 -0
  62. data/test/dummy/config/environments/development.rb +51 -0
  63. data/test/dummy/config/environments/production.rb +83 -0
  64. data/test/dummy/config/environments/test.rb +44 -0
  65. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  66. data/test/dummy/config/initializers/assets.rb +11 -0
  67. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  68. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  69. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  70. data/test/dummy/config/initializers/inflections.rb +16 -0
  71. data/test/dummy/config/initializers/mime_types.rb +4 -0
  72. data/test/dummy/config/initializers/new_framework_defaults.rb +18 -0
  73. data/test/dummy/config/initializers/workarea.rb +5 -0
  74. data/test/dummy/config/initializers/wrap_parameters.rb +9 -0
  75. data/test/dummy/config/locales/en.yml +23 -0
  76. data/test/dummy/config/puma.rb +47 -0
  77. data/test/dummy/config/routes.rb +5 -0
  78. data/test/dummy/config/secrets.yml +22 -0
  79. data/test/dummy/config/spring.rb +6 -0
  80. data/test/dummy/db/seeds.rb +2 -0
  81. data/test/dummy/lib/assets/.keep +0 -0
  82. data/test/dummy/log/.keep +0 -0
  83. data/test/integration/workarea/admin/product_documents_integration_test.rb +85 -0
  84. data/test/integration/workarea/storefront/product_documents_integration_test.rb +28 -0
  85. data/test/teaspoon_env.rb +6 -0
  86. data/test/test_helper.rb +15 -0
  87. data/test/view_models/workarea/admin/product_view_model_test.decorator +28 -0
  88. data/workarea-product_documents.gemspec +18 -0
  89. metadata +144 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d59e9ef25d717590bb3a54df6cf2e6d0b8e43c4d91650e0d52b837b7b429945e
4
+ data.tar.gz: 9f9043874a201750bdbf4f5699888f69dc7fcb3ef97efcac427babd335bc9ef5
5
+ SHA512:
6
+ metadata.gz: f652e0b942a7ab63199e5d85bbfd8c0154305466d25a13b1e4d3c23a33f4d2da19f58de0f2de6d08ee575f51bdbe4bf6516566b7344b08ba9d4310a15b8f2100
7
+ data.tar.gz: 810f7ae861289df7b26c0af0ce973285ccc729d88e8ba7113ba922722e1ebbf4152b5c0e057f5b042831f186606944cf421f4d1bb90cb553bfb1baafc9b6d16c
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.
@@ -0,0 +1,57 @@
1
+ name: CI
2
+ on: [push]
3
+
4
+ jobs:
5
+ static_analysis:
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - uses: actions/checkout@v1
9
+ - uses: workarea-commerce/ci/bundler-audit@v1
10
+ - uses: workarea-commerce/ci/rubocop@v1
11
+ - uses: workarea-commerce/ci/eslint@v1
12
+ with:
13
+ args: '**/*.js'
14
+
15
+ admin_tests:
16
+ runs-on: ubuntu-latest
17
+ steps:
18
+ - uses: actions/checkout@v1
19
+ - uses: actions/setup-ruby@v1
20
+ with:
21
+ ruby-version: 2.6.x
22
+ - uses: workarea-commerce/ci/test@v1
23
+ with:
24
+ command: bin/rails app:workarea:test:admin
25
+
26
+ core_tests:
27
+ runs-on: ubuntu-latest
28
+ steps:
29
+ - uses: actions/checkout@v1
30
+ - uses: actions/setup-ruby@v1
31
+ with:
32
+ ruby-version: 2.6.x
33
+ - uses: workarea-commerce/ci/test@v1
34
+ with:
35
+ command: bin/rails app:workarea:test:core
36
+
37
+ storefront_tests:
38
+ runs-on: ubuntu-latest
39
+ steps:
40
+ - uses: actions/checkout@v1
41
+ - uses: actions/setup-ruby@v1
42
+ with:
43
+ ruby-version: 2.6.x
44
+ - uses: workarea-commerce/ci/test@v1
45
+ with:
46
+ command: bin/rails app:workarea:test:storefront
47
+
48
+ plugins_tests:
49
+ runs-on: ubuntu-latest
50
+ steps:
51
+ - uses: actions/checkout@v1
52
+ - uses: actions/setup-ruby@v1
53
+ with:
54
+ ruby-version: 2.6.x
55
+ - uses: workarea-commerce/ci/test@v1
56
+ with:
57
+ command: bin/rails app:workarea:test:plugins
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/tmp/
5
+ .DS_Store
6
+ .byebug_history
7
+ .bundle/
8
+ .sass-cache/
9
+ Gemfile.lock
10
+ pkg/
11
+ test/dummy/tmp/
12
+ test/dummy/public/
13
+ log/*.log
14
+ test/dummy/log/*.log
15
+ test/dummy/db/*.sqlite3
16
+ test/dummy/db/*.sqlite3-journal
17
+ coverage/
18
+ .rubocop-http*
data/.rubocop.yml ADDED
@@ -0,0 +1,3 @@
1
+ inherit_from:
2
+ - https://raw.githubusercontent.com/workarea-commerce/workarea/master/.rubocop.yml
3
+
data/CHANGELOG.md ADDED
@@ -0,0 +1,16 @@
1
+ Workarea ProductDocuments 1.0.0 (2019-11-26)
2
+ --------------------------------------------------------------------------------
3
+
4
+
5
+ Workarea ProductDocuments 1.0.0 (2018-04-25)
6
+ --------------------------------------------------------------------------------
7
+
8
+ * Upgrade product documents to v.3 compatibility
9
+
10
+ Upgrades the plugin to v3. Commit does away with explicit document types,
11
+ instead it groups documents by display name, making this a zero configuration
12
+ plugin. New drag-and-drop functionality for ordering has been introduced
13
+ in this version.
14
+
15
+ DOCUMENTS-1
16
+ Jeff Yucis
@@ -0,0 +1,3 @@
1
+ View this plugin's code of conduct here:
2
+
3
+ <https://github.com/workarea-commerce/workarea/blob/master/CODE_OF_CONDUCT.md>
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,3 @@
1
+ View this plugin's contribution guidelines here:
2
+
3
+ <https://github.com/workarea-commerce/workarea/blob/master/CONTRIBUTING.md>
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
+
4
+ gemspec
5
+
6
+ gem 'workarea', github: 'workarea-commerce/workarea'
7
+
8
+ group :test do
9
+ gem 'simplecov', require: false
10
+ end
data/LICENSE.md ADDED
@@ -0,0 +1,3 @@
1
+ View this plugin's license here:
2
+
3
+ <https://github.com/workarea-commerce/workarea/blob/master/LICENSE.md>
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ WebLinc Product Documents
2
+ ================================================================================
3
+
4
+ Product Documents plugin for the Workarea platform.
5
+ -------------------------------------------------------------------------------
6
+
7
+ This gem adds the ability to add documents to a product for display on the detail page.
8
+
9
+ Files can be added via the product admin. Each file requires a display name and a file for downloading.
10
+ Files with the same display name will be grouped together when output on the product detail page.
11
+
12
+ The display order of the files can be modified via drag-and-drop in the admin.
13
+
14
+
15
+ Getting Started
16
+ --------------------------------------------------------------------------------
17
+
18
+ This gem contains a rails engine that must be mounted onto a host Rails application.
19
+
20
+ Add the gem to your application's Gemfile specifying the source:
21
+
22
+ # ...
23
+ gem 'workarea-product_documents'
24
+ # ...
25
+
26
+ Update your application's bundle.
27
+
28
+ cd path/to/application
29
+ bundle
30
+
31
+ WebLinc Platform Documentation
32
+ --------------------------------------------------------------------------------
33
+
34
+ See [https://developer.workarea.com/](https://developer.workarea.com/) for Workarea platform documentation.
35
+
36
+ License
37
+ --------------------------------------------------------------------------------
38
+
39
+ Workarea Emarsys is released under the [Business Software License](LICENSE)
data/Rakefile ADDED
@@ -0,0 +1,116 @@
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 = "ProductDocuments"
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", __dir__)
17
+ load "rails/tasks/engine.rake"
18
+ load "rails/tasks/statistics.rake"
19
+
20
+ require "rake/testtask"
21
+ Rake::TestTask.new(:test) do |t|
22
+ t.libs << "lib"
23
+ t.libs << "test"
24
+ t.pattern = "test/**/*_test.rb"
25
+ t.verbose = false
26
+ end
27
+ task default: :test
28
+
29
+ $LOAD_PATH.unshift File.expand_path("lib", __dir__)
30
+ require "workarea/product_documents/version"
31
+
32
+ desc "Generate the changelog based on git history"
33
+ task :changelog, :from, :to do |_t, args|
34
+ require "date"
35
+
36
+ from = if args[:from].present?
37
+ args[:from]
38
+ elsif `git tag`.empty?
39
+ `git rev-list --max-parents=0 HEAD`
40
+ else
41
+ `git describe --tags --abbrev=0`.strip
42
+ end
43
+
44
+ to = args[:to] || "HEAD"
45
+ log = `git log #{from}..#{to} --pretty=format:'%an|%B___'`
46
+
47
+ puts "Workarea ProductDocuments #{Workarea::ProductDocuments::VERSION} (#{Date.today})"
48
+ puts "-" * 80
49
+ puts
50
+
51
+ log.split(/___/).each do |commit|
52
+ pieces = commit.split("|").reverse
53
+ author = pieces.pop.strip
54
+ message = pieces.join.strip
55
+
56
+ next if message =~ /^\s*Merge pull request/
57
+ next if message =~ /No changelog/i
58
+
59
+ project_key = "DOCUMENTS" # TODO: Replace with your Project's Jira key
60
+
61
+ if project_key.blank?
62
+ puts "To clean up your release notes, add your project's Jira key to the Changelog Rake task!"
63
+ else
64
+ ticket = message.scan(/#{project_key}-\d+/)[0]
65
+ next if ticket.nil?
66
+ next if message =~ /^\s*Merge branch/ && ticket.nil?
67
+ end
68
+
69
+ first_line = false
70
+
71
+ message.each_line do |line|
72
+ if !first_line
73
+ first_line = true
74
+ puts "* #{line}"
75
+ elsif line.strip.empty?
76
+ puts
77
+ else
78
+ puts " #{line}"
79
+ end
80
+ end
81
+
82
+ puts " #{author}"
83
+ puts
84
+ end
85
+ end
86
+
87
+ desc "Release version #{Workarea::ProductDocuments::VERSION} of the gem"
88
+ task :release do
89
+ host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
90
+
91
+ system "touch CHANGELOG.md"
92
+ system 'echo "$(rake changelog)
93
+
94
+
95
+ $(cat CHANGELOG.md)" > CHANGELOG.md'
96
+ system 'git add CHANGELOG.md && git commit -m "Update changelog" && git push origin HEAD'
97
+
98
+ system "git tag -a v#{Workarea::ProductDocuments::VERSION} -m 'Tagging #{Workarea::ProductDocuments::VERSION}'"
99
+ system "git push --tags"
100
+
101
+ system "gem build workarea-product_documents.gemspec"
102
+ system "gem push workarea-product_documents-#{Workarea::ProductDocuments::VERSION}.gem"
103
+ system "gem push workarea-product_documents-#{Workarea::ProductDocuments::VERSION}.gem --host #{host}"
104
+ system "rm workarea-product_documents-#{Workarea::ProductDocuments::VERSION}.gem"
105
+ end
106
+
107
+ desc "Run the JavaScript tests"
108
+ ENV["TEASPOON_RAILS_ENV"] = File.expand_path("test/dummy/config/environment", __dir__)
109
+ task teaspoon: "app:teaspoon"
110
+
111
+ desc "Start a server at http://localhost:3000/teaspoon for JavaScript tests"
112
+ task :teaspoon_server do
113
+ Dir.chdir("test/dummy")
114
+ teaspoon_env = File.expand_path("test/teaspoon_env.rb", __dir__)
115
+ system "RAILS_ENV=test TEASPOON_ENV=#{teaspoon_env} rails s"
116
+ end
@@ -0,0 +1,68 @@
1
+ /**
2
+ * @namespace WORKAREA.sortDocuments
3
+ */
4
+ WORKAREA.registerModule('sortDocuments', (function () {
5
+ 'use strict';
6
+
7
+ var findDocumentPositions = function (event) {
8
+ var result = {},
9
+ $documents = $('[data-sort-document-id]', event.target);
10
+
11
+ $documents.each(function (index, menu) {
12
+ var id = $(menu).data('sortDocumentId');
13
+
14
+ if (id) {
15
+ result['positions[' + id + ']'] = index;
16
+ }
17
+ });
18
+
19
+ return result;
20
+ },
21
+
22
+ saveSort = function (event) {
23
+ var productId = $(event.target)
24
+ .closest('[data-sort-document]')
25
+ .data('productId'),
26
+
27
+ url = WORKAREA.routes.admin.moveCatalogProductDocumentsPath(
28
+ { catalog_product_id: productId }
29
+ );
30
+
31
+ $.post(url, findDocumentPositions(event));
32
+ },
33
+
34
+ setCellWidth = function (event, ui) {
35
+ $('td', ui.item).each(function (index, cell) {
36
+ $(cell).width($(cell).width());
37
+ });
38
+
39
+ return ui;
40
+ },
41
+
42
+ resetCellWidth = function (event, ui) {
43
+ $('td', ui.item).each(function (index, cell) {
44
+ $(cell).width('auto');
45
+ });
46
+
47
+ return ui;
48
+ },
49
+
50
+ /**
51
+ * @method
52
+ * @name init
53
+ * @memberof WORKAREA.sortDocuments
54
+ */
55
+ init = function ($scope) {
56
+ $('[data-sort-document]', $scope).sortable({
57
+ axis: 'y',
58
+ update: saveSort,
59
+ tolerance: 'pointer',
60
+ helper: setCellWidth,
61
+ stop: resetCellWidth
62
+ });
63
+ };
64
+
65
+ return {
66
+ init: init
67
+ };
68
+ }()));