46b0c2df |
1 | <% @header[("title", ["Contact kind admin"])]; |
2 | |
3 | Group.requireGroupName "contact"; |
4 | |
5 | ref showNormal = true; |
6 | |
7 | if $"cmd" = "add" then |
8 | val id = Contact.addKind ($"name", (iff $"url" = "on" then SOME ($"urlPrefix", $"urlPostfix") else NONE)) |
1fe415e0 |
9 | %> <h3>Contact kind added</h3> |
46b0c2df |
10 | |
11 | <% elseif $"mod" <> "" then |
12 | showNormal := false; |
13 | val id = Web.stoi ($"mod"); |
14 | val kind = Contact.lookupKind id %> |
15 | |
add44c00 |
16 | <form action="kind" method="post"> |
46b0c2df |
17 | <input type="hidden" name="save" value="<% id %>"> |
1fe415e0 |
18 | <table class="blanks"> |
19 | <tr> <td>Name:</td> <td><input name="name" value="<% Web.html (#name kind) %>"></td> </tr> |
20 | <tr> <td>URL pattern:</td> <td><% |
46b0c2df |
21 | switch #makeUrl kind of |
22 | NONE => %><input type="checkbox" name="url"> <input name="urlPrefix">...<input name="urlPostfix"><% |
23 | | SOME (pre, post) => %><input type="checkbox" name="url" checked> <input name="urlPrefix" value="<% Web.html pre %>">...<input name="urlPostfix" value="<% Web.html post %>"><% |
24 | end |
25 | %></td> </tr> |
26 | <tr> <td><input type="submit" value="Save"></td> </tr> |
27 | </table> |
28 | </form> |
29 | |
30 | <% elseif $"save" <> "" then |
31 | val id = Web.stoi ($"save"); |
32 | val kind = Contact.lookupKind id; |
33 | Contact.modKind {kind with name = $"name", makeUrl = (iff $"url" = "on" then SOME ($"urlPrefix", $"urlPostfix") else NONE)} |
1fe415e0 |
34 | %> <h3>Contact kind modified</h3> |
46b0c2df |
35 | |
36 | <% elseif $"del" <> "" then |
37 | showNormal := false; |
38 | val id = Web.stoi ($"del"); |
39 | val kind = Contact.lookupKind id %> |
1fe415e0 |
40 | <h3>Are you sure you want to delete "<% Web.html (#name kind) %>"?</h3> |
46b0c2df |
41 | |
42 | <a href="kind?del2=<% $"del" %>">Yes, delete "<% Web.html (#name kind) %>"!</a> |
43 | |
44 | <% elseif $"del2" <> "" then |
45 | val id = Web.stoi ($"del2"); |
46 | val kind = Contact.lookupKind id; |
47 | Contact.deleteKind id %> |
1fe415e0 |
48 | <h3>"<% Web.html (#name kind) %>" deleted</h3> |
46b0c2df |
49 | |
50 | <% end %> |
51 | |
52 | <% if showNormal then %> |
53 | |
1fe415e0 |
54 | <h3>Add a contact kind</h3> |
46b0c2df |
55 | |
add44c00 |
56 | <form action="kind" method="post"> |
46b0c2df |
57 | <input type="hidden" name="cmd" value="add"> |
1fe415e0 |
58 | <table class="blanks"> |
59 | <tr> <td>Name:</td> <td><input name="name"></td> </tr> |
60 | <tr> <td>URL pattern:</td> <td><input type="checkbox" name="url"> <input name="urlPrefix">...<input name="urlPostfix"></td> </tr> |
46b0c2df |
61 | <tr> <td><input type="submit" value="Add"></td> </tr> |
62 | </table> |
63 | </form> |
64 | |
1fe415e0 |
65 | <h3>Current contact kinds</h3> |
46b0c2df |
66 | |
67 | <table> |
68 | <tr> <td><b>Kind</b></td> <td><b>URL pattern</b></td> </tr> |
69 | <% foreach kind in Contact.listKinds () do %> |
70 | <tr> |
71 | <td><% Web.html (#name kind) %></td> |
72 | <td><% switch #makeUrl kind of |
73 | NONE => %><i>none</i><% |
74 | | SOME (pre, post) => Web.html pre %>...<% Web.html post |
75 | end %></td> |
76 | <td><a href="kind?mod=<% #id kind %>">[Modify]</a> <a href="kind?del=<% #id kind %>">[Delete]</a></td> |
77 | </tr> |
78 | <% end %> |
79 | |
80 | <% end %> |
81 | |
82 | <% @footer[] %> |