Completed checkbox_query and rewrite of change_modules module with checkboxes

This commit is contained in:
Nathan Schneider
2022-01-02 23:13:56 -07:00
parent 28a05c584c
commit 2989bd34bd
6 changed files with 195 additions and 23 deletions

View File

@ -187,7 +187,12 @@ function modpol.interactions.org_dashboard(user, org_string)
print("Interact with which one (use [id] number)?")
local to_interact = io.read()
local process = org.processes[tonumber(to_interact)]
if not process then return end
if not process then
modpol.interactions.message(
user, "Not a pending process")
modpol.interactions.org_dashboard(user, org.id)
return
end
if org:has_pending_actions(user) then
if org.pending[user][process.id] then
org:interact(process.id, user)
@ -381,8 +386,10 @@ function modpol.interactions.checkbox_query(
end
local result_table = modpol.util.copy_table(options)
for i,v in ipairs(answer_table) do
-- flip the boolean on selected options
result_table[v][2] = not result_table[v][2]
if result_table[v] then
-- flip the boolean on selected options
result_table[v][2] = not result_table[v][2]
end
end
func(result_table)
end
@ -433,5 +440,5 @@ end
--testing command
function modpol.msg(text)
modpol.interactions.message("TEST MSG: ",text)
modpol.interactions.message("TEST MSG",text)
end