factor out code to move between pages of items
authordjfiander <djfiander@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 19 Feb 2008 22:29:08 +0000 (22:29 +0000)
committerdjfiander <djfiander@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 19 Feb 2008 22:29:08 +0000 (22:29 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8784 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/oilsweb/oilsweb/templates/oils/default/acq/picklist/view.html
Open-ILS/web/oilsweb/oilsweb/templates/oils/default/common/widgets.html

index 8b11417..6f944e6 100644 (file)
@@ -3,6 +3,8 @@
  vim:ft=mako: 
 -->
 <%inherit file='../base.html'/>
+<%namespace file='../../common/widgets.html' name='widget' />
+
 <%def name="page_title()">${_('Picklist')}</%def>
 <%def name="block_content()">
 
     <thead>
         <tr>
             <td colspan='3' id='oils-acq-picklist-header-block'>
-                <table id='oils-acq-pikclist-header-subtable'><tr>
+                <table id='oils-acq-picklist-header-subtable'><tr>
                 <td id='oils-acq-picklist-paging-block'>
-                    <%
-                        c.oils.acq.offset.value = int(c.oils.acq.offset.value)
-                        c.oils.acq.limit.value = int(c.oils.acq.limit.value)
-                        # set up the paging info
-                        paging = _('Entries %(offset)s - %(limit)s') % {
-                            'offset': c.oils.acq.offset.value + 1,
-                            'limit': c.oils.acq.limit.value + c.oils.acq.offset.value
-                        }
-                    %>
-                    ${paging}
-                    % if c.oils.acq.offset.value > 0:
-                        <a href='?${c.oils.acq.offset.cgi_name}=${c.oils.acq.offset.value - c.oils.acq.limit.value}'>&#171;</a>
-                    % endif
-                    <a href='?${c.oils.acq.offset.cgi_name}=${c.oils.acq.offset.value + c.oils.acq.limit.value}'>&#187;</a>
+                 ${widget.paging(c.oils.acq.offset.value,
+                                 c.oils.acq.limit.value,
+                                 c.oils.acq.picklist.value.entry_count())}
                 </td>
                 <td id='oils-acq-picklist-actions-block'>
                     <select name='${c.oils.acq.picklist_action.cgi_name}'>
index 19dd43c..8e0458f 100644 (file)
         ${org_draw_node(tree, 0, selected, disable_depth)}
     </select>
 </%def>
+
+<%def name='paging(start, count, max)'>
+    <!--
+       Creating paging links to move from page to page in long
+       list of results
+      -->
+
+    <%
+       start = int(start)
+       if (start + count > max):
+           end = max
+       else:
+           end = start + count
+       # set up the paging info
+       paging = _('Entries %(offset)d - %(limit)d of %(max)d') % {
+           'offset': start + 1, 'limit': end, 'max': max }
+    %>
+
+    % if start > 0:
+        <a href='?${c.oils.acq.offset.cgi_name}=${start - count}'>&#171;</a>
+    % endif
+
+    ${paging}
+
+    % if end < max:
+        <a href='?${c.oils.acq.offset.cgi_name}=${end}'>&#187;</a>
+    % endif
+</%def>