adding class version of join org module
This commit is contained in:
parent
0ca04294b7
commit
db43df6ce2
@ -16,5 +16,6 @@ dofile (localdir .. "/interactions/interactions.lua")
|
|||||||
|
|
||||||
--modules
|
--modules
|
||||||
dofile (localdir .. "/modules/join_org.lua")
|
dofile (localdir .. "/modules/join_org.lua")
|
||||||
|
dofile (localdir .. "/modules/join_org_class.lua")
|
||||||
dofile (localdir .. "/modules/remove_org.lua")
|
dofile (localdir .. "/modules/remove_org.lua")
|
||||||
dofile (localdir .. "/modules/child_org.lua")
|
dofile (localdir .. "/modules/child_org.lua")
|
||||||
|
@ -12,6 +12,21 @@ function join_org.initiate(initiator, org, result)
|
|||||||
end
|
end
|
||||||
)
|
)
|
||||||
|
|
||||||
|
-- for i, member in ipairs(org.members) do
|
||||||
|
-- org:add_pending_action(
|
||||||
|
-- member,
|
||||||
|
-- function ()
|
||||||
|
-- modpol.interactions.binary_poll_user(
|
||||||
|
-- member,
|
||||||
|
-- "Let " .. initiator .. " join " .. org.name .. "?",
|
||||||
|
-- function (resp)
|
||||||
|
|
||||||
|
-- end
|
||||||
|
-- )
|
||||||
|
-- end
|
||||||
|
-- )
|
||||||
|
-- end
|
||||||
|
|
||||||
if result then result() end
|
if result then result() end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,25 +1,35 @@
|
|||||||
-- JOIN ORG
|
-- JOIN ORG
|
||||||
-- Module that enables a user to join an org
|
-- Module that enables a user to join an org
|
||||||
|
|
||||||
modpol.modules.join_org = {}
|
|
||||||
module = modpol.modules.join_org
|
|
||||||
|
|
||||||
JoinOrg = {}
|
JoinOrg = {}
|
||||||
JoinOrg_mt = { __index = JoinOrg }
|
JoinOrg_mt = { __index = JoinOrg }
|
||||||
|
|
||||||
|
|
||||||
function JoinOrg:create(initiator, org)
|
function JoinOrg.create(initiator, org)
|
||||||
local inst = {
|
local inst = {
|
||||||
name = "Join an org",
|
name = "Join an org",
|
||||||
desc = "Initiator chooses an org to become a member of. Nothing happens if they are already in an org."
|
desc = "Initiator chooses an org to become a member of. Nothing happens if they are already in an org.",
|
||||||
|
initiator = initiator,
|
||||||
|
org = org
|
||||||
}
|
}
|
||||||
setmetatable(inst, JoinOrg_mt)
|
setmetatable(inst, JoinOrg_mt)
|
||||||
return inst
|
return inst
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function JoinOrg:initiate(initiator, org, result)
|
function JoinOrg:initiate(result)
|
||||||
modpol.interactions.binary_poll_user(initiator, "Would you like to join", )
|
modpol.interactions.binary_poll_user(
|
||||||
|
self.initiator,
|
||||||
|
"Would you like to join",
|
||||||
|
function (resp)
|
||||||
|
if resp == "Yes" then
|
||||||
|
self:implement()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
if result then result() end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function JoinOrg:request()
|
function JoinOrg:request()
|
||||||
@ -33,5 +43,4 @@ end
|
|||||||
-- ===================================
|
-- ===================================
|
||||||
-- When calling a module internally
|
-- When calling a module internally
|
||||||
|
|
||||||
test = JoinOrg.create()
|
modpol.modules.join_org_class = JoinOrg
|
||||||
test:initiate("luke")
|
|
@ -7,4 +7,11 @@ test_org:add_member('nathan')
|
|||||||
|
|
||||||
print(table.concat(test_org:list_members(), ", "))
|
print(table.concat(test_org:list_members(), ", "))
|
||||||
|
|
||||||
modpol.modules.join_org.initiate("paul", test_org, function () print("callback") end)
|
function completion()
|
||||||
|
print("completed")
|
||||||
|
end
|
||||||
|
|
||||||
|
-- modpol.modules.join_org.initiate("paul", test_org, completion)
|
||||||
|
|
||||||
|
process = modpol.modules.join_org_class.create("paul", test_org)
|
||||||
|
process:initiate(completion)
|
Loading…
x
Reference in New Issue
Block a user