Commit | Line | Data |
---|---|---|
d6223be9 AC |
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)) | |
b6dd1aaf | 9 | %> <h3>Contact kind added</h3> |
d6223be9 AC |
10 | |
11 | <% elseif $"mod" <> "" then | |
12 | showNormal := false; | |
13 | val id = Web.stoi ($"mod"); | |
14 | val kind = Contact.lookupKind id %> | |
15 | ||
a4ccdb5e | 16 | <form action="kind" method="post"> |
d6223be9 | 17 | <input type="hidden" name="save" value="<% id %>"> |
b6dd1aaf AC |
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><% | |
d6223be9 AC |
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)} | |
b6dd1aaf | 34 | %> <h3>Contact kind modified</h3> |
d6223be9 AC |
35 | |
36 | <% elseif $"del" <> "" then | |
37 | showNormal := false; | |
38 | val id = Web.stoi ($"del"); | |
39 | val kind = Contact.lookupKind id %> | |
b6dd1aaf | 40 | <h3>Are you sure you want to delete "<% Web.html (#name kind) %>"?</h3> |
d6223be9 AC |
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 %> | |
b6dd1aaf | 48 | <h3>"<% Web.html (#name kind) %>" deleted</h3> |
d6223be9 AC |
49 | |
50 | <% end %> | |
51 | ||
52 | <% if showNormal then %> | |
53 | ||
b6dd1aaf | 54 | <h3>Add a contact kind</h3> |
d6223be9 | 55 | |
a4ccdb5e | 56 | <form action="kind" method="post"> |
d6223be9 | 57 | <input type="hidden" name="cmd" value="add"> |
b6dd1aaf AC |
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> | |
d6223be9 AC |
61 | <tr> <td><input type="submit" value="Add"></td> </tr> |
62 | </table> | |
63 | </form> | |
64 | ||
b6dd1aaf | 65 | <h3>Current contact kinds</h3> |
d6223be9 AC |
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[] %> |