breadcrumb for imprint and pagination-julius cleanup
This commit is contained in:
parent
5285c6c01f
commit
16315e55fb
@ -187,7 +187,7 @@ getTimeLocale' = $(timeLocaleMap [("de", "de_DE.utf8")])
|
|||||||
appTZ :: TZ
|
appTZ :: TZ
|
||||||
appTZ = $(includeSystemTZ "Europe/Berlin")
|
appTZ = $(includeSystemTZ "Europe/Berlin")
|
||||||
|
|
||||||
|
|
||||||
-- Access Control
|
-- Access Control
|
||||||
data AccessPredicate
|
data AccessPredicate
|
||||||
= APPure (Route UniWorX -> Bool -> Reader MsgRenderer AuthResult)
|
= APPure (Route UniWorX -> Bool -> Reader MsgRenderer AuthResult)
|
||||||
@ -604,7 +604,7 @@ instance YesodBreadcrumbs UniWorX where
|
|||||||
breadcrumb UsersR = return ("Benutzer", Just HomeR)
|
breadcrumb UsersR = return ("Benutzer", Just HomeR)
|
||||||
breadcrumb AdminTestR = return ("Test" , Just HomeR)
|
breadcrumb AdminTestR = return ("Test" , Just HomeR)
|
||||||
breadcrumb (AdminUserR _) = return ("Users" , Just UsersR)
|
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 ProfileR = return ("Profile" , Just HomeR)
|
||||||
breadcrumb ProfileDataR = return ("Data" , Just ProfileR)
|
breadcrumb ProfileDataR = return ("Data" , Just ProfileR)
|
||||||
|
|||||||
@ -3,27 +3,21 @@
|
|||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function DOMContentLoaded() {
|
document.addEventListener('DOMContentLoaded', function DOMContentLoaded() {
|
||||||
|
|
||||||
var ASC = 'asc';
|
|
||||||
var DESC = 'desc';
|
|
||||||
|
|
||||||
function setupAsync(wrapper) {
|
function setupAsync(wrapper) {
|
||||||
|
|
||||||
var table = wrapper.querySelector('#' + #{String $ dbtIdent});
|
var table = wrapper.querySelector('#' + #{String $ dbtIdent});
|
||||||
var ths = Array.from(table.querySelectorAll('th.sortable'));
|
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');
|
var pagination = wrapper.querySelector('#' + #{String $ dbtIdent} + '-pagination');
|
||||||
|
|
||||||
|
ths.forEach(function(th) {
|
||||||
|
th.addEventListener('click', clickHandler);
|
||||||
|
});
|
||||||
|
|
||||||
if (pagination) {
|
if (pagination) {
|
||||||
var paginationLinks = Array.from(pagination.querySelectorAll('.pagination-link'));
|
Array.from(pagination.querySelectorAll('.pagination-link'))
|
||||||
// attach click handler to pagination links if any
|
.forEach(function(p) {
|
||||||
paginationLinks.forEach(function(p) {
|
p.addEventListener('click', clickHandler);
|
||||||
p.addEventListener('click', clickHandler);
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function clickHandler(event) {
|
function clickHandler(event) {
|
||||||
@ -31,12 +25,20 @@
|
|||||||
var url = new URL(window.location.origin + window.location.pathname + getClickDestination(this));
|
var url = new URL(window.location.origin + window.location.pathname + getClickDestination(this));
|
||||||
url.searchParams.set(#{String $ wIdent "table-only"}, 'yes');
|
url.searchParams.set(#{String $ wIdent "table-only"}, 'yes');
|
||||||
updateTableFrom(url);
|
updateTableFrom(url);
|
||||||
|
|
||||||
|
|
||||||
|
ths.forEach(function(th) {
|
||||||
|
// th.removeEventListener('click', clickHandler);
|
||||||
|
console.log('removed handler from', th);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getClickDestination(el) {
|
function getClickDestination(el) {
|
||||||
var link = el.querySelector('a');
|
console.log(el);
|
||||||
if (!link) { return false; }
|
if (!el.querySelector('a')) {
|
||||||
return link.getAttribute('href');
|
return false;
|
||||||
|
}
|
||||||
|
return el.querySelector('a').getAttribute('href');
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetches new sorted table from url with params and replaces contents of current table
|
// fetches new sorted table from url with params and replaces contents of current table
|
||||||
@ -47,14 +49,19 @@
|
|||||||
'Accept': 'text/html'
|
'Accept': 'text/html'
|
||||||
}
|
}
|
||||||
}).then(function(response) {
|
}).then(function(response) {
|
||||||
var contentType = response.headers.get("content-type");
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw ('Looks like there was a problem fetching ' + url.toString() + '. Status Code: ' + response.status);
|
throw ('Looks like there was a problem fetching ' + url.toString() + '. Status Code: ' + response.status);
|
||||||
}
|
}
|
||||||
return response.text();
|
return response.text();
|
||||||
}).then(function(data) {
|
}).then(function(data) {
|
||||||
|
// remove listeners
|
||||||
|
ths.forEach(function(th) {
|
||||||
|
th.removeEventListener('click', clickHandler);
|
||||||
|
});
|
||||||
|
|
||||||
// replace contents of table body
|
// replace contents of table body
|
||||||
wrapper.innerHTML = data;
|
wrapper.innerHTML = data;
|
||||||
|
|
||||||
// set up async functionality again
|
// set up async functionality again
|
||||||
setupAsync(wrapper);
|
setupAsync(wrapper);
|
||||||
table.querySelector('tbody').innerHTML = data;
|
table.querySelector('tbody').innerHTML = data;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user