Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4 1 stable #4

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ bower.json

# Ignore node_modules
node_modules/
spec/dummy
Gemfile.lock
gemfiles/*.gemfile.lock

6 changes: 6 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ appraise 'spree-3-5' do
gem 'rails-controller-testing'
end

appraise 'spree-4-1' do
gem 'spree', '~> 4.1'
gem 'spree_auth_devise', '~> 4.1'
gem 'rails-controller-testing', '~> 1.0.2'
end

appraise 'spree-master' do
gem 'spree', github: 'spree/spree', branch: 'master'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
source 'https://rubygems.org'

gem 'spree', github: 'spree/spree', branch: 'master'
gem 'spree', '~> 4.1'
tanmay3011 marked this conversation as resolved.
Show resolved Hide resolved
# Provides basic authentication functionality for testing parts of your engine
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master'
gem 'spree_auth_devise', '~> 4.1'
tanmay3011 marked this conversation as resolved.
Show resolved Hide resolved
gem 'rails-controller-testing'

gemspec
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ Introduction goes here.
4. Restart your server

If your server was running, restart it so that it can find the assets properly.

Demo
----
Try Spree One Page Stock Management for Spree 4.1 with direct deployment on Heroku:

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/vinsol-spree-contrib/spree-demo-heroku/tree/spree-one-page-stock-management-4-1)

## Testing

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Placeholder manifest file.
// the installer will append this file to the app vendored assets here: vendor/assets/javascripts/spree/backend/all.js'
//= require spree/backend/per_page_selector
//= require jquery3

//= require popper

//= require bootstrap-sprockets
16 changes: 16 additions & 0 deletions app/assets/javascripts/spree/backend/stock_management.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(function() {
jQuery(function() {
$('[data-hook="admin_stock_inventory_management"]').on('click', '.stock_item_backorderable', function() {
return $(this).parent('form').submit();
});
return $('[data-hook="admin_stock_inventory_management"]').on('submit', '.toggle_stock_item_backorderable', function() {
$.ajax({
type: this.method,
url: this.action,
data: $(this).serialize()
});
return false;
});
});

}).call(this);

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@ the installer will append this file to the app vendored assets here: 'vendor/ass
*/

@import 'global/variables';
@import 'bootstrap-sprockets';
@import 'bootstrap';
@import 'shared/base';
2 changes: 1 addition & 1 deletion app/controllers/spree/admin/stock_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def collection
@search = @collection.ransack(params[:q])
@collection = @search.result.
page(params[:page]).
per(params[:per_page] || Spree::Config[:stock_items_per_page])
per(params[:per_page] || SpreeOnePageStockManagement::Config[:stock_items_per_page])
end

def stock_item_params
Expand Down
3 changes: 0 additions & 3 deletions app/models/spree/app_configuration_decorator.rb

This file was deleted.

1 change: 0 additions & 1 deletion app/models/spree/backend_configuration_decorator.rb

This file was deleted.

5 changes: 5 additions & 0 deletions app/models/spree/spree_one_page_stock_management_setting.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module Spree
class SpreeOnePageStockManagementSetting < Preferences::Configuration
preference :stock_items_per_page, :integer, default: 15
end
end
3 changes: 0 additions & 3 deletions app/models/spree/stock_item_decorator.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module SpreeOnePageStockManagement::BackendConfigurationDecorator
rishabhguptarishi marked this conversation as resolved.
Show resolved Hide resolved
end

Spree::BackendConfiguration::STOCKS_TABS ||= [:stock_items]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module SpreeOnePageStockManagement::StockItemDecorator

def self.prepended(base)
base.whitelisted_ransackable_associations = ['variant']
end

end

Spree::StockItem.prepend SpreeOnePageStockManagement::StockItemDecorator
6 changes: 3 additions & 3 deletions app/overrides/spree/admin/add_stock_item_tab.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Deface::Override.new(
virtual_path: 'spree/layouts/admin',
virtual_path: 'spree/admin/shared/_main_menu',
name: 'add_stock_item_tab',
insert_bottom: "[data-hook='admin_tabs']",
insert_bottom: "nav",
text: %q{
<% if can? :admin, Spree::StockItem %>
<ul class="nav nav-sidebar">
<ul class="nav nav-sidebar border-bottom">
<%= tab *Spree::BackendConfiguration::STOCKS_TABS, icon: 'th-list' %>
</ul>
<% end %>
Expand Down
10 changes: 5 additions & 5 deletions app/views/spree/admin/stock_items/_custom_table_options.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<div class="row index-pagination-row">
<div class="col-sm-6">
<%= paginate collection, params: { stock_location: params[:stock_location] || @stock_location.id } %>
<div class="row index-pagination-row mt-4">
<div class="col-6 text-left">
<%= paginate collection, params: { stock_location: params[:stock_location] || @stock_location.id }, theme: 'twitter-bootstrap-4' %>
</div>
<div class="col-sm-6">
<div class="col-6">
<div class="pagination-wrap">
<%= form_tag(per_page_dropdown_params(params), { method: :get, class: 'js-per-page-form form-inline' }) do %>
<%= form_tag(per_page_dropdown_params(params), { method: :get, class: 'js-per-page-form form-inline justify-content-end' }) do %>
<%= per_page_dropdown %>
<% end %>
<div class="clearfix"></div>
Expand Down
8 changes: 6 additions & 2 deletions app/views/spree/admin/stock_items/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@

<div id='stock-items-div' class='container-fluid' >
<div class="row">
<%= label_tag Spree.t(:select_stock_location) %>
<%= select_tag :stock_location, options_for_select(Spree::StockLocation.all.map { |stock_location| [stock_location.name, stock_location.id, data: { url: admin_stock_items_url(q: search_params, per_page: params[:per_page], stock_location: stock_location.name) }] }, @stock_location.id), class: 'select2', id: 'stock-location-selector', data: { hook: 'stock-location-selector' } %>
<div class="col-1">
<%= label_tag Spree.t(:select_stock_location) %>
</div>
<div class="col-4">
<%= select_tag :stock_location, options_for_select(Spree::StockLocation.all.map { |stock_location| [stock_location.name, stock_location.id, data: { url: admin_stock_items_url(q: search_params, per_page: params[:per_page], stock_location: stock_location.name) }] }, @stock_location.id), class: 'select2', id: 'stock-location-selector', data: { hook: 'stock-location-selector' } %>
</div>
</div>
</div>

Expand Down
4 changes: 4 additions & 0 deletions lib/spree_one_page_stock_management/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ def self.activate
end
end

initializer "spree_one_page_stock_management.preferences", before: :load_config_initializers do
SpreeOnePageStockManagement::Config = Spree::SpreeOnePageStockManagementSetting.new
end

config.to_prepare &method(:activate).to_proc
end
end
2 changes: 1 addition & 1 deletion spec/models/spree/app_configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

describe Spree::AppConfiguration, type: :model do
describe 'per_page preferences' do
it { expect(Spree::Config.stock_items_per_page).to eq(15) }
it { expect(SpreeOnePageStockManagement::Config.stock_items_per_page).to eq(15) }
end
end
10 changes: 7 additions & 3 deletions spree_one_page_stock_management.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Gem::Specification.new do |s|
s.version = SpreeOnePageStockManagement.version
s.summary = 'Add extension summary here'
s.description = 'Add (optional) extension description here'
s.required_ruby_version = '>= 2.2.7'
s.required_ruby_version = '>= 2.5'

s.author = 'You'
s.email = 'you@example.com'
Expand All @@ -21,7 +21,7 @@ Gem::Specification.new do |s|
s.require_path = 'lib'
s.requirements << 'none'

s.add_dependency 'spree_core', '>= 3.1.0', '< 4.0'
s.add_dependency 'spree_core', '~> 4.0'
s.add_dependency 'spree_extension'

s.add_development_dependency 'capybara'
Expand All @@ -34,8 +34,12 @@ Gem::Specification.new do |s|
s.add_development_dependency 'sass-rails'
s.add_development_dependency 'selenium-webdriver'
s.add_development_dependency 'simplecov'
s.add_development_dependency 'pg', '~> 0.18'
s.add_development_dependency 'pg', '>= 0.18'
s.add_development_dependency 'mysql2'
s.add_development_dependency 'sqlite3'
s.add_development_dependency 'appraisal'
s.add_development_dependency 'bootstrap', '~> 4.3.1'
s.add_development_dependency 'jquery-rails'
s.add_development_dependency 'kaminari', '~> 1.2.1'
s.add_development_dependency 'bootstrap4-kaminari-views'
end