From 5bec887f93129fca23579396a3f9f193a86095cb Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 29 Jun 2020 19:57:36 +0200 Subject: [PATCH 1/4] Move /assets/images/noimage/* to /public/noimage/* --- {app/assets/images => public}/noimage/group.png | Bin {app/assets/images => public}/noimage/large.png | Bin {app/assets/images => public}/noimage/mini.png | Bin {app/assets/images => public}/noimage/product.png | Bin {app/assets/images => public}/noimage/small.png | Bin 5 files changed, 0 insertions(+), 0 deletions(-) rename {app/assets/images => public}/noimage/group.png (100%) rename {app/assets/images => public}/noimage/large.png (100%) rename {app/assets/images => public}/noimage/mini.png (100%) rename {app/assets/images => public}/noimage/product.png (100%) rename {app/assets/images => public}/noimage/small.png (100%) diff --git a/app/assets/images/noimage/group.png b/public/noimage/group.png similarity index 100% rename from app/assets/images/noimage/group.png rename to public/noimage/group.png diff --git a/app/assets/images/noimage/large.png b/public/noimage/large.png similarity index 100% rename from app/assets/images/noimage/large.png rename to public/noimage/large.png diff --git a/app/assets/images/noimage/mini.png b/public/noimage/mini.png similarity index 100% rename from app/assets/images/noimage/mini.png rename to public/noimage/mini.png diff --git a/app/assets/images/noimage/product.png b/public/noimage/product.png similarity index 100% rename from app/assets/images/noimage/product.png rename to public/noimage/product.png diff --git a/app/assets/images/noimage/small.png b/public/noimage/small.png similarity index 100% rename from app/assets/images/noimage/small.png rename to public/noimage/small.png From b441ac2644296341c5e849c90b578ab2e0773fff Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Mon, 29 Jun 2020 20:07:08 +0200 Subject: [PATCH 2/4] Update paths to "noimage" images --- app/assets/javascripts/darkswarm/services/products.js.coffee | 2 +- app/assets/javascripts/templates/product_modal.html.haml | 2 +- app/serializers/api/admin/product_serializer.rb | 4 ++-- app/serializers/api/variant_serializer.rb | 2 +- app/views/groups/show.html.haml | 2 +- app/views/spree/admin/products/new.html.haml | 2 +- app/views/spree/admin/variants/_autocomplete.js.erb | 2 +- spec/features/admin/bulk_product_update_spec.rb | 2 +- .../unit/darkswarm/services/products_spec.js.coffee | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/darkswarm/services/products.js.coffee b/app/assets/javascripts/darkswarm/services/products.js.coffee index 59bd19efb4..83b19251bb 100644 --- a/app/assets/javascripts/darkswarm/services/products.js.coffee +++ b/app/assets/javascripts/darkswarm/services/products.js.coffee @@ -34,7 +34,7 @@ Darkswarm.factory 'Products', (OrderCycleResource, OrderCycle, Shopfront, curren product.price = Math.min.apply(null, prices) product.hasVariants = product.variants?.length > 0 product.primaryImage = product.images[0]?.small_url if product.images - product.primaryImageOrMissing = product.primaryImage || "/assets/noimage/small.png" + product.primaryImageOrMissing = product.primaryImage || "/noimage/small.png" product.largeImage = product.images[0]?.large_url if product.images dereference: -> diff --git a/app/assets/javascripts/templates/product_modal.html.haml b/app/assets/javascripts/templates/product_modal.html.haml index 9c65bbbad7..95c74c5f72 100644 --- a/app/assets/javascripts/templates/product_modal.html.haml +++ b/app/assets/javascripts/templates/product_modal.html.haml @@ -15,6 +15,6 @@ .columns.small-12.medium-6.large-6.product-img %img{"ng-src" => "{{::product.largeImage}}", "ng-if" => "::product.largeImage"} - %img.placeholder{ src: "/assets/noimage/large.png", "ng-if" => "::!product.largeImage"} + %img.placeholder{ src: "/noimage/large.png", "ng-if" => "::!product.largeImage"} %ng-include{src: "'partials/close.html'"} diff --git a/app/serializers/api/admin/product_serializer.rb b/app/serializers/api/admin/product_serializer.rb index c4b9f15a34..2be4995305 100644 --- a/app/serializers/api/admin/product_serializer.rb +++ b/app/serializers/api/admin/product_serializer.rb @@ -12,7 +12,7 @@ class Api::Admin::ProductSerializer < ActiveModel::Serializer if object.images.present? object.images.first.attachment.url(:product) else - "/assets/noimage/product.png" + "/noimage/product.png" end end @@ -20,7 +20,7 @@ class Api::Admin::ProductSerializer < ActiveModel::Serializer if object.images.present? object.images.first.attachment.url(:mini) else - "/assets/noimage/mini.png" + "/noimage/mini.png" end end diff --git a/app/serializers/api/variant_serializer.rb b/app/serializers/api/variant_serializer.rb index 38cc649910..0306c95f95 100644 --- a/app/serializers/api/variant_serializer.rb +++ b/app/serializers/api/variant_serializer.rb @@ -35,7 +35,7 @@ class Api::VariantSerializer < ActiveModel::Serializer if object.product.images.present? object.product.images.first.attachment.url(:mini) else - "/assets/noimage/mini.png" + "/noimage/mini.png" end end end diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml index 4701791daa..b5622063a2 100644 --- a/app/views/groups/show.html.haml +++ b/app/views/groups/show.html.haml @@ -22,7 +22,7 @@ - if @group.logo.present? %img.group-logo{"src" => @group.logo} - else - %img.group-logo{"src" => image_path('noimage/group.png') } + %img.group-logo{"src" => '/noimage/group.png' } %h2.group-name= @group.name %p= @group.description diff --git a/app/views/spree/admin/products/new.html.haml b/app/views/spree/admin/products/new.html.haml index 34665fbdcb..908f30b5b9 100644 --- a/app/views/spree/admin/products/new.html.haml +++ b/app/views/spree/admin/products/new.html.haml @@ -83,7 +83,7 @@ %fieldset.no-border-bottom{ id: "image" } %legend{align: "center"}= t(".image") .row - = image_tag "noimage/product.png", class: "four columns alpha" + = image_tag "/noimage/product.png", class: "four columns alpha" .row = f.fields_for 'images_attributes[]', f.object.images.build do |image_fields| = image_fields.file_field :attachment diff --git a/app/views/spree/admin/variants/_autocomplete.js.erb b/app/views/spree/admin/variants/_autocomplete.js.erb index 9e4c29a50a..c4d1f8d96a 100644 --- a/app/views/spree/admin/variants/_autocomplete.js.erb +++ b/app/views/spree/admin/variants/_autocomplete.js.erb @@ -4,7 +4,7 @@ {{#if variant.image }} {{ else }} - + {{/if}} diff --git a/spec/features/admin/bulk_product_update_spec.rb b/spec/features/admin/bulk_product_update_spec.rb index 09bdf68fca..c0b55ed224 100644 --- a/spec/features/admin/bulk_product_update_spec.rb +++ b/spec/features/admin/bulk_product_update_spec.rb @@ -770,7 +770,7 @@ feature ' expect(page).to have_selector "td.image" # Shows default image when no image set - expect(page).to have_css "img[src='/assets/noimage/mini.png']" + expect(page).to have_css "img[src='/noimage/mini.png']" @old_thumb_src = page.find("a.image-modal img")['src'] # Click image diff --git a/spec/javascripts/unit/darkswarm/services/products_spec.js.coffee b/spec/javascripts/unit/darkswarm/services/products_spec.js.coffee index 88ff585f00..db9ed1e628 100644 --- a/spec/javascripts/unit/darkswarm/services/products_spec.js.coffee +++ b/spec/javascripts/unit/darkswarm/services/products_spec.js.coffee @@ -107,7 +107,7 @@ describe 'Products service', -> $httpBackend.expectGET(endpoint).respond([product]) $httpBackend.flush() expect(Products.products[0].primaryImage).toBeUndefined() - expect(Products.products[0].primaryImageOrMissing).toEqual "/assets/noimage/small.png" + expect(Products.products[0].primaryImageOrMissing).toEqual "/noimage/small.png" it "sets largeImage", -> $httpBackend.expectGET(endpoint).respond([productWithImage]) From eeb6c57f9945dbdaec69a16f6d5f48ac70c24461 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Thu, 2 Jul 2020 17:55:35 +0200 Subject: [PATCH 3/4] Update missing image paths in other order views --- app/views/spree/orders/_bought.html.haml | 6 +++--- app/views/spree/orders/_line_item.html.haml | 6 +++--- app/views/spree/orders/_summary.html.haml | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/views/spree/orders/_bought.html.haml b/app/views/spree/orders/_bought.html.haml index e739caeff2..eb9e9edd48 100644 --- a/app/views/spree/orders/_bought.html.haml +++ b/app/views/spree/orders/_bought.html.haml @@ -16,10 +16,10 @@ %td.cart-item-description %div.item-thumb-image - - if variant.images.length == 0 - = mini_image(variant.product) + - if variant.product.images.length == 0 + = image_tag("/noimage/mini.png") - else - = image_tag(variant.images.first.attachment.url(:mini)) + = image_tag(variant.product.images.first.attachment.url(:mini)) = render 'spree/shared/line_item_name', line_item: line_item %span.already-confirmed= t(:orders_bought_already_confirmed) diff --git a/app/views/spree/orders/_line_item.html.haml b/app/views/spree/orders/_line_item.html.haml index 918a520fdf..97fce45415 100644 --- a/app/views/spree/orders/_line_item.html.haml +++ b/app/views/spree/orders/_line_item.html.haml @@ -2,10 +2,10 @@ %td.cart-item-description{'data-hook' => "cart_item_description"} %div.item-thumb-image{"data-hook" => "cart_item_image"} - - if variant.images.length == 0 - = mini_image(variant.product) + - if variant.product.images.length == 0 + = image_tag("/noimage/mini.png") - else - = image_tag(variant.images.first.attachment.url(:mini)) + = image_tag(variant.product.images.first.attachment.url(:mini)) = render 'spree/shared/line_item_name', line_item: line_item diff --git a/app/views/spree/orders/_summary.html.haml b/app/views/spree/orders/_summary.html.haml index 670a9b6ec7..1227dd24ff 100644 --- a/app/views/spree/orders/_summary.html.haml +++ b/app/views/spree/orders/_summary.html.haml @@ -16,10 +16,10 @@ %td(data-hook = "order_item_description") %div.item-thumb-image{"data-hook" => "order_item_image"} - - if item.variant.images.length == 0 - = mini_image(item.variant.product) + - if item.variant.product.images.length == 0 + = image_tag("/noimage/mini.png") - else - = image_tag(item.variant.images.first.attachment.url(:mini)) + = image_tag(item.variant.product.images.first.attachment.url(:mini)) = render 'spree/shared/line_item_name', line_item: item From 8fc407a9d54623a691c310825b3f6155f33eda4f Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Thu, 2 Jul 2020 17:58:51 +0200 Subject: [PATCH 4/4] Extract repeated variant thumbnail code to a shared partial --- app/views/spree/orders/_bought.html.haml | 5 +---- app/views/spree/orders/_line_item.html.haml | 5 +---- app/views/spree/orders/_summary.html.haml | 6 +----- app/views/spree/shared/_variant_thumbnail.html.haml | 4 ++++ 4 files changed, 7 insertions(+), 13 deletions(-) create mode 100644 app/views/spree/shared/_variant_thumbnail.html.haml diff --git a/app/views/spree/orders/_bought.html.haml b/app/views/spree/orders/_bought.html.haml index eb9e9edd48..f7030b31a8 100644 --- a/app/views/spree/orders/_bought.html.haml +++ b/app/views/spree/orders/_bought.html.haml @@ -16,10 +16,7 @@ %td.cart-item-description %div.item-thumb-image - - if variant.product.images.length == 0 - = image_tag("/noimage/mini.png") - - else - = image_tag(variant.product.images.first.attachment.url(:mini)) + = render 'spree/shared/variant_thumbnail', variant: variant = render 'spree/shared/line_item_name', line_item: line_item %span.already-confirmed= t(:orders_bought_already_confirmed) diff --git a/app/views/spree/orders/_line_item.html.haml b/app/views/spree/orders/_line_item.html.haml index 97fce45415..19292cb219 100644 --- a/app/views/spree/orders/_line_item.html.haml +++ b/app/views/spree/orders/_line_item.html.haml @@ -2,10 +2,7 @@ %td.cart-item-description{'data-hook' => "cart_item_description"} %div.item-thumb-image{"data-hook" => "cart_item_image"} - - if variant.product.images.length == 0 - = image_tag("/noimage/mini.png") - - else - = image_tag(variant.product.images.first.attachment.url(:mini)) + = render 'spree/shared/variant_thumbnail', variant: variant = render 'spree/shared/line_item_name', line_item: line_item diff --git a/app/views/spree/orders/_summary.html.haml b/app/views/spree/orders/_summary.html.haml index 1227dd24ff..f1c25fea61 100644 --- a/app/views/spree/orders/_summary.html.haml +++ b/app/views/spree/orders/_summary.html.haml @@ -16,11 +16,7 @@ %td(data-hook = "order_item_description") %div.item-thumb-image{"data-hook" => "order_item_image"} - - if item.variant.product.images.length == 0 - = image_tag("/noimage/mini.png") - - else - = image_tag(item.variant.product.images.first.attachment.url(:mini)) - + = render 'spree/shared/variant_thumbnail', variant: item.variant = render 'spree/shared/line_item_name', line_item: item diff --git a/app/views/spree/shared/_variant_thumbnail.html.haml b/app/views/spree/shared/_variant_thumbnail.html.haml new file mode 100644 index 0000000000..719725c927 --- /dev/null +++ b/app/views/spree/shared/_variant_thumbnail.html.haml @@ -0,0 +1,4 @@ +- if variant.product.images.length == 0 + = image_tag("/noimage/mini.png") +- else + = image_tag(variant.product.images.first.attachment.url(:mini))