publik-famille: check event overlaps (#65272)
gitea-wip/publik-base-theme/pipeline/head Build started... Details

This commit is contained in:
Lauréline Guérin 2022-05-16 16:59:43 +02:00
parent 200d8451f4
commit 77a77eb365
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 23 additions and 0 deletions

View File

@ -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 %}><span>{{ option.options.label }}</span></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');

View File

@ -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 %}><span>{{ option.options.label }}</span></label>
@ -77,4 +79,12 @@
background: #3c3;
}
</style>
<script>
/* check overlaps */
$('.template-famille-reservations-recurrentes input').on('change', function() {
if ($(this).is(':checked')) {
$(this).parents('ul').find("input[data-overlaps~='"+$(this).data('event-id')+"']").prop('checked', false);
}
});
</script>
{% endblock %}