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:
@@ -2893,11 +2893,43 @@ 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/jquery/jquery-3.5.1.min.js"></script>
|
||||||
<script type="text/javascript" src="/plugins/Semantic-UI-master/semantic.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')?>">
|
<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>
|
<script>
|
||||||
|
|
||||||
var $y = jQuery.noConflict();
|
var $y = jQuery.noConflict();
|
||||||
$y( document ).ready(function() {
|
$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() {
|
$("<?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) ?>);
|
||||||
|
|||||||
@@ -572,11 +572,43 @@ 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/jquery/jquery-3.5.1.min.js"></script>
|
||||||
<script type="text/javascript" src="/plugins/Semantic-UI-master/semantic.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')?>">
|
<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>
|
<script>
|
||||||
|
|
||||||
var $y = jQuery.noConflict();
|
var $y = jQuery.noConflict();
|
||||||
$y( document ).ready(function() {
|
$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() {
|
$("<?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) ?>);
|
||||||
|
|||||||
@@ -134,6 +134,13 @@ while ($row = mysqli_fetch_assoc($resultSavedEinrichts)) {
|
|||||||
$savedEinrichts[] = $row['einricht_id'];
|
$savedEinrichts[] = $row['einricht_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verknüpfungskarte für Einrichtungen (Gruppen → Mitglieder)
|
||||||
|
$einrichtLinks = [];
|
||||||
|
$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']);
|
||||||
|
}
|
||||||
|
|
||||||
// Array mit Daten für Tagify (Einrichtungen)
|
// Array mit Daten für Tagify (Einrichtungen)
|
||||||
$savedEinrichtsData = [];
|
$savedEinrichtsData = [];
|
||||||
foreach ($einrichts as $einricht) {
|
foreach ($einrichts as $einricht) {
|
||||||
@@ -842,6 +849,17 @@ $parentCount = count($parentCategories);
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
var einrichtLinks = <?= json_encode($einrichtLinks) ?>;
|
||||||
|
tagifyEinrichts.on('add', function(e) {
|
||||||
|
var addedId = String(e.detail.data.value);
|
||||||
|
(einrichtLinks[addedId] || []).forEach(function(lid) {
|
||||||
|
var exists = tagifyEinrichts.value.some(function(t) { return String(t.value) === lid; });
|
||||||
|
if (!exists) {
|
||||||
|
var item = einrichtsData.find(function(d) { return String(d.value) === lid; });
|
||||||
|
if (item) tagifyEinrichts.addTags([item]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
var tagifyFachbereiche = new Tagify(document.getElementById('selected_fachbereiche'), {
|
var tagifyFachbereiche = new Tagify(document.getElementById('selected_fachbereiche'), {
|
||||||
whitelist: fachbereicheData,
|
whitelist: fachbereicheData,
|
||||||
|
|||||||
@@ -136,6 +136,13 @@ $result = mysqli_query($GLOBALS['mysql_con'], $query);
|
|||||||
while ($row = mysqli_fetch_assoc($result)) {
|
while ($row = mysqli_fetch_assoc($result)) {
|
||||||
$postEinrichtsData[] = ['value' => $row['id'], 'name' => $row['description']];
|
$postEinrichtsData[] = ['value' => $row['id'], 'name' => $row['description']];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Verknüpfungskarte für Einrichtungen (Gruppen → Mitglieder)
|
||||||
|
$postEinrichtLinks = [];
|
||||||
|
$linkRes = mysqli_query($GLOBALS['mysql_con'], "SELECT einricht_id, linked_einricht_id FROM organigramm_einricht_link");
|
||||||
|
while ($lr = mysqli_fetch_assoc($linkRes)) {
|
||||||
|
$postEinrichtLinks[strval($lr['einricht_id'])][] = strval($lr['linked_einricht_id']);
|
||||||
|
}
|
||||||
$selectedPostEinrichts = [];
|
$selectedPostEinrichts = [];
|
||||||
if ($postId != 0) {
|
if ($postId != 0) {
|
||||||
$querySelected = "SELECT e.id, e.description
|
$querySelected = "SELECT e.id, e.description
|
||||||
@@ -409,6 +416,17 @@ if (!empty($post['text_color'])) {
|
|||||||
if (selectedPostEinrichts.length) {
|
if (selectedPostEinrichts.length) {
|
||||||
tagifyPostEinrichts.addTags(selectedPostEinrichts);
|
tagifyPostEinrichts.addTags(selectedPostEinrichts);
|
||||||
}
|
}
|
||||||
|
var postEinrichtLinks = <?= json_encode($postEinrichtLinks) ?>;
|
||||||
|
tagifyPostEinrichts.on('add', function(e) {
|
||||||
|
var addedId = String(e.detail.data.value);
|
||||||
|
(postEinrichtLinks[addedId] || []).forEach(function(lid) {
|
||||||
|
var exists = tagifyPostEinrichts.value.some(function(t) { return String(t.value) === lid; });
|
||||||
|
if (!exists) {
|
||||||
|
var item = postEinrichtsData.find(function(d) { return String(d.value) === lid; });
|
||||||
|
if (item) tagifyPostEinrichts.addTags([item]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Fachbereiche für Post
|
// Fachbereiche für Post
|
||||||
var tagifyPostFachbereiche = new Tagify(document.getElementById('postFachbereichTags'), {
|
var tagifyPostFachbereiche = new Tagify(document.getElementById('postFachbereichTags'), {
|
||||||
|
|||||||
@@ -747,10 +747,42 @@ function multi_select_permission($navigation_id, $type){
|
|||||||
<script type="text/javascript" src="/plugins/jquery/jquery-3.5.1.min.js"></script>
|
<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>
|
<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')?>">
|
<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>
|
<script>
|
||||||
var $y = jQuery.noConflict();
|
var $y = jQuery.noConflict();
|
||||||
$y( document ).ready(function() {
|
$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_".$type;?>").click(function() {
|
$("<?php echo "#all_".$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) ?>);
|
||||||
|
|||||||
Reference in New Issue
Block a user