solidus_stock_supplier 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +1 -0
  4. data/.rubocop.yml +235 -0
  5. data/.rvmrc +1 -0
  6. data/.travis.yml +30 -0
  7. data/Gemfile +8 -0
  8. data/LICENSE +26 -0
  9. data/README.md +36 -0
  10. data/Rakefile +30 -0
  11. data/app/assets/javascripts/spree/backend/solidus_stock_supplier.js +47 -0
  12. data/app/assets/javascripts/spree/backend/templates/stock_transfers/supplier_checkbox.hbs +4 -0
  13. data/app/assets/javascripts/spree/frontend/solidus_stock_supplier.js +2 -0
  14. data/app/assets/stylesheets/spree/backend/solidus_stock_supplier.css +4 -0
  15. data/app/assets/stylesheets/spree/frontend/solidus_stock_supplier.css +4 -0
  16. data/app/controllers/spree/admin/stock_items_controller_decorator.rb +1 -0
  17. data/app/controllers/spree/admin/stock_locations_controller_decorator.rb +6 -0
  18. data/app/controllers/spree/admin/stock_transfers_controller_decorator.rb +13 -0
  19. data/app/controllers/spree/admin/suppliers_controller.rb +12 -0
  20. data/app/models/concerns/solidus_stock_supplier/location_scopes_concern.rb +10 -0
  21. data/app/models/concerns/solidus_stock_supplier/stock_items_controller_extension.rb +7 -0
  22. data/app/models/spree/supplier.rb +17 -0
  23. data/app/models/spree/supplier_stock_location.rb +5 -0
  24. data/app/models/stock_location_decorator.rb +1 -0
  25. data/app/views/spree/admin/stock_locations/index.json.jbuilder +11 -0
  26. data/app/views/spree/admin/suppliers/_form.html.erb +20 -0
  27. data/app/views/spree/admin/suppliers/edit.html.erb +13 -0
  28. data/app/views/spree/admin/suppliers/index.html.erb +43 -0
  29. data/app/views/spree/admin/suppliers/new.html.erb +15 -0
  30. data/bin/rails +7 -0
  31. data/config/locales/en.yml +13 -0
  32. data/config/routes.rb +5 -0
  33. data/db/migrate/20171028052439_create_suppliers.rb +11 -0
  34. data/db/migrate/20171029052411_add_type_to_stock_locations.rb +6 -0
  35. data/lib/generators/solidus_stock_supplier/install/install_generator.rb +30 -0
  36. data/lib/solidus_stock_supplier.rb +3 -0
  37. data/lib/solidus_stock_supplier/engine.rb +30 -0
  38. data/lib/solidus_stock_supplier/version.rb +3 -0
  39. data/solidus_stock_supplier.gemspec +36 -0
  40. data/spec/controllers/spree/admin/suppliers_controller_spec.rb +100 -0
  41. data/spec/factories.rb +6 -0
  42. data/spec/models/spree/supplier_spec.rb +8 -0
  43. data/spec/spec_helper.rb +96 -0
  44. metadata +295 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3e2fc09f7d050afbb0ac33ba8e7f1318579d3934
