From 7930d7af40d525cdb39753328f039321729a2259 Mon Sep 17 00:00:00 2001 From: Tobias Herre Date: Wed, 26 Feb 2025 12:13:46 +0000 Subject: [PATCH] otrs_link.js fixes *all* links on a page. for travel and project forms. --- input/admin.py | 4 ++++ input/forms.py | 2 +- input/static/dropdown/js/otrs_link.js | 13 +++++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/input/admin.py b/input/admin.py index 1f1ffa7..7cd76fe 100755 --- a/input/admin.py +++ b/input/admin.py @@ -105,6 +105,10 @@ class TravelAdmin(admin.ModelAdmin): autocomplete_fields = ['project'] readonly_fields = ['service_id'] + class Media: + js = ('dropdown/js/otrs_link.js',) + + @admin.register(Email) class EmailAdmin(admin.ModelAdmin): save_as = True diff --git a/input/forms.py b/input/forms.py index d67ba51..bc020cd 100755 --- a/input/forms.py +++ b/input/forms.py @@ -84,11 +84,11 @@ class TravelForm(FdbForm): hotel = ChoiceField(label='Hotelzimmer benötigt:', choices=HOTEL_CHOICES.items(), widget=RadioSelect()) class Media: + js = ('dropdown/js/otrs_link.js',) css = { 'all': ('css/dateFieldNoNowShortcutInTravels.css',) } - class LibraryForm(FdbForm): class Meta: diff --git a/input/static/dropdown/js/otrs_link.js b/input/static/dropdown/js/otrs_link.js index 3420e9f..b5685e1 100644 --- a/input/static/dropdown/js/otrs_link.js +++ b/input/static/dropdown/js/otrs_link.js @@ -1,9 +1,18 @@ window.addEventListener("load", function() { + + + (function($) { $(function() { +document.querySelectorAll("a").forEach(link => { + link.href = link.href.replace(/%3B/g, ";").replace(/%3D/g, "="); +}); + +/* // let linkElement = document.querySelector(".field-otrs > div > p.url > a"); - let linkElement = document.querySelector(".field-otrs p.url a"); + //let linkElement = document.querySelector(".field-otrs p.url a"); + let linkElement = document.querySelector("a"); if (!linkElement) { console.error("OTRS-Link not found!"); return; @@ -18,7 +27,7 @@ window.addEventListener("load", function() { //console.log("Modified link:", otrs_link_pretty); linkElement.href = otrs_link_pretty; - +*/ }); })(django.jQuery); });