diff --git a/src/Foundation.hs b/src/Foundation.hs index 0a6a3b50d..90fb562c2 100644 --- a/src/Foundation.hs +++ b/src/Foundation.hs @@ -187,7 +187,7 @@ getTimeLocale' = $(timeLocaleMap [("de", "de_DE.utf8")]) appTZ :: TZ appTZ = $(includeSystemTZ "Europe/Berlin") - + -- Access Control data AccessPredicate = APPure (Route UniWorX -> Bool -> Reader MsgRenderer AuthResult) @@ -604,7 +604,7 @@ instance YesodBreadcrumbs UniWorX where breadcrumb UsersR = return ("Benutzer", Just HomeR) breadcrumb AdminTestR = return ("Test" , Just HomeR) breadcrumb (AdminUserR _) = return ("Users" , Just UsersR) - breadcrumb VersionR = return ("Info" , Just HomeR) + breadcrumb VersionR = return ("Impressum" , Just HomeR) breadcrumb ProfileR = return ("Profile" , Just HomeR) breadcrumb ProfileDataR = return ("Data" , Just ProfileR) diff --git a/templates/table/layout.julius b/templates/table/layout.julius index a9885d599..79862009f 100644 --- a/templates/table/layout.julius +++ b/templates/table/layout.julius @@ -3,27 +3,21 @@ document.addEventListener('DOMContentLoaded', function DOMContentLoaded() { - var ASC = 'asc'; - var DESC = 'desc'; - function setupAsync(wrapper) { var table = wrapper.querySelector('#' + #{String $ dbtIdent}); var ths = Array.from(table.querySelectorAll('th.sortable')); - if (ths) { - // attach click handler to each sortable column if any - ths.forEach(function(th) { - th.addEventListener('click', clickHandler); - }); - } - var pagination = wrapper.querySelector('#' + #{String $ dbtIdent} + '-pagination'); + + ths.forEach(function(th) { + th.addEventListener('click', clickHandler); + }); + if (pagination) { - var paginationLinks = Array.from(pagination.querySelectorAll('.pagination-link')); - // attach click handler to pagination links if any - paginationLinks.forEach(function(p) { - p.addEventListener('click', clickHandler); - }); + Array.from(pagination.querySelectorAll('.pagination-link')) + .forEach(function(p) { + p.addEventListener('click', clickHandler); + }); } function clickHandler(event) { @@ -31,12 +25,20 @@ var url = new URL(window.location.origin + window.location.pathname + getClickDestination(this)); url.searchParams.set(#{String $ wIdent "table-only"}, 'yes'); updateTableFrom(url); + + + ths.forEach(function(th) { + // th.removeEventListener('click', clickHandler); + console.log('removed handler from', th); + }); } function getClickDestination(el) { - var link = el.querySelector('a'); - if (!link) { return false; } - return link.getAttribute('href'); + console.log(el); + if (!el.querySelector('a')) { + return false; + } + return el.querySelector('a').getAttribute('href'); } // fetches new sorted table from url with params and replaces contents of current table @@ -47,14 +49,19 @@ 'Accept': 'text/html' } }).then(function(response) { - var contentType = response.headers.get("content-type"); if (!response.ok) { throw ('Looks like there was a problem fetching ' + url.toString() + '. Status Code: ' + response.status); } return response.text(); }).then(function(data) { + // remove listeners + ths.forEach(function(th) { + th.removeEventListener('click', clickHandler); + }); + // replace contents of table body wrapper.innerHTML = data; + // set up async functionality again setupAsync(wrapper); table.querySelector('tbody').innerHTML = data;