2
1
Fork 0

otrs_link.js fixes *all* links on a page. for travel and project forms.

This commit is contained in:
Tobias Herre 2025-02-26 12:13:46 +00:00
parent 723f7b42cf
commit 7930d7af40
3 changed files with 16 additions and 3 deletions

View File

@ -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

View File

@ -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:

View File

@ -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);
});