diff --git a/backend/app/assets/javascripts/spree/backend/handlebars_extensions.coffee b/backend/app/assets/javascripts/spree/backend/handlebars_extensions.coffee deleted file mode 100644 index abb4f1a0648..00000000000 --- a/backend/app/assets/javascripts/spree/backend/handlebars_extensions.coffee +++ /dev/null @@ -1,11 +0,0 @@ -#= require handlebars -#= require spree/backend/translation - -Handlebars.registerHelper "t", (key, options) -> - Spree.t(key, options.hash) - -Handlebars.registerHelper "human_attribute_name", (model, attr) -> - Spree.human_attribute_name(model, attr) - -Handlebars.registerHelper "admin_url", -> - Spree.pathFor("admin") diff --git a/backend/app/assets/javascripts/spree/backend/handlebars_extensions.js b/backend/app/assets/javascripts/spree/backend/handlebars_extensions.js new file mode 100644 index 00000000000..dcd11a6c8e9 --- /dev/null +++ b/backend/app/assets/javascripts/spree/backend/handlebars_extensions.js @@ -0,0 +1,18 @@ +//= require handlebars +//= require spree/backend/translation + +Handlebars.registerHelper("t", function(key, options) { + return Spree.t(key, options.hash); +}); + +Handlebars.registerHelper("human_attribute_name", function(model, attr) { + return Spree.human_attribute_name(model, attr); +}); + +Handlebars.registerHelper("admin_url", function() { + return Spree.pathFor("admin") +}); + +Handlebars.registerHelper("concat", function() { + return Array.prototype.slice.call(arguments, 0, -1).join(''); +}); diff --git a/backend/app/assets/javascripts/spree/backend/stock_transfers/variant_form.coffee b/backend/app/assets/javascripts/spree/backend/stock_transfers/variant_form.coffee index 5500a22de12..74fb31a830f 100644 --- a/backend/app/assets/javascripts/spree/backend/stock_transfers/variant_form.coffee +++ b/backend/app/assets/javascripts/spree/backend/stock_transfers/variant_form.coffee @@ -84,7 +84,7 @@ class VariantForm variantId: transferItem.variant.id variantDisplayAttributes: formatVariantDisplayAttributes(transferItem.variant) variantOptions: formatVariantOptionValues(transferItem.variant) - variantImageURL: transferItem.variant.images[0]?.small_url + variantImage: transferItem.variant.images[0] if isReceiving templateAttributes["receivedQuantity"] = transferItem.received_quantity diff --git a/backend/app/assets/javascripts/spree/backend/templates/_image.hbs b/backend/app/assets/javascripts/spree/backend/templates/_image.hbs new file mode 100644 index 00000000000..f6fb264d69a --- /dev/null +++ b/backend/app/assets/javascripts/spree/backend/templates/_image.hbs @@ -0,0 +1,5 @@ +{{#if image }} + {{ alt }} +{{ else }} + +{{/if}} diff --git a/backend/app/assets/javascripts/spree/backend/templates/index.js b/backend/app/assets/javascripts/spree/backend/templates/index.js index 52227647742..908ce31db3e 100644 --- a/backend/app/assets/javascripts/spree/backend/templates/index.js +++ b/backend/app/assets/javascripts/spree/backend/templates/index.js @@ -1,3 +1,4 @@ +//= require spree/backend/templates/_image //= require spree/backend/templates/orders/customer_details/autocomplete //= require spree/backend/templates/orders/details_adjustment_row //= require spree/backend/templates/orders/line_item diff --git a/backend/app/assets/javascripts/spree/backend/templates/orders/line_item.hbs b/backend/app/assets/javascripts/spree/backend/templates/orders/line_item.hbs index b437abc124b..24a570bbb99 100644 --- a/backend/app/assets/javascripts/spree/backend/templates/orders/line_item.hbs +++ b/backend/app/assets/javascripts/spree/backend/templates/orders/line_item.hbs @@ -4,11 +4,7 @@ {{else}} - {{#if image }} - - {{else}} - - {{/if}} + {{> _image image=line_item.variant.images.[0] size="mini" }} {{ line_item.variant.name }}
diff --git a/backend/app/assets/javascripts/spree/backend/templates/stock_transfers/transfer_item.hbs b/backend/app/assets/javascripts/spree/backend/templates/stock_transfers/transfer_item.hbs index 622c72cf198..a87a593e969 100644 --- a/backend/app/assets/javascripts/spree/backend/templates/stock_transfers/transfer_item.hbs +++ b/backend/app/assets/javascripts/spree/backend/templates/stock_transfers/transfer_item.hbs @@ -2,11 +2,7 @@
- {{#if variantImageURL }} - {{variantName}} - {{ else }} - - {{/if}} + {{> _image image=variantImage size="small" alt=variantName }}
diff --git a/backend/app/assets/javascripts/spree/backend/templates/variants/autocomplete.hbs b/backend/app/assets/javascripts/spree/backend/templates/variants/autocomplete.hbs index 1413594ba2b..5ebb38500ae 100644 --- a/backend/app/assets/javascripts/spree/backend/templates/variants/autocomplete.hbs +++ b/backend/app/assets/javascripts/spree/backend/templates/variants/autocomplete.hbs @@ -1,10 +1,6 @@
- {{#if image }} - - {{ else }} - - {{/if}} + {{> _image image=variant.images.[0] size="mini" }}
diff --git a/backend/app/assets/javascripts/spree/backend/variant_autocomplete.js.coffee b/backend/app/assets/javascripts/spree/backend/variant_autocomplete.js.coffee index 2d14fc01181..65dadd1296d 100644 --- a/backend/app/assets/javascripts/spree/backend/variant_autocomplete.js.coffee +++ b/backend/app/assets/javascripts/spree/backend/variant_autocomplete.js.coffee @@ -3,10 +3,8 @@ variantTemplate = HandlebarsTemplates["variants/autocomplete"] formatVariantResult = (variant) -> - image = variant.images[0].mini_url if variant["images"][0] isnt undefined and variant["images"][0].mini_url isnt undefined variantTemplate( variant: variant - image: image ) $.fn.variantAutocomplete = (searchOptions = {}) -> diff --git a/backend/app/assets/javascripts/spree/backend/views/cart/line_item_row.js b/backend/app/assets/javascripts/spree/backend/views/cart/line_item_row.js index f0a1672c13b..b0877690041 100644 --- a/backend/app/assets/javascripts/spree/backend/views/cart/line_item_row.js +++ b/backend/app/assets/javascripts/spree/backend/views/cart/line_item_row.js @@ -76,11 +76,8 @@ Spree.Views.Cart.LineItemRow = Backbone.View.extend({ }, render: function() { - var line_item = this.model.attributes - var image = line_item.variant && line_item.variant.images[0] var html = HandlebarsTemplates['orders/line_item']({ - line_item: line_item, - image: image, + line_item: this.model.toJSON(), editing: this.editing, isNew: this.model.isNew(), noCancel: this.model.isNew() && this.model.collection.length == 1 diff --git a/backend/app/assets/stylesheets/spree/backend/components/_stock_table.scss b/backend/app/assets/stylesheets/spree/backend/components/_stock_table.scss index b5c10706701..6f3d0287e17 100644 --- a/backend/app/assets/stylesheets/spree/backend/components/_stock_table.scss +++ b/backend/app/assets/stylesheets/spree/backend/components/_stock_table.scss @@ -31,8 +31,7 @@ padding: 0px 5px; } .variant-image, - .variant-details, - .variant-container { + .variant-details { float: left; } .variant-container {