simpl-schema not working with autoform using meteor flow-db-admin

267 Views Asked by At

Currently using meteor flow-db-admin as admin template https://github.com/sachinbhutani/flow-db-admin

But the autoform doesn't seem to work with the simpl-schema as the labels don't show and the validation doesn't work

package.json

{
  "name": "tours",
  "private": true,
  "scripts": {
    "start": "meteor run",
    "test": "meteor test --once --driver-package meteortesting:mocha",
    "test-app": "TEST_WATCH=1 meteor test --full-app --driver-package meteortesting:mocha",
    "visualize": "meteor --production --extra-packages bundle-visualizer"
  },
  "dependencies": {
    "@babel/runtime": "^7.1.5",
    "bcrypt": "^3.0.0",
    "classnames": "^2.2.6",
    "meteor-node-stubs": "^0.4.1",
    "react": "^16.4.2",
    "react-addons-pure-render-mixin": "^15.6.2",
    "react-dom": "^16.4.2",
    "react-mounter": "^1.2.0",
    "simpl-schema": "^1.5.3"
  },
  "meteor": {
    "mainModule": {
      "client": "client/main.js",
      "server": "server/main.js"
    },
    "testModule": "tests/main.js"
  },
  "devDependencies": {
    "chai": "^4.1.2"
  }
}

.meteor/packages

# Meteor packages used by this project, one per line.
# Check this file (and the other files in this directory) into your repository.
#
# 'meteor add' and 'meteor remove' will edit this file for you,
# but you can also edit it by hand.

[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]            # 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

react-meteor-data
[email protected]
[email protected]
meteortesting:mocha
twbs:bootstrap
static-html
jquery
kadira:flow-router
kadira:blaze-layout
dburles:collection-helpers
[email protected]
alanning:roles
fortawesome:fontawesome
meteortoys:allthings
[email protected]
aldeed:collection2-core
sach:flow-db-admin
aldeed:simple-schema

server/main.js

import { Meteor } from 'meteor/meteor';

// import '../imports/startup/accounts-config.js';
import '../imports/routes.js';
import '../imports/schemas.js';
// import '../imports/startup/admin-config.js';

Meteor.startup(() => {
/*
*/
  AdminConfig = {
  collections: {
    Posts: {}
  }
};

});

client/main.js

import React from 'react';
import { Meteor } from 'meteor/meteor';
import { render } from 'react-dom';

import '../imports/startup/accounts-config.js';
import '../imports/routes.js';
import '../imports/schemas.js';
// import '../imports/startup/admin-config.js';

Meteor.startup(() => {

/*
*/
  AdminConfig = {
  collections: {
    Posts: {}
  }
};
});

imports/schemas.js

import React from 'react';
// import { FlowRouter } from 'meteor/kadira:flow-router'
import { mount } from 'react-mounter';
import SimpleSchema from 'simpl-schema';
SimpleSchema.extendOptions(['autoform']);



Schemas = {};

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

Schemas.Posts = new SimpleSchema({
  title: {
    label: 'Title',
    type: String,
    max: 60
  },
  content: {
    label: 'Content',
    type: String,
    autoform: {
      rows: 5
    }
  },
  createdAt: {
    type: Date,
    label: 'Date',
    autoValue: function () {
      if (this.isInsert) {
        return new Date();
      }
    }
  },
  owner: {
    label: 'Author',
    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.attachSchema(Schemas.Posts);

Then after launching, it shows the below; the validation doesn't work and the labels are not displayed also.

Please help

enter image description here

0

There are 0 best solutions below