Skip to content

Commit

Permalink
Fix a couple of minor corner cases
Browse files Browse the repository at this point in the history
- Allow to have pages for collections written as "Package.collection"
- Remove a couple of white spaces from the code
- in getPage add a guard if total is not defined
  • Loading branch information
Pietro Abate committed Oct 16, 2017
1 parent ac13371 commit 3529c91
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/pages.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@
setId: (name) ->
if @templateName
name = @templateName
name = name.replace(".","_")
while name of Pages::instances
n = name.match /[0-9]+$/
if n?
Expand Down Expand Up @@ -469,7 +470,7 @@
self.routeSettings @
Tracker.nonreactive =>
self.onNavClick page
@next()
@next()

# Create one or more routes for the home (first) page

Expand All @@ -496,7 +497,7 @@
FastRender.route pr, (params) ->
@subscribe self.id, parseInt params.page
FastRender.route @homeRoute, ->
@subscribe self.id, 1
@subscribe self.id, 1

isEmpty: ->
@isReady() and @Collection.find(_.object [["_#{@id}_i", 0]]).count() is 0
Expand All @@ -516,7 +517,7 @@
helpers = pagesData: @
_.each Template[i].__helpers, (helper, name) =>
if name[0] is " "
helpers[name.slice(1)] = _.bind helper, @
helpers[name.slice(1)] = _.bind helper, @
Template[tn].helpers helpers

# Set our helpers on the main template set for this pagination
Expand Down Expand Up @@ -599,7 +600,7 @@

filters = get "filters"

options =
options =
sort: get "sort"
fields: get "fields"
skip: skip
Expand Down Expand Up @@ -657,7 +658,7 @@
doc["_#{@id}_p"] = page
doc["_#{@id}_i"] = at
id = doc._id
delete doc._id
delete doc._id
# Add to @Collection
query().forEach (o, i) =>
if i is at
Expand Down Expand Up @@ -874,7 +875,7 @@
@sess "ready", true

checkInitPage: ->
if @init and !@initPage
if @init and !@initPage
if @router
Router.current()?.route?.getName()
try
Expand All @@ -897,7 +898,7 @@

# Request data for the page

if page <= total
if !total? or (page <= total)
@requestPage page
@queueNeighbors page
@checkQueue()
Expand Down

0 comments on commit 3529c91

Please sign in to comment.