mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Merge remote-tracking branch 'origin/master' into HEAD
This commit is contained in:
@@ -1 +1 @@
|
||||
angular.module("admin.products", [])
|
||||
angular.module("admin.products", ["admin.utils"])
|
||||
@@ -15,7 +15,7 @@ Darkswarm.directive 'mapOsmTiles', ($timeout) ->
|
||||
if x < 0
|
||||
x = tilesPerGlobe + x
|
||||
# Wrap y (latitude) in a like manner if you want to enable vertical infinite scroll
|
||||
'http://tile.openstreetmap.org/' + zoom + '/' + x + '/' + coord.y + '.png'
|
||||
'https://a.tile.openstreetmap.org/' + zoom + '/' + x + '/' + coord.y + '.png'
|
||||
tileSize: new google.maps.Size(256, 256)
|
||||
name: 'OpenStreetMap'
|
||||
maxZoom: 18
|
||||
|
||||
@@ -33,16 +33,18 @@
|
||||
|
||||
|
||||
ordercycle
|
||||
p.text-right
|
||||
text-align: right
|
||||
p
|
||||
max-width: 400px
|
||||
@media all and (max-width: 640px)
|
||||
float: left
|
||||
clear: left
|
||||
text-align: left
|
||||
padding: 12px 10px
|
||||
width: 100%
|
||||
margin-top: 10px
|
||||
background: #e5e5e5
|
||||
p.text-right
|
||||
p
|
||||
max-width: 100%
|
||||
float: right
|
||||
form.custom
|
||||
|
||||
@@ -237,6 +237,7 @@ Spree::Product.class_eval do
|
||||
variant = self.master.dup
|
||||
variant.product = self
|
||||
variant.is_master = false
|
||||
variant.on_demand = self.on_demand
|
||||
self.variants << variant
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
add_to_attributes '[data-hook="admin_variant_form_fields"]'
|
||||
attributes 'ng-app' => 'admin.products'
|
||||
@@ -0,0 +1,28 @@
|
||||
/ insert_bottom "[data-hook='admin_variant_form_fields']"
|
||||
:javascript
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
var on_demand = $('input#variant_on_demand');
|
||||
var on_hand = $('input#variant_on_hand');
|
||||
|
||||
on_hand.attr('disabled', on_demand.attr('checked'));
|
||||
|
||||
on_demand.change(function(){
|
||||
|
||||
on_hand.attr('disabled', this.checked);
|
||||
|
||||
if(this.checked) {
|
||||
on_hand.attr('data-stock', on_hand.val());
|
||||
on_hand.val("Infinity");
|
||||
} else {
|
||||
if(on_hand.attr('data-stock') !== undefined) {
|
||||
on_hand.val(on_hand.attr('data-stock'));
|
||||
} else {
|
||||
on_hand.val("0");
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
/ insert_bottom "[data-hook='on_demand']"
|
||||
%div{'ofn-with-tip' => t('admin.products.variants.to_order_tip')}
|
||||
%a What's this?
|
||||
@@ -3,10 +3,10 @@
|
||||
angular.module('Darkswarm').value('orderCycleData', #{render "json/order_cycle"})
|
||||
|
||||
- if @order_cycles and @order_cycles.empty?
|
||||
%h4.text-right
|
||||
%h4
|
||||
%i.ofn-i_032-closed-sign
|
||||
= t :shopping_oc_closed
|
||||
%p.text-right
|
||||
%p
|
||||
= t :shopping_oc_closed_description
|
||||
.text-right
|
||||
%small
|
||||
|
||||
@@ -112,6 +112,8 @@ en-GB:
|
||||
inherits_properties?: Inherits Properties?
|
||||
available_on: Available On
|
||||
av_on: "Av. On"
|
||||
variants:
|
||||
to_order_tip: "Items made to order do not have a set stock level, such as loaves of bread made fresh to order."
|
||||
variant_overrides:
|
||||
index:
|
||||
title: Inventory
|
||||
|
||||
@@ -176,6 +176,8 @@ en:
|
||||
inherits_properties?: Inherits Properties?
|
||||
available_on: Available On
|
||||
av_on: "Av. On"
|
||||
variants:
|
||||
to_order_tip: "Items made to order do not have a set stock level, such as loaves of bread made fresh to order."
|
||||
|
||||
variant_overrides:
|
||||
loading_flash:
|
||||
|
||||
@@ -59,6 +59,33 @@ feature %q{
|
||||
product.master.options_text.should == "5kg"
|
||||
end
|
||||
|
||||
scenario "creating an on-demand product", js: true do
|
||||
login_to_admin_section
|
||||
|
||||
click_link 'Products'
|
||||
click_link 'New Product'
|
||||
|
||||
fill_in 'product_name', with: 'Hot Cakes'
|
||||
select 'New supplier', from: 'product_supplier_id'
|
||||
select "Weight (kg)", from: 'product_variant_unit_with_scale'
|
||||
fill_in 'product_unit_value_with_description', with: 1
|
||||
select taxon.name, from: "product_primary_taxon_id"
|
||||
fill_in 'product_price', with: '1.99'
|
||||
fill_in 'product_on_hand', with: 0
|
||||
check 'product_on_demand'
|
||||
select 'Test Tax Category', from: 'product_tax_category_id'
|
||||
select 'Test Shipping Category', from: 'product_shipping_category_id'
|
||||
fill_in 'product_description', with: "In demand, and on_demand! The hottest cakes in town."
|
||||
|
||||
click_button 'Create'
|
||||
|
||||
expect(current_path).to eq spree.bulk_edit_admin_products_path
|
||||
product = Spree::Product.find_by_name('Hot Cakes')
|
||||
product.variants.count.should == 1
|
||||
variant = product.variants.first
|
||||
variant.on_demand.should be_true
|
||||
end
|
||||
|
||||
scenario "making a product into a group buy product" do
|
||||
product = create(:simple_product, name: 'group buy product')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user