Exemple #1
0
// this file should be generated from the application JSON

// see server.js for a example Apimoons.insert clauses which should match with this schema

// https://github.com/gcanti/tcomb-form/blob/master/GUIDE.md



// Import with  import FormSchema from "schema-apimoon.js";
export default function() {
  
  // this is like join field sharedTo: "users.profile.name" of type array in collection todos
  // displayHelper is in columns-todo.jsx
  var values = {};
  Meteor.users.find().fetch().map((user) => {
    values[user._id] = user.profile.name;
  });

  var User=t.struct({
    profile: t.struct({
      name: t.String,
    })
  },"User");
  var Users = t.enums(values, "Users");
  
   
  var Schema = t.struct({
    _id: t.maybe(t.String),
    name: t.String, // a required string
    owner: t.maybe(User),
    sharedTo: t.list(Users),
    done: t.Boolean

  });

  return Schema;
}
export default (
  attributes = attributesInitialState.attributeList,
  attribute = attributesInitialState.defaultValue,
) => {
  const name = t.refinement(
    t.String,
    n => !attributes.some(a => a.name === n && a.id !== attribute.id),
  );
  name.getValidationErrorMessage = (n) => {
    if (!n) {
      return ERROR_REQUIRED;
    }
    if (attributes.some(a => a.name === n && a.id !== attribute.id)) {
      return ERROR_DUPLICATED;
    }
    return '';
  };

  const description = t.maybe(t.String);

  const deviceResourceType = t.enums({ 0: DEVICE_RESOURCE_TYPE_DEFAULT_VALUE });

  const defaultValue = t.maybe(t.String);

  const dataType = t.enums({
    string: DATA_TYPE_VALUE_STRING,
    object: DATA_TYPE_VALUE_OBJECT,
  });

  const format = t.enums({
    none: FORMAT_VALUE_NONE,
    number: FORMAT_VALUE_NUMBER,
    boolean: FORMAT_VALUE_BOOLEAN,
    dateTime: FORMAT_VALUE_DATETIME,
    cdata: FORMAT_VALUE_CDATA,
    uri: FORMAT_VALUE_URI,
  });

  let optionalFields = {};

  if (attribute.dataType === 'string') {
    const { maxRange, minRange } = attribute;
    switch (attribute.format) {
      case 'none':
        optionalFields = {
          enumerations: t.list(t.String),
        };
        break;
      case 'number':
        optionalFields = {
          minRange: t.refinement(t.Number, n =>
            !Number.isNaN(Number(n)) && isRangeValid(n, maxRange)),
          maxRange: t.refinement(t.Number, n =>
            !Number.isNaN(Number(n)) && isRangeValid(minRange, n)),
          unitOfMeasurement: t.String,
          precision: t.refinement(
            t.Number,
            n => !Number.isNaN(Number(n)) && isPrecisionValid(minRange, maxRange, n),
          ),
          accuracy: t.refinement(
            t.Number,
            n => !Number.isNaN(Number(n)) && isPrecisionValid(minRange, maxRange, n),
          ),
        };
        setNumberValidationMessages(optionalFields, attribute);
        break;
      default:
        // Do nothing.
    }
  }

  return t.struct({
    name,
    description,
    deviceResourceType,
    defaultValue,
    dataType,
    format,
    ...optionalFields,
  });
};
import React from 'react';
import { render } from 'react-dom';
import t from 'tcomb-form';
import DatePicker from 'react-bootstrap-date-picker';
import restCalls from '../../utils/restCalls';
import {Button} from 'react-bootstrap';

const Form = t.form.Form;



const method = t.enums({
  ach: "ACH Return",
  chk: 'Cashier Check Mailed',
  mix: 'Mixed Method',
});



var options = {
  auto: 'placeholders',
};


function getType(value){

var CaseStatus = {
  method: method,
  fullRecovery: t.Boolean,
  dateComplete: t.maybe(t.Date),
  notes:t.String,