Changesets can be listed by changeset number.
The Git repository is here.
Changeset 166
Added pagination to Hub account lists. Sort order is whatever the database
feels like (so, usually, least to most recently updated). User-selectable
sorting might be needed in future but this current implementation does, at
least, provide the feature requested in Ticket #99.
Rather than using the much-maligned Rails default paginator, an external
paginator gem is used - "gem install paginator" grabs it. For more, see:
http://codefluency.com/2006/10/24/paginator-released
http://paginator.rubyforge.org/
- Comitted by: rool
- Date: Saturday December 23 18:16:41 2006 (over 17 years ago)
Affected files:
- rool/rails/hub/trunk/VERSION (diff)
- rool/rails/hub/trunk/app/controllers/account_controller.rb (diff)
- rool/rails/hub/trunk/app/views/account/list.rhtml (diff)
- rool/rails/hub/trunk/public/stylesheets/risc_os_open.css (diff)
rool/rails/hub/trunk/VERSION:
prev. | current | |
1 | ||
1 | 0.1.1 (23-Dec-2006) |
rool/rails/hub/trunk/app/controllers/account_controller.rb:
prev. | current | |
def list | ||
@title = 'List of user accounts' | ||
249 | | |
249 | ||
250 | # Page number zero is magic; it indicates "all items". | |
251 | ||
252 | count = User.count | |
253 | ||
254 | if (params[:page] == '0') | |
255 | limit = count | |
256 | @all = true | |
257 | else | |
258 | limit = 10 | |
259 | @all = false | |
260 | end | |
261 | ||
262 | @pager = ::Paginator.new(count, limit) do |offset, per_page| | |
263 | User.find(:all, :limit => per_page, :offset => offset) | |
264 | end | |
265 | ||
266 | @page = @pager.page(params[:page]) | |
end | ||
def show |
rool/rails/hub/trunk/app/views/account/list.rhtml:
prev. | current | |
1 | | |
2 | | |
3 |
| |
4 | | |
5 | | |
6 | | |
7 | | |
8 | | |
9 | | |
10 | | |
11 | | |
12 | | |
13 | | |
14 | | |
15 | | |
16 | | |
17 | | |
18 | | |
19 | | |
20 | | |
21 | | |
22 | | |
23 | | |
24 | | |
25 | | |
26 |
| |
27 | | |
28 | | |
29 | | |
2 | <b>Administrators, be warned!</b> If you delete an account it can only be | |
3 | recreated by the person who created it originally. | |
4 | ||
5 | <p /> | |
6 | <table class="list" style="font-size: 80%" border="1" align="center" cellspacing="1" cellpadding="4"> | |
7 | <tr bgcolor="#eeeeee"> | |
8 | <th>Owner</th> | |
9 | <th>Last updated</th> | |
10 | <th>Activated?</th> | |
11 | <th>Remembered?</th> | |
12 | <th>Password reset?</th> | |
13 | <th>Actions</th> | |
14 | </tr> | |
15 | ||
16 | <% @page.each do |user| -%><tr class="<%= cycle('even', 'odd') %>"> | |
17 | <td> | |
18 | <%= h(user.real_name) %><br /> | |
19 | <a href="mailto:<%= h(user.email) %>"><%= h(user.email) %></a> | |
20 | </td> | |
21 | <td><%= user.updated_at %></td> | |
22 | <%= boolean_cell(user.activated_at) %> | |
23 | <%= expired_cell(user.remember_token_expires_at) %> | |
24 | <%= expired_cell(user.password_reset_code_expires_at) %> | |
25 | <%= list_actions(user) %> | |
26 | </tr><% end %> | |
27 | </table> | |
28 | ||
29 | <p align="center" class="paginator"> | |
30 | Page <%= @page.number %> of <%= @pager.number_of_pages %> | |
31 | <% if @page.prev? -%> | |
32 | | <%= link_to("First", :page => 1) %> | |
33 | | <%= link_to("Previous", :page => @page.prev.number) %> | |
34 | <% else -%> | |
35 | | <span class="disabled">First</span> | |
36 | | <span class="disabled">Previous</span> | |
37 | <% end -%> | |
38 | <% if @page.next? -%> | |
39 | | <%= link_to("Next", :page => @page.next.number) %> | |
40 | | <%= link_to("Last", :page => @pager.number_of_pages) %> | |
41 | <% else -%> | |
42 | | <span class="disabled">Next</span> | |
43 | | <span class="disabled">Last</span> | |
44 | <% end -%> | |
45 | <% if @pager.number_of_pages > 1 -%> | |
46 | | <%= link_to("All", :page => 0) %> | |
47 | <% else -%><% if @all -%> | |
48 | | <%= link_to("Paged", :page => 1) %> | |
49 | <% end -%><% end -%> | |
50 | </p> | |
51 | ||
52 | <p> | |
53 | When you've finished managing accounts, you can | |
54 | <%= link_to 'return to control panel', :controller => 'tasks', :action => nil %>. | |
55 | </p> |
rool/rails/hub/trunk/public/stylesheets/risc_os_open.css:
prev. | current | |
/* Account listings */ | ||
10 | ||
10 | table.list | |
{ | ||
border-collapse: collapse; | ||
border: 1px solid #6E915E; | ||
} | ||
16 | ||
16 | table.list tr.odd | |
{ | ||
background-color: #f8fff8; | ||
} | ||
21 | ||
21 | table.list td.yes | |
{ | ||
background-color: #DFD; | ||
text-align: center; | ||
} | ||
27 | ||
27 | table.list td.no | |
{ | ||
background-color: #FDB; | ||
text-align: center; | ||
} | ||
33 | ||
33 | table.list td.expired | |
{ | ||
background-color: #FDD; | ||
text-align: center; | ||
} | ||
39 | ||
39 | table.list td.actions | |
{ | ||
background-color: #DDD; | ||
text-align: center; | ||
... | ... | |
/* Button-based dangerous action links */ | ||
47 | ||
48 | ||
47 | table td.dangerous img, | |
48 | table td.dangerous input[type='image'] | |
{ | ||
border: 2px solid #966; | ||
background: #fee; | ||
margin: 1px; | ||
} | ||
55 | ||
55 | form.button-to input | |
{ | ||
margin-top: 4px; | ||
} | ||
60 | ||
60 | table.list form.button-to input | |
{ | ||
font-size: 80%; | ||
margin-top: 4px; | ||
width: 100%; | ||
} | ||
67 | ||
67 | table td input[type='image'] | |
{ | ||
border: none; | ||
background: inherit; | ||
... | ... | |
/* Icon-based buttons */ | ||
75 | ||
76 | ||
75 | div.content a.image, | |
76 | div.content a.image:hover | |
{ | ||
background: inherit; | ||
border: none; | ||
} | ||
82 | /* Paginated navigation */ | |
83 | ||
84 | p.paginator | |
85 | { | |
86 | font-size: small; | |
87 | font-weight: bold; | |
88 | } | |
89 | ||
90 | p.paginator span.disabled | |
91 | { | |
92 | color: #bbb; | |
93 | } | |
94 | ||
/* Exception handling */ | ||
84 | ||
97 | div.exception | |
{ | ||
border: 1px solid #aaa; | ||
background: #eee; | ||
... | ... | |
font-size: 90% | ||
} | ||
93 | ||
106 | div.exception p | |
{ | ||
margin: 0; | ||
padding: 0; | ||
} | ||
98 |