Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add image partial to handlebars #1764

Merged
merged 4 commits into from
Mar 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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('');
});
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{#if image }}
<img src='{{ lookup image (concat size "_url") }}' alt="{{ alt }}" />
{{ else }}
<span class="image-placeholder {{ size }}"></span>
{{/if}}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -4,11 +4,7 @@
</td>
{{else}}
<td class="line-item-image">
{{#if image }}
<img src="{{ image.mini_url }}">
{{else}}
<span class="image-placeholder mini"></span>
{{/if}}
{{> _image image=line_item.variant.images.[0] size="mini" }}
</td>
<td class="line-item-name">
{{ line_item.variant.name }}<br>
Original file line number Diff line number Diff line change
@@ -2,11 +2,7 @@
<td class="align-center no-padding">
<div class='variant-container' data-variant-id="{{variantId}}">
<div class='variant-image'>
{{#if variantImageURL }}
<img alt="{{variantName}}" src="{{variantImageURL}}">
{{ else }}
<span class="image-placeholder small"></span>
{{/if}}
{{> _image image=variantImage size="small" alt=variantName }}
</div>
<div class='variant-details'>
<table class='stock-variant-field-table'>
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<div class="variant-autocomplete-item media">
<div class="media-left">
{{#if image }}
<img class="media-object" src='{{variant.image}}' />
{{ else }}
<span class="image-placeholder mini"></span>
{{/if}}
{{> _image image=variant.images.[0] size="mini" }}
</div>

<div class="media-body">
Original file line number Diff line number Diff line change
@@ -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 = {}) ->
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -31,8 +31,7 @@
padding: 0px 5px;
}
.variant-image,
.variant-details,
.variant-container {
.variant-details {
float: left;
}
.variant-container {