Closed epaminond closed 9 years ago
What version of meteor are you on?
1.0
It looks like a problem with your AdminConfig. Double check that the collection names are spelt correctly and that they are global variables.
Collection names are correct and available globally. AdminConfig is very simple:
AdminConfig = {
collections: {
Services: {
icon: 'wrench',
color: 'green'
},
TradesmenCategories: {
icon: 'sitemap',
color: 'yellow'
}
}
};
An error trace starts from line 102 of client/html/admin_templates.html
and collection
is evaluated from view.lookup("admin_collection")
function call.
An error can be reproduced only when switching from non-User collection routes (adminDashboardView
, adminDashboardNew
and adminDashboardEdit
) to dashboard. It doesn't appear for User-related routes.
As far as I see, error appears because before rendering AdminDashboard
template an if statement that checks for the dynamic template is evaluated for second time.
For example if I open adminDashboardNew
route for collection different from User an {{#if adminTemplate admin_collection 'new'}}
will be evaluated normally. But then if I click dashboard link {{#if adminTemplate admin_collection 'new'}}
will be evaluated again and then AdminDashboard
will be rendered normally.
I could see this by adding breakpoints in the source of compiled package.
if you comment out the collections object, does the error persist?
Do you mean in AdminConfig?
Disregard, I can reproduce the error - looking into it.
Found what appears to be a fix.
in the router place all session sets in an onAfterAction instead of in the action. This prevents this race condition from occurring.
I am working on a pull request but if you have a local copy of the module running here is the gist
Before:
@route "adminDashboardView",
path: "/admin/:collection/"
template: "AdminDashboardView"
layoutTemplate: "AdminLayout"
waitOn: ->
[Meteor.subscribe('adminCollection', @params.collection), Meteor.subscribe('adminAuxCollections', @params.collection), Meteor.subscribe('adminUsers'), Meteor.subscribe 'adminUser']
data: -> { documents : window[ @params.collection ].find({},{sort: {createdAt: -1}}).fetch() }
action: ->
Session.set 'admin_title', AdminDashboard.collectionLabel(@params.collection)
Session.set 'admin_subtitle', 'View '
Session.set 'admin_collection_page', ''
Session.set 'admin_collection', @params.collection.charAt(0).toUpperCase() + @params.collection.slice(1)
@render()
# onBeforeAction: ->
# AccountsEntry.signInRequired this
After
@route "adminDashboardView",
path: "/admin/:collection/"
template: "AdminDashboardView"
layoutTemplate: "AdminLayout"
waitOn: ->
[Meteor.subscribe('adminCollection', @params.collection), Meteor.subscribe('adminAuxCollections', @params.collection), Meteor.subscribe('adminUsers'), Meteor.subscribe 'adminUser']
data: -> { documents : window[ @params.collection ].find({},{sort: {createdAt: -1}}).fetch() }
action: ->
@render()
onAfterAction: ->
Session.set 'admin_title', AdminDashboard.collectionLabel(@params.collection)
Session.set 'admin_subtitle', 'View '
Session.set 'admin_collection_page', ''
Session.set 'admin_collection', @params.collection.charAt(0).toUpperCase() + @params.collection.slice(1)
# onBeforeAction: ->
# AccountsEntry.signInRequired this
Thanks for quick fixing! Sorry, I don't know how to test it locally.
Create packages folder in your app root Clone the repo into packages/admin Meteor remove yogiben:admin Meteor add yogiben:admin
Then just run as normal, it will build the package from the local copy instead of fetching it.
Or you can hold off until @yogiben addresses the open PRs
@epaminond run meteor update
and then meteor list
to check the package version is 1.0.1
. Please let us know if this problem persists.
Thanks @WillHall.
@yogiben I've updated package to 1.0.1 and I get another error now: admin actions don't open and an error in client console appears:
Route dispatch never rendered. Did you forget to call this.next() in an onBeforeAction?
How are you producing this error?
Just opening /admin
route. I see layout and Loading...
which never changes.
If I then press a button to open a collection list Route dispatch never rendered. Did you forget to call this.next() in an onBeforeAction?
in client console appears.
@epaminond Please try updating the admin package. I updated it last night.
@yogiben thank you for quick response. As of version 1.0.3 collection routes do open correctly. But problem with dashboard remains: a "Loading..." sign appears and never changes. Errors in client console don't appear however.
Oh, sorry, Dashboard didn't load because my AdminConfig wasn't available on server (adminAllCollections would never publish without it). So subject issue seems to be fixed. Thank you so much!
Get a following exception in client console when switching from a list of elements to dashboard (initial load of dashboard is OK):
At that line we have:
And
collection
variable at this moment equals empty string ('').