solidus_subscription_boxes 0.0.6 → 0.0.7
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/solidus_subscription_boxes/subscription_selection.js +20 -10
- data/app/assets/stylesheets/solidus_subscription_boxes/subscription_box.css.scss +7 -12
- data/app/decorators/spree/controllers/orders/meal_preference_decorator.rb +6 -0
- data/app/decorators/spree/controllers/users/set_box_preference_decorator.rb +2 -1
- data/app/helpers/solidus_subscription_boxes/application_helper.rb +8 -0
- data/app/models/solidus_subscription_boxes/box_preference.rb +1 -1
- data/app/views/solidus_subscription_boxes/subscription_boxes/_box_variants.html.erb +9 -7
- data/app/views/solidus_subscription_boxes/subscription_boxes/_manage.html.erb +1 -1
- data/app/views/solidus_subscription_boxes/subscription_boxes/get_started.html.erb +1 -1
- data/lib/solidus_subscription_boxes/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 777198967dcf84fbc05e24af7413e926c0d4f4e9
|
4
|
+
data.tar.gz: d433bbcd05a1b4c8ed33d264c750bfa91be67327
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8326e926d6e118e57381bcf25069eda78b5671b14b3d7671832fce17fa5757dbd5f03a1e34b17823882be9b215aab709dd422c17588bd407365af10fd2c04376
|
7
|
+
data.tar.gz: e983251c8b6481b0d951428f4000726c8b464347819a9c757d26c395a57342a2927964bc59a9094ba1c7f832f6d93aba2f8debb0772b0a617eb177f168c051a1
|
@@ -13,29 +13,39 @@ function subscriptionFormatDate(date) {
|
|
13
13
|
return monthNames[monthIndex] + ' ' + day;
|
14
14
|
}
|
15
15
|
|
16
|
+
$('.box-controls i').click(function(event) {
|
17
|
+
var value = parseInt($(this).siblings('input').val());
|
18
|
+
if(this.classList.contains('add')) {
|
19
|
+
value = Math.min(value + 1, 9);
|
20
|
+
} else {
|
21
|
+
value = Math.max(value - 1, 0);
|
22
|
+
}
|
23
|
+
$(this).siblings('input').val(value);
|
24
|
+
|
25
|
+
|
26
|
+
var numberOfMeals = function() {
|
27
|
+
var total = 0;
|
28
|
+
$('.box-controls input').each( function(element) {
|
29
|
+
total = total + parseInt(this.value);
|
30
|
+
});
|
31
|
+
return total;
|
32
|
+
}
|
16
33
|
|
17
|
-
$('.meal-selection').click( function(event) {
|
18
34
|
if( $('body.get_started').length > 0 ) {
|
19
35
|
var submitButtonText = "Subscribe Now";
|
20
36
|
} else {
|
21
37
|
var submitButtonText = "Update My Order";
|
22
38
|
}
|
23
39
|
|
24
|
-
if(
|
25
|
-
alert("Only choose 3 meals");
|
26
|
-
event.target.checked = false;
|
27
|
-
event.preventDefault();
|
28
|
-
}
|
29
|
-
|
30
|
-
if( $('.meal-selection input:checked').length == 3 ) {
|
40
|
+
if( numberOfMeals() >= 3 ) {
|
31
41
|
$('input[type=submit].meal-update').removeAttr('disabled');
|
32
42
|
$('input[type=submit].meal-update').attr("value",submitButtonText);
|
33
43
|
} else {
|
34
44
|
$('input[type=submit].meal-update').attr("disabled","disabled");
|
35
|
-
$('input[type=submit].meal-update').attr("value","Choose " + (3 -
|
45
|
+
$('input[type=submit].meal-update').attr("value","Choose " + (Math.max(3 - numberOfMeals(), 0)).toString() + " More");
|
36
46
|
}
|
37
47
|
|
38
|
-
$('.number_more_meals').text(3 -
|
48
|
+
$('.number_more_meals').text(3 - numberOfMeals());
|
39
49
|
});
|
40
50
|
|
41
51
|
$(document).ajaxSuccess(function( event, xhr, settings ) {
|
@@ -20,15 +20,10 @@
|
|
20
20
|
.flash.success {
|
21
21
|
background-color: green;
|
22
22
|
}
|
23
|
-
.meal-selector
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
}
|
31
|
-
input:checked + .image {
|
32
|
-
border: 3px $btn-box-shadow-color solid;
|
33
|
-
}
|
34
|
-
}
|
23
|
+
.meal-selector input{
|
24
|
+
width: 100px;
|
25
|
+
}
|
26
|
+
.box-controls i {
|
27
|
+
cursor: pointer;
|
28
|
+
}
|
29
|
+
|
@@ -14,6 +14,12 @@ module Spree
|
|
14
14
|
if params[:box_preference_attributes]
|
15
15
|
params[:box_preference_attributes].permit!
|
16
16
|
@order.update_attributes(box_preference_attributes: params[:box_preference_attributes].to_hash)
|
17
|
+
@order.box_preference.preference.each do |key, value|
|
18
|
+
if value.to_i > 0 then
|
19
|
+
variant = Spree::Variant.find(key.to_i)
|
20
|
+
@order.contents.add(variant, value.to_i)
|
21
|
+
end
|
22
|
+
end
|
17
23
|
end
|
18
24
|
end
|
19
25
|
end
|
@@ -19,7 +19,8 @@ module Spree
|
|
19
19
|
|
20
20
|
must_change_subscriptions.each do |subscription|
|
21
21
|
potential_variants = SolidusSubscriptionBoxes::SubscriptionPeriod.period_for_date(subscription.actionable_date).variants
|
22
|
-
|
22
|
+
selected_preferences = Hash[potential_variants.sample(3).collect { |variant| [variant.id.to_s, 1.to_s] } ]
|
23
|
+
subscription.box_preference = SolidusSubscriptionBoxes::BoxPreference.new(preference: selected_preferences)
|
23
24
|
end
|
24
25
|
end
|
25
26
|
end
|
@@ -1,13 +1,15 @@
|
|
1
1
|
<div class="meal-selector row row-centered">
|
2
2
|
<%- box_variants.each do |variant| %>
|
3
3
|
<div class="col-xs-12 col-md-4 col-centered text-center meal">
|
4
|
-
<
|
5
|
-
|
6
|
-
<
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
<div class="image">
|
5
|
+
<%= image_tag variant.display_image.attachment.url(:large) %>
|
6
|
+
<h4><%= variant.name %></h4>
|
7
|
+
</div>
|
8
|
+
<div class="box-controls display-4">
|
9
|
+
<i class="fa fa-3 fa-minus-circle remove" aria-hidden="true"></i>
|
10
|
+
<input class="border-0 col-4 text-right" type="number" name="<%= preference_scope %>[<%= variant.id %>]" value="<%= preferable_value(preferable.box_preference, variant.id) %>" readonly>
|
11
|
+
<i class="fa fa-3 fa-plus-circle add" aria-hidden="true"></i>
|
12
|
+
</div>
|
11
13
|
</div>
|
12
14
|
<% end %>
|
13
15
|
</div>
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<%= render partial: 'solidus_subscription_boxes/subscription_boxes/box_variants',
|
9
9
|
locals: {
|
10
10
|
box_variants: SolidusSubscriptionBoxes::SubscriptionPeriod.period_for_date(subscription.actionable_date).variants,
|
11
|
-
preference_scope: "subscription[box_preference_attributes][preference]
|
11
|
+
preference_scope: "subscription[box_preference_attributes][preference]",
|
12
12
|
preferable: subscription
|
13
13
|
}
|
14
14
|
%>
|
@@ -34,7 +34,7 @@
|
|
34
34
|
<h4 class="text-center">We update the menu seasonally to use the freshest ingredients</h4>
|
35
35
|
<div class="pt-5">
|
36
36
|
<%= form_for :order, url: '/orders/populate' do |f| %>
|
37
|
-
<%= render partial: 'box_variants', locals: {box_variants: @box_variants, preference_scope: "box_preference_attributes[preference]
|
37
|
+
<%= render partial: 'box_variants', locals: {box_variants: @box_variants, preference_scope: "box_preference_attributes[preference]", preferable: f.object} %>
|
38
38
|
<div class="row mt-5">
|
39
39
|
<div class="col-12 content text-center">
|
40
40
|
<%= hidden_field_tag :variant_id, @variant.id %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_subscription_boxes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Jackson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus
|