Set product.largeImage in JS, use for product modal

This commit is contained in:
Rohan Mitchell
2014-09-01 16:21:23 +10:00
parent e72c3d861b
commit 2cd5afbf9c
3 changed files with 16 additions and 1 deletions

View File

@@ -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

View File

@@ -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}}"}

View File

@@ -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])