ignacy130 / yadmin

A complete admin dashboard solution
https://atmospherejs.com/ignacy130/yadmin
GNU General Public License v3.0
11 stars 2 forks source link

Problem with the display of collections in the table #2

Open Kirpich634 opened 7 years ago

Kirpich634 commented 7 years ago

There was a problem with the display of collections in the table, I do not yet understand how to solve it.

image

image

/imports/collections/posts.js

import SimpleSchema from 'simpl-schema';

console.log('import post file');

SimpleSchema.extendOptions(['autoform']);

Posts = new Meteor.Collection('posts');

Posts.attachSchema(new SimpleSchema({
    title: {
        type: String,
        max: 60
    },
    content: {
        type: String,
        autoform: {
            rows: 5
        }
    },
    createdAt: {
        type: Date,
        label: 'Date',
        autoValue: function() {
            if (this.isInsert) {
                return new Date();
            }
        }
    },
    owner: {
        type: String,
        regEx: SimpleSchema.RegEx.Id,
        autoValue: function() {
            if (this.isInsert) {
                return Meteor.userId();
            }
        },
        autoform: {
            options: function() {
                return _.map(Meteor.users.find().fetch(), function(user) {
                    return {
                        label: user.emails[0].address,
                        value: user._id
                    };
                });
            }
        }
    }
}));

Posts.helpers({
    postTitle: function() {
        if (this.post) {
            return Posts.findOne(this.post).title;
        }
    }
});

export default Posts;

/server/collections/posts.js

import Posts from '/imports/collections/posts';

Meteor.publish('posts', function () {
    return Posts.find();
});

/both/admin.js

import Pages from '/imports/collections/pages'
import Posts from '/imports/collections/posts'

AdminConfig = {
    name: 'Rudenko',
    adminEmails: ['kirpich634@gmail.com'],
    nonAdminRedirectRoute: 'main',
    collections: {
        Pages: {
            icon: 'pencil',
            omitFields: ['owner'],
            tableColumns: [
                {
                    label: 'Content',
                    name: 'content'
                }, {
                    label: 'User',
                    name: 'owner',
                    template: 'userEmail'
                }
            ]
        },
        Posts: {
            icon: 'pencil',
            omitFields: ['owner'],
            tableColumns: [
                {
                    label: 'Content',
                    name: 'content'
                }, {
                    label: 'User',
                    name: 'owner',
                    template: 'userEmail'
                }
            ]
        },
    },
    autoForm: {
        omitFields: ['createdAt', 'updatedAt']
    },
    dashboard: {
        homeUrl: '/dashboard',
        widgets: [
            {
                template: 'adminCollectionWidget',
                data: {
                    collection: 'Posts',
                    "class": 'col-lg-3 col-xs-6'
                }
            }, {
                template: 'adminUserWidget',
                data: {
                    "class": 'col-lg-3 col-xs-6'
                }
            }
        ]
    }
};

Meteor packages used by this project

meteor-base@1.1.0             # Packages every Meteor app needs to have
mobile-experience@1.0.4       # Packages for a great mobile UX
mongo@1.2.0                   # The database Meteor supports right now
blaze-html-templates@1.0.4 # Compile .html files into Meteor Blaze views
reactive-var@1.0.11            # Reactive variable for tracker
tracker@1.1.3                 # Meteor's client-side reactive programming library

standard-minifier-css@1.3.4   # CSS minifier run for production mode
standard-minifier-js@2.1.1    # JS minifier run for production mode
es5-shim@4.6.15                # ECMAScript 5 compatibility for older browsers
ecmascript@0.8.2              # Enable ECMAScript2015+ syntax in app code
shell-server@0.2.4            # Server-side component of the `meteor shell` command

insecure@1.0.7                # Allow all DB writes from clients (for prototyping)
fourseven:scss
accounts-base@1.3.2
accounts-password@1.4.0
nolimits4web:swiper
dburles:google-maps
iron:router
dburles:collection-helpers
alanning:roles
ignacy130:yadmin
aldeed:collection2-core
session
aldeed:autoform
fortawesome:fontawesome
ignacy130 commented 7 years ago

That is something with line 30: template: 'userEmail' - comment it to make the list work. I guess the template userEmail should be defined.