Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 98
- Log:
Initial import of Hub, an account management application.
- Author:
- adh
- Date:
- Thu Oct 19 15:18:43 +0100 2006
- Size:
- 2609 Bytes
1 | module AccountHelper |
2 | |
3 | # Return a table cell with class 'yes' or 'no' and text contents 'Yes' or |
4 | # 'No' according to "if (value) 'yes' else 'no'". |
5 | # |
6 | def boolean_cell(value) |
7 | if (value) |
8 | '<td class="yes">Yes</td>' |
9 | else |
10 | '<td class="no">No</td>' |
11 | end |
12 | end |
13 | |
14 | # Return a table cell with class 'yes', 'no' or 'expired' and text contents |
15 | # 'Yes', 'No' or 'Expired' according to whether or not the given value is |
16 | # set and less than "Time.now.utc". |
17 | # |
18 | def expired_cell(value) |
19 | if (value) |
20 | if (Time.now.utc >= value) |
21 | '<td class="expired">Expired</td>' |
22 | else |
23 | '<td class="yes">yes</td>' |
24 | end |
25 | else |
26 | '<td class="no">No</td>' |
27 | end |
28 | end |
29 | |
30 | # Return a table cell containing a series of actions to perform from a list |
31 | # of user accounts. The cell will have class name 'actions'. Pass the user |
32 | # object for which the actions should be generated. |
33 | # |
34 | def list_actions(user) |
35 | '<td class="actions">' << |
36 | button_to('Details', { :action => 'show', :id => user.id }) << |
37 | button_to('Delete', { :action => 'destroy', :id => user.id }, :confirm => "Are you absolutely sure you want to permanently delete this account?") << |
38 | '</td>' |
39 | end |
40 | |
41 | # Return a series of actions to perform from details of a user account, in |
42 | # "<li>" tags. Pass the user object for which the actions should |
43 | # be generated. |
44 | # |
45 | def show_actions(user) |
46 | '<li>' << |
47 | button_to('Edit account roles', { :action => 'edit_roles', :id => user.id }) << |
48 | '</li><li>' << |
49 | button_to('Delete this account', { :action => 'destroy', :id => user.id }, :confirm => "Are you absolutely sure you want to permanently delete this account?") << |
50 | '</li>' |
51 | end |
52 | |
53 | # Output a selection list for roles. Pass the name of the parent |
54 | # object, the name of the field to take the selected value, an array |
55 | # of option values for the selection list and the associated roles |
56 | # string. Must be followed by a code block that translates its given |
57 | # argument into a printable string for the selection menu. Multiple |
58 | # selections will be allowed. |
59 | |
60 | def create_roles_selector(name, field, values, roles) |
61 | roles = roles.to_authenticated_roles |
62 | str = "<select multiple name=\"%s[%s][]\" id=\"%s_%s\">\n" % [ name, field, name, field ] |
63 | |
64 | for value in values |
65 | str += ' <option value="%s"' % value |
66 | str += ' selected' if (roles.include? value) |
67 | str += '>' + yield(value) # Call the code block the caller set up |
68 | str += "</option>\n" |
69 | end |
70 | |
71 | str += " </select>\n" |
72 | |
73 | return str |
74 | end |
75 | |
76 | end |