meteor-admin
meteor-admin copied to clipboard
How can I add column to admin users table?
Is there an easy way to add a column to /admin/Users
template? It seems AdminConfig Users collection doesn't override default options.
Create a new User Schema and attach the field you desire. When you restart the application, the field should be available.
@rwatts3 I've tried it. Can you provide a code snippet with example of configuration? I'm trying to show a field from user's profile on users list table.
That's actually more complex as there is custom template for users
collection which is not using schema. You would have to customize adminPagesTable
and adminPagesUserItem
templates.
Got same needs. Users table columns will be customisable in a future version ?
Thanks. Pascoual
Add another vote for being able to customize the user table columns.
plus 1 for custom user templates and extending user schema.
Would love to see the ability to extend the user templates and columns.
I was hoping this is available already
So we still cant customize the user templates?
+1
+1
+1
+1
+1
@mpowaga I can't find those two templates in the code (adminPagesTable
and adminPagesUserItem
) and this has no effect:
<template name="adminPagesTable">
Hello world
</template>
<template name="adminPagesUserItem">
Goodnight moon
</template>
Did the names of these templates change?
Update: code: https://github.com/yogiben/meteor-admin/blob/4b20c82aa39addcc2cc5cb9f93b835c56a31e60d/lib/both/startup.coffee#L172
Ok, this is hacky, but here's how to do it:
AdminConfig = {
// Define your admin config here.
};
// Hack for admin user's table: https://github.com/yogiben/meteor-admin/blob/4b20c82aa39addcc2cc5cb9f93b835c56a31e60d/lib/both/startup.coffee#L172
import Tabular from 'meteor/aldeed:tabular';
// Don't forget Meteor.startup, and change Tabular.Table to Tabular.Tabular.Table
Meteor.startup(()=>{
var adminDelButton, adminEditButton, adminEditDelButtons, adminTablesDom;
adminTablesDom = '<"box"<"box-header"<"box-toolbar"<"pull-left"<lf>><"pull-right"p>>><"box-body"t>><r>';
adminEditButton = {
data: '_id',
title: 'Edit',
createdCell: function(node, cellData, rowData) {
return $(node).html(Blaze.toHTMLWithData(Template.adminEditBtn, {
_id: cellData
}));
},
width: '40px',
orderable: false
};
adminDelButton = {
data: '_id',
title: 'Delete',
createdCell: function(node, cellData, rowData) {
return $(node).html(Blaze.toHTMLWithData(Template.adminDeleteBtn, {
_id: cellData
}));
},
width: '40px',
orderable: false
};
adminEditDelButtons = [adminEditButton, adminDelButton];
//...
AdminTables.Users = new Tabular.Tabular.Table({
changeSelector: function(selector, userId) {
var $or;
$or = selector['$or'];
$or && (selector['$or'] = _.map($or, function(exp) {
var ref;
if (((ref = exp.emails) != null ? ref['$regex'] : void 0) != null) {
return {
emails: {
$elemMatch: {
address: exp.emails
}
}
};
} else {
return exp;
}
}));
return selector;
},
name: 'Users',
collection: Meteor.users,
columns: _.union([
{
data: '_id',
title: 'Hello',
createdCell: function(node, cellData, rowData) {
return $(node).html(Blaze.toHTMLWithData(Template.adminUsersIsAdmin, {
_id: cellData
}));
},
width: '40px'
}, {
data: 'emails',
title: 'World',
render: function(value) {
return value[0].address;
},
searchable: true
}, {
data: 'emails',
title: 'Mail',
createdCell: function(node, cellData, rowData) {
return $(node).html(Blaze.toHTMLWithData(Template.adminUsersMailBtn, {
emails: cellData
}));
},
width: '40px'
}, {
data: 'createdAt',
title: 'Joined'
}
], adminEditDelButtons),
dom: adminTablesDom
});
});
+1