merged changes, using standardized lazy table length function instead of for loop in interactions module

This commit is contained in:
Luke Miller
2022-08-16 11:12:07 -04:00
6 changed files with 22 additions and 51 deletions

View File

@ -223,20 +223,17 @@ function modpol.interactions.org_dashboard(user, org_string)
print("Error: Module not found.")
modpol.interactions.org_dashboard(user, org.id)
end
elseif sel == 'p' or sel == 'P' then
local processes = {}
elseif sel == 'p' or sel == 'P' then -- Pending processes
print("All processes: (* indicates pending)")
for i,v in ipairs(org.processes) do
if v ~= "deleted" then
local active = ''
if org.pending[user] then
if org.pending[user][v.id] then
active = '*'
end
for i,v in ipairs(processes) do
local active = ''
if org.pending[user] then
if org.pending[user][v.id] then
active = '*'
end
print("["..v.id.."] "..v.slug..active)
end
print("["..v.id.."] "..v.slug..active)
end
print()
print("Interact with which one (use [id] number)?")

View File

@ -32,7 +32,8 @@ function defer:initiate(result)
self.org:delete_process(self.id)
else
defer_org:call_module(
self.config.approval_module, self.initiator,
self.config.approval_module,
self.initiator,
{
prompt = self.config.prompt
},
@ -40,6 +41,8 @@ function defer:initiate(result)
if result then result() end
end)
end
modpol.interactions.org_dashboard(
self.initiator, self.org.id)
if result then result() end
self.org:delete_process(self.id)
end

View File

@ -19,7 +19,7 @@ display_processes.config = {
-- @param result Callback if this module is embedded in other modules
function display_processes:initiate(result)
local display_table = {}
for k,v in pairs(self.org.processes) do
for k,v in ipairs(self.org.processes) do
if v ~= "deleted" then
local input = v.id..": "..v.slug
table.insert(display_table, input)

View File

@ -4,7 +4,7 @@
local remove_process = {
name = "Remove process",
slug = "remove_process",
desc = "User can remove own processes, consent required for those of others",
desc = "User can remove own processes, approval required for those of others",
hide = false;
}
@ -12,6 +12,7 @@ remove_process.data = {
}
remove_process.config = {
approval_module = "consent"
}
--- Initiate function
@ -71,11 +72,12 @@ function remove_process:initiate(result)
self.org:delete_process(self.id)
else
self:call_module(
"consent",
self.config.approval_module,
self.initiator,
{
prompt = "Approve removal of process "..process_choice.."?",
votes_required = #self.org.members
prompt =
"Approve removal of process "
..process_choice.."?"
},
function(input)
modpol.interactions.message_org(