Improve add-to-cart checkbox for items with max. 1 per order (Z#178704) (#2413)

This commit is contained in:
Richard Schreiber
2022-01-12 17:10:00 +01:00
committed by GitHub
parent cf751d38d2
commit 701c4f768e
3 changed files with 20 additions and 2 deletions

View File

@@ -174,15 +174,20 @@
<div class="col-md-2 col-xs-6 availability-box unavailable">
<p><small><a href="#voucher">{% trans "Enter a voucher code below to buy this ticket." %}</a></small></p>
</div>
{% elif var.cached_availability.0 == 100 %}
{% elif var.cached_availability.0 == 100 %}
<div class="col-md-2 col-xs-6 availability-box available">
{% if var.order_max == 1 %}
<label class="item-checkbox-label">
<input type="checkbox" value="1"
{% if item.free_price %}
data-checked-onchange="price-variation-{{ item.pk }}-{{ var.pk }}"
{% endif %}
{% if not ev.presale_is_running %}disabled{% endif %}
id="variation_{{ item.id }}_{{ var.id }}"
name="variation_{{ item.id }}_{{ var.id }}"
title="{% blocktrans with item=item.name var=var.name %}Do you want to order {{ item }}, {{ var }}?{% endblocktrans %}">
aria-label="{% blocktrans with item=item.name var=var %}Add {{ item }}, {{ var }} to cart{% endblocktrans %}"
{% if var.description %} aria-describedby="item-{{ item.pk }}-{{ var.pk }}-description"{% endif %}>
<i class="fa fa-cart-plus fa-lg" aria-hidden="true"></i>
</label>
{% else %}
<input type="number" class="form-control input-item-count" placeholder="0" min="0"
@@ -303,10 +308,14 @@
{% if item.order_max == 1 %}
<label class="item-checkbox-label">
<input type="checkbox" value="1" {% if itemnum == 1 %}checked{% endif %}
{% if item.free_price %}
data-checked-onchange="price-item-{{ item.pk }}"
{% endif %}
{% if not ev.presale_is_running %}disabled{% endif %}
name="item_{{ item.id }}" id="item_{{ item.id }}"
aria-label="{% blocktrans with item=item.name %}Add {{ item }} to cart{% endblocktrans %}"
{% if item.description %} aria-describedby="item-{{ item.id }}-description"{% endif %}>
<i class="fa fa-cart-plus fa-lg" aria-hidden="true"></i>
</label>
{% else %}
<input type="number" class="form-control input-item-count" placeholder="0" min="0"

View File

@@ -634,6 +634,14 @@ $(function () {
// Lightbox
lightbox.init();
// free-range price input auto-check checkbox
$("[data-checked-onchange]").each(function() {
var checkbox = this;
$("#" + this.getAttribute("data-checked-onchange")).on("change", function() {
checkbox.checked = true;
});
});
});
function copy_answers(elements, answers) {

View File

@@ -31,6 +31,7 @@
}
.item-checkbox-label {
display: block;
margin-top: .4em;
}
.product-description.with-picture {