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>That location already exists!</h3><%
14 val id = Location.addLocation (parent, $"name")
15 %><h3>Location added</h3>
18 elseif $"mod" <> "" then
19 Group.requireGroupName "location";
21 val id = Web.stoi ($"mod");
22 val loc = Location.lookupLocation id %>
24 <h3>Modify a location</h3>
26 <form action="location" method="post">
27 <input type="hidden" name="save" value="<% id %>">
28 <table class="blanks">
29 <tr> <td>Parent:</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>Name:</td> <td><input name="name" required="required" 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>Location saved</h3>
58 <% elseif $"del" <> "" then
59 Group.requireGroupName "location";
61 val id = Web.stoi ($"del");
62 val loc = Location.lookupLocation id %>
63 <h3>Are you sure you want to delete "<% Web.html (#name loc) %>"?</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>Deleted location "<% Web.html (#name loc) %>"</h3>
73 <% elseif $"addLoc" <> "" then
74 Location.addToLocation {loc = Web.stoi ($"addLoc"), usr = Init.getUserId ()}
77 <% elseif $"remLoc" <> "" then
78 Location.removeFromLocation {loc = Web.stoi ($"remLoc"), usr = Init.getUserId ()}
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><%
96 foreach user in Location.residents id do
102 %><a href="user?id=<% #id user %>"><% #name user %></a><%
106 <% foreach loc in Location.subLocations (SOME id) do %>
107 <a href="location?id=<% #id loc %>"><% Web.html (#name loc) %></a><br>
113 <h3>Add a new location</h3>
115 <form action="location" method="post">
116 <input type="hidden" name="cmd" value="add">
117 <table class="blanks">
118 <tr> <td>Parent:</td> <td><select name="parent">
119 <option value=""><None></option>
121 foreach item in Location.locationTree (NONE, NONE) do
124 indent := indent + 1 %>
127 indent := indent - 1 %>
129 <% | Util.ITEM loc => %>
130 <option value="<% #id loc %>"><% for i in 1 .. indent do %>-<% end %><% Web.html (#name loc) %></option>
134 <tr> <td>Name:</td> <td><input name="name" required="required"></td> </tr>
135 <tr> <td><input type="submit" value="Add"></td> </tr>
139 <% val withUser = Location.locationTreeWithUser (NONE, NONE, Init.getUserId ()) %>
141 <h3>Add yourself to a location</h3>
143 Adding yourself to a location automatically adds you to all more general loations.
145 <form action="location" method="post">
146 <select name="addLoc">
148 foreach item in withUser do
151 indent := indent + 1 %>
154 indent := indent - 1 %>
156 <% | Util.ITEM (true, _) =>
157 | Util.ITEM (false, loc) => %>
158 <option value="<% #id loc %>"><% for i in 1 .. indent do %>-<% end %><% Web.html (#name loc) %></option>
161 </select> <input type="submit" value="Add">
164 <h3>Remove yourself from a location</h3>
166 <form action="location" method="post">
167 <select name="remLoc">
169 foreach item in withUser do
172 indent := indent + 1 %>
175 indent := indent - 1 %>
177 <% | Util.ITEM (false, _) =>
178 | Util.ITEM (true, loc) => %>
179 <option value="<% #id loc %>"><% for i in 1 .. indent do %>-<% end %><% Web.html (#name loc) %></option>
182 </select> <input type="submit" value="Remove">
186 <% if showNormal then %>
188 <% foreach item in Location.locationTreeWithCounts (NONE, NONE) do
194 <% | Util.ITEM (num, loc) => %>
195 <li> <a href="location?id=<% #id loc %>"><% Web.html (#name loc) %></a> (<% num %>)
196 <a href="location?mod=<% #id loc %>">[Modify]</a> <a href="location?del=<% #id loc %>">[Delete]</a></li>