move exclusive to containing fieldset

This commit is contained in:
Richard Schreiber
2024-03-11 09:19:41 +01:00
parent 9b94e0f918
commit 282b8a7abf
2 changed files with 3 additions and 7 deletions
@@ -6,7 +6,7 @@
{% load eventsignal %}
{% load rich_text %}
{% for c in form.categories %}
<fieldset>
<fieldset{% if c.max_count == 1 or not c.multi_allowed %} data-addon-exclusive{% endif %}>
<legend>{{ c.category.name }}</legend>
{% if c.category.description %}
{{ c.category.description|rich_text }}
@@ -193,7 +193,6 @@
{% endif %}
id="cp_{{ form.pos.pk }}_variation_{{ item.id }}_{{ var.id }}"
name="cp_{{ form.pos.pk }}_variation_{{ item.id }}_{{ var.id }}"
data-exclusive-prefix="cp_{{ form.pos.pk }}_"
aria-label="{% blocktrans with item=item.name var=var %}Add {{ item }}, {{ var }} to cart{% endblocktrans %}">
<i class="fa fa-shopping-cart" aria-hidden="true"></i>
{% trans "Select" context "checkbox" %}
@@ -333,9 +332,6 @@
{% elif item.initial %}
checked="checked"
{% endif %}
{% if c.max_count == 1 %}
data-exclusive-prefix="cp_{{ form.pos.pk }}_"
{% endif %}
name="cp_{{ form.pos.pk }}_item_{{ item.id }}"
id="cp_{{ form.pos.pk }}_item_{{ item.id }}"
aria-label="{% blocktrans with item=item.name %}Add {{ item }} to cart{% endblocktrans %}"
@@ -150,9 +150,9 @@ var form_handlers = function (el) {
});
el.find("fieldset:has(input[data-exclusive-prefix])").on('change', function (e) {
el.find("fieldset[data-addon-exclusive]").on('change', function (e) {
if (e.target.checked) {
$(".input[type=checkbox][name^=" + e.target.getAttribute("data-exclusive-prefix") + "]:checked", this).not(e.target).prop('checked', false).trigger('change');
$(".availability-box input:checked", this).not(e.target).prop('checked', false).trigger('change');
}
});