spree_promo 1.3.0.rc1 → 1.3.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/admin/product_picker.js +31 -0
- data/app/assets/javascripts/admin/spree_promo.js +2 -37
- data/app/assets/javascripts/admin/user_picker.js +31 -0
- data/app/models/spree/promotion/rules/first_order.rb +11 -1
- data/app/views/spree/admin/promotion_actions/create.js.erb +5 -5
- data/app/views/spree/admin/promotion_rules/create.js.erb +2 -8
- data/app/views/spree/admin/promotions/rules/_product.html.erb +2 -2
- metadata +8 -5
@@ -0,0 +1,31 @@
|
|
1
|
+
$.fn.productAutocomplete = function() {
|
2
|
+
this.select2({
|
3
|
+
minimumInputLength: 1,
|
4
|
+
multiple: true,
|
5
|
+
initSelection: function(element, callback) {
|
6
|
+
$.get(Spree.routes.product_search, { ids: element.val() }, function(data) {
|
7
|
+
callback(data)
|
8
|
+
})
|
9
|
+
},
|
10
|
+
ajax: {
|
11
|
+
url: Spree.routes.product_search,
|
12
|
+
datatype: 'json',
|
13
|
+
data: function(term, page) {
|
14
|
+
return { q: term }
|
15
|
+
},
|
16
|
+
results: function(data, page) {
|
17
|
+
return { results: data }
|
18
|
+
}
|
19
|
+
},
|
20
|
+
formatResult: function(product) {
|
21
|
+
return product.name;
|
22
|
+
},
|
23
|
+
formatSelection: function(product) {
|
24
|
+
return product.name;
|
25
|
+
}
|
26
|
+
});
|
27
|
+
}
|
28
|
+
|
29
|
+
$(document).ready(function () {
|
30
|
+
$('.product_picker').productAutocomplete();
|
31
|
+
})
|
@@ -1,39 +1,4 @@
|
|
1
1
|
//= require admin/spree_core
|
2
|
+
//= require admin/user_picker
|
3
|
+
//= require admin/product_picker
|
2
4
|
//= require_tree .
|
3
|
-
|
4
|
-
function cleanUsers(data) {
|
5
|
-
var users = $.map(data['users'], function(result) {
|
6
|
-
return result['user']
|
7
|
-
})
|
8
|
-
return users;
|
9
|
-
}
|
10
|
-
|
11
|
-
$(document).ready(function() {
|
12
|
-
if ($('user_picker').length > 0) {
|
13
|
-
$('.user_picker').select2({
|
14
|
-
minimumInputLength: 1,
|
15
|
-
multiple: true,
|
16
|
-
initSelection: function(element, callback) {
|
17
|
-
$.get(Spree.routes.user_search, { ids: element.val() }, function(data) {
|
18
|
-
callback(cleanUsers(data))
|
19
|
-
})
|
20
|
-
},
|
21
|
-
ajax: {
|
22
|
-
url: Spree.routes.user_search,
|
23
|
-
datatype: 'json',
|
24
|
-
data: function(term, page) {
|
25
|
-
return { q: term }
|
26
|
-
},
|
27
|
-
results: function(data, page) {
|
28
|
-
return { results: cleanUsers(data) }
|
29
|
-
}
|
30
|
-
},
|
31
|
-
formatResult: function(user) {
|
32
|
-
return user.email;
|
33
|
-
},
|
34
|
-
formatSelection: function(user) {
|
35
|
-
return user.email;
|
36
|
-
}
|
37
|
-
});
|
38
|
-
}
|
39
|
-
})
|
@@ -0,0 +1,31 @@
|
|
1
|
+
$.fn.userAutocomplete = function() {
|
2
|
+
this.select2({
|
3
|
+
minimumInputLength: 1,
|
4
|
+
multiple: true,
|
5
|
+
initSelection: function(element, callback) {
|
6
|
+
$.get(Spree.routes.user_search, { ids: element.val() }, function(data) {
|
7
|
+
callback(data)
|
8
|
+
})
|
9
|
+
},
|
10
|
+
ajax: {
|
11
|
+
url: Spree.routes.user_search,
|
12
|
+
datatype: 'json',
|
13
|
+
data: function(term, page) {
|
14
|
+
return { q: term }
|
15
|
+
},
|
16
|
+
results: function(data, page) {
|
17
|
+
return { results: data }
|
18
|
+
}
|
19
|
+
},
|
20
|
+
formatResult: function(user) {
|
21
|
+
return user.email;
|
22
|
+
},
|
23
|
+
formatSelection: function(user) {
|
24
|
+
return user.email;
|
25
|
+
}
|
26
|
+
});
|
27
|
+
}
|
28
|
+
|
29
|
+
$(document).ready(function () {
|
30
|
+
$('.user_picker').userAutocomplete();
|
31
|
+
})
|
@@ -4,7 +4,17 @@ module Spree
|
|
4
4
|
class FirstOrder < PromotionRule
|
5
5
|
def eligible?(order, options = {})
|
6
6
|
user = order.try(:user) || options[:user]
|
7
|
-
|
7
|
+
if user
|
8
|
+
return orders_by_email(user.email) == 0
|
9
|
+
elsif order.email
|
10
|
+
return orders_by_email(order.email) == 0
|
11
|
+
end
|
12
|
+
|
13
|
+
return false
|
14
|
+
end
|
15
|
+
|
16
|
+
def orders_by_email(email)
|
17
|
+
Spree::Order.where(:email => email).count
|
8
18
|
end
|
9
19
|
end
|
10
20
|
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
$('#actions').append('<%= escape_javascript( render(:partial => 'spree/admin/promotions/promotion_action', :object => @promotion_action) ) %>');
|
2
2
|
$('#actions .no-objects-found').hide();
|
3
|
+
$(document).ready(function(){
|
4
|
+
$(".variant_autocomplete").variantAutocomplete();
|
5
|
+
});
|
3
6
|
initProductActions();
|
4
7
|
|
5
|
-
|
6
|
-
$('.type-select.select2').select2();
|
7
|
-
<% end %>
|
8
|
+
$('.type-select.select2').select2();
|
8
9
|
|
9
10
|
$('#<%= dom_id @promotion_action %>').hide();
|
10
11
|
$('#<%= dom_id @promotion_action %>').fadeIn();
|
11
|
-
|
12
|
-
$('.product_autocomplete').product_autocomplete();
|
12
|
+
|
@@ -1,13 +1,7 @@
|
|
1
1
|
$('#rules').append('<%= escape_javascript( render(:partial => 'spree/admin/promotions/promotion_rule', :object => @promotion_rule) ) %>');
|
2
2
|
$('#rules .no-objects-found').hide();
|
3
3
|
|
4
|
-
$('
|
5
|
-
$('
|
6
|
-
$('#<%= dom_id @promotion_rule %> .tokeninput.products').productPicker();
|
7
|
-
$('#<%= dom_id @promotion_rule %> .tokeninput.users').userPicker();
|
4
|
+
$('.product_picker').productAutocomplete();
|
5
|
+
$('.user_picker').userAutocomplete();
|
8
6
|
|
9
7
|
$('#promotion_rule_type').html('<%= escape_javascript options_for_promotion_rule_types(@promotion) %>');
|
10
|
-
|
11
|
-
<% unless Rails.env.test? %>
|
12
|
-
$('.select_item_total.select2, .select_product.select2').select2();
|
13
|
-
<% end %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<div class="field alpha omega eight columns products_rule_products">
|
2
|
-
<%= label_tag t('product_rule.choose_products') %>
|
3
|
-
<%=
|
2
|
+
<%= label_tag "#{param_prefix}_product_ids_string", t('product_rule.choose_products') %>
|
3
|
+
<%= hidden_field_tag "#{param_prefix}[product_ids_string]", promotion_rule.product_ids.join(","), :class => "product_picker fullwidth" %>
|
4
4
|
</div>
|
5
5
|
<div class="field alpha omega eight columns">
|
6
6
|
<label>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_promo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.0.
|
4
|
+
version: 1.3.0.rc2
|
5
5
|
prerelease: 6
|
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-12-
|
12
|
+
date: 2012-12-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spree_core
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.3.0.
|
21
|
+
version: 1.3.0.rc2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.3.0.
|
29
|
+
version: 1.3.0.rc2
|
30
30
|
description: Required dependency for Spree
|
31
31
|
email: david@spreecommerce.com
|
32
32
|
executables: []
|
@@ -34,8 +34,10 @@ extensions: []
|
|
34
34
|
extra_rdoc_files: []
|
35
35
|
files:
|
36
36
|
- LICENSE
|
37
|
+
- app/assets/javascripts/admin/product_picker.js
|
37
38
|
- app/assets/javascripts/admin/promotions.js
|
38
39
|
- app/assets/javascripts/admin/spree_promo.js
|
40
|
+
- app/assets/javascripts/admin/user_picker.js
|
39
41
|
- app/assets/javascripts/store/spree_promo.js
|
40
42
|
- app/assets/stylesheets/admin/spree_promo.css
|
41
43
|
- app/assets/stylesheets/store/spree_promo.css
|
@@ -101,7 +103,8 @@ files:
|
|
101
103
|
- lib/spree_promo.rb
|
102
104
|
- db/migrate/20120831092359_spree_promo_one_two.rb
|
103
105
|
homepage: http://spreecommerce.com
|
104
|
-
licenses:
|
106
|
+
licenses:
|
107
|
+
- BSD-3
|
105
108
|
post_install_message:
|
106
109
|
rdoc_options: []
|
107
110
|
require_paths:
|