https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36437

--- Comment #10 from MichaƂ <[email protected]> ---
Until I get around to contributing a correction to re-order this facet in Perl
here, I came up with this JavaScript snippet as a temporary replacement after
being asked by library (works in both OPAC and Intranet), thought I could share
in case someone finds it useful:

// date-of-publication facet in descending order
const dateOfPublicationFacet =
document.querySelector("li#date-of-publication_id:has(#facet-date-of-publication)");
if (dateOfPublicationFacet) {
    const numberOfUncollapsed = dateOfPublicationFacet.querySelectorAll("ul
li:not(.collapsible-facet):not(.moretoggle)").length;
    [...dateOfPublicationFacet.querySelectorAll("ul li:not(.moretoggle)")]
    .map(element => {
        element.classList.remove("collapsible-facet");
        element.setAttribute("style", "");
        return element;
    })
    .sort((el_a, el_b) => {
        const n = e => +e.querySelector(".facet-label").innerText;
        const [a, b] = [n(el_a), n(el_b)];
        return a > b;
    })
    .map(element => element.parentNode.insertAdjacentElement("afterbegin",
element))
    .reverse()
    .slice(numberOfUncollapsed)
    .forEach(element => {
        element.classList.add("collapsible-facet");
        element.setAttribute("style", "display: none;");
    });
}

-- 
You are receiving this mail because:
You are watching all bug changes.
_______________________________________________
Koha-bugs mailing list
[email protected]
https://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs
website : http://www.koha-community.org/
git : http://git.koha-community.org/
bugs : http://bugs.koha-community.org/

Reply via email to