komentify / meteor-comments-ui

Simple templates for comment functionality in your Meteor App
MIT License
76 stars 40 forks source link

Admin Control #55

Closed ritchieng closed 8 years ago

ritchieng commented 8 years ago

Hi,

May I know if the admin can have access to delete any comments? Currently only users are able to delete their own comments.

Thanks.

zyleee commented 8 years ago

Hey @ritchieng

We are going to provide access to the raw collection with v1 to allow this.

Christian

matteodem commented 8 years ago

As of 1.0 you have access to the underlying comments collection, see https://github.com/ARKHAM-Enterprises/meteor-comments-ui#event-hooks

ritchieng commented 8 years ago

Hi matteodam, are you able to brief on how do we go about to implement this for admin to be able to edit/remove all comments?

matteodem commented 8 years ago

you could use the raw collection instance (Comments.getCollection() with a custom built UI or one of the admin packages that's out there, for exampel hosuton and add the collection there with the provided method: https://atmospherejs.com/houston/admin

ritchieng commented 8 years ago

How about for a case for Yogiben using AdminConfig?

I tried accessing the schema for CommentsCollection but there's an error where I can't access CommentsCollection's scheme defined in your package.

Thanks!

matteodem commented 8 years ago

Can you please show me the errors and some of your code related to it?

ritchieng commented 8 years ago

This is my admin configuration:

AdminConfig = {
  skin: 'red-light',
  name: 'Admin',
  collections: {
    Profiles: {
      icon: 'file-text-o',
      tableColumns: [
        {label: 'ID', name: '_id'},
        {label: 'Title', name: 'title'},
        {label: 'Email', name: 'userName'},
        {label: 'Company', name:'company'},
        {label: 'Status', name: 'status'}
      ],
      color: 'green'
    },
    CommentsCollection: {
      icon: 'comment',
      tableColumns: [
          { label: 'Content', name: 'content' },
          { label: 'User', name: 'owner', template: 'userEmail' }
      ],
      color: 'red'
    }
  },
  autoForm:{
    omitFields: ['createdAt','updatedAt']
  }
};

This is the error showing undefined object global:

W20160309-13:28:40.497(1)? (STDERR)                                             throw(ex);
W20160309-13:28:40.497(1)? (STDERR)                                                   ^
W20160309-13:28:40.541(1)? (STDERR) Error: CommentsCollection is not in the [object global]
matteodem commented 8 years ago

I don't know how to use these admin packages, please refer to the package itself if you have problems.

ritchieng commented 8 years ago

No problem. I found a solution for anyone using with the popular yogiben.

If anyone wants a fix. Within the admin.js file (or wherever you placed your admin configuration code from Yogiben):

  1. Create a global variable Reviews = Comments.getCollection();
  2. Configure your admin panel to display the fields Reviews: {

    icon: 'comment',
     tableColumns: [
       {label: 'Comment ID', name: '_id'},
       {label: 'User ID', name: 'userId'},
       {label: 'Username', name: 'user'},
       {label: 'Review', name: 'content'}
     ],

A note: I'm unable to display the username at the moment unfortunately. It has to do with the schema and your accounts configuration. I'll post an update if I have a fix to that. But this will enable you to delete or add comments in Yogiben!