Filter des Dropdowns angepasst
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name academyFIVE::AddSelectBox
|
// @name academyFIVE::AddSelectBox
|
||||||
// @namespace dakp/academyfive
|
// @namespace dakp/academyfive
|
||||||
// @version 2026.04.001
|
// @version 2026.04.002
|
||||||
// @description Füge Selectbox für Kohorten hinzu
|
// @description Füge Selectbox für Kohorten/Planungsgruppen hinzu
|
||||||
// @author Dims Akpan
|
// @author Dims Akpan
|
||||||
// @match https://a5.fhdw-hannover.de/*
|
// @match https://a5.fhdw-hannover.de/*
|
||||||
// @match https://a5.fhdw.de/*
|
// @match https://a5.fhdw.de/*
|
||||||
@@ -14,34 +14,43 @@
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
function getDropdownSelector() {
|
||||||
|
const url = window.location.href;
|
||||||
|
if (url.includes('/course/planning-group/list')) {
|
||||||
|
return 'select[name="cohort-ids[]"]';
|
||||||
|
}
|
||||||
|
if (url.includes('/course/list')) {
|
||||||
|
return 'select[name="planningGroupIds[]"]';
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
function addSelectButtons() {
|
function addSelectButtons() {
|
||||||
// Prüfe ob wir auf der richtigen Seite sind
|
const selector = getDropdownSelector();
|
||||||
if (!window.location.href.includes('/course/list') && !window.location.href.includes('/course/planning-group/list')) {
|
if (!selector) return;
|
||||||
|
|
||||||
|
const dropdown = document.querySelector(selector);
|
||||||
|
|
||||||
|
if (!dropdown) {
|
||||||
|
console.log('Dropdown nicht gefunden:', selector);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const cohortsDropdown = document.querySelector('select[name="cohort-ids[]"]');
|
const dropdownContainer = dropdown.closest('.btn-group.bootstrap-select');
|
||||||
|
|
||||||
if (!cohortsDropdown) {
|
|
||||||
console.log('Kohorten-Dropdown nicht gefunden');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const dropdownContainer = cohortsDropdown.closest('.btn-group.bootstrap-select');
|
|
||||||
const searchBox = dropdownContainer?.querySelector('.bs-searchbox');
|
const searchBox = dropdownContainer?.querySelector('.bs-searchbox');
|
||||||
|
|
||||||
if (!searchBox) {
|
if (!searchBox) {
|
||||||
console.log('Searchbox nicht gefunden');
|
console.log('Searchbox nicht gefunden');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prüfe ob schon vorhanden
|
// Prüfe ob schon vorhanden
|
||||||
if (searchBox.nextElementSibling?.classList.contains('bs-actionsbox')) {
|
if (searchBox.nextElementSibling?.classList.contains('bs-actionsbox')) {
|
||||||
console.log('Select/Deselect Buttons bereits vorhanden');
|
console.log('Select/Deselect Buttons bereits vorhanden');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Füge die Buttons hinzu
|
|
||||||
const actionsBox = document.createElement('div');
|
const actionsBox = document.createElement('div');
|
||||||
actionsBox.className = 'bs-actionsbox';
|
actionsBox.className = 'bs-actionsbox';
|
||||||
actionsBox.innerHTML = `
|
actionsBox.innerHTML = `
|
||||||
@@ -50,15 +59,15 @@
|
|||||||
<button type="button" class="actions-btn bs-deselect-all btn btn-default">Nichts auswählen</button>
|
<button type="button" class="actions-btn bs-deselect-all btn btn-default">Nichts auswählen</button>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
searchBox.insertAdjacentElement('afterend', actionsBox);
|
searchBox.insertAdjacentElement('afterend', actionsBox);
|
||||||
|
|
||||||
console.log('Select/Deselect Buttons erfolgreich eingefügt');
|
console.log('Select/Deselect Buttons erfolgreich eingefügt');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Versuche es direkt
|
// Versuche es direkt
|
||||||
addSelectButtons();
|
addSelectButtons();
|
||||||
|
|
||||||
// Falls das Element noch nicht da ist, warte auf DOMContentLoaded
|
// Falls das Element noch nicht da ist, warte auf DOMContentLoaded
|
||||||
if (document.readyState === 'loading') {
|
if (document.readyState === 'loading') {
|
||||||
document.addEventListener('DOMContentLoaded', addSelectButtons);
|
document.addEventListener('DOMContentLoaded', addSelectButtons);
|
||||||
|
|||||||
Reference in New Issue
Block a user