Projet

Général

Profil

0001-publik-famille-check-event-overlaps-65272.patch

Lauréline Guérin, 16 mai 2022 17:00

Télécharger (3,06 ko)

Voir les différences:

Subject: [PATCH] publik-famille: check event overlaps (#65272)

 .../widgets/famille-reservations-par-semaine.html   | 13 +++++++++++++
 .../widgets/famille-reservations-recurrentes.html   | 10 ++++++++++
 2 files changed, 23 insertions(+)
templates/qommon/forms/widgets/famille-reservations-par-semaine.html
34 34
   {% if widget.readonly or option.disabled %}disabled{% endif %}
35 35
   {% for attr in widget.attrs.items %}{{attr.0}}="{{attr.1}}"{% endfor %}
36 36
   type="checkbox"
37
   data-event-id="{{ option.options.id }}"
38
   data-overlaps="{{ option.options.overlaps|join:" " }}"
37 39
   {% if widget.readonly %}value="yes" disabled
38 40
   {% else %}name="{{ option.name }}" value="yes"
39 41
       {% endif %}><span>{{ option.options.label }}</span></label>
......
198 200
    $(elem).hide();
199 201
  }
200 202
});
203
/* check overlaps */
204
$('.template-famille-reservations-par-semaine input').on('change', function() {
205
  if ($(this).is(':checked')) {
206
    $(this).parents('ul').find("input[data-overlaps~='"+$(this).data('event-id')+"']").prop('checked', false);
207
  }
208
});
209
$('.template-famille-reservations-par-semaine input:disabled').each(function(index) {
210
  if ($(this).attr('checked')) {
211
    $(this).parents('ul').find("input[data-overlaps~='"+$(this).data('event-id')+"']").prop('disabled', true);
212
  }
213
});
201 214
/* init first week shown */
202 215
var $cell = $('.template-famille-reservations-par-semaine');
203 216
$cell.find('li').removeClass('shown');
templates/qommon/forms/widgets/famille-reservations-recurrentes.html
12 12
   {% elif widget.readonly or option.disabled %}disabled{% endif %}
13 13
   {% for attr in widget.attrs.items %}{{attr.0}}="{{attr.1}}"{% endfor %}
14 14
   type="checkbox"
15
   data-event-id="{{ option.options.id }}"
16
   data-overlaps="{{ option.options.overlaps|join:" " }}"
15 17
   {% if widget.readonly %}value="yes" disabled
16 18
   {% else %}name="{{ option.name }}" value="yes"
17 19
   {% endif %}><span>{{ option.options.label }}</span></label>
......
77 79
        background: #3c3;
78 80
}
79 81
</style>
82
<script>
83
/* check overlaps */
84
$('.template-famille-reservations-recurrentes input').on('change', function() {
85
  if ($(this).is(':checked')) {
86
    $(this).parents('ul').find("input[data-overlaps~='"+$(this).data('event-id')+"']").prop('checked', false);
87
  }
88
});
89
</script>
80 90
{% endblock %}
81
-