spree_zoned 0.5.8 → 0.5.9

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.
data/.gitignore CHANGED
@@ -1,4 +1,6 @@
1
1
  *.tmproj
2
+ *.sublime-project
3
+ *.sublime-workspace
2
4
  \#*
3
5
  *~
4
6
  .#*
@@ -2,28 +2,25 @@ module Spree
2
2
  module Admin
3
3
  ProductsController.class_eval do
4
4
 
5
- before_filter :filter_countries, :only => :index
6
-
7
5
  def deletefc
8
- country = session[:zoned] && session[:zoned][:prd_country]
9
- @product.delfrom country.to_i if country
10
- respond_to do |format|
11
- format.html { redirect_to collection_url }
12
- format.js { render :nothing => true }
13
- end
6
+ inorout(@product.method :delfrom)
14
7
  end
15
8
 
9
+ def backtocountry
10
+ inorout(@product.method :backtocountry)
11
+ end
12
+
16
13
  protected
17
-
18
- def filter_countries
14
+
15
+ def inorout(m)
19
16
  country = session[:zoned] && session[:zoned][:prd_country]
20
- if country
21
- collection # returns immediately if already done
22
- newcoll = @collection.select { |p| p.incountry? country.to_i }
23
- @collection = newcoll
17
+ m.call(country.to_i) if country
18
+ respond_to do |format|
19
+ format.html { redirect_to collection_url }
20
+ format.js { render nothing: true }
24
21
  end
25
22
  end
26
-
23
+
27
24
  end
28
25
  end
29
26
  end
@@ -3,7 +3,9 @@ module Spree
3
3
 
4
4
  def index
5
5
  p = params ? params : {}
6
- @searcher = Spree::Config.searcher_class.new(p.merge({zoned_country: (session[:zoned] && session[:zoned][:current_country]) || {}}))
6
+ @searcher = Spree::Config.searcher_class.new(
7
+ p.merge(
8
+ {zoned_country: (session[:zoned] && session[:zoned][:current_country]) || -214 }))
7
9
  @products = @searcher.retrieve_products
8
10
  respond_with(@products)
9
11
  end
@@ -5,15 +5,27 @@ module Spree
5
5
  def link_to_deletefc(resource, options = {}, html_options={})
6
6
  options.assert_valid_keys(:url, :caption, :title, :dataType, :success, :error, :name)
7
7
 
8
- options.reverse_merge! :url => object_url(resource) + '/zoneddfc' unless options.key? :url
9
- options.reverse_merge! :caption => t(:are_you_sure)
10
- options.reverse_merge! :title => t(:confirm_delete)
11
- options.reverse_merge! :dataType => 'script'
12
- options.reverse_merge! :success => "function(r){ $('##{spree_dom_id resource}').fadeOut('hide'); }"
13
- options.reverse_merge! :error => "function(jqXHR, textStatus, errorThrown){ show_flash_error(jqXHR.responseText); }"
14
- options.reverse_merge! :name => icon('delete') + ' ' + t(:deletefc)
8
+ country = session[:zoned] && session[:zoned][:prd_country]
9
+ if country && !resource.incountry?(country.to_i)
10
+ options.reverse_merge! :url => object_url(resource) + '/zonedbtc' unless options.key? :url
11
+ options.reverse_merge! :caption => t(:are_you_sure)
12
+ options.reverse_merge! :title => t(:backtocountry)
13
+ options.reverse_merge! :dataType => 'script'
14
+ options.reverse_merge! :success => "function(r){ location.reload(); }"
15
+ options.reverse_merge! :error => "function(jqXHR, textStatus, errorThrown){ show_flash_error(jqXHR.responseText); }"
16
+ options.reverse_merge! :name => icon('add') + ' ' + t(:backtocountry)
17
+ link_to_function_btc(options, html_options)
18
+ else
19
+ options.reverse_merge! :url => object_url(resource) + '/zoneddfc' unless options.key? :url
20
+ options.reverse_merge! :caption => t(:are_you_sure)
21
+ options.reverse_merge! :title => t(:confirm_delete)
22
+ options.reverse_merge! :dataType => 'script'
23
+ options.reverse_merge! :success => "function(r){ $('##{spree_dom_id resource}').prop('disabled', 'disabled'); location.reload(); }"
24
+ options.reverse_merge! :error => "function(jqXHR, textStatus, errorThrown){ show_flash_error(jqXHR.responseText); }"
25
+ options.reverse_merge! :name => icon('delete') + ' ' + t(:deletefc)
26
+ link_to_function_deletefc(options, html_options)
27
+ end
15
28
 
