<commit_before>Requests = new Mongo.Collection("requests");
Categories = new Mongo.Collection("categories");

// db.categories.insert({ name: "Type 1" });

// See: https://github.com/peerlibrary/meteor-peerdb/issues/17
// see also: https://github.com/aldeed/meteor-collection2/issues/31

var Schemas = {};

Schemas.Categories = new SimpleSchema({
  name: {
    type: String,
    label: "Name",
    max: 100,
    optional: false
  }
});

// So why do we have a schema with autoform specifying html styles here?  That seems wrong.
Schemas.Request = new SimpleSchema({
  first_name: {
    type: String,
    label: "First name",
    max: 100,
    optional: false,
    autoform: {
      style: "width: 90%"
    }
  },
  last_name: {
    type: String,
    label: "Last name",
    max: 100,
    autoform: {
      style: "width: 90%"
    }
  },
  email: {
    type: String,
    label: "Email",
    regEx: SimpleSchema.RegEx.Email,
    optional: false,
    max:50,
    autoform: {
      style: "width: 90%"
    }
  },
  subject: {
    type: String,
    label: "Subject",
    max: 100,
    optional: false,
    autoform: {
      style: "width: 90%"
    }
  },
  text: {
    type: String,
    label: "Description",
    max: 2000,
    optional: false,
    autoform: {
      type: "textarea",
      rows: 6,
      style: "width: 90%"
    }
  },
  category: {
    type: Schemas.Categories._id,
    label: "Category",
    optional: false,
    autoform: {
        // http://stackoverflow.com/questions/23644355/how-to-generate-a-form-to-select-a-user-using-autoform-and-collection2-in-meteor
        options: function () {
          var options = [];
          Categories.find().forEach(function (element) {
            options.push({
              label: element.name, value: element._id._str
            })
          });
          return options;
        }
    }
  }
});

Requests.attachSchema(Schemas.Request);
Categories.attachSchema(Schemas.Categories);


Router.route('/', function() {
  templateData = { requests: Requests.find({}), categories: Categories.find({}) };
  this.render('home', {data: templateData} );
});

Router.map(function() {

  this.route('requests', {
    data: function() {
      requests: Requests.find({});
      categories: Categories.find({_id: requests.category})

      templateData = { requests: requests, categories: categories };
      return templateData;
    }
  });
<commit_msg>I give up on binding collections and displaying them correctly for now.<commit_after>Requests = new Mongo.Collection("requests");
Categories = new Mongo.Collection("categories");

// db.categories.insert({ name: "Type 1" });

// See: https://github.com/peerlibrary/meteor-peerdb/issues/17
// see also: https://github.com/aldeed/meteor-collection2/issues/31

var Schemas = {};

Schemas.Categories = new SimpleSchema({
  name: {
    type: String,
    label: "Name",
    max: 100,
    optional: false
  }
});

// So why do we have a schema with autoform specifying html styles here?  That seems wrong.
Schemas.Request = new SimpleSchema({
  first_name: {
    type: String,
    label: "First name",
    max: 100,
    optional: false,
    autoform: {
      style: "width: 90%"
    }
  },
  last_name: {
    type: String,
    label: "Last name",
    max: 100,
    autoform: {
      style: "width: 90%"
    }
  },
  email: {
    type: String,
    label: "Email",
    regEx: SimpleSchema.RegEx.Email,
    optional: false,
    max:50,
    autoform: {
      style: "width: 90%"
    }
  },
  subject: {
    type: String,
    label: "Subject",
    max: 100,
    optional: false,
    autoform: {
      style: "width: 90%"
    }
  },
  text: {
    type: String,
    label: "Description",
    max: 2000,
    optional: false,
    autoform: {
      type: "textarea",
      rows: 6,
      style: "width: 90%"
    }
  },
  category: {
    type: Schemas.Categories._id,
    label: "Category",
    optional: false,
    autoform: {
      type: "select",
        // http://stackoverflow.com/questions/23644355/how-to-generate-a-form-to-select-a-user-using-autoform-and-collection2-in-meteor
      options: function () {
        var options = [];
        Categories.find().forEach(function (element) {
          options.push({
            label: element.name, value: element._id._str
          })
        });
        return options;
      }
    }
  }
});

Requests.attachSchema(Schemas.Request);
Categories.attachSchema(Schemas.Categories);


Router.route('/', function() {
  templateData = { requests: Requests.find({}), categories: Categories.find({}) };
  this.render('home', {data: templateData} );
});

Router.map(function() {

  this.route('requests', {
    data: function() {
      requests = Requests.find({});
      templateData = { requests: requests };
      return templateData;
    }
  });

{'fraction_non_alphanumeric': 0.15251046025104603, 'fraction_numerical': 0.018410041841004185, 'mean_word_length': 2.5051319648093844, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7066256', 'n_tokens_mistral': 1633, 'n_tokens_neox': 1522, 'n_words': 344}