Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with the display of collections in the table #2

Open
Kirpich634 opened this issue Sep 10, 2017 · 1 comment
Open

Problem with the display of collections in the table #2

Kirpich634 opened this issue Sep 10, 2017 · 1 comment

Comments

@Kirpich634
Copy link

Kirpich634 commented Sep 10, 2017

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: ['[email protected]'],
    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

[email protected]             # Packages every Meteor app needs to have
[email protected]       # Packages for a great mobile UX
[email protected]                   # The database Meteor supports right now
[email protected] # Compile .html files into Meteor Blaze views
[email protected]            # Reactive variable for tracker
[email protected]                 # Meteor's client-side reactive programming library

[email protected]   # CSS minifier run for production mode
[email protected]    # JS minifier run for production mode
[email protected]                # ECMAScript 5 compatibility for older browsers
[email protected]              # Enable ECMAScript2015+ syntax in app code
[email protected]            # Server-side component of the `meteor shell` command

[email protected]                # Allow all DB writes from clients (for prototyping)
fourseven:scss
[email protected]
[email protected]
nolimits4web:swiper
dburles:google-maps
iron:router
dburles:collection-helpers
alanning:roles
ignacy130:yadmin
aldeed:collection2-core
session
aldeed:autoform
fortawesome:fontawesome
@ignacy130
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants