admin: add AJAX fallback for wahl phase count; use ajax in force-zuteilung JS
All checks were successful
Deploy Workshop-Wahlen (DEV / PROD) / deploy (push) Successful in 11s

This commit is contained in:
Blitz08
2026-01-31 11:45:36 +01:00
parent eb7afe06ff
commit 67222fc6f9
2 changed files with 27 additions and 1 deletions

View File

@@ -138,7 +138,21 @@ jQuery(function($){
$(document).on("change", "#kc-force-wahl-dropdown", function(){
var $w = $(this);
var $phase = $w.closest("form").find("[name='phase']");
refreshPhaseSelect($w, $phase);
// try immediate refresh; if no data found, fallback to AJAX
var sel = $w.find('option:selected');
var einheiten = sel.data('einheiten') || kcWahlPhases[parseInt($w.val(),10)];
if (einheiten) {
refreshPhaseSelect($w, $phase);
} else {
// AJAX fallback to ask server for anzahl_einheiten
$.get(ajaxurl, {action: 'kc_get_wahl', id: $w.val()}).done(function(r){
if (r && r.success && r.data && r.data.anzahl_einheiten) {
// set data attribute so future reads find it
sel.data('einheiten', parseInt(r.data.anzahl_einheiten,10));
}
refreshPhaseSelect($w, $phase);
}).fail(function(){ refreshPhaseSelect($w, $phase); });
}
});
// Initialize existing phase selects based on their selected wahl