expand inactive users when filter is applied

This commit is contained in:
metamuffin 2024-11-26 19:26:30 +01:00
parent 8e02438ea7
commit 15f4cc0c85
No known key found for this signature in database
GPG key ID: 718F9749DCDBD654

View file

@ -536,7 +536,7 @@ local function r_users(show_special, filter_negative)
end end
return respond(200, "Abrechenbarkeit", function() return respond(200, "Abrechenbarkeit", function()
local users = get_active_users() local users = get_active_users()
if not show_special then if not show_special then
print(format([[ print(format([[
@ -548,34 +548,34 @@ local function r_users(show_special, filter_negative)
</form> </form>
]])) ]]))
-- get first letters -- get first letters
local firstletters = {} local firstletters = {}
local function contains(char) local function contains(char)
for _, firstchar in ipairs(firstletters) do for _, firstchar in ipairs(firstletters) do
if firstchar == char then if firstchar == char then
return true return true
end end
end end
return false return false
end end
for _, user in ipairs(users) do for _, user in ipairs(users) do
user.firstchar = user.name:sub(1,1):lower() user.firstchar = user.name:sub(1, 1):lower()
if user.firstchar ~= "@" and not contains(user.firstchar) then if user.firstchar ~= "@" and not contains(user.firstchar) then
table.insert(firstletters, user.firstchar) table.insert(firstletters, user.firstchar)
end end
end end
table.sort(firstletters) table.sort(firstletters)
print(format([[<section class="firstletterlist"><h3>{+users.filter}</h3><ul>]])) print(format([[<section class="firstletterlist"><h3>{+users.filter}</h3><ul>]]))
for k, letter in ipairs(firstletters) do for k, letter in ipairs(firstletters) do
print(format([[<li><a href="?users&prefix={letter}">{letter}</a></li>]], { print(format([[<li><a href="?users&prefix={letter}">{letter}</a></li>]], {
letter = letter, letter = letter,
})) }))
end end
print([[</ul></section>]]) print([[</ul></section>]])
end end
print([[<div class="userlist"></div>]]) -- for printing print([[<div class="userlist"></div>]]) -- for printing
print([[<ul class="userlist">]]) print([[<ul class="userlist">]])
@ -624,7 +624,9 @@ local function r_users(show_special, filter_negative)
return return
end end
print(format([[<details><summary>{+users.inactive_list}</summary><ul class="userlist">]])) print(format([[
<details {oclass}><summary>{+users.inactive_list}</summary><ul class="userlist">
]], { oclass = query.prefix and "open" or "" }))
for _, user in ipairs(users) do for _, user in ipairs(users) do
if user.time <= inactive_cutoff then show_user(user) end if user.time <= inactive_cutoff then show_user(user) end
end end