|
@@ -54,11 +54,11 @@ function modpol.interactions.dashboard(user)
|
|
|
"size[10,6]",
|
|
|
"label[0.5,0.5;M O D U L A R P O L I T I C S]",
|
|
|
"label[0.5,2;All orgs:]",
|
|
|
- "dropdown[2,1.5;5,0.8;all_orgs;"..formspec_list(all_orgs)..";;]",
|
|
|
+ "dropdown[2,1.5;7,0.8;all_orgs;"..formspec_list(all_orgs)..";;]",
|
|
|
"label[0.5,3;Your orgs:]",
|
|
|
- "dropdown[2,2.5;5,0.8;user_orgs;"..formspec_list(user_orgs)..";;]",
|
|
|
+ "dropdown[2,2.5;7,0.8;user_orgs;"..formspec_list(user_orgs)..";;]",
|
|
|
"label[0.5,4;All users:]",
|
|
|
- "dropdown[2,3.5;5,0.8;all_users;"..formspec_list(all_users)..";;]",
|
|
|
+ "dropdown[2,3.5;7,0.8;all_users;"..formspec_list(all_users)..";;]",
|
|
|
"button_exit[8.5,5;1,0.8;close;Close]",
|
|
|
}
|
|
|
local formspec_string = table.concat(formspec, "")
|
|
@@ -108,14 +108,16 @@ function modpol.interactions.org_dashboard(user, org_string)
|
|
|
else parent = "none" end
|
|
|
|
|
|
-- prepare children menu
|
|
|
- local children = {"View..."}
|
|
|
+ local children = {}
|
|
|
for k,v in ipairs(org.children) do
|
|
|
local this_child = modpol.orgs.get_org(v)
|
|
|
table.insert(children, this_child.name)
|
|
|
end
|
|
|
+ table.sort(children)
|
|
|
+ table.insert(children,1,"View...")
|
|
|
|
|
|
-- prepare modules menu
|
|
|
- local modules = {"View..."}
|
|
|
+ local modules = {}
|
|
|
if org.modules then
|
|
|
for k,v in pairs(org.modules) do
|
|
|
if not v.hide then -- hide utility modules
|
|
@@ -125,9 +127,11 @@ function modpol.interactions.org_dashboard(user, org_string)
|
|
|
end
|
|
|
end
|
|
|
end
|
|
|
+ table.sort(modules)
|
|
|
+ table.insert(modules,1,"View...")
|
|
|
|
|
|
-- prepare pending menu
|
|
|
- local pending = {"View..."}
|
|
|
+ local pending = {}
|
|
|
local num_pending = 0
|
|
|
if org.pending[user] then
|
|
|
for k,v in pairs(org.pending[user]) do
|
|
@@ -137,6 +141,8 @@ function modpol.interactions.org_dashboard(user, org_string)
|
|
|
num_pending = num_pending + 1
|
|
|
end
|
|
|
end
|
|
|
+ table.sort(pending)
|
|
|
+ table.insert(pending,1,"View...")
|
|
|
|
|
|
-- set player context
|
|
|
local user_context = {}
|
|
@@ -150,13 +156,13 @@ function modpol.interactions.org_dashboard(user, org_string)
|
|
|
minetest.formspec_escape(org.name)..membership_toggle(org.name).."]",
|
|
|
"label[0.5,1;Parent: "..parent..membership_toggle(parent).."]",
|
|
|
"label[0.5,2;Members:]",
|
|
|
- "dropdown[2,1.5;5,0.8;user_orgs;"..formspec_list(org.members)..";;]",
|
|
|
+ "dropdown[2,1.5;7,0.8;user_orgs;"..formspec_list(org.members)..";;]",
|
|
|
"label[0.5,3;Children:]",
|
|
|
- "dropdown[2,2.5;5,0.8;children;"..formspec_list(children)..";;]",
|
|
|
+ "dropdown[2,2.5;7,0.8;children;"..formspec_list(children)..";;]",
|
|
|
"label[0.5,4;Modules:]",
|
|
|
- "dropdown[2,3.5;5,0.8;modules;"..formspec_list(modules)..";;]",
|
|
|
+ "dropdown[2,3.5;7,0.8;modules;"..formspec_list(modules)..";;]",
|
|
|
"label[0.5,5;Pending ("..num_pending.."):]",
|
|
|
- "dropdown[2,4.5;5,0.8;pending;"..formspec_list(pending)..";;]",
|
|
|
+ "dropdown[2,4.5;7,0.8;pending;"..formspec_list(pending)..";;]",
|
|
|
"button[8.5,7;1,0.8;back;Back]",
|
|
|
}
|
|
|
local formspec_string = table.concat(formspec, "")
|
|
@@ -186,7 +192,7 @@ minetest.register_on_player_receive_fields(function (player, formname, fields)
|
|
|
fields.modules,"%[(.*)%]")
|
|
|
modpol.interactions.binary_poll_user(
|
|
|
pname,
|
|
|
- modpol.modules[module].name.."\n"..
|
|
|
+ modpol.modules[module].name..":\n"..
|
|
|
modpol.modules[module].desc.."\n"..
|
|
|
"Proceed?",
|
|
|
function(input)
|
|
@@ -283,6 +289,8 @@ end)
|
|
|
-- func input: choice (string)
|
|
|
-- output: calls func on user choice
|
|
|
function modpol.interactions.dropdown_query(user, label, options, func)
|
|
|
+ -- Add "View..." to the top of the list
|
|
|
+ table.insert(options,1,"View...")
|
|
|
-- set up formspec
|
|
|
local formspec = {
|
|
|
"formspec_version[4]",
|
|
@@ -302,20 +310,25 @@ end
|
|
|
minetest.register_on_player_receive_fields(function (player, formname, fields)
|
|
|
if formname == "modpol:dropdown_query" then
|
|
|
local pname = player:get_player_name()
|
|
|
- if fields.cancel == "cancel" then
|
|
|
- -- cancel, do nothing
|
|
|
+ if fields.cancel then
|
|
|
+ minetest.close_formspec(pname, formname)
|
|
|
+ elseif fields.input == "View..." then
|
|
|
+ -- "View...", do nothing
|
|
|
else
|
|
|
local choice = fields.input
|
|
|
local func = _contexts[pname]["dropdown_query_func"]
|
|
|
if not choice then
|
|
|
-- empty, do nothing
|
|
|
elseif func then
|
|
|
+ --not sure if we should close
|
|
|
+ --breaks sequential dropdown_queries:
|
|
|
+ --minetest.close_formspec(pname, formname)
|
|
|
func(choice)
|
|
|
else
|
|
|
+ minetest.close_formspec(pname, formname)
|
|
|
modpol.interactions.message(pname, "dropdown_query: " .. choice)
|
|
|
end
|
|
|
end
|
|
|
- minetest.close_formspec(pname, formname)
|
|
|
end
|
|
|
end)
|
|
|
|