meteor-admin
meteor-admin copied to clipboard
"No data available in table" for Users with no email associated
This is related to this closed issue.
As some other users have pointed out, if the users without email address (Facebook logins) are removed or if dummy email is filled in, the Users collection shows data. Else, it does not show any data and this is the exception in the console:
Exception from Tracker recompute function:
debug.js:41 TypeError: Cannot read property '0' of undefined
at AdminTables.Users.Tabular.Table.columns._.union.render (startup.coffee:58)
at jquery.dataTables.min.js:15
at Object.b.fnGetData (jquery.dataTables.min.js:9)
at w (jquery.dataTables.min.js:14)
at Ia (jquery.dataTables.min.js:21)
at I (jquery.dataTables.min.js:13)
at ub (jquery.dataTables.min.js:36)
at jquery.dataTables.min.js:33
at Template.tabular.rendered.ajaxOptions.ajax (tabular.js:68)
at qa (jquery.dataTables.min.js:33)
Is there a way to fix this? I am trying to avoid adding dummy emails since that is not a good solution.
I think we just need to do a PR to add an if statement to line 195 of meteor-admin/lib/both/startup.coffee to check if any emails are present before returning the address of the first one.
However, if you want a quick fix, I used the following hack (coffee script):
Meteor.startup ->
# Patch the way yogiben:admin renders users, to fix a bug where they are forced to have emails
emailColumn = AdminTables.Users.options.columns[1]
emailColumn.render = (value) ->
return value[0].address if value? and value[0]?
"No email"
thanks @tdenovan your workaround works well.
For those who need it in JS:
Meteor.startup(function () {
var emailCol = AdminTables.Users.options.columns[1];
emailCol.render = function(value){
return value && value[0] ? value[0].address : 'no email';
}
});
I placed it in lib/
any file
thanks, this is helpful. I hope it can be fixed
+1