stall 0.3.4 → 0.3.5
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/para/stall/inputs/variants-matrix/input.coffee +39 -8
- data/app/assets/javascripts/para/stall/inputs/variants-matrix/properties_select.coffee +12 -1
- data/app/assets/javascripts/para/stall/inputs/variants-matrix/variant.coffee +10 -4
- data/app/assets/javascripts/stall/add-product-to-wish-list-button.coffee +0 -1
- data/app/services/stall/cart_update_service.rb +1 -1
- data/app/services/stall/shipping_fee_calculator_service.rb +7 -1
- data/app/views/para/admin/resources/_variant_row.html.haml +1 -1
- data/lib/stall/rails/routing_mapper.rb +2 -2
- data/lib/stall/routes.rb +61 -41
- data/lib/stall/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: 2ada0574ad0ed8cfa93095644bdf32a04bcb0509
|
4
|
+
data.tar.gz: a14972609cff3c4e91cc431dfcf052a8d32a646d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2d940165c3b6162689bc986170b9d0d43bbb66a4a093db2d36afd82f49119db11d70ecafd28ed44092d1dcaec48f1cc1eca4e1f88f3e9cec0121bb987b683d8
|
7
|
+
data.tar.gz: 6260a59db786d455c54a10dd4806ad19e568bb529f697d8dcf57d1c6675dcff52b4e1d4857a391a6023899528594640cbee24fde91c9a1c1fbe3b21c17597e9f
|
@@ -57,27 +57,42 @@ class VariantsMatrix.Input extends Vertebra.View
|
|
57
57
|
|
58
58
|
refreshAvailableVariants: ->
|
59
59
|
combinations = @buildPossibleCombinations()
|
60
|
-
@
|
61
|
-
@createVariantsIn(combinations)
|
60
|
+
removeableVariants = @variantsNotIn(combinations)
|
61
|
+
createdVariants = @createVariantsIn(combinations)
|
62
62
|
|
63
|
-
|
63
|
+
# Copy default values from removeable variants before they're removed from
|
64
|
+
# the DOM, allowing the Variant#copyInputsFrom method to work
|
65
|
+
@applyDefaultValuesForNewVariants(removeableVariants, createdVariants)
|
66
|
+
|
67
|
+
@removeVariants(removeableVariants)
|
68
|
+
|
69
|
+
variantsNotIn: (combinations) ->
|
64
70
|
removeableVariants = []
|
65
71
|
|
66
72
|
for variant, index in @variants
|
67
|
-
continue
|
73
|
+
continue if !variant or variant.isDestroyed
|
68
74
|
matches = false
|
69
75
|
matches = true for combination in combinations when variant.matches(combination)
|
70
76
|
removeableVariants.push(variant) unless matches
|
71
77
|
|
72
|
-
|
73
|
-
|
78
|
+
removeableVariants
|
79
|
+
|
80
|
+
removeVariants: (removeableVariants) ->
|
74
81
|
variant.remove() for variant in removeableVariants
|
75
82
|
|
76
83
|
createVariantsIn: (combinations) ->
|
84
|
+
@newVariants = []
|
85
|
+
|
77
86
|
for combination in combinations
|
78
87
|
existingVariant = @findVariantFor(combination)
|
79
|
-
|
88
|
+
newVariant = false
|
89
|
+
|
90
|
+
unless (variant = existingVariant)
|
91
|
+
variant = @createVariantFor(combination)
|
92
|
+
@newVariants.push(variant)
|
93
|
+
|
80
94
|
variant.show()
|
95
|
+
variant
|
81
96
|
|
82
97
|
findVariantFor: (combination) ->
|
83
98
|
return variant for variant, index in @variants when variant.matches(combination)
|
@@ -128,6 +143,23 @@ class VariantsMatrix.Input extends Vertebra.View
|
|
128
143
|
|
129
144
|
if !combinations.length && @allowEmptyVariant then [{}] else combinations
|
130
145
|
|
146
|
+
applyDefaultValuesForNewVariants: (removeableVariants, createdVariants) ->
|
147
|
+
existingVariants = if removeableVariants.length >= createdVariants.length
|
148
|
+
removeableVariants
|
149
|
+
else
|
150
|
+
(v for v in createdVariants when !@isNewVariant(v))
|
151
|
+
|
152
|
+
if existingVariants.length >= @newVariants.length
|
153
|
+
v.copyInputsFrom(existingVariants[i]) for v, i in @newVariants
|
154
|
+
else if existingVariants.length
|
155
|
+
v.copyInputsFrom(existingVariants[0]) for v, i in @newVariants
|
156
|
+
|
157
|
+
isNewVariant: (variant) ->
|
158
|
+
for v in @newVariants
|
159
|
+
return true if variant.cid is v.cid
|
160
|
+
|
161
|
+
false
|
162
|
+
|
131
163
|
onVariantApplyToAll: (variant) =>
|
132
164
|
v.copyInputsFrom(variant) for v in @variants when v.cid isnt variant.cid
|
133
165
|
|
@@ -137,4 +169,3 @@ class VariantsMatrix.Input extends Vertebra.View
|
|
137
169
|
destroyedVariant.destroy()
|
138
170
|
# Remove variant from @variants array
|
139
171
|
@variants.splice(index, 1) for variant, index in @variants when variant?.matches(destroyedVariant.combination)
|
140
|
-
|
@@ -12,6 +12,8 @@ class VariantsMatrix.PropertiesSelect extends Vertebra.View
|
|
12
12
|
# field name and the selected property values ids
|
13
13
|
#
|
14
14
|
getSelectedProperties: ->
|
15
|
+
selectedProperties = []
|
16
|
+
|
15
17
|
for el in @$propertySelects.get()
|
16
18
|
$field = $(el)
|
17
19
|
|
@@ -23,7 +25,16 @@ class VariantsMatrix.PropertiesSelect extends Vertebra.View
|
|
23
25
|
|
24
26
|
fieldName = $field.data('variants-matrix-property-select')
|
25
27
|
values = @serializeFieldValues($field, propertyId)
|
26
|
-
|
28
|
+
|
29
|
+
continue unless values?.length
|
30
|
+
|
31
|
+
selectedProperties.push
|
32
|
+
id: propertyId
|
33
|
+
name: fieldName
|
34
|
+
values: values
|
35
|
+
active: !!values.length
|
36
|
+
|
37
|
+
selectedProperties
|
27
38
|
|
28
39
|
serializeFieldValues: ($field, propertyId) ->
|
29
40
|
for option in $field.find(':selected').get()
|
@@ -6,6 +6,7 @@ class VariantsMatrix.Variant extends Vertebra.View
|
|
6
6
|
initialize: (options = {}) ->
|
7
7
|
@combination = options.combination
|
8
8
|
@persisted = @$el?.data('variant-id')
|
9
|
+
@isDestroyed = false
|
9
10
|
@input = options.input
|
10
11
|
|
11
12
|
renderTo: ($container) ->
|
@@ -16,6 +17,9 @@ class VariantsMatrix.Variant extends Vertebra.View
|
|
16
17
|
@fillProperties()
|
17
18
|
|
18
19
|
fillProperties: ->
|
20
|
+
# Reset all properties to hidden
|
21
|
+
@$("[data-variants-matrix-variant-property]").addClass('hidden')
|
22
|
+
|
19
23
|
for propertyValue in @propertyValues()
|
20
24
|
$propertyValue = @$("[data-variants-matrix-variant-property='#{ propertyValue.propertyId }']")
|
21
25
|
$propertyValue.find('[data-property-name]').html(propertyValue.name)
|
@@ -23,9 +27,10 @@ class VariantsMatrix.Variant extends Vertebra.View
|
|
23
27
|
$propertyValue.removeClass('hidden')
|
24
28
|
|
25
29
|
remove: ->
|
30
|
+
@setDestroyed(true)
|
31
|
+
|
26
32
|
if @persisted
|
27
33
|
@$el.hide(0)
|
28
|
-
@setDestroyed(true)
|
29
34
|
else
|
30
35
|
@$el.remove()
|
31
36
|
@trigger('destroy', this)
|
@@ -54,15 +59,16 @@ class VariantsMatrix.Variant extends Vertebra.View
|
|
54
59
|
|
55
60
|
onEnabledStateChanged: (e) ->
|
56
61
|
checked = @$('[data-variants-matrix-variant-enabled]').prop('checked')
|
57
|
-
@$el.toggleClass('disabled')
|
62
|
+
@$el.toggleClass('disabled', !checked)
|
58
63
|
|
59
64
|
setDestroyed: (state) ->
|
60
|
-
|
65
|
+
@isDestroyed = state
|
66
|
+
@$el.find('[data-variant-remove]').val(if @isDestroyed then 'true' else 'false')
|
61
67
|
|
62
68
|
onApplyToAllClicked: ->
|
63
69
|
@trigger('applytoall', this)
|
64
70
|
|
65
71
|
copyInputsFrom: (otherVariant) ->
|
66
|
-
@$('input:visible').each (i, el)
|
72
|
+
@$('input:visible').each (i, el) =>
|
67
73
|
otherValue = otherVariant.$('input:visible').eq(i).val()
|
68
74
|
$(el).val(otherValue)
|
@@ -17,7 +17,7 @@ module Stall
|
|
17
17
|
def refresh_associated_services!
|
18
18
|
# Recalculate shipping fee if available for calculation to ensure
|
19
19
|
# that the fee us always up to date when displayed to the customer
|
20
|
-
shipping_fee_service.call
|
20
|
+
shipping_fee_service.call
|
21
21
|
|
22
22
|
# Recalculate the credit usage amount if already used to avoid negative
|
23
23
|
# cart totals
|
@@ -7,7 +7,7 @@ module Stall
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def call
|
10
|
-
return unless
|
10
|
+
return reset_shipment_price unless available?
|
11
11
|
|
12
12
|
update_price_for(cart.shipment, calculator) if calculator
|
13
13
|
end
|
@@ -32,6 +32,12 @@ module Stall
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
def reset_shipment_price
|
36
|
+
return unless cart.shipment
|
37
|
+
|
38
|
+
cart.shipment.update_attributes(price: 0, eot_price: 0, vat_rate: 0)
|
39
|
+
end
|
40
|
+
|
35
41
|
def calculator
|
36
42
|
@calculator ||= calculator_class && calculator_class.new(cart, cart.shipment.shipping_method)
|
37
43
|
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
%span.checkbox
|
7
7
|
%label
|
8
|
-
= form.check_box :published, checked: (form.object.published? || form.object.new_record?), data: { :'variants-matrix-variant-enabled' => true }
|
8
|
+
= form.check_box :published, checked: (form.object.published? || form.object.new_record?), autocomplete: 'off', data: { :'variants-matrix-variant-enabled' => true }
|
9
9
|
%i.checkbox-icon
|
10
10
|
|
11
11
|
- all_properties.each do |property_config|
|
data/lib/stall/routes.rb
CHANGED
@@ -6,67 +6,87 @@ module Stall
|
|
6
6
|
@router = router
|
7
7
|
end
|
8
8
|
|
9
|
-
|
9
|
+
# This method is called with the options passed to the `mount_stall` routes
|
10
|
+
# helper.
|
11
|
+
#
|
12
|
+
# You can pass it one of the following options to disable parts of the
|
13
|
+
# routing :
|
14
|
+
#
|
15
|
+
# - { users: false } => Disables built in devise user authentication
|
16
|
+
# - { products: false } => Disables all products related routing
|
17
|
+
# - { checkout: false } => Disables all checkout and cart related routing
|
18
|
+
#
|
19
|
+
def draw(mount_location, options = {})
|
10
20
|
routes = self
|
11
21
|
|
22
|
+
users = options.fetch(:users, true)
|
23
|
+
products = options.fetch(:products, true)
|
24
|
+
checkout = options.fetch(:checkout, true)
|
25
|
+
|
12
26
|
router.instance_eval do
|
13
|
-
|
27
|
+
if users
|
28
|
+
devise_for :users, Stall.config.devise_for_user_config
|
14
29
|
|
15
|
-
|
16
|
-
|
30
|
+
devise_scope :user do
|
31
|
+
get '/users/omniauth/:provider/redirect' => 'stall/omniauth_callbacks#redirect', as: :user_omniauth_redirect
|
32
|
+
end
|
17
33
|
end
|
18
34
|
|
19
35
|
scope mount_location do
|
20
|
-
|
36
|
+
if products
|
37
|
+
resources :products, only: [:index], as: :products, controller: routes.controller_for(:products)
|
21
38
|
|
22
|
-
|
23
|
-
|
24
|
-
|
39
|
+
constraints ProductExistsConstraint.new do
|
40
|
+
resources :products, path: '/', only: [:show], controller: routes.controller_for(:products)
|
41
|
+
end
|
25
42
|
|
26
|
-
|
27
|
-
|
28
|
-
|
43
|
+
constraints ProductCategoryExistsConstraint.new do
|
44
|
+
resources :product_categories, path: '/', only: [:show], controller: routes.controller_for(:product_categories)
|
45
|
+
end
|
29
46
|
|
30
|
-
|
31
|
-
|
32
|
-
|
47
|
+
constraints CuratedProductListExistsConstraint.new do
|
48
|
+
resources :curated_product_lists, path: '/', only: [:show], controller: routes.controller_for(:curated_product_lists) do
|
49
|
+
resources :products, only: [:show], path: '/', controller: routes.controller_for(:products)
|
50
|
+
end
|
33
51
|
end
|
34
|
-
end
|
35
52
|
|
36
|
-
|
37
|
-
|
38
|
-
|
53
|
+
constraints ManufacturerExistsConstraint.new do
|
54
|
+
resources :manufacturers, path: '/', only: [:show], controller: routes.controller_for(:manufacturers) do
|
55
|
+
resources :products, only: [:show], path: '/', controller: routes.controller_for(:products)
|
56
|
+
end
|
39
57
|
end
|
40
58
|
end
|
41
59
|
|
42
|
-
|
43
|
-
resources :
|
44
|
-
|
45
|
-
|
60
|
+
if checkout
|
61
|
+
resources :carts, controller: routes.controller_for(:carts) do
|
62
|
+
resources :line_items, only: [:create], controller: routes.controller_for(:cart_line_items)
|
63
|
+
resource :credit, only: [:update, :destroy], controller: routes.controller_for(:cart_credits)
|
64
|
+
end
|
46
65
|
|
47
|
-
|
48
|
-
|
49
|
-
|
66
|
+
resources :wish_lists, only: [:show], controller: routes.controller_for(:wish_lists) do
|
67
|
+
resources :line_items, only: [:create, :destroy], controller: routes.controller_for(:wish_list_line_items)
|
68
|
+
end
|
50
69
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
70
|
+
get 'checkout/:cart_key' => "#{routes.controller_for(:checkouts)}#show", as: :checkout
|
71
|
+
|
72
|
+
scope 'checkout', as: :checkout do
|
73
|
+
scope '(:cart_key)' do
|
74
|
+
resource :step, only: [:show, :update], controller: routes.controller_for(:'checkout/steps') do
|
75
|
+
post '/', action: :update, as: :update
|
76
|
+
get '/process', action: :update, as: :process
|
77
|
+
# Allow external URLs process steps, allowing some payment
|
78
|
+
# gateways to return the user through a POST request
|
79
|
+
post '/process', action: :foreign_update
|
80
|
+
get 'change/:step', action: :change, as: :change
|
81
|
+
end
|
62
82
|
end
|
63
83
|
end
|
64
|
-
end
|
65
84
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
85
|
+
scope '/:gateway' do
|
86
|
+
resource :payment, only: [], controller: routes.controller_for(:payments) do
|
87
|
+
member do
|
88
|
+
match 'notify', action: 'notify', via: [:get, :post]
|
89
|
+
end
|
70
90
|
end
|
71
91
|
end
|
72
92
|
end
|
data/lib/stall/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stall
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vala
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|