1 <% @header[("title", ["Member locations"])];
3 val admin = Group.inGroupName "location";
8 val parent = (case $"parent" of "" => NONE | parent => SOME (Web.stoi parent));
11 if Location.alreadyExists (parent, name) then
12 %><h3><b>That location already exists!</b></h3><%
14 val id = Location.addLocation (parent, $"name")
15 %><h3><b>Location added</b></h3>
18 elseif $"mod" <> "" then
19 Group.requireGroupName "location";
21 val id = Web.stoi ($"mod");
22 val loc = Location.lookupLocation id %>
24 <h3><b>Modify a location</b></h3>
26 <form action="location">
27 <input type="hidden" name="save" value="<% id %>">
29 <tr> <td align="right"><b>Parent</b>:</td> <td><select name="parent">
30 <option value=""<% if #parent loc = NONE then %> selected<% end %>><None></option>
32 foreach item in Location.locationTree (NONE, NONE) do
35 indent := indent + 1 %>
38 indent := indent - 1 %>
40 <% | Util.ITEM loc2 => %>
41 <option value="<% #id loc2 %>"<% if SOME (#id loc2) = #parent loc then %> selected<% end %>><% for i in 1 .. indent do %>-<% end %><% Web.html (#name loc2) %></option>
45 <tr> <td align="right"><b>Name</b>:</td> <td><input name="name" value="<% Web.html (#name loc) %>"></td> </tr>
46 <tr> <td><input type="submit" value="Save"></td> </tr>
50 <% elseif $"save" <> "" then
51 Group.requireGroupName "location";
52 val id = Web.stoi ($"save");
53 val loc = Location.lookupLocation id;
54 Location.modLocation {loc with parent = (case $"parent" of "" => NONE | parent => SOME (Web.stoi parent)),
56 %><h3><b>Location saved</b></h3>
58 <% elseif $"del" <> "" then
59 Group.requireGroupName "location";
61 val id = Web.stoi ($"del");
62 val loc = Location.lookupLocation id %>
63 <h3><b>Are you sure you want to delete "<% Web.html (#name loc) %>"?</b></h3>
64 <a href="location?del2=<% id %>">Yes, delete "<% Web.html (#name loc) %>"!</a>
66 <% elseif $"del2" <> "" then
67 Group.requireGroupName "location";
68 val id = Web.stoi ($"del2");
69 val loc = Location.lookupLocation id;
70 Location.deleteLocation id %>
71 <h3><b>Deleted location "<% Web.html (#name loc) %>"</b></h3>
73 <% elseif $"addLoc" <> "" then
74 Location.addToLocation {loc = Web.stoi ($"addLoc"), usr = Init.getUserId ()}
75 %><h3><b>Added</b></h3>
77 <% elseif $"remLoc" <> "" then
78 Location.removeFromLocation {loc = Web.stoi ($"remLoc"), usr = Init.getUserId ()}
79 %><h3><b>Removed</b></h3>
81 <% elseif $"id" <> "" then
83 val id = Web.stoi ($"id");
84 val loc = Location.lookupLocation id %>
86 <h2><b><% Web.html (#name loc) %></b></h2>
88 <% switch #parent loc of
90 val ploc = Location.lookupLocation par;
91 %><b>Parent</b>: <a href="location?id=<% par %>"><% Web.html (#name ploc) %></a><%
94 <h3><b>Residents:</b></h3>
96 foreach user in Location.residents id do
102 %><a href="user?id=<% #id user %>"><% #name user %></a><%
105 <h3><b>Regions:</b></h3>
106 <% foreach loc in Location.subLocations (SOME id) do %>
107 <a href="location?id=<% #id loc %>"><% Web.html (#name loc) %></a><br>
112 if showNormal then %>
114 <% foreach item in Location.locationTreeWithCounts (NONE, NONE) do
120 <% | Util.ITEM (num, loc) => %>
121 <li> <a href="location?id=<% #id loc %>"><% Web.html (#name loc) %></a> (<% num %>)
122 <a href="location?mod=<% #id loc %>">[Modify]</a> <a href="location?del=<% #id loc %>">[Delete]</a></li>
127 <h3><b>Add a new location</b></h3>
129 <form action="location">
130 <input type="hidden" name="cmd" value="add">
132 <tr> <td align="right"><b>Parent</b>:</td> <td><select name="parent">
133 <option value=""><None></option>
135 foreach item in Location.locationTree (NONE, NONE) do
138 indent := indent + 1 %>
141 indent := indent - 1 %>
143 <% | Util.ITEM loc => %>
144 <option value="<% #id loc %>"><% for i in 1 .. indent do %>-<% end %><% Web.html (#name loc) %></option>
148 <tr> <td align="right"><b>Name</b>:</td> <td><input name="name"></td> </tr>
149 <tr> <td><input type="submit" value="Add"></td> </tr>
153 <% val withUser = Location.locationTreeWithUser (NONE, NONE, Init.getUserId ()) %>
155 <h3><b>Add yourself to a location</b></h3>
157 Adding yourself to a location automatically adds you to all more general loations.
159 <form action="location">
160 <select name="addLoc">
162 foreach item in withUser do
165 indent := indent + 1 %>
168 indent := indent - 1 %>
170 <% | Util.ITEM (true, _) =>
171 | Util.ITEM (false, loc) => %>
172 <option value="<% #id loc %>"><% for i in 1 .. indent do %>-<% end %><% Web.html (#name loc) %></option>
175 </select> <input type="submit" value="Add">
178 <h3><b>Remove yourself from a location</b></h3>
180 <form action="location">
181 <select name="remLoc">
183 foreach item in withUser do
186 indent := indent + 1 %>
189 indent := indent - 1 %>
191 <% | Util.ITEM (false, _) =>
192 | Util.ITEM (true, loc) => %>
193 <option value="<% #id loc %>"><% for i in 1 .. indent do %>-<% end %><% Web.html (#name loc) %></option>
196 </select> <input type="submit" value="Remove">