Bugfixes on CLI interactions
This commit is contained in:
@ -22,6 +22,7 @@ function modpol.interactions.dashboard(user)
|
||||
|
||||
local all_users = modpol.instance:list_members()
|
||||
|
||||
print('\n-=< MODPOL DASHBOARD >=-')
|
||||
print('All orgs: (user orgs indicated by *)')
|
||||
for id, org in ipairs(modpol.orgs.array) do
|
||||
if type(org) == "table" then
|
||||
@ -36,7 +37,6 @@ function modpol.interactions.dashboard(user)
|
||||
local user_pending_count = 0
|
||||
for k,v in ipairs(modpol.orgs.array) do
|
||||
if v.pending and v.pending[user] then
|
||||
modpol.msg(v.name)
|
||||
table.insert(user_pending, v.name)
|
||||
user_pending_count = user_pending_count + 1
|
||||
end
|
||||
@ -82,31 +82,37 @@ function modpol.interactions.org_dashboard(user, org_string)
|
||||
table.insert(children, this_child.name)
|
||||
end
|
||||
|
||||
-- list available modules
|
||||
local org_modules = {}
|
||||
for k,v in pairs(org.modules) do
|
||||
if not v.hide then
|
||||
table.insert(org_modules, v.slug)
|
||||
-- prepare modules menu
|
||||
local modules = {}
|
||||
if org.modules then
|
||||
for k,v in pairs(org.modules) do
|
||||
if not v.hide then -- hide utility modules
|
||||
local module_entry = v.slug
|
||||
table.insert(modules, module_entry)
|
||||
end
|
||||
end
|
||||
end
|
||||
table.sort(modules)
|
||||
|
||||
-- list pending
|
||||
local process_msg = #org.processes .. " total processes"
|
||||
if org.pending[user] then
|
||||
process_msg = process_msg .. " (" .. #org.pending[user] .. " pending)"
|
||||
process_msg = process_msg .. " (" ..
|
||||
modpol.util.num_pairs(org.pending[user]) .. " pending)"
|
||||
else
|
||||
process_msg = process_msg .. " (0 pending)"
|
||||
end
|
||||
|
||||
-- set up output
|
||||
print('\n-=< ORG DASHBOARD >=-')
|
||||
print("Org: " .. org.name)
|
||||
print("Parent: " .. parent)
|
||||
print("Members: " .. table.concat(org.members, ", "))
|
||||
print("Children: " .. table.concat(children, ", "))
|
||||
print("Modules: " .. table.concat(org_modules, ", "))
|
||||
print("Modules: " .. table.concat(modules, ", "))
|
||||
print("Pending: " .. process_msg)
|
||||
print()
|
||||
print("Commands: (M)odules, (P)ending")
|
||||
print("Commands: (M)odules, (P)ending, (B)ack")
|
||||
|
||||
local sel = io.read()
|
||||
print()
|
||||
@ -116,7 +122,7 @@ function modpol.interactions.org_dashboard(user, org_string)
|
||||
local module_sel = io.read()
|
||||
print()
|
||||
local module_result = false
|
||||
for k,v in ipairs(org_modules) do
|
||||
for k,v in ipairs(modules) do
|
||||
if v == module_sel then
|
||||
module_result = true
|
||||
end
|
||||
@ -127,19 +133,20 @@ function modpol.interactions.org_dashboard(user, org_string)
|
||||
print("Error: Module not found.")
|
||||
end
|
||||
|
||||
elseif sel == 'a' or sel == 'A' then
|
||||
elseif sel == 'p' or sel == 'P' then
|
||||
local processes = {}
|
||||
print("All processes: (* indicates pending)")
|
||||
for k,v in ipairs(org.processes) do
|
||||
for i,v in ipairs(org.processes) do
|
||||
local active = ''
|
||||
if org.pending[user] then
|
||||
if org.pending[user][v.id] then
|
||||
active = '*'
|
||||
end
|
||||
end
|
||||
print("["..v.id.."] "..v.slug..active)
|
||||
end
|
||||
print()
|
||||
print("Interact with which one?")
|
||||
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
|
||||
@ -148,6 +155,8 @@ function modpol.interactions.org_dashboard(user, org_string)
|
||||
org:interact(process.id, user)
|
||||
end
|
||||
end
|
||||
elseif sel == 'b' or sel == 'B' then
|
||||
modpol.interactions.dashboard(user)
|
||||
else
|
||||
print("Command not found")
|
||||
modpol.interactions.org_dashboard(user, org.name)
|
||||
|
Reference in New Issue
Block a user