aboutsummaryrefslogtreecommitdiff
path: root/views
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-07-01 04:30:29 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2012-07-01 04:30:29 +0200
commitf895dfeb979f1a98ea38a6a88f99ff63422d4348 (patch)
treeab3707f819cca5cf33c91bb642485c4c8cead220 /views
parentc66f8be25f230f8fcea2774e54a56ad43fba9b58 (diff)
downloadexample-collection-json-db-f895dfeb979f1a98ea38a6a88f99ff63422d4348.tar.gz
example-collection-json-db-f895dfeb979f1a98ea38a6a88f99ff63422d4348.tar.bz2
example-collection-json-db-f895dfeb979f1a98ea38a6a88f99ff63422d4348.tar.xz
example-collection-json-db-f895dfeb979f1a98ea38a6a88f99ff63422d4348.zip
o Better error handling.
Diffstat (limited to 'views')
-rw-r--r--views/departments.jade2
-rw-r--r--views/employees.jade2
-rw-r--r--views/employees_in_department.jade2
-rw-r--r--views/lib/pager.jade21
4 files changed, 15 insertions, 12 deletions
diff --git a/views/departments.jade b/views/departments.jade
index bdcb0ae..14d4a31 100644
--- a/views/departments.jade
+++ b/views/departments.jade
@@ -12,4 +12,4 @@ block content
tr
td: a(href=urlgenerator.department(department.dept_no)) #{department.dept_name}
- mixin pager(pager, departments.length, urlgenerator.departments)
+ mixin pager(pager, urlgenerator.departments)
diff --git a/views/employees.jade b/views/employees.jade
index d7d9005..cea80ed 100644
--- a/views/employees.jade
+++ b/views/employees.jade
@@ -12,4 +12,4 @@ block content
tr
td: a(href=urlgenerator.employee(employee.emp_no)) #{employee.first_name} #{employee.last_name}
- mixin pager(pager, employees.length, urlgenerator.employees)
+ mixin pager(pager, urlgenerator.employees)
diff --git a/views/employees_in_department.jade b/views/employees_in_department.jade
index c341647..8313b2c 100644
--- a/views/employees_in_department.jade
+++ b/views/employees_in_department.jade
@@ -18,4 +18,4 @@ block content
tr
td: a(href=urlgenerator.employee(employee.emp_no)) #{employee.first_name} #{employee.last_name}
- mixin pager(pager, employees.length, function(offset) { return urlgenerator.employees_in_department(dept_no, offset) })
+ mixin pager(pager, function(offset) { return urlgenerator.employees_in_department(dept_no, offset) })
diff --git a/views/lib/pager.jade b/views/lib/pager.jade
index a762735..1a47e12 100644
--- a/views/lib/pager.jade
+++ b/views/lib/pager.jade
@@ -1,14 +1,17 @@
-mixin pager(pager, length, f)
+mixin pager(pager, f)
p
- if pager.offset > 0
- a(href=f(pager.prevOffset)) prev
- |
+ if typeof pager.prevOffset == 'number'
+ a(href=f(pager.prevOffset)) &lt;&lt; Previous
else
- | prev
+ | Previous
- - var nextOffset = pager.nextOffset(length)
- if nextOffset > 0
- a(href=f(nextOffset)) next
+ |
+ | #{pager.offset / pager.pageSize + 1} /
+ | #{Math.round(pager.count / pager.pageSize)}
+ |
+
+ if typeof pager.nextOffset == 'number'
+ a(href=f(pager.nextOffset)) Next &gt;&gt;
else
- | next
+ | Next