Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alethes committed Feb 13, 2015
2 parents 6311c88 + 28900c2 commit 5821277
Show file tree
Hide file tree
Showing 30 changed files with 1,678 additions and 221 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ Unavailable to the client:
- a *Mongo.Collection.Cursor* (or some other cursor with a compatible interface) - publishes the cursor.
- an *Array of Mongo.Collection.Cursor objects* (or some others cursor with a compatible interface) - publishes the cursors.
When publishing a cursor or an array of cursors, you have to make sure to set *realFilters* (filters used in publication; sometimes different from filters visible to the client) or *nPublishedPages* (explicit number of published pages) manually to ensure proper rendering of navigation controls. In most cases, it's recommended to return an array with filters and options (option 4) instead.
+ **availableSettings (*Object*, default = {})** - defines rules for changes in settings initiated by the client. A valid entry references the name of a setting by key and has one of the following:
+ **availableSettings (*Object*, default = {})** - defines rules for changes in settings initiated by the client. A valid entry references the name of a setting by key and has one of the following as a value:
- *true* - allows all changes to the setting (if not otherwise limited by constraints such as `pageSizeLimit`)
- a *falsy value* - explicitly disallows or modifications. Has the same effect as leaving the setting out.
- a *falsy value* - explicitly disallows all modifications. Has the same effect as leaving the setting out.
- a *Function* - defines a policy controlling changes in the specified setting.
+ **divWrapper (*String, Boolean*, default = "pageCont")** - if it's specified and table mode is not enabled, the Pagination page is wrapped in a div with the provided class name
+ **fastRender (*Boolean*, default = false)** - determines whether *fast-render* package should be used to speed up page loading
Expand Down
3 changes: 2 additions & 1 deletion client/controllers.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Template._pagesTable.helpers
_.map @table.fields, (v) -> value: v
header: ->
_.map (@table.header or @table.fields), (v) -> value: v

Template._pagesPage.helpers
ready: ->
@sess "ready"
Expand All @@ -41,6 +41,7 @@ Template._pagesPage.helpers
cp = @sess "currentPage"
op = @sess "oldPage"
@sess "ready"
return [] if @sess "totalPages" is 0
if @received[cp] or (@fastRender and cp is @initPage)
@ready true
n = cp
Expand Down
2 changes: 1 addition & 1 deletion examples/basic/.meteor/versions
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
alethes:pages@1.6.2
alethes:pages@1.7.0
[email protected]
[email protected]
[email protected]
Expand Down
1 change: 1 addition & 0 deletions examples/basic/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
@Pages = new Meteor.Pagination Items,
availableSettings:
perPage: true

if Meteor.isClient
Template.items.events
"click .perPage": (e) ->
Expand Down
3 changes: 3 additions & 0 deletions examples/infinite/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
body{
margin: 0;
}
27 changes: 25 additions & 2 deletions examples/iron-router/main.coffee
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#Uses the Items collection object previously defined in testdata.coffee
# Uses the Items collection object previously defined in testdata.coffee
#
# Note that the routes will be created by the Pages instances

@Pages = new Meteor.Pagination Items,
router: "iron-router"
homeRoute: ["/", "/items/"]
route: "/items/"
routerTemplate: "items"
routerLayout: "layout"

@Pages2 = new Meteor.Pagination Items,
router: "iron-router"
homeRoute: "/items2/"
Expand All @@ -13,6 +17,7 @@
routerLayout: "layout"
sort: id: -1
perPage: 5

@Pages3 = new Meteor.Pagination Items,
availableSettings:
filters: true
Expand All @@ -23,4 +28,22 @@
routerLayout: "layout"
routeSettings: (route) ->
@set "filters", if route.params.group? then {group: Number route.params.group} else {}
sort: id: 1
sort: id: 1

# We need to tell the Page controllers to clear their subscriptions when moving to another route.
#
# The easiest way to do this is to create a main route controller for all your other routes, and to
# call the Pages unsubscribe method when one of those routes is hit:

