mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Set product.largeImage in JS, use for product modal
This commit is contained in:
@@ -48,3 +48,4 @@ Darkswarm.factory 'Products', ($resource, Enterprises, Dereferencer, Taxons, Car
|
||||
|
||||
product.primaryImage = product.images[0]?.small_url if product.images
|
||||
product.primaryImageOrMissing = product.primaryImage || "/assets/noimage/small.png"
|
||||
product.largeImage = product.images[0]?.large_url if product.images
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.row
|
||||
.columns.small-12.large-6
|
||||
%img.product-img{"ng-src" => "{{product.primaryImage}}", "ng-if" => "product.primaryImage"}
|
||||
%img.product-img{"ng-src" => "{{product.largeImage}}", "ng-if" => "product.largeImage"}
|
||||
.columns.small-12.large-6.product-header
|
||||
%h2
|
||||
/ %render-svg{path: "{{product.primary_taxon.icon}}"}
|
||||
|
||||
@@ -7,6 +7,7 @@ describe 'Products service', ->
|
||||
CurrentHubMock = {}
|
||||
currentOrder = null
|
||||
product = null
|
||||
productWithImage = null
|
||||
|
||||
beforeEach ->
|
||||
product =
|
||||
@@ -16,6 +17,14 @@ describe 'Products service', ->
|
||||
price: 11
|
||||
master: {}
|
||||
variants: []
|
||||
productWithImage =
|
||||
supplier:
|
||||
id: 9
|
||||
master: {}
|
||||
variants: []
|
||||
images: [
|
||||
large_url: 'foo.png'
|
||||
]
|
||||
currentOrder =
|
||||
line_items: []
|
||||
|
||||
@@ -62,6 +71,11 @@ describe 'Products service', ->
|
||||
expect(Products.products[0].primaryImage).toBeUndefined()
|
||||
expect(Products.products[0].primaryImageOrMissing).toEqual "/assets/noimage/small.png"
|
||||
|
||||
it "sets largeImage", ->
|
||||
$httpBackend.expectGET("/shop/products").respond([productWithImage])
|
||||
$httpBackend.flush()
|
||||
expect(Products.products[0].largeImage).toEqual("foo.png")
|
||||
|
||||
describe "determining the price to display for a product", ->
|
||||
it "displays the product price when the product does not have variants", ->
|
||||
$httpBackend.expectGET("/shop/products").respond([product])
|
||||
|
||||
Reference in New Issue
Block a user