diff --git a/templates/qommon/forms/widgets/famille-reservations-par-semaine.html b/templates/qommon/forms/widgets/famille-reservations-par-semaine.html index 1adbde4f..5f1ca25a 100644 --- a/templates/qommon/forms/widgets/famille-reservations-par-semaine.html +++ b/templates/qommon/forms/widgets/famille-reservations-par-semaine.html @@ -34,6 +34,8 @@ {% if widget.readonly or option.disabled %}disabled{% endif %} {% for attr in widget.attrs.items %}{{attr.0}}="{{attr.1}}"{% endfor %} type="checkbox" + data-event-id="{{ option.options.id }}" + data-overlaps="{{ option.options.overlaps|join:" " }}" {% if widget.readonly %}value="yes" disabled {% else %}name="{{ option.name }}" value="yes" {% endif %}>{{ option.options.label }} @@ -198,6 +200,17 @@ $('.template-famille-reservations-par-semaine li.day-title').each(function(idx, $(elem).hide(); } }); +/* check overlaps */ +$('.template-famille-reservations-par-semaine input').on('change', function() { + if ($(this).is(':checked')) { + $(this).parents('ul').find("input[data-overlaps~='"+$(this).data('event-id')+"']").prop('checked', false); + } +}); +$('.template-famille-reservations-par-semaine input:disabled').each(function(index) { + if ($(this).attr('checked')) { + $(this).parents('ul').find("input[data-overlaps~='"+$(this).data('event-id')+"']").prop('disabled', true); + } +}); /* init first week shown */ var $cell = $('.template-famille-reservations-par-semaine'); $cell.find('li').removeClass('shown'); diff --git a/templates/qommon/forms/widgets/famille-reservations-recurrentes.html b/templates/qommon/forms/widgets/famille-reservations-recurrentes.html index 84688f2d..d1ed60a6 100644 --- a/templates/qommon/forms/widgets/famille-reservations-recurrentes.html +++ b/templates/qommon/forms/widgets/famille-reservations-recurrentes.html @@ -12,6 +12,8 @@ {% elif widget.readonly or option.disabled %}disabled{% endif %} {% for attr in widget.attrs.items %}{{attr.0}}="{{attr.1}}"{% endfor %} type="checkbox" + data-event-id="{{ option.options.id }}" + data-overlaps="{{ option.options.overlaps|join:" " }}" {% if widget.readonly %}value="yes" disabled {% else %}name="{{ option.name }}" value="yes" {% endif %}>{{ option.options.label }} @@ -77,4 +79,12 @@ background: #3c3; } + {% endblock %}