@MainRouteController = RouteController.extend
onBeforeAction: ->
console.log 'Clearing subscriptions'
Pages.unsubscribe()
Pages2.unsubscribe()
Pages3.unsubscribe()
@next()

Router.route '/noPages',
template: 'noPages'
layoutTemplate: 'layout'
controller: 'MainRouteController'
6 changes: 6 additions & 0 deletions examples/iron-router/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
<a href="/items/">View 1</a>
<a href="/items2/">View 2</a>
<a href="/items3/">View 3</a>
<a href="/noPages">View without Pager</a>
{{> yield}}
</template>

<template name="noPages">
<h1>View without Pager</h1>
<b>Pages subscriptions are stopped.</b>
</template>

<template name="items">
<h1>View 1</h1>
<b>Ascending sort, 10 items per page</b>
Expand Down
2 changes: 1 addition & 1 deletion examples/multi-collection/.meteor/versions
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
alethes:pages@1.4.0
alethes:pages@1.6.2
[email protected]
[email protected]
[email protected]
Expand Down
16 changes: 16 additions & 0 deletions examples/multi-collection/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,27 @@
sort:
items_id: 1
templateName: "items"
dataMargin: 0
availableSettings:
filters: true
@Pages2 = new Meteor.Pagination Items,
sort:
items_id: -1
templateName: "items2"
dataMargin: 0
@Pages3 = new Meteor.Pagination Items2,
sort:
items2_id: 1
templateName: "items3"
dataMargin: 0

if Meteor.isClient
Template.body.events
"click #clearItemsFilter": (e) ->
Pages.set filters: {}
return
"click #setItemsFilter": (e) ->
Pages.set filters:
items_id:
$gt: 25
return
4 changes: 4 additions & 0 deletions examples/multi-collection/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
</head>

<body>
<div>
<button id="setItemsFilter">Set filter items_id > 25 on Items</button>
<button id="clearItemsFilter">Clear Items filters</button>
</div>
{{> items}}
{{> items2}}
{{> items3}}
Expand Down
7 changes: 7 additions & 0 deletions examples/test/.meteor/.finished-upgraders
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file contains information which helps Meteor properly upgrade your
# app when you run 'meteor update'. You should check it into version control
# with your project.

notices-for-0.9.0
notices-for-0.9.1
0.9.4-platform-file
1 change: 1 addition & 0 deletions examples/test/.meteor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
local
7 changes: 7 additions & 0 deletions examples/test/.meteor/.id
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file contains a token that is unique to your project.
# Check it into your repository along with the rest of this directory.
# It can be used for purposes such as:
# - ensuring you don't accidentally deploy one app on top of another
# - providing package authors with aggregated statistics

1o2406g174246g123e0c7
12 changes: 12 additions & 0 deletions examples/test/.meteor/packages
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

meteor-platform
autopublish
insecure
coffeescript
mquandalle:jade
alethes:pages
2 changes: 2 additions & 0 deletions examples/test/.meteor/platforms
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server
browser
1 change: 1 addition & 0 deletions examples/test/.meteor/release
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[email protected]
5 changes: 5 additions & 0 deletions examples/test/client/templates.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
body
+items
template(name="items")
+pagesNav
+pages
1 change: 1 addition & 0 deletions examples/test/lib/collections.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@Items = new Meteor.Collection "items"
1 change: 1 addition & 0 deletions examples/test/packages/alethes:pages
12 changes: 12 additions & 0 deletions examples/test/server/testdata.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
randstr = (len) ->
str = ""
for i in [1 .. len]
str += chars[Math.floor(Math.random() * chars.length)]
str

if !Items.findOne()
for i in [1 .. 100]
Items.insert
id: i
name: randstr 12
4 changes: 4 additions & 0 deletions examples/test/test.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@Pages = new Meteor.Pagination Items,
perPage: 10
availableSettings:
filter: true
Loading

0 comments on commit 5821277

Please sign in to comment.