【发布时间】:2016-04-02 16:04:15
【问题描述】:
我的网站允许用户通过连接他们的谷歌帐户来申请,一旦创建了一个帐户,他们就会被赋予一个“待定”角色(使用alanning:roles 包)。我想有一个table 供管理员查看新申请人何时申请,管理员可以从那里正确管理用户申请(将角色更改为接受、拒绝等)。所以,我已经创建了我的表,但它显示了所有用户,我想知道是否有人知道一种方法,所以只有具有“待定”角色的用户才会显示在我的表中?
这是我目前所拥有的:
TabularTables.ManageApplications = new Tabular.Table({
name: 'ManageApplications',
collection: Meteor.users,
allow: function (userId) {
return Roles.userIsInRole(userId, 'admin');
},
autoWidth: false,
oLanguage: {
"sSearch": "Search: "
},
columns: [
{ data: //column details here },
{ data: //column details here },
{ data: //column details here },
{ data: //column details here },
{ data: //column details here },
],
});
这可行,但它会显示每个用户(不仅仅是具有“待定”角色的用户)。
然后我创建了这个来尝试只为待定用户发布数据:
Meteor.publish("pendingUsers", function() {
var isAdmin = Roles.userIsInRole(this.userId, 'admin');
if (isAdmin) {
return Roles.getUsersInRole('pending').fetch();
} else {
return null;
}
});
并通过在我的表中添加pub: "pendingUsers", 进行订阅。这有点工作,它使它只在“待定”角色用户的列中显示数据,但是,它仍然列出每个用户,并且只有数据所在的空格。
如果有人知道我如何实现这一点,如果您能提供一些见解,将不胜感激,因为我已经坚持了很长一段时间......我相信这可能与“Displaying Only Part of a Collection's Data Set”有关在表格自述文件中,但我非常不确定如何设置它。非常感谢任何示例或帮助。
【问题讨论】:
标签: meteor datatables aldeed-tabular