4
+ data.tar.gz: dff19909e3cb4c59ee7a65486efda79475ab36fd
5
+ SHA512:
6
+ metadata.gz: 50dc4bac55cb40a6908c5857f4ee87c0d4f8c3d7d3c23bf11fd15b3c8c9d6252c756cbb0be278339cfe64a57102d7c9b8a17ebe02e70da42414ff2c64911a953
7
+ data.tar.gz: 64c552b5e4d24bb86622f712793aa2d3e96e8e1e3be5732b69ad2aeba019aa2a81acb1b1266ce2fc13653f1ce71f37fe27f3584098df9fa0a19fc587ebb98651
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ *.gem
2
+ \#*
3
+ *~
4
+ .#*
5
+ .DS_Store
6
+ .idea
7
+ .project
8
+ .sass-cache
9
+ coverage
10
+ Gemfile.lock
11
+ tmp
12
+ nbproject
13
+ pkg
14
+ *.swp
15
+ spec/dummy
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,235 @@
1
+ # Relaxed.Ruby.Style
2
+
3
+ AllCops:
4
+ Exclude:
5
+ - 'spec/dummy/**/*'
6
+ - 'vendor/bundle/**/*'
7
+ TargetRubyVersion: 2.1
8
+
9
+ # Sometimes I believe this reads better
10
+ # This also causes spacing issues on multi-line fixes
11
+ Style/BracesAroundHashParameters:
12
+ Enabled: false
13
+
14
+ # We use class vars and will have to continue doing so for compatability
15
+ Style/ClassVars:
16
+ Enabled: false
17
+
18
+ # This has been used for customization
19
+ Style/MutableConstant:
20
+ Enabled: false
21
+
22
+ Style/ClassAndModuleChildren:
23
+ Enabled: false
24
+
25
+ Style/GuardClause:
26
+ Enabled: false
27
+
28
+ Style/WordArray:
29
+ Enabled: false
30
+
31
+ Style/ConditionalAssignment:
32
+ Enabled: false
33
+
34
+ Performance/Count:
35
+ Enabled: false
36
+
37
+ Style/RaiseArgs:
38
+ Enabled: false
39
+
40
+ # We can use good judgement here
41
+ Style/RegexpLiteral:
42
+ Enabled: false
43
+
44
+ # Unicode comments are useful
45
+ Style/AsciiComments:
46
+ Enabled: false
47
+
48
+ Lint/EndAlignment:
49
+ Enabled: false
50
+
51
+ # From http://relaxed.ruby.style/
52
+
53
+ Style/Alias:
54
+ Enabled: false
55
+ StyleGuide: http://relaxed.ruby.style/#stylealias
56
+
57
+ Style/BeginBlock:
58
+ Enabled: false
59
+ StyleGuide: http://relaxed.ruby.style/#stylebeginblock
60
+
61
+ Style/BlockDelimiters:
62
+ Enabled: false
63
+ StyleGuide: http://relaxed.ruby.style/#styleblockdelimiters
64
+
65
+ Style/Documentation:
66
+ Enabled: false
67
+ StyleGuide: http://relaxed.ruby.style/#styledocumentation
68
+
69
+ Style/DoubleNegation:
70
+ Enabled: false
71
+ StyleGuide: http://relaxed.ruby.style/#styledoublenegation
72
+
73
+ Style/EndBlock:
74
+ Enabled: false
75
+ StyleGuide: http://relaxed.ruby.style/#styleendblock
76
+
77
+ Style/FormatString:
78
+ Enabled: false
79
+ StyleGuide: http://relaxed.ruby.style/#styleformatstring
80
+
81
+ Style/IfUnlessModifier:
82
+ Enabled: false
83
+ StyleGuide: http://relaxed.ruby.style/#styleifunlessmodifier
84
+
85
+ Style/Lambda:
86
+ Enabled: false
87
+ StyleGuide: http://relaxed.ruby.style/#stylelambda
88
+
89
+ Style/ModuleFunction:
90
+ Enabled: false
91
+ StyleGuide: http://relaxed.ruby.style/#stylemodulefunction
92
+
93
+ Style/MultilineBlockChain:
94
+ Enabled: false
95
+ StyleGuide: http://relaxed.ruby.style/#stylemultilineblockchain
96
+
97
+ Style/NegatedIf:
98
+ Enabled: false
99
+ StyleGuide: http://relaxed.ruby.style/#stylenegatedif
100
+
101
+ Style/NegatedWhile:
102
+ Enabled: false
103
+ StyleGuide: http://relaxed.ruby.style/#stylenegatedwhile
104
+
105
+ Style/ParallelAssignment:
106
+ Enabled: false
107
+ StyleGuide: http://relaxed.ruby.style/#styleparallelassignment
108
+
109
+ Style/PercentLiteralDelimiters:
110
+ Enabled: false
111
+ StyleGuide: http://relaxed.ruby.style/#stylepercentliteraldelimiters
112
+
113
+ Style/PerlBackrefs:
114
+ Enabled: false
115
+ StyleGuide: http://relaxed.ruby.style/#styleperlbackrefs
116
+
117
+ Style/Semicolon:
118
+ Enabled: false
119
+ StyleGuide: http://relaxed.ruby.style/#stylesemicolon
120
+
121
+ Style/SignalException:
122
+ Enabled: false
123
+ StyleGuide: http://relaxed.ruby.style/#stylesignalexception
124
+
125
+ Style/SingleLineBlockParams:
126
+ Enabled: false
127
+ StyleGuide: http://relaxed.ruby.style/#stylesinglelineblockparams
128
+
129
+ Style/SingleLineMethods:
130
+ Enabled: false
131
+ StyleGuide: http://relaxed.ruby.style/#stylesinglelinemethods
132
+
133
+ Style/SpecialGlobalVars:
134
+ Enabled: false
135
+ StyleGuide: http://relaxed.ruby.style/#stylespecialglobalvars
136
+
137
+ Style/StringLiterals:
138
+ Enabled: false
139
+ StyleGuide: http://relaxed.ruby.style/#stylestringliterals
140
+
141
+ Style/SymbolProc:
142
+ Enabled: false
143
+
144
+ Style/WhileUntilModifier:
145
+ Enabled: false
146
+ StyleGuide: http://relaxed.ruby.style/#stylewhileuntilmodifier
147
+
148
+ Lint/AmbiguousRegexpLiteral:
149
+ Enabled: false
150
+ StyleGuide: http://relaxed.ruby.style/#lintambiguousregexpliteral
151
+
152
+ Lint/AssignmentInCondition:
153
+ Enabled: false
154
+ StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition
155
+
156
+ Lint/HandleExceptions:
157
+ Exclude:
158
+ - 'Rakefile'
159
+
160
+ Metrics/AbcSize:
161
+ Enabled: false
162
+
163
+ Metrics/BlockLength:
164
+ Exclude:
165
+ - 'spec/**/*'
166
+
167
+ Metrics/BlockNesting:
168
+ Enabled: false
169
+
170
+ Metrics/ClassLength:
171
+ Enabled: false
172
+
173
+ Metrics/ModuleLength:
174
+ Enabled: false
175
+
176
+ Metrics/CyclomaticComplexity:
177
+ Enabled: false
178
+
179
+ Metrics/LineLength:
180
+ Enabled: false
181
+
182
+ Metrics/MethodLength:
183
+ Enabled: false
184
+
185
+ Metrics/ParameterLists:
186
+ Enabled: false
187
+
188
+ Metrics/PerceivedComplexity:
189
+ Enabled: false
190
+
191
+ Naming/BinaryOperatorParameterName:
192
+ Enabled: false
193
+
194
+ # We need these names for backwards compatability
195
+ Naming/PredicateName:
196
+ Enabled: false
197
+
198
+ Naming/AccessorMethodName:
199
+ Enabled: false
200
+
201
+ Layout/ElseAlignment:
202
+ Enabled: false
203
+
204
+ Layout/IndentationWidth:
205
+ Enabled: false
206
+
207
+ Layout/AlignParameters:
208
+ Enabled: false
209
+
210
+ Layout/ClosingParenthesisIndentation:
211
+ Enabled: false
212
+
213
+ Layout/MultilineMethodCallIndentation:
214
+ Enabled: false
215
+
216
+ Layout/IndentArray:
217
+ Enabled: false
218
+
219
+ Layout/IndentHash:
220
+ Enabled: false
221
+
222
+ Layout/AlignHash:
223
+ Enabled: false
224
+
225
+ Layout/DotPosition:
226
+ Enabled: false
227
+ StyleGuide: http://relaxed.ruby.style/#styledotposition
228
+
229
+ Layout/SpaceBeforeBlockBraces:
230
+ Enabled: false
231
+ StyleGuide: http://relaxed.ruby.style/#stylespacebeforeblockbraces
232
+
233
+ Layout/SpaceInsideParens:
234
+ Enabled: false
235
+ StyleGuide: http://relaxed.ruby.style/#stylespaceinsideparens
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm --create use 2.4.1@solidus_stock_supplier
data/.travis.yml ADDED
@@ -0,0 +1,30 @@
1
+ sudo: false
2
+ cache: bundler
3
+ language: ruby
4
+ bundler_args: --quiet
5
+ script:
6
+ - bundle exec rake
7
+ rvm:
8
+ - 2.4.1
9
+ env:
10
+ matrix:
11
+ - SOLIDUS_BRANCH=v1.0 DB=postgres
12
+ - SOLIDUS_BRANCH=v1.1 DB=postgres
13
+ - SOLIDUS_BRANCH=v1.2 DB=postgres
14
+ - SOLIDUS_BRANCH=v1.3 DB=postgres
15
+ - SOLIDUS_BRANCH=v1.4 DB=postgres
16
+ - SOLIDUS_BRANCH=v2.0 DB=postgres
17
+ - SOLIDUS_BRANCH=v2.1 DB=postgres
18
+ - SOLIDUS_BRANCH=v2.2 DB=postgres
19
+ - SOLIDUS_BRANCH=v2.3 DB=postgres
20
+ - SOLIDUS_BRANCH=master DB=postgres
21
+ - SOLIDUS_BRANCH=v1.0 DB=mysql
22
+ - SOLIDUS_BRANCH=v1.1 DB=mysql
23
+ - SOLIDUS_BRANCH=v1.2 DB=mysql
24
+ - SOLIDUS_BRANCH=v1.3 DB=mysql
25
+ - SOLIDUS_BRANCH=v1.4 DB=mysql
26
+ - SOLIDUS_BRANCH=v2.0 DB=mysql
27
+ - SOLIDUS_BRANCH=v2.1 DB=mysql
28
+ - SOLIDUS_BRANCH=v2.2 DB=mysql
29
+ - SOLIDUS_BRANCH=v2.3 DB=mysql
30
+ - SOLIDUS_BRANCH=master DB=mysql
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" }
4
+
5
+ branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
6
+ gem 'solidus', github: 'solidusio/solidus', branch: branch
7
+
8
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2017 César Carruitero
2
+ All rights reserved.
3
+
4
+ Redistribution and use in source and binary forms, with or without modification,
5
+ are permitted provided that the following conditions are met:
6
+
7
+ * Redistributions of source code must retain the above copyright notice,
8
+ this list of conditions and the following disclaimer.
9
+ * Redistributions in binary form must reproduce the above copyright notice,
10
+ this list of conditions and the following disclaimer in the documentation
11
+ and/or other materials provided with the distribution.
12
+ * Neither the name Spree nor the names of its contributors may be used to
13
+ endorse or promote products derived from this software without specific
14
+ prior written permission.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
25
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ SolidusStockSupplier
2
+ ====================
3
+
4
+ Adds support to receive stock from supplier in Solidus Admin
5
+
6
+ Installation
7
+ ------------
8
+
9
+ Add solidus_stock_supplier to your Gemfile:
10
+
11
+ ```ruby
12
+ gem 'solidus_stock_supplier'
13
+ ```
14
+
15
+ Bundle your dependencies and run the installation generator:
16
+
17
+ ```shell
18
+ bundle
19
+ bundle exec rails g solidus_stock_supplier:install
20
+ ```
21
+
22
+ Testing
23
+ -------
24
+
25
+ First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs, and [Rubocop](https://github.com/bbatsov/rubocop) static code analysis. The dummy app can be regenerated by using `rake test_app`.
26
+
27
+ ```shell
28
+ bundle
29
+ bundle exec rake
30
+ ```
31
+
32
+ ```ruby
33
+ require 'solidus_stock_supplier/factories'
34
+ ```
35
+
36
+ Copyright (c) 2017 César Carruitero and [contributors](https://github.com/ccarruitero/solidus_stock_supplier/graphs/contributors), released under the New BSD License
data/Rakefile ADDED
@@ -0,0 +1,30 @@
1
+ require 'bundler'
2
+
3
+ Bundler::GemHelper.install_tasks
4
+
5
+ begin
6
+ require 'spree/testing_support/extension_rake'
7
+ require 'rubocop/rake_task'
8
+ require 'rspec/core/rake_task'
9
+
10
+ RSpec::Core::RakeTask.new(:spec)
11
+
12
+ RuboCop::RakeTask.new
13
+
14
+ task default: %i(first_run rubocop spec)
15
+ rescue LoadError
16
+ # no rspec available
17
+ end
18
+
19
+ task :first_run do
20
+ if Dir['spec/dummy'].empty?
21
+ Rake::Task[:test_app].invoke
22
+ Dir.chdir('../../')
23
+ end
24
+ end
25
+
26
+ desc 'Generates a dummy app for testing'
27
+ task :test_app do
28
+ ENV['LIB_NAME'] = 'solidus_stock_supplier'
29
+ Rake::Task['extension:test_app'].invoke
30
+ end
@@ -0,0 +1,47 @@
1
+ //= require_tree ./templates
2
+
3
+ (function($) {
4
+ var newStockTransfer = {
5
+ init: function() {
6
+ if($('#stock_transfer_source_location_field').length) {
7
+ var supplierTemplate = HandlebarsTemplates['stock_transfers/supplier_checkbox'];
8
+ $('#stock_transfer_source_location_field').before(supplierTemplate);
9
+ this.getLocations();
10
+ this.addCheckboxEvent();
11
+ }
12
+ },
13
+
14
+ getLocations: function() {
15
+ var locationsUrl = '/admin/stock_locations';
16
+ $.get(locationsUrl, function(data) {
17
+ Spree.StockLocations = data;
18
+ });
19
+ },
20
+
21
+ populateSelect: function(locationsType) {
22
+ var select = $('#stock_transfer_source_location_id');
23
+ var locations = Spree.StockLocations[locationsType];
24
+ select.children().remove();
25
+ withBlank = [{ name: '', id: ''}].concat(locations)
26
+ $.map(withBlank, function(location) {
27
+ var opt = $(document.createElement('option')).attr('value', location.id).html(location.name);
28
+ select.append(opt);
29
+ });
30
+ },
31
+
32
+ addCheckboxEvent: function() {
33
+ var _this = this;
34
+ $('#supplier').change(function() {
35
+ if (this.checked) {
36
+ _this.populateSelect('supplier');
37
+ } else {
38
+ _this.populateSelect('store');
39
+ }
40
+ });
41
+ }
42
+ };
43
+
44
+ Spree.ready(function() {
45
+ newStockTransfer.init();
46
+ });
47
+ }(jQuery));