spree_sort_products 1.3.4 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +14 -0
- data/.rspec +1 -0
- data/.travis.yml +13 -0
- data/Gemfile +10 -0
- data/README.md +18 -9
- data/Rakefile +15 -0
- data/Versionfile +13 -0
- data/app/assets/javascripts/admin/spree_sort_products.js +1 -1
- data/app/assets/javascripts/admin/taxon_tree_menu_overrides.js.coffee +28 -0
- data/app/assets/stylesheets/admin/spree_sort_products.css +1 -1
- data/app/controllers/spree/admin/taxons_controller_decorator.rb +4 -4
- data/app/models/spree/classification_decorator.rb +5 -0
- data/app/models/spree/products_taxon.rb +2 -5
- data/app/models/spree/taxon_decorator.rb +1 -2
- data/app/overrides/add_sort_products_link.rb +4 -0
- data/app/views/spree/admin/taxonomies/_sort_products_js.erb +26 -0
- data/config/routes.rb +2 -3
- data/lib/generators/spree_sort_products/install/install_generator.rb +8 -6
- data/lib/spree_sort_products/engine.rb +1 -1
- data/lib/spree_sort_products/factories.rb +19 -0
- data/script/rails +7 -0
- data/spec/features/sort_products_spec.rb +21 -0
- data/spec/spec_helper.rb +94 -0
- data/spree_sort_products.gemspec +32 -0
- metadata +68 -28
- data/app/assets/javascripts/admin/taxonomy_overrides.js +0 -137
- data/app/models/spree/product_decorator.rb +0 -6
- data/app/views/spree/admin/taxonomies/edit.erb +0 -65
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c63721d253244793555b960086794f415a2627fd
|
4
|
+
data.tar.gz: 12485436443ed2a249dfb2fe7fdbbdeda7a3f18b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 709af048a998c55d602851130cb435a3e11bc0bfa8e680966c43e2901675a1af069ba6d031135f50a906af5f047579715d91c7f8eced3d2c0ee953eba16138c7
|
7
|
+
data.tar.gz: 812c5e11507cec8e72d800ec816af082fce03e43c99292e5289e569f919e27a31a434e30f2470c3d103f354bd10632152a3ad3e41bc96046c3f134e2dc6debfb
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Provides basic authentication functionality for testing parts of your engine
|
4
|
+
gem 'spree_auth_devise', :git => "git://github.com/spree/spree_auth_devise", :branch => '2-0-stable'
|
5
|
+
|
6
|
+
gem 'jquery-dragsort-rails', '~> 1.0.0'
|
7
|
+
|
8
|
+
gem 'coveralls', require: false
|
9
|
+
|
10
|
+
gemspec
|
data/README.md
CHANGED
@@ -12,18 +12,18 @@ Spree Sort Products extends the ability of a taxon on its products to be sorted
|
|
12
12
|
gem 'spree_sort_products' , :git => 'git://github.com/suryart/spree_sort_products.git'
|
13
13
|
```
|
14
14
|
|
15
|
-
* Get the
|
15
|
+
* Get the 2-0-stable branch for Spree 2.0.x from github:
|
16
16
|
|
17
17
|
```ruby
|
18
18
|
gem 'jquery-dragsort-rails', '~> 1.0.0'
|
19
|
-
gem 'spree_sort_products' , :git => 'git://github.com/suryart/spree_sort_products.git', :branch => '
|
19
|
+
gem 'spree_sort_products' , :git => 'git://github.com/suryart/spree_sort_products.git', :branch => '2-0-stable'
|
20
20
|
```
|
21
21
|
|
22
22
|
* Or get it from rubygems.org by mentioning the following line in your Gemfile:
|
23
23
|
|
24
24
|
```ruby
|
25
25
|
gem 'jquery-dragsort-rails', '~> 1.0.0'
|
26
|
-
gem 'spree_sort_products', '
|
26
|
+
gem 'spree_sort_products', '2.0.0'
|
27
27
|
```
|
28
28
|
|
29
29
|
### Then run the following commands:
|
@@ -38,9 +38,9 @@ Please note that this extension uses [jquery-dragsort-rails](https://github.com/
|
|
38
38
|
|
39
39
|
## Caution
|
40
40
|
|
41
|
-
Just make sure that you have **admin/
|
41
|
+
Just make sure that you have **admin/taxon_tree_menu_overrides** and **admin/sort_products** files precompiled. If it's not happening by default then please add/edit this in your **config/environments/production.rb** file:
|
42
42
|
|
43
|
-
Rails.application.config.assets.precompile += %w(admin/
|
43
|
+
Rails.application.config.assets.precompile += %w(admin/taxon_tree_menu_overrides admin/sort_products)
|
44
44
|
|
45
45
|
## TODOs
|
46
46
|
|
@@ -50,15 +50,24 @@ Just make sure that you have **admin/taxonomy_overrides** and **admin/sort_produ
|
|
50
50
|
|
51
51
|
* Dependency status: [![Dependency Status](https://gemnasium.com/suryart/spree_sort_products.png)](https://gemnasium.com/suryart/spree_sort_products)
|
52
52
|
* Code climate: [![Code Climate](https://codeclimate.com/github/suryart/spree_sort_products.png)](https://codeclimate.com/github/suryart/spree_sort_products)
|
53
|
-
* Issues: [Project issues](https://github.com/suryart/
|
53
|
+
* Issues: [Project issues](https://github.com/suryart/spree_sort_products/issues)
|
54
54
|
|
55
55
|
## Testing
|
56
56
|
|
57
57
|
Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
59
|
+
```shell
|
60
|
+
bundle
|
61
|
+
bundle exec rake test_app
|
62
|
+
bundle exec rspec spec
|
63
|
+
```
|
64
|
+
|
65
|
+
When testing your applications integration with this extension you may use it's factories.
|
66
|
+
Simply add this require statement to your spec_helper:
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
require 'spree_sort_products/factories'
|
70
|
+
```
|
62
71
|
|
63
72
|
## Contributing
|
64
73
|
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'spree/testing_support/extension_rake'
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new
|
8
|
+
|
9
|
+
task :default => [:spec]
|
10
|
+
|
11
|
+
desc 'Generates a dummy app for testing'
|
12
|
+
task :test_app do
|
13
|
+
ENV['LIB_NAME'] = 'spree_sort_products'
|
14
|
+
Rake::Task['extension:test_app'].invoke
|
15
|
+
end
|
data/Versionfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# This file is used to designate compatibilty with different versions of Spree
|
2
|
+
# Please see http://spreecommerce.com/documentation/extensions.html#versionfile for details
|
3
|
+
|
4
|
+
# Examples
|
5
|
+
#
|
6
|
+
# '1.2.x' => { :branch => 'master' }
|
7
|
+
# '1.1.x' => { :branch => '1-1-stable' }
|
8
|
+
# '1.0.x' => { :branch => '1-0-stable' }
|
9
|
+
# '0.70.x' => { :branch => '0-70-stable' }
|
10
|
+
# '0.40.x' => { :tag => 'v1.0.0', :version => '1.0.0' }
|
11
|
+
|
12
|
+
'1.3.x' => { :branch => '1-3-stable' }
|
13
|
+
'2.0.x' => { :branch => '2-0-stable' }
|
@@ -1,2 +1,2 @@
|
|
1
|
-
//= require admin/
|
1
|
+
//= require admin/spree_backend
|
2
2
|
//= require jquery-dragsort
|
@@ -0,0 +1,28 @@
|
|
1
|
+
root = exports ? this
|
2
|
+
|
3
|
+
root.taxon_tree_menu = (obj, context) ->
|
4
|
+
|
5
|
+
base_url = Spree.url(Spree.routes.taxonomy_taxons_path)
|
6
|
+
admin_base_url = Spree.url(Spree.routes.admin_taxonomy_taxons_path)
|
7
|
+
edit_url = admin_base_url.clone()
|
8
|
+
edit_url.setPath(edit_url.path() + '/' + obj.attr("id") + "/edit");
|
9
|
+
sort_url = admin_base_url.clone()
|
10
|
+
sort_url.setPath(sort_url.path() + '/' + obj.attr("id") + "/sort_products");
|
11
|
+
|
12
|
+
create:
|
13
|
+
label: "<i class='icon-plus'></i> " + Spree.translations.add,
|
14
|
+
action: (obj) -> context.create(obj)
|
15
|
+
rename:
|
16
|
+
label: "<i class='icon-pencil'></i> " + Spree.translations.rename,
|
17
|
+
action: (obj) -> context.rename(obj)
|
18
|
+
remove:
|
19
|
+
label: "<i class='icon-trash'></i> " + Spree.translations.remove,
|
20
|
+
action: (obj) -> context.remove(obj)
|
21
|
+
sort:
|
22
|
+
separator_before: true,
|
23
|
+
label: "<i class='icon-th'></i> " + Spree.taxonomy_translations.sort_products,
|
24
|
+
action: (obj) -> window.location = sort_url
|
25
|
+
edit:
|
26
|
+
separator_before: true,
|
27
|
+
label: "<i class='icon-edit'></i> " + Spree.translations.edit,
|
28
|
+
action: (obj) -> window.location = edit_url.toString()
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Spree
|
2
2
|
module Admin
|
3
|
-
|
3
|
+
TaxonsController.class_eval do
|
4
4
|
before_filter :load_taxon, :only => [:sort_products, :update_products]
|
5
5
|
|
6
6
|
def sort_products
|
@@ -8,13 +8,13 @@ module Spree
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def update_products
|
11
|
-
products = @taxon.
|
12
|
-
product_ids_positions = params[:product_positions].split(",").map(&:to_i)
|
11
|
+
products = @taxon.classifications
|
12
|
+
product_ids_positions = params[:product_positions].split(",").reject(&:blank?).map(&:to_i)
|
13
13
|
product_ids_positions.each_with_index do |id, index|
|
14
14
|
product = products.detect{|p| p.product_id == id }
|
15
15
|
product.update_attributes(:position => index) unless product.nil?
|
16
16
|
end
|
17
|
-
redirect_to sort_products_taxons_path(@taxonomy, @taxon.id), :notice => t(:sort_products_taxons_update_message)
|
17
|
+
redirect_to sort_products_taxons_path(@taxonomy.id, @taxon.id), :notice => t(:sort_products_taxons_update_message)
|
18
18
|
end
|
19
19
|
|
20
20
|
def load_taxon
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module Spree
|
2
2
|
Taxon.class_eval do
|
3
|
-
has_many :
|
4
|
-
has_many :products, :through => :products_taxons, :order => 'spree_products_taxons.position'
|
3
|
+
has_many :products, :through => :classifications, :order => 'spree_products_taxons.position'
|
5
4
|
end
|
6
5
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<% content_for :head do %>
|
2
|
+
<%= javascript_include_tag 'admin/taxon_tree_menu_overrides' %>
|
3
|
+
<%= render :partial => 'spree/admin/shared/taxonomy_translations' %>
|
4
|
+
|
5
|
+
<%= javascript_tag do -%>
|
6
|
+
var initial = [
|
7
|
+
{ "attr" :
|
8
|
+
{ "id" : "<%= @taxonomy.root.id %>", "rel" : "root" },
|
9
|
+
"data" : "<%= escape_javascript(raw(@taxonomy.root.name)) %>",
|
10
|
+
"state" : "open",
|
11
|
+
"children" : [
|
12
|
+
<% @taxonomy.root.children.each_with_index do |taxon,i| %>
|
13
|
+
{
|
14
|
+
"attr" :
|
15
|
+
{ "id" : "<%= taxon.id %>"},
|
16
|
+
"data" : "<%= escape_javascript(raw(taxon.name)) %>"
|
17
|
+
<% unless taxon.children.empty? %>
|
18
|
+
,"state" : "closed"
|
19
|
+
<% end %>
|
20
|
+
}<%= ',' if i < (@taxonomy.root.children.size - 1) %>
|
21
|
+
<% end %>
|
22
|
+
]
|
23
|
+
}
|
24
|
+
];
|
25
|
+
<% end -%>
|
26
|
+
<% end %>
|
data/config/routes.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
Spree::Core::Engine.routes.draw do
|
2
2
|
# Add extension routes here
|
3
|
-
|
4
|
-
|
5
|
-
match 'admin/taxonomies/:taxonomy_id/taxons/:id/update_products/' => 'admin/taxons#update_products', :as => :update_products_admin_taxonomy_taxon, :method => :post
|
3
|
+
get '/admin/taxonomies/:taxonomy_id/taxons/:id/sort_products' => 'admin/taxons#sort_products', :as => :sort_products_taxons
|
4
|
+
post '/admin/taxonomies/:taxonomy_id/taxons/:id/update_products' => 'admin/taxons#update_products', :as => :update_products_admin_taxonomy_taxon
|
6
5
|
|
7
6
|
end
|
@@ -2,6 +2,8 @@ module SpreeSortProducts
|
|
2
2
|
module Generators
|
3
3
|
class InstallGenerator < Rails::Generators::Base
|
4
4
|
|
5
|
+
class_option :auto_run_migrations, :type => :boolean, :default => false
|
6
|
+
|
5
7
|
def add_javascripts
|
6
8
|
append_file 'app/assets/javascripts/admin/all.js', "//= require admin/spree_sort_products\n"
|
7
9
|
end
|
@@ -15,12 +17,12 @@ module SpreeSortProducts
|
|
15
17
|
end
|
16
18
|
|
17
19
|
def run_migrations
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
|
21
|
+
if run_migrations
|
22
|
+
run 'bundle exec rake db:migrate'
|
23
|
+
else
|
24
|
+
puts 'Skipping rake db:migrate, don\'t forget to run it!'
|
25
|
+
end
|
24
26
|
end
|
25
27
|
end
|
26
28
|
end
|
@@ -12,7 +12,7 @@ module SpreeSortProducts
|
|
12
12
|
end
|
13
13
|
|
14
14
|
initializer :assets do |config|
|
15
|
-
Rails.application.config.assets.precompile += %w(admin/
|
15
|
+
Rails.application.config.assets.precompile += %w(admin/taxon_tree_menu_overrides admin/sort_products)
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.activate
|
@@ -0,0 +1,19 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
# Example adding this to your spec_helper will load these Factories for use:
|
3
|
+
# require 'spree_sort_products/factories'
|
4
|
+
|
5
|
+
sequence :name do |n|
|
6
|
+
"Taxon #{n}"
|
7
|
+
end
|
8
|
+
|
9
|
+
factory :products_with_taxon, :class => Spree::Taxonomy do
|
10
|
+
name
|
11
|
+
after(:create) do |taxonomy|
|
12
|
+
taxon = taxonomy.root
|
13
|
+
1.upto(10).each do |i|
|
14
|
+
product = FactoryGirl.create(:product)
|
15
|
+
taxon.products << product unless taxon.products.include? product
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/script/rails
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
2
|
+
|
3
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
4
|
+
ENGINE_PATH = File.expand_path('../../lib/spree_sort_products/engine', __FILE__)
|
5
|
+
|
6
|
+
require 'rails/all'
|
7
|
+
require 'rails/engine/commands'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Taxon' do
|
4
|
+
stub_authorization!
|
5
|
+
|
6
|
+
context 'admin should be able sort products within a taxon' do
|
7
|
+
it 'goes in a taxon and sort products' do
|
8
|
+
create_list(:products_with_taxon, 4)
|
9
|
+
|
10
|
+
visit spree.admin_path
|
11
|
+
|
12
|
+
click_link "Configuration"
|
13
|
+
|
14
|
+
click_link "Taxonomies"
|
15
|
+
|
16
|
+
# sleep(10)
|
17
|
+
# need to write drag and drop and expected result check here
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# Run Coverage report
|
2
|
+
require 'coveralls'
|
3
|
+
Coveralls.wear!
|
4
|
+
|
5
|
+
require 'simplecov'
|
6
|
+
SimpleCov.start do
|
7
|
+
add_group 'Controllers', 'app/controllers'
|
8
|
+
add_group 'Helpers', 'app/helpers'
|
9
|
+
add_group 'Mailers', 'app/mailers'
|
10
|
+
add_group 'Models', 'app/models'
|
11
|
+
add_group 'Views', 'app/views'
|
12
|
+
add_group 'Libraries', 'lib'
|
13
|
+
end
|
14
|
+
|
15
|
+
# Configure Rails Environment
|
16
|
+
ENV['RAILS_ENV'] = 'test'
|
17
|
+
|
18
|
+
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
19
|
+
|
20
|
+
require 'rspec/rails'
|
21
|
+
require 'database_cleaner'
|
22
|
+
require 'ffaker'
|
23
|
+
require 'factory_girl'
|
24
|
+
FactoryGirl.find_definitions
|
25
|
+
|
26
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
27
|
+
# in spec/support/ and its subdirectories.
|
28
|
+
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
|
29
|
+
|
30
|
+
# Requires factories defined in spree_core
|
31
|
+
require 'spree/testing_support/factories'
|
32
|
+
require 'spree/testing_support/controller_requests'
|
33
|
+
require 'spree/testing_support/authorization_helpers'
|
34
|
+
require 'spree/testing_support/url_helpers'
|
35
|
+
require 'spree/testing_support/order_walkthrough'
|
36
|
+
|
37
|
+
# Requires factories defined in lib/spree_sort_products/factories.rb
|
38
|
+
require 'spree_sort_products/factories'
|
39
|
+
|
40
|
+
RSpec.configure do |config|
|
41
|
+
config.include FactoryGirl::Syntax::Methods
|
42
|
+
|
43
|
+
# == URL Helpers
|
44
|
+
#
|
45
|
+
# Allows access to Spree's routes in specs:
|
46
|
+
#
|
47
|
+
# visit spree.admin_path
|
48
|
+
# current_path.should eql(spree.products_path)
|
49
|
+
# config.include Spree::TestingSupport::UrlHelpers
|
50
|
+
config.include Spree::TestingSupport::AuthorizationHelpers
|
51
|
+
config.include Spree::TestingSupport::UrlHelpers
|
52
|
+
config.include Spree::TestingSupport::ControllerRequests
|
53
|
+
config.include Spree::TestingSupport::Preferences
|
54
|
+
config.include Spree::TestingSupport::Flash
|
55
|
+
config.include Capybara::DSL
|
56
|
+
|
57
|
+
# == Mock Framework
|
58
|
+
#
|
59
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
60
|
+
#
|
61
|
+
# config.mock_with :mocha
|
62
|
+
# config.mock_with :flexmock
|
63
|
+
# config.mock_with :rr
|
64
|
+
config.mock_with :rspec
|
65
|
+
config.color = true
|
66
|
+
|
67
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
68
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
69
|
+
|
70
|
+
# Capybara javascript drivers require transactional fixtures set to false, and we use DatabaseCleaner
|
71
|
+
# to cleanup after each test instead. Without transactional fixtures set to false the records created
|
72
|
+
# to setup a test will be unavailable to the browser, which runs under a seperate server instance.
|
73
|
+
config.use_transactional_fixtures = false
|
74
|
+
|
75
|
+
# Ensure Suite is set to use transactions for speed.
|
76
|
+
config.before :suite do
|
77
|
+
DatabaseCleaner.strategy = :transaction
|
78
|
+
DatabaseCleaner.clean_with :truncation
|
79
|
+
end
|
80
|
+
|
81
|
+
# Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
|
82
|
+
config.before :each do
|
83
|
+
DatabaseCleaner.strategy = example.metadata[:js] ? :truncation : :transaction
|
84
|
+
DatabaseCleaner.start
|
85
|
+
reset_spree_preferences
|
86
|
+
end
|
87
|
+
|
88
|
+
# After each spec clean the database.
|
89
|
+
config.after :each do
|
90
|
+
DatabaseCleaner.clean
|
91
|
+
end
|
92
|
+
|
93
|
+
config.fail_fast = ENV['FAIL_FAST'] || false
|
94
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.platform = Gem::Platform::RUBY
|
4
|
+
s.name = 'spree_sort_products'
|
5
|
+
s.version = '2.0.0'
|
6
|
+
s.summary = 'Spree Sort Products gives you ability to sort products with in a taxon for spree.'
|
7
|
+
s.description = 'Spree Sort Products extends the ability of a taxon on its products to be sorted from the web interface using the drag and drop behavior.'
|
8
|
+
s.required_ruby_version = '>= 1.9.2'
|
9
|
+
|
10
|
+
s.author = 'Surya Tripathi'
|
11
|
+
s.email = 'raj.surya19@gmail.com'
|
12
|
+
s.homepage = 'https://github.com/suryart/spree_sort_products'
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.require_path = 'lib'
|
17
|
+
s.requirements << 'none'
|
18
|
+
|
19
|
+
s.add_dependency 'spree_core', '~> 2.0.0'
|
20
|
+
s.add_dependency 'jquery-dragsort-rails', '~> 1.0.0'
|
21
|
+
|
22
|
+
s.add_development_dependency 'capybara', '~> 2.1'
|
23
|
+
s.add_development_dependency 'coffee-rails'
|
24
|
+
s.add_development_dependency 'database_cleaner', '1.0.1'
|
25
|
+
s.add_development_dependency 'factory_girl', '~> 4.2'
|
26
|
+
s.add_development_dependency 'ffaker'
|
27
|
+
s.add_development_dependency 'rspec-rails', '~> 2.13'
|
28
|
+
s.add_development_dependency 'sass-rails'
|
29
|
+
s.add_development_dependency 'selenium-webdriver'
|
30
|
+
s.add_development_dependency 'simplecov'
|
31
|
+
s.add_development_dependency 'sqlite3'
|
32
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_sort_products
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Surya Tripathi
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 2.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: jquery-dragsort-rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 2.
|
47
|
+
version: '2.1'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
54
|
+
version: '2.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: coffee-rails
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,19 +67,33 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: database_cleaner
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.0.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.0.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: factory_girl
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - ~>
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: 4.2
|
89
|
+
version: '4.2'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
94
|
- - ~>
|
81
95
|
- !ruby/object:Gem::Version
|
82
|
-
version: 4.2
|
96
|
+
version: '4.2'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: ffaker
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,30 +114,44 @@ dependencies:
|
|
100
114
|
requirements:
|
101
115
|
- - ~>
|
102
116
|
- !ruby/object:Gem::Version
|
103
|
-
version: '2.
|
117
|
+
version: '2.13'
|
104
118
|
type: :development
|
105
119
|
prerelease: false
|
106
120
|
version_requirements: !ruby/object:Gem::Requirement
|
107
121
|
requirements:
|
108
122
|
- - ~>
|
109
123
|
- !ruby/object:Gem::Version
|
110
|
-
version: '2.
|
124
|
+
version: '2.13'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
126
|
+
name: sass-rails
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
114
128
|
requirements:
|
115
|
-
- -
|
129
|
+
- - '>='
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
131
|
+
version: '0'
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
|
-
- -
|
136
|
+
- - '>='
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
138
|
+
version: '0'
|
125
139
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
140
|
+
name: selenium-webdriver
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: simplecov
|
127
155
|
requirement: !ruby/object:Gem::Requirement
|
128
156
|
requirements:
|
129
157
|
- - '>='
|
@@ -157,26 +185,38 @@ executables: []
|
|
157
185
|
extensions: []
|
158
186
|
extra_rdoc_files: []
|
159
187
|
files:
|
188
|
+
- .gitignore
|
189
|
+
- .rspec
|
190
|
+
- .travis.yml
|
191
|
+
- Gemfile
|
160
192
|
- LICENSE
|
161
193
|
- README.md
|
162
|
-
-
|
163
|
-
-
|
164
|
-
- app/models/spree/products_taxon.rb
|
165
|
-
- app/assets/stylesheets/admin/spree_sort_products.css
|
166
|
-
- app/assets/javascripts/admin/taxonomy_overrides.js
|
167
|
-
- app/assets/javascripts/admin/spree_sort_products.js
|
194
|
+
- Rakefile
|
195
|
+
- Versionfile
|
168
196
|
- app/assets/javascripts/admin/sort_products.js.coffee.erb
|
197
|
+
- app/assets/javascripts/admin/spree_sort_products.js
|
198
|
+
- app/assets/javascripts/admin/taxon_tree_menu_overrides.js.coffee
|
199
|
+
- app/assets/stylesheets/admin/spree_sort_products.css
|
200
|
+
- app/controllers/spree/admin/taxons_controller_decorator.rb
|
201
|
+
- app/models/spree/classification_decorator.rb
|
202
|
+
- app/models/spree/products_taxon.rb
|
203
|
+
- app/models/spree/taxon_decorator.rb
|
204
|
+
- app/overrides/add_sort_products_link.rb
|
169
205
|
- app/spree.rb
|
170
206
|
- app/views/spree/admin/shared/_taxonomy_translations.html.erb
|
207
|
+
- app/views/spree/admin/taxonomies/_sort_products_js.erb
|
171
208
|
- app/views/spree/admin/taxons/sort_products.html.erb
|
172
|
-
- app/views/spree/admin/taxonomies/edit.erb
|
173
|
-
- app/controllers/spree/admin/taxons_controller_decorator.rb
|
174
|
-
- config/routes.rb
|
175
209
|
- config/locales/en.yml
|
176
|
-
-
|
210
|
+
- config/routes.rb
|
211
|
+
- db/migrate/20130417071146_create_products_taxons.rb
|
177
212
|
- lib/generators/spree_sort_products/install/install_generator.rb
|
178
213
|
- lib/spree_sort_products.rb
|
179
|
-
-
|
214
|
+
- lib/spree_sort_products/engine.rb
|
215
|
+
- lib/spree_sort_products/factories.rb
|
216
|
+
- script/rails
|
217
|
+
- spec/features/sort_products_spec.rb
|
218
|
+
- spec/spec_helper.rb
|
219
|
+
- spree_sort_products.gemspec
|
180
220
|
homepage: https://github.com/suryart/spree_sort_products
|
181
221
|
licenses: []
|
182
222
|
metadata: {}
|
@@ -197,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
197
237
|
requirements:
|
198
238
|
- none
|
199
239
|
rubyforge_project:
|
200
|
-
rubygems_version: 2.0.
|
240
|
+
rubygems_version: 2.0.3
|
201
241
|
signing_key:
|
202
242
|
specification_version: 4
|
203
243
|
summary: Spree Sort Products gives you ability to sort products with in a taxon for
|
@@ -1,137 +0,0 @@
|
|
1
|
-
var taxonomy_id;
|
2
|
-
|
3
|
-
$(document).ready(function(){
|
4
|
-
if(taxonomy_id!=undefined){
|
5
|
-
|
6
|
-
base_url = $("#taxonomy_tree").data("url").split("?")[0] + "/" ;
|
7
|
-
child_url = base_url.replace("/taxons", "/get_children.json");
|
8
|
-
|
9
|
-
is_cut = false;
|
10
|
-
last_rollback = null;
|
11
|
-
|
12
|
-
var conf = {
|
13
|
-
json_data : {
|
14
|
-
"data" : initial,
|
15
|
-
"ajax" : {
|
16
|
-
"url" : child_url,
|
17
|
-
"data" : function (n) {
|
18
|
-
return { parent_id : n.attr ? n.attr("id") : 0 };
|
19
|
-
}
|
20
|
-
}
|
21
|
-
},
|
22
|
-
"themes" : {
|
23
|
-
"theme" : "apple",
|
24
|
-
"url" : "/assets/jquery.jstree/themes/apple/style.css"
|
25
|
-
},
|
26
|
-
"strings" : {
|
27
|
-
"new_node" : new_taxon,
|
28
|
-
"loading" : Spree.translations.loading + "..."
|
29
|
-
},
|
30
|
-
"crrm" : {
|
31
|
-
"move" : {
|
32
|
-
"check_move" : function (m) {
|
33
|
-
var position = m.cp;
|
34
|
-
var node = m.o;
|
35
|
-
var new_parent = m.np;
|
36
|
-
|
37
|
-
if(!new_parent) return false; //no parent
|
38
|
-
|
39
|
-
if(node.attr("rel")=="root") return false; //can't drag root
|
40
|
-
|
41
|
-
if(new_parent.attr("id")=="taxonomy_tree" && position==0) return false; // can't drop before root
|
42
|
-
|
43
|
-
return true;
|
44
|
-
|
45
|
-
}
|
46
|
-
}
|
47
|
-
},
|
48
|
-
"contextmenu" : {
|
49
|
-
"items" : function(obj) {
|
50
|
-
var id_of_node = obj.attr("id");
|
51
|
-
var type_of_node = obj.attr("rel");
|
52
|
-
var menu = {};
|
53
|
-
if(type_of_node == "root") {
|
54
|
-
menu = {
|
55
|
-
"create" : {
|
56
|
-
"label" : "<i class='icon-plus'></i> " + Spree.translations.add,
|
57
|
-
"action" : function (obj) { this.create(obj); }
|
58
|
-
},
|
59
|
-
"paste" : {
|
60
|
-
"separator_before" : true,
|
61
|
-
"label" : "<i class='icon-paste'></i> " + Spree.translations.paste,
|
62
|
-
"action" : function (obj) { is_cut = false; this.paste(obj); },
|
63
|
-
"_disabled" : is_cut == false
|
64
|
-
},
|
65
|
-
"edit" : {
|
66
|
-
"separator_before" : true,
|
67
|
-
"label" : "<i class='icon-edit'></i> " + Spree.translations.edit,
|
68
|
-
"action" : function (obj) { window.location = base_url + obj.attr("id") + "/edit/"; }
|
69
|
-
},
|
70
|
-
"sort" : {
|
71
|
-
"separator_before" : true,
|
72
|
-
"label" : "<i class='icon-th'></i> " + Spree.taxonomy_translations.sort_products,
|
73
|
-
"action" : function (obj) { window.location = base_url + obj.attr("id") + "/sort_products/"; }
|
74
|
-
}
|
75
|
-
}
|
76
|
-
} else {
|
77
|
-
menu = {
|
78
|
-
"create" : {
|
79
|
-
"label" : "<i class='icon-plus'></i> " + Spree.translations.add,
|
80
|
-
"action" : function (obj) { this.create(obj); }
|
81
|
-
},
|
82
|
-
"rename" : {
|
83
|
-
"label" : "<i class='icon-pencil'></i> " + Spree.translations.rename,
|
84
|
-
"action" : function (obj) { this.rename(obj); }
|
85
|
-
},
|
86
|
-
"remove" : {
|
87
|
-
"label" : "<i class='icon-trash'></i> " + Spree.translations.remove,
|
88
|
-
"action" : function (obj) { this.remove(obj); }
|
89
|
-
},
|
90
|
-
"cut" : {
|
91
|
-
"separator_before" : true,
|
92
|
-
"label" : "<i class='icon-cut'></i> " + Spree.translations.cut,
|
93
|
-
"action" : function (obj) { is_cut = true; this.cut(obj); }
|
94
|
-
},
|
95
|
-
"paste" : {
|
96
|
-
"label" : "<i class='icon-paste'></i> " + Spree.translations.paste,
|
97
|
-
"action" : function (obj) { is_cut = false; this.paste(obj); },
|
98
|
-
"_disabled" : is_cut == false
|
99
|
-
},
|
100
|
-
"edit" : {
|
101
|
-
"separator_before" : true,
|
102
|
-
"label" : "<i class='icon-edit'></i> " + Spree.translations.edit,
|
103
|
-
"action" : function (obj) { window.location = base_url + obj.attr("id") + "/edit/"; }
|
104
|
-
},
|
105
|
-
"sort" : {
|
106
|
-
"separator_before" : true,
|
107
|
-
"label" : "<i class='icon-th'></i> " + Spree.taxonomy_translations.sort_products,
|
108
|
-
"action" : function (obj) { window.location = base_url + obj.attr("id") + "/sort_products/"; }
|
109
|
-
}
|
110
|
-
}
|
111
|
-
}
|
112
|
-
return menu;
|
113
|
-
}
|
114
|
-
},
|
115
|
-
|
116
|
-
"plugins" : [ "themes", "json_data", "dnd", "crrm", "contextmenu"]
|
117
|
-
}
|
118
|
-
|
119
|
-
$("#taxonomy_tree").jstree(conf)
|
120
|
-
.bind("move_node.jstree", handle_move)
|
121
|
-
.bind("remove.jstree", handle_delete)
|
122
|
-
.bind("create.jstree", handle_create)
|
123
|
-
.bind("rename.jstree", handle_rename);
|
124
|
-
|
125
|
-
$("#taxonomy_tree a").on("dblclick", function (e) {
|
126
|
-
$("#taxonomy_tree").jstree("rename", this)
|
127
|
-
});
|
128
|
-
|
129
|
-
|
130
|
-
$(document).keypress(function(e){
|
131
|
-
//surpress form submit on enter/return
|
132
|
-
if (e.keyCode == 13){
|
133
|
-
e.preventDefault();
|
134
|
-
}
|
135
|
-
});
|
136
|
-
}
|
137
|
-
});
|
@@ -1,65 +0,0 @@
|
|
1
|
-
<%= render :partial => 'spree/admin/shared/configuration_menu' %>
|
2
|
-
|
3
|
-
<%= render :partial => 'js_head' %>
|
4
|
-
|
5
|
-
<% content_for :page_title do %>
|
6
|
-
<%= t(:taxonomy_edit) %>
|
7
|
-
<% end %>
|
8
|
-
|
9
|
-
<% content_for :page_actions do %>
|
10
|
-
<li>
|
11
|
-
<%= button_link_to t(:back_to_taxonomies_list), spree.admin_taxonomies_path, :icon => 'icon-arrow-left' %>
|
12
|
-
</li>
|
13
|
-
<% end %>
|
14
|
-
|
15
|
-
<div id="ajax_error" class="errorExplanation" style="display:none;"></div>
|
16
|
-
|
17
|
-
<%= form_for [:admin, @taxonomy] do |f| %>
|
18
|
-
<fieldset class="no-border-top">
|
19
|
-
<%= render :partial => 'form', :locals => { :f => f } %>
|
20
|
-
<div>
|
21
|
-
<%= label_tag nil, t(:tree) %><br />
|
22
|
-
<div id="taxonomy_tree" class="tree" data-url="<%= admin_taxonomy_taxons_path @taxonomy %>"></div>
|
23
|
-
</div>
|
24
|
-
<div id="progress" style="display:none;">
|
25
|
-
<%= image_tag 'spinner.gif', :title => 'Spinner', :style => "vertical-align:bottom;" %> <%= t(:updating) %>..
|
26
|
-
</div>
|
27
|
-
|
28
|
-
<div class="info"><%= t(:taxonomy_tree_instruction) %></div>
|
29
|
-
|
30
|
-
<br>
|
31
|
-
|
32
|
-
<div class="filter-actions actions">
|
33
|
-
<%= button t(:update), 'icon-refresh' %>
|
34
|
-
<span class="or"><%= t(:or) %></span>
|
35
|
-
<%= button_link_to t(:cancel), admin_taxonomies_path, :icon => 'icon-remove' %>
|
36
|
-
</div>
|
37
|
-
</fieldset>
|
38
|
-
<% end %>
|
39
|
-
|
40
|
-
<% content_for :head do %>
|
41
|
-
<%= javascript_include_tag 'admin/taxonomy_overrides' %>
|
42
|
-
<%= render :partial => 'spree/admin/shared/taxonomy_translations' %>
|
43
|
-
|
44
|
-
<%= javascript_tag do -%>
|
45
|
-
var initial = [
|
46
|
-
{ "attr" :
|
47
|
-
{ "id" : "<%= @taxonomy.root.id %>", "rel" : "root" },
|
48
|
-
"data" : "<%= escape_javascript(raw(@taxonomy.root.name)) %>",
|
49
|
-
"state" : "open",
|
50
|
-
"children" : [
|
51
|
-
<% @taxonomy.root.children.each_with_index do |taxon,i| %>
|
52
|
-
{
|
53
|
-
"attr" :
|
54
|
-
{ "id" : "<%= taxon.id %>"},
|
55
|
-
"data" : "<%= escape_javascript(raw(taxon.name)) %>"
|
56
|
-
<% unless taxon.children.empty? %>
|
57
|
-
,"state" : "closed"
|
58
|
-
<% end %>
|
59
|
-
}<%= ',' if i < (@taxonomy.root.children.size - 1) %>
|
60
|
-
<% end %>
|
61
|
-
]
|
62
|
-
}
|
63
|
-
];
|
64
|
-
<% end -%>
|
65
|
-
<% end %>
|