16
- link_to_function_deletefc(options, html_options)
17
29
  #link_to_function_delete_native(options, html_options)
18
30
  end
19
31
 
@@ -32,6 +44,12 @@ module Spree
32
44
  });", html_options
33
45
  end
34
46
 
47
+ def link_to_function_btc(options, html_options)
48
+ link_to_function options[:name], "jConfirm('#{options[:caption]}', '#{options[:title]}', function(r) {
49
+ if(r){ #{link_to_function_btc_ajax(options)} }
50
+ });", html_options
51
+ end
52
+
35
53
  def link_to_function_deletefc_ajax(options)
36
54
  %Q{
37
55
  $.ajax({
@@ -45,6 +63,19 @@ module Spree
45
63
  }
46
64
  end
47
65
 
66
+ def link_to_function_btc_ajax(options)
67
+ %Q{
68
+ $.ajax({
69
+ type: 'POST',
70
+ url: '#{options[:url]}',
71
+ data: ({_method: 'put', authenticity_token: AUTH_TOKEN}),
72
+ dataType:'#{options[:dataType]}',
73
+ success: #{options[:success]},
74
+ error: #{options[:error]}
75
+ });
76
+ }
77
+ end
78
+
48
79
  end
49
80
  end
50
81
  end
@@ -7,6 +7,16 @@ module Spree
7
7
  end
8
8
 
9
9
  def delfrom(country)
10
+ setorderno country, -1
11
+ end
12
+
13
+ def backtocountry(country)
14
+ setorderno country, 0
15
+ end
16
+
17
+ protected
18
+
19
+ def setorderno(country, ono)
10
20
  clist = Spree::Zoned::Product.where "spree_product_id = ? AND spree_country_id = ?", id, country
11
21
  if clist == []
12
22
  zp = Spree::Zoned::Product.new
@@ -15,9 +25,9 @@ module Spree
15
25
  else
16
26
  zp = clist[0]
17
27
  end
18
- zp.orderno = -1
19
- zp.save!
28
+ zp.orderno = ono
29
+ zp.save
20
30
  end
21
-
31
+
22
32
  end
23
33
  end
@@ -4,4 +4,4 @@
4
4
  de:
5
5
  nocountrysel: "Kein Land ausgewählt"
6
6
  deletefc: "Aus Land löschen"
7
-
7
+ backtocountry: "Wieder ins Land"
@@ -4,3 +4,4 @@
4
4
  en:
5
5
  nocountrysel: "No country selected"
6
6
  deletefc: "Delete from country"
7
+ backtocountry: "Reassign to country"
data/config/routes.rb CHANGED
@@ -3,5 +3,6 @@ Spree::Core::Engine.routes.draw do
3
3
  namespace :admin do
4
4
  match '/zonedcs' => "zoned#setcountry"
5
5
  match '/products/:id/zoneddfc' => "products#deletefc", :via => :delete
6
+ match '/products/:id/zonedbtc' => "products#backtocountry", :via => :put
6
7
  end
7
8
  end
data/spree_zoned.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
  Gem::Specification.new do |s|
3
3
  s.platform = Gem::Platform::RUBY
4
4
  s.name = 'spree_zoned'
5
- s.version = '0.5.8'
5
+ s.version = '0.5.9'
6
6
  s.summary = 'A Spree extension to make your store zoned'
7
7
  s.description = "Everything you need for a zoned Spree store: zoned pricing, zoned products, zoned product ordering, zoned locales, ...\nProbalbly essential to you if you operate outside of the US."
8
8
  s.required_ruby_version = '>= 1.9.2'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_zoned
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.5.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-18 00:00:00.000000000 Z
12
+ date: 2012-06-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: spree_core