meteor-admin icon indicating copy to clipboard operation
meteor-admin copied to clipboard

"No data available in table" for Users with no email associated

Open niranjans opened this issue 9 years ago • 4 comments

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.

niranjans avatar Oct 15 '15 18:10 niranjans

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"

tdenovan avatar Jan 05 '16 07:01 tdenovan

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

Kostanos avatar Jan 26 '16 17:01 Kostanos

thanks, this is helpful. I hope it can be fixed

zhaoyao91 avatar Mar 28 '16 07:03 zhaoyao91

+1

paniwani avatar Apr 28 '16 13:04 paniwani