Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
WIP Render images in variant image selector
Marcin Gębala8c039ed462d0
diff --git a/saleor/dashboard/templatetags/utils.py b/saleor/dashboard/templatetags/utils.pyindex 6b610d3322..319a0eeb95 100644--- a/saleor/dashboard/templatetags/utils.py+++ b/saleor/dashboard/templatetags/utils.py@@ -25,3 +25,9 @@ def construct_get_query(context, **params):@register.filterdef is_versatile_image_ppoi_click_widget(field):return isinstance(field.field.widget, VersatileImagePPOIClickWidget)++[email protected]_tag('dashboard/product/_image_select.html')+def render_image_choice(field):+ choices = zip(field, field.field.queryset)+ return {'field': field, 'choices_with_images': choices}diff --git a/templates/dashboard/product/_variant_image_select.html b/templates/dashboard/product/_variant_image_select.htmlnew file mode 100644index 0000000000..70752789c1--- /dev/null+++ b/templates/dashboard/product/_variant_image_select.html@@ -0,0 +1,29 @@+{% load i18n %}++<div class="input input-field col">+ {% if field.auto_id %}+ <label class="control-label">+ {{ field.label }}+ {% if not field.field.required %}+ {% trans "(optional)" context "Dashboard form labels" %}+ {% endif %}+ </label>+ {% endif %}+ {% for choice_with_image in choices_with_images %}+ {% with choice=choice_with_image.0 image=choice_with_image.1 %}+ <p>+ <input id="{{ choice.id_for_label }}" name="{{ choice.name }}" class="filled-in" type="checkbox" value="{{ choice.choice_value }}" {% if choice.choice_value in choice.value %} checked="checked" {% endif %}>+ <label for="{{ choice.id_for_label }}">+ {{ choice.choice_label }}+ <img class="responsive-img" src="{{ image.image.crop.120x120 }}" srcset="{{ image.image.crop.120x120 }} 1x" alt="">+ </label>+ </p>+ {% endwith %}+ {% endfor %}+ {% for error in field.errors %}+ <p class="help-block materialize-red-text">{{ error }}</p>+ {% endfor %}+ {% if field.help_text %}+ <p class="help-block">{{ field.help_text|safe }}</p>+ {% endif %}+</div>\ No newline at end of filediff --git a/templates/dashboard/product/modal_select_variant_images.html b/templates/dashboard/product/modal_select_variant_images.htmlindex 4513c9be0a..058f6c3e37 100644--- a/templates/dashboard/product/modal_select_variant_images.html+++ b/templates/dashboard/product/modal_select_variant_images.html@@ -1,5 +1,6 @@{% load i18n %}{% load materializecss %}+{% load utils %}<form action="{% url "dashboard:variant-images" product_pk=product.pk variant_pk=variant.pk %}" method="post" novalidate>{% csrf_token %}@@ -8,7 +9,7 @@{% trans "Select variant images" context "Dashboard variant images modal" %}</h5><div class="row">- {{ form|materializecss }}+ <p>{% render_image_choice form.images %}</p></div></div><div class="modal-footer">