feat(einricht): Verknüpfte Einrichtungen bei Mehrfachauswahl automatisch mitselektieren

Wenn eine Einrichtung mit hinterlegten Links ausgewählt wird, werden alle
verknüpften Einrichtungen (aus organigramm_einricht_link) automatisch
mitausgewählt. Gilt für alle 5 Einrichtungs-Multiselects (3× Semantic UI
Dropdown, 2× Tagify).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-29 10:07:25 +02:00
parent ab4f38a360
commit 8aadf65cc3
5 changed files with 140 additions and 8 deletions

View File

@@ -572,18 +572,50 @@ function multi_select_permission($collection_id, $type){
<script type="text/javascript" src="/plugins/jquery/jquery-3.5.1.min.js"></script>
<script type="text/javascript" src="/plugins/Semantic-UI-master/semantic.min.js"></script>
<link rel="stylesheet" type="text/css" href="/plugins/Semantic-UI-master/bc-semantic.css?time=<?= filemtime($_SERVER['DOCUMENT_ROOT'] . '/plugins/Semantic-UI-master/bc-semantic.css')?>">
<?php
$einrichtLinks = [];
if ($type == "einricht") {
$linkRes = mysqli_query($GLOBALS['mysql_con'],
"SELECT einricht_id, linked_einricht_id FROM organigramm_einricht_link");
while ($lr = mysqli_fetch_assoc($linkRes)) {
$einrichtLinks[strval($lr['einricht_id'])][] = strval($lr['linked_einricht_id']);
}
}
?>
<script>
var $y = jQuery.noConflict();
$y( document ).ready(function() {
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('set selected', <?= json_encode($preselect) ?>);
var $drop = $y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>');
<?php if ($type == "einricht"): ?>
var einrichtLinks = <?= json_encode($einrichtLinks) ?>;
var busy = false;
$drop.dropdown({
onChange: function(value) {
if (busy) return;
var current = value ? value.split(',').filter(Boolean) : [];
var toAdd = [];
current.forEach(function(id) {
(einrichtLinks[id] || []).forEach(function(lid) {
if (current.indexOf(lid) < 0 && toAdd.indexOf(lid) < 0) toAdd.push(lid);
});
});
if (toAdd.length) {
busy = true;
$drop.dropdown('set selected', current.concat(toAdd));
busy = false;
}
}
});
<?php endif; ?>
$drop.dropdown('set selected', <?= json_encode($preselect) ?>);
});
$("<?php echo "#all_get".$type;?>").click(function() {
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('set selected', <?= json_encode($allselect) ?>);
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('set selected', <?= json_encode($allselect) ?>);
});
$("<?php echo "#all_del".$type;?>").click(function() {
console.log("delete");
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('clear');
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('clear');
});
</script>
<?