Removed child org from parent children list
This commit is contained in:
@ -152,7 +152,9 @@ function modpol.interactions.org_dashboard(user, org_string)
|
|||||||
local children = {}
|
local children = {}
|
||||||
for k,v in ipairs(org.children) do
|
for k,v in ipairs(org.children) do
|
||||||
local this_child = modpol.orgs.get_org(v)
|
local this_child = modpol.orgs.get_org(v)
|
||||||
table.insert(children, this_child.name)
|
if this_child then
|
||||||
|
table.insert(children, this_child.name)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- prepare modules menu
|
-- prepare modules menu
|
||||||
|
@ -40,6 +40,8 @@ function defer:initiate(result)
|
|||||||
function()
|
function()
|
||||||
if result then result() end
|
if result then result() end
|
||||||
end)
|
end)
|
||||||
|
modpol.interactions.message(
|
||||||
|
self.initiator, "Defer: action sent to " .. defer_org.name)
|
||||||
end
|
end
|
||||||
modpol.interactions.org_dashboard(
|
modpol.interactions.org_dashboard(
|
||||||
self.initiator, self.org.id)
|
self.initiator, self.org.id)
|
||||||
|
@ -25,19 +25,24 @@ end
|
|||||||
|
|
||||||
--- Return org when given its id or name
|
--- Return org when given its id or name
|
||||||
-- @function modpol.orgs.get_org
|
-- @function modpol.orgs.get_org
|
||||||
-- @param arg string for name of org or id of org
|
-- @param arg string for name of org or id of org, or nil if no org
|
||||||
-- @return org specified by id or name
|
-- @return org specified by id or name
|
||||||
function modpol.orgs.get_org(arg)
|
function modpol.orgs.get_org(arg)
|
||||||
if type(arg) == 'string' then
|
local output = nil
|
||||||
for id, org in ipairs(modpol.orgs.array) do
|
if type(arg) == 'string' then
|
||||||
|
for id, org in ipairs(modpol.orgs.array) do
|
||||||
|
if org ~= "deleted" then
|
||||||
if org.name == arg then
|
if org.name == arg then
|
||||||
return org
|
output = org
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif type(arg) == 'number' then
|
end
|
||||||
return modpol.orgs.array[arg]
|
elseif type(arg) == 'number' then
|
||||||
end
|
if modpol.orgs.array[arg] ~= "deleted" then
|
||||||
return nil
|
output = modpol.orgs.array[arg]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return output
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Return a table list of all org names
|
--- Return a table list of all org names
|
||||||
@ -80,7 +85,7 @@ function modpol.orgs.reset()
|
|||||||
modpol.util.copy_table(modpol.instance.members)
|
modpol.util.copy_table(modpol.instance.members)
|
||||||
for id, org in ipairs(modpol.orgs.array) do
|
for id, org in ipairs(modpol.orgs.array) do
|
||||||
if id > 1 then
|
if id > 1 then
|
||||||
modpol.orgs.array[id] = "removed"
|
modpol.orgs.array[id] = "deleted"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -215,6 +220,17 @@ function modpol.orgs:delete()
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- remove from parent's list
|
||||||
|
local parent = modpol.orgs.get_org(self.id)
|
||||||
|
if parent then
|
||||||
|
for k,v in ipairs(parent.children) do
|
||||||
|
if v == self.id then
|
||||||
|
v = "deleted"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- remove children
|
||||||
if #self.children > 0 then
|
if #self.children > 0 then
|
||||||
for i, child_id in pairs(self.children) do
|
for i, child_id in pairs(self.children) do
|
||||||
local child = modpol.orgs.get_org(child_id)
|
local child = modpol.orgs.get_org(child_id)
|
||||||
@ -223,7 +239,7 @@ function modpol.orgs:delete()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
modpol.orgs.array[self.id] = 'removed'
|
modpol.orgs.array[self.id] = 'deleted'
|
||||||
modpol.orgs.count = modpol.orgs.count - 1
|
modpol.orgs.count = modpol.orgs.count - 1
|
||||||
modpol.ocutil.log('Deleted org ' .. self.name .. ': ' .. self.id)
|
modpol.ocutil.log('Deleted org ' .. self.name .. ': ' .. self.id)
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ end
|
|||||||
-- @param user
|
-- @param user
|
||||||
function modpol.orgs:remove_pending_action(process_id, user)
|
function modpol.orgs:remove_pending_action(process_id, user)
|
||||||
if self.pending[user] then
|
if self.pending[user] then
|
||||||
self.pending[user][process_id] = nil
|
self.pending[user][process_id] = "deleted"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ end
|
|||||||
-- @param process_id
|
-- @param process_id
|
||||||
function modpol.orgs:wipe_pending_actions(process_id)
|
function modpol.orgs:wipe_pending_actions(process_id)
|
||||||
for user in pairs(self.pending) do
|
for user in pairs(self.pending) do
|
||||||
self.pending[user][process_id] = nil
|
self.pending[user][process_id] = "deleted"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -137,11 +137,15 @@ function modpol.interactions.org_dashboard(user, org_string)
|
|||||||
|
|
||||||
-- prepare children menu
|
-- prepare children menu
|
||||||
local children = {}
|
local children = {}
|
||||||
for k,v in ipairs(org.children) do
|
if org.children then
|
||||||
local this_child = modpol.orgs.get_org(v)
|
for k,v in ipairs(org.children) do
|
||||||
table.insert(children, this_child.name)
|
local this_child = modpol.orgs.get_org(v)
|
||||||
|
if this_child then
|
||||||
|
table.insert(children, this_child.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
table.sort(children)
|
||||||
end
|
end
|
||||||
table.sort(children)
|
|
||||||
|
|
||||||
-- prepare modules menu
|
-- prepare modules menu
|
||||||
local modules = {}
|
local modules = {}
|
||||||
|
Reference in New Issue
Block a user