Compare commits

...

3 Commits

Author SHA1 Message Date
Raphael Michel
3420a51e95 Update alerts 2025-06-12 13:56:43 +02:00
Raphael Michel
687e55cec1 Fix condition 2025-06-12 13:52:15 +02:00
Raphael Michel
56432a81c6 Subevent bulk editing: Warn about deleted quotas 2025-06-11 15:50:37 +02:00
2 changed files with 58 additions and 14 deletions

View File

@@ -5,6 +5,7 @@
{% load captureas %} {% load captureas %}
{% load static %} {% load static %}
{% load eventsignal %} {% load eventsignal %}
{% load dialog %}
{% block title %}{% trans "Change multiple dates" context "subevent" %}{% endblock %} {% block title %}{% trans "Change multiple dates" context "subevent" %}{% endblock %}
{% block content %} {% block content %}
<h1> <h1>
@@ -182,21 +183,22 @@
</fieldset> </fieldset>
<fieldset> <fieldset>
<legend>{% trans "Quotas" %}</legend> <legend>{% trans "Quotas" %}</legend>
{% if sampled_quotas|default_if_none:"NONE" == "NONE" %} <div class="bulk-edit-field-group"
<div class="alert alert-warning"> {% if sampled_quotas|default_if_none:"NONE" == "NONE" %}
{% blocktrans trimmed %} data-confirm-dialog="#confirm-override-quotas"
You selected a set of dates that currently have different quota setups. You can therefore {% endif %}>
not change their quotas in bulk. If you want, you can set up a new set of quotas to
<strong>replace</strong> the quota setup of all selected dates.
{% endblocktrans %}
</div>
{% endif %}
<div class="bulk-edit-field-group">
<label class="field-toggle"> <label class="field-toggle">
<input type="checkbox" name="_bulk" value="__quotas" {% if "__quotas" in bulk_selected %}checked{% endif %}> <input type="checkbox" name="_bulk" value="__quotas" {% if "__quotas" in bulk_selected %}checked{% endif %}>
{% trans "change" context "form_bulk" %} {% trans "change" context "form_bulk" %}
</label> </label>
<div class="field-content"> <div class="field-content">
{% if sampled_quotas|default_if_none:"NONE" == "NONE" %}
<div class="alert alert-warning">
{% trans "You selected a set of dates that currently have different quota setups." %}
{% trans "Using this option will <strong>delete all current quotas</strong> from <strong>all selected dates</strong>." %}
</div>
{% endif %}
<div class="formset" data-formset data-formset-prefix="{{ formset.prefix }}"> <div class="formset" data-formset data-formset-prefix="{{ formset.prefix }}">
{{ formset.management_form }} {{ formset.management_form }}
{% bootstrap_formset_errors formset %} {% bootstrap_formset_errors formset %}
@@ -271,7 +273,7 @@
<fieldset> <fieldset>
<legend>{% trans "Check-in lists" %}</legend> <legend>{% trans "Check-in lists" %}</legend>
{% if sampled_lists|default_if_none:"NONE" == "NONE" %} {% if sampled_lists|default_if_none:"NONE" == "NONE" %}
<div class="alert alert-warning"> <div class="alert alert-info">
{% blocktrans trimmed %} {% blocktrans trimmed %}
You selected a set of dates that currently have different check-in list setups. You can You selected a set of dates that currently have different check-in list setups. You can
therefore not change their check-in lists in bulk. therefore not change their check-in lists in bulk.
@@ -367,4 +369,17 @@
</button> </button>
</div> </div>
</form> </form>
{% trans "Delete existing quotas" as dialog_title %}
{% trans "Using this option will <strong>delete all current quotas</strong> from <strong>all selected dates</strong>." as dialog_text %}
{% trans "This cannot be reverted. Are you sure to proceed?" as dialog_text2 %}
{% dialog "confirm-override-quotas" dialog_title dialog_text|add:" "|add:dialog_text2 icon="trash" %}
<p class="modal-card-confirm modal-card-confirm-spread">
<button class="btn btn-lg btn-default" value="no">
{% trans "Cancel" %}
</button>
<button class="btn btn-lg btn-danger" value="yes">
{% trans "Proceed" %}
</button>
</p>
{% enddialog %}
{% endblock %} {% endblock %}

View File

@@ -648,18 +648,47 @@ var form_handlers = function (el) {
var $checkbox = $(this).find("input[type=checkbox][name=_bulk]"); var $checkbox = $(this).find("input[type=checkbox][name=_bulk]");
var $content = $(this).find(".field-content"); var $content = $(this).find(".field-content");
var $fields = $content.find("input, select, textarea, button"); var $fields = $content.find("input, select, textarea, button");
var $dialog = $(this).attr("data-confirm-dialog") ? $($(this).attr("data-confirm-dialog")) : null;
var warningShown = false;
if ($dialog) {
$dialog.on("close", function () {
if ($dialog.get(0).returnValue === "yes") {
$checkbox.prop("checked", true);
} else {
$checkbox.prop("checked", false);
warningShown = false;
}
update();
});
}
var update = function () { var update = function () {
var isChecked = $checkbox.prop("checked"); var isChecked = $checkbox.prop("checked");
$content.toggleClass("enabled", isChecked); $content.toggleClass("enabled", isChecked);
$fields.attr("tabIndex", isChecked ? 0 : -1); $fields.attr("tabIndex", isChecked ? 0 : -1);
} }
$content.on("focusin change click", function () { $content.on("focusin change click", function () {
if ($checkbox.prop("checked")) return; if ($checkbox.prop("checked")) return;
$checkbox.prop("checked", true); if ($dialog && !warningShown) {
update(); warningShown = true;
$dialog.get(0).showModal();
} else {
$checkbox.prop("checked", true);
update();
}
}); });
$checkbox.on('change', update) $checkbox.on('change', function () {
var isChecked = $checkbox.prop("checked");
if (isChecked && $dialog && !warningShown) {
warningShown = true;
$dialog.get(0).showModal();
} else if (!isChecked) {
warningShown = false;
}
update();
})
update(); update();
}); });