diff options
author | Arthur Zamarin <arthurzam@gentoo.org> | 2024-03-21 19:58:32 +0200 |
---|---|---|
committer | Arthur Zamarin <arthurzam@gentoo.org> | 2024-03-21 19:58:32 +0200 |
commit | 25882c2dd8e07dca5553e034b14a288ef727eb11 (patch) | |
tree | 657299aa6e0488ca9e1f18dab97c80b04efe4f4c /pkg | |
parent | app/category: add search for packages list (diff) | |
download | soko-25882c2dd8e07dca5553e034b14a288ef727eb11.tar.gz soko-25882c2dd8e07dca5553e034b14a288ef727eb11.tar.bz2 soko-25882c2dd8e07dca5553e034b14a288ef727eb11.zip |
app/maintainer: add search for packages list
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/app/handler/maintainer/show.templ | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/pkg/app/handler/maintainer/show.templ b/pkg/app/handler/maintainer/show.templ index 4923cbf..317ce70 100644 --- a/pkg/app/handler/maintainer/show.templ +++ b/pkg/app/handler/maintainer/show.templ @@ -112,10 +112,28 @@ templ show(packagesCount int, maintainer *models.Maintainer, currentSubTab strin </div> } +script filter() { + const value = document.querySelector("#filter").value.toLowerCase(); + const groups = document.querySelectorAll("#pkglist .list-group"); + for (let i = 0; i < groups.length; i++) { + let visible = false; + const rows = groups[i].querySelectorAll(".list-group-item"); + for (let j = 0; j < rows.length; j++) { + const flag = rows[j].children[0].children[0].innerText.toLowerCase().includes(value); + rows[j].style.display = flag ? "" : "none"; + visible ||= flag; + } + groups[i].style.display = visible ? "" : "none"; + } +} + templ showPackages(packages []*models.Package, maintainer *models.Maintainer) { <div class="row"> - <div class="col-md-9"> + <div class="col-md-9" id="pkglist"> if len(packages) > 0 { + <p> + <input onKeyup={ filter() } id="filter" type="text" class="form-control form-control-xl" placeholder={ "Search packages maintained by " + maintainer.Email }/> + </p> <ul class="list-group"> <h3 id={ packages[0].Category }>{ packages[0].Category }</h3> for i, pkg := range packages { @@ -136,6 +154,7 @@ templ showPackages(packages []*models.Package, maintainer *models.Maintainer) { </li> } </ul> + @filter() } else { <div class="row"> <div class="col-md-8"></